diff options
author | Ken VanDine <ken.vandine@canonical.com> | 2011-03-23 12:03:02 -0400 |
---|---|---|
committer | Ken VanDine <ken.vandine@canonical.com> | 2011-03-23 12:03:02 -0400 |
commit | f05dff9b5d6c5e921f3056c142068ea7f6f41486 (patch) | |
tree | 9be3a5ff03f17db4a06e56815ad68de4c588c1ec | |
parent | 7619eab48daaa739fb3418237c693b7b463182f0 (diff) | |
parent | fb3a829f4bca4f16c51cb5305b941928296c52a7 (diff) | |
download | ayatana-indicator-sound-f05dff9b5d6c5e921f3056c142068ea7f6f41486.tar.gz ayatana-indicator-sound-f05dff9b5d6c5e921f3056c142068ea7f6f41486.tar.bz2 ayatana-indicator-sound-f05dff9b5d6c5e921f3056c142068ea7f6f41486.zip |
Import upstream version 0.6.5
-rwxr-xr-x | configure | 20 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | data/com.canonical.indicators.sound.gschema.xml | 2 | ||||
-rw-r--r-- | src/common-defs.h | 3 | ||||
-rw-r--r-- | src/indicator-sound.c | 4 | ||||
-rw-r--r-- | src/mpris2-controller.c | 55 | ||||
-rw-r--r-- | src/mpris2-controller.vala | 14 | ||||
-rw-r--r-- | src/mpris2-watcher.vala | 2 | ||||
-rw-r--r-- | src/music-player-bridge.h | 1 | ||||
-rw-r--r-- | src/player-controller.c | 138 | ||||
-rw-r--r-- | src/player-controller.vala | 28 | ||||
-rw-r--r-- | src/player-item.c | 2 | ||||
-rw-r--r-- | src/player-item.vala | 4 | ||||
-rw-r--r-- | src/playlists-menu-item.c | 225 | ||||
-rw-r--r-- | src/playlists-menu-item.vala | 31 | ||||
-rw-r--r-- | src/slider-menu-item.c | 49 | ||||
-rw-r--r-- | src/sound-service-dbus.c | 5 | ||||
-rw-r--r-- | src/sound-service.c | 2 | ||||
-rw-r--r-- | src/transport-menu-item.c | 126 | ||||
-rw-r--r-- | src/transport-menu-item.vala | 56 | ||||
-rw-r--r-- | src/transport-widget.c | 108 | ||||
-rw-r--r-- | src/voip-input-menu-item.c | 5 | ||||
-rw-r--r-- | src/voip-input-widget.c | 13 | ||||
-rw-r--r-- | src/volume-widget.c | 66 | ||||
-rw-r--r-- | src/volume-widget.h | 2 | ||||
-rw-r--r-- | vapi/common-defs.vapi | 6 |
26 files changed, 595 insertions, 376 deletions
@@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.67 for indicator-sound 0.6.4. +# Generated by GNU Autoconf 2.67 for indicator-sound 0.6.5. # # Report bugs to <conor.curran@canonical.com>. # @@ -761,8 +761,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='indicator-sound' PACKAGE_TARNAME='indicator-sound' -PACKAGE_VERSION='0.6.4' -PACKAGE_STRING='indicator-sound 0.6.4' +PACKAGE_VERSION='0.6.5' +PACKAGE_STRING='indicator-sound 0.6.5' PACKAGE_BUGREPORT='conor.curran@canonical.com' PACKAGE_URL='' @@ -1564,7 +1564,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures indicator-sound 0.6.4 to adapt to many kinds of systems. +\`configure' configures indicator-sound 0.6.5 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1634,7 +1634,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of indicator-sound 0.6.4:";; + short | recursive ) echo "Configuration of indicator-sound 0.6.5:";; esac cat <<\_ACEOF @@ -1767,7 +1767,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -indicator-sound configure 0.6.4 +indicator-sound configure 0.6.5 generated by GNU Autoconf 2.67 Copyright (C) 2010 Free Software Foundation, Inc. @@ -2136,7 +2136,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by indicator-sound $as_me 0.6.4, which was +It was created by indicator-sound $as_me 0.6.5, which was generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -2956,7 +2956,7 @@ fi # Define the identity of the package. PACKAGE=indicator-sound - VERSION=0.6.4 + VERSION=0.6.5 cat >>confdefs.h <<_ACEOF @@ -14349,7 +14349,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by indicator-sound $as_me 0.6.4, which was +This file was extended by indicator-sound $as_me 0.6.5, which was generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14415,7 +14415,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -indicator-sound config.status 0.6.4 +indicator-sound config.status 0.6.5 configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 796b124..be50971 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ -AC_INIT(indicator-sound, 0.6.4, conor.curran@canonical.com) +AC_INIT(indicator-sound, 0.6.5, conor.curran@canonical.com) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-sound, 0.6.4) +AM_INIT_AUTOMAKE(indicator-sound, 0.6.5) AM_MAINTAINER_MODE diff --git a/data/com.canonical.indicators.sound.gschema.xml b/data/com.canonical.indicators.sound.gschema.xml index 1e08269..dc63bcb 100644 --- a/data/com.canonical.indicators.sound.gschema.xml +++ b/data/com.canonical.indicators.sound.gschema.xml @@ -11,7 +11,7 @@ </key> <key name="interested-media-players" type="as"> <summary>A list of applications which at some point have registered with the sound menu</summary> - <default>[ 'banshee-1' ]</default> + <default>[ 'banshee' ]</default> <description> Each media player which abides by the MPRIS2 spec will automatically appear in the menu. This array should contain the desktop file names (minus .desktop suffix) of applications which diff --git a/src/common-defs.h b/src/common-defs.h index 68cb0b8..b118d4b 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -45,7 +45,8 @@ typedef enum { typedef enum { TRANSPORT_STATE_PLAYING, - TRANSPORT_STATE_PAUSED + TRANSPORT_STATE_PAUSED, + TRANSPORT_STATE_LAUNCHING }TransportState; #define NOT_ACTIVE -1 diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 7d74a42..042bf89 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -539,7 +539,7 @@ key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) voip_input_widget_update (VOIP_INPUT_WIDGET(priv->voip_widget), new_value); } else{ - volume_widget_update (VOLUME_WIDGET(priv->volume_widget), new_value); + volume_widget_update (VOLUME_WIDGET(priv->volume_widget), new_value, "keypress-update"); } } } @@ -660,7 +660,7 @@ indicator_sound_scroll (IndicatorObject *io, gint delta, value -= adj->step_increment; } //g_debug("indicator-sound-scroll - update slider with value %f", value); - volume_widget_update(VOLUME_WIDGET(priv->volume_widget), value); + volume_widget_update(VOLUME_WIDGET(priv->volume_widget), value, "scroll updates"); sound_state_manager_show_notification (priv->state_manager, value); } diff --git a/src/mpris2-controller.c b/src/mpris2-controller.c index 89ef02d..0576340 100644 --- a/src/mpris2-controller.c +++ b/src/mpris2-controller.c @@ -344,7 +344,6 @@ MprisRoot* mpris2_controller_get_mpris2_root (Mpris2Controller* self); gchar* mpris_root_get_Identity (MprisRoot* self); GHashTable* mpris_player_get_Metadata (MprisPlayer* self); static GVariant* _variant_new1 (const gchar* value); -static const gchar* _variant_get2 (GVariant* value); void mpris2_controller_initial_update (Mpris2Controller* self); void mpris2_controller_transport_update (Mpris2Controller* self, TransportAction command); void mpris_player_PlayPause (MprisPlayer* self, GAsyncReadyCallback _callback_, gpointer _user_data_); @@ -635,11 +634,6 @@ static GVariant* _variant_new1 (const gchar* value) { } -static const gchar* _variant_get2 (GVariant* value) { - return g_variant_dup_string (value, NULL); -} - - static GHashTable* mpris2_controller_clean_metadata (Mpris2Controller* self) { GHashTable* result = NULL; GHashTable* _tmp0_ = NULL; @@ -667,11 +661,9 @@ static GHashTable* mpris2_controller_clean_metadata (Mpris2Controller* self) { GVariant* _tmp9_; GVariant* _tmp10_; GVariant* v_artists; - const gchar* _tmp11_ = NULL; gchar* display_artists = NULL; - const gchar* _tmp12_ = NULL; - gchar* _tmp18_; - gconstpointer _tmp19_ = NULL; + const gchar* _tmp11_ = NULL; + gchar* _tmp17_; _tmp6_ = mpris_player_get_Metadata (self->priv->_player); _tmp7_ = _tmp6_; _tmp8_ = g_hash_table_lookup (_tmp7_, "xesam:artist"); @@ -680,36 +672,31 @@ static GHashTable* mpris2_controller_clean_metadata (Mpris2Controller* self) { _g_hash_table_unref0 (_tmp7_); v_artists = _tmp10_; _tmp11_ = g_variant_get_type_string (v_artists); - g_debug ("mpris2-controller.vala:130: artists is of type %s", _tmp11_); - _tmp12_ = g_variant_get_type_string (v_artists); - if (g_strcmp0 (_tmp12_, "s") == 0) { - const gchar* _tmp13_ = NULL; - gchar* _tmp14_; - g_debug ("mpris2-controller.vala:133: SPOTIFY is that you ?"); - _tmp13_ = g_variant_get_string (v_artists, NULL); - _tmp14_ = g_strdup (_tmp13_); + if (g_strcmp0 (_tmp11_, "s") == 0) { + const gchar* _tmp12_ = NULL; + gchar* _tmp13_; + _tmp12_ = g_variant_get_string (v_artists, NULL); + _tmp13_ = g_strdup (_tmp12_); _g_free0 (display_artists); - display_artists = _tmp14_; + display_artists = _tmp13_; } else { - size_t _tmp15_; - gchar** _tmp16_ = NULL; + size_t _tmp14_; + gchar** _tmp15_ = NULL; gchar** artists; gint artists_length1; gint _artists_size_; - gchar* _tmp17_ = NULL; - _tmp16_ = g_variant_dup_strv (v_artists, &_tmp15_); - artists = _tmp16_; - artists_length1 = _tmp15_; - _artists_size_ = _tmp15_; - _tmp17_ = g_strjoinv (", ", artists); + gchar* _tmp16_ = NULL; + _tmp15_ = g_variant_dup_strv (v_artists, &_tmp14_); + artists = _tmp15_; + artists_length1 = _tmp14_; + _artists_size_ = _tmp14_; + _tmp16_ = g_strjoinv (", ", artists); _g_free0 (display_artists); - display_artists = _tmp17_; + display_artists = _tmp16_; artists = (_vala_array_free (artists, artists_length1, (GDestroyNotify) g_free), NULL); } - _tmp18_ = g_strdup ("xesam:artist"); - g_hash_table_replace (changed_updates, _tmp18_, _variant_new1 (display_artists)); - _tmp19_ = g_hash_table_lookup (changed_updates, "xesam:artist"); - g_debug ("mpris2-controller.vala:141: artist : %s", _variant_get2 ((GVariant*) _tmp19_)); + _tmp17_ = g_strdup ("xesam:artist"); + g_hash_table_replace (changed_updates, _tmp17_, _variant_new1 (display_artists)); _g_free0 (display_artists); _g_variant_unref0 (v_artists); } @@ -977,7 +964,6 @@ static gboolean mpris2_controller_fetch_playlists_co (Mpris2ControllerFetchPlayl { data->e = data->_inner_error_; data->_inner_error_ = NULL; - g_debug ("mpris2-controller.vala:229: Could not fetch playlists because %s", data->e->message); _g_error_free0 (data->e); data->current_playlists = (_vala_PlaylistDetails_array_free (data->current_playlists, data->current_playlists_length1), NULL); if (data->_state_ == 0) { @@ -996,7 +982,6 @@ static gboolean mpris2_controller_fetch_playlists_co (Mpris2ControllerFetchPlayl return FALSE; } if (data->current_playlists != NULL) { - g_debug ("mpris2-controller.vala:234: Size of the playlist array = %i", data->current_playlists_length1); data->_tmp3_ = NULL; data->_tmp3_ = gee_abstract_list_get ((GeeAbstractList*) data->self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS); data->_tmp4_ = (PlayerItem*) data->_tmp3_; @@ -1038,7 +1023,6 @@ static gboolean mpris2_controller_fetch_active_playlist (Mpris2Controller* self) _tmp2_ = _tmp1_.valid == FALSE; active_playlist_container_destroy (&_tmp1_); if (_tmp2_) { - g_debug ("mpris2-controller.vala:247: We don't have an active playlist"); } _tmp3_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->_owner->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS); _tmp4_ = (PlayerItem*) _tmp3_; @@ -1064,7 +1048,6 @@ void mpris2_controller_activate_playlist (Mpris2Controller* self, const char* pa GError * e; e = _inner_error_; _inner_error_ = NULL; - g_debug ("mpris2-controller.vala:260: Could not activate playlist %s because %s", (const gchar*) path, e->message); _g_error_free0 (e); } __finally12: diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 6129458..94c52c0 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -127,10 +127,10 @@ public class Mpris2Controller : GLib.Object Variant? artist_v = this.player.Metadata.lookup("xesam:artist"); if(artist_v != null){ Variant? v_artists = this.player.Metadata.lookup("xesam:artist"); - debug("artists is of type %s", v_artists.get_type_string ()); + //debug("artists is of type %s", v_artists.get_type_string ()); string display_artists; if(v_artists.get_type_string() == "s"){ - debug("SPOTIFY is that you ?"); + //debug("SPOTIFY is that you ?"); display_artists = v_artists.get_string(); } else{ @@ -138,7 +138,7 @@ public class Mpris2Controller : GLib.Object display_artists = string.joinv(", ", artists); } changed_updates.replace("xesam:artist", display_artists); - debug("artist : %s", (string)changed_updates.lookup("xesam:artist")); + //debug("artist : %s", (string)changed_updates.lookup("xesam:artist")); } return changed_updates; } @@ -226,12 +226,12 @@ public class Mpris2Controller : GLib.Object false); } catch (IOError e){ - debug("Could not fetch playlists because %s", e.message); + //debug("Could not fetch playlists because %s", e.message); return; } if( current_playlists != null ){ - debug( "Size of the playlist array = %i", current_playlists.length ); + //debug( "Size of the playlist array = %i", current_playlists.length ); PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem; playlists_item.update(current_playlists); } @@ -244,7 +244,7 @@ public class Mpris2Controller : GLib.Object private bool fetch_active_playlist() { if (this.playlists.ActivePlaylist.valid == false){ - debug(" We don't have an active playlist"); + //debug(" We don't have an active playlist"); } PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem; playlists_item.active_playlist_update ( this.playlists.ActivePlaylist.details ); @@ -257,7 +257,7 @@ public class Mpris2Controller : GLib.Object this.playlists.ActivatePlaylist.begin(path); } catch(IOError e){ - debug("Could not activate playlist %s because %s", (string)path, e.message); + //debug("Could not activate playlist %s because %s", (string)path, e.message); } } } diff --git a/src/mpris2-watcher.vala b/src/mpris2-watcher.vala index 0b37506..d508959 100644 --- a/src/mpris2-watcher.vala +++ b/src/mpris2-watcher.vala @@ -168,4 +168,4 @@ public class Mpris2Watcher : GLib.Object delete xml_doc; return result; } -}
\ No newline at end of file +} diff --git a/src/music-player-bridge.h b/src/music-player-bridge.h index 857e220..b155c6a 100644 --- a/src/music-player-bridge.h +++ b/src/music-player-bridge.h @@ -426,6 +426,7 @@ GType transport_menuitem_get_type (void) G_GNUC_CONST; GType player_controller_get_type (void) G_GNUC_CONST; TransportMenuitem* transport_menuitem_new (PlayerController* parent); TransportMenuitem* transport_menuitem_construct (GType object_type, PlayerController* parent); +void transport_menuitem_handle_cached_action (TransportMenuitem* self); void transport_menuitem_change_play_state (TransportMenuitem* self, TransportState update); GeeHashSet* transport_menuitem_attributes_format (void); GType metadata_menuitem_get_type (void) G_GNUC_CONST; diff --git a/src/player-controller.c b/src/player-controller.c index 2eb7992..5a2a64f 100644 --- a/src/player-controller.c +++ b/src/player-controller.c @@ -34,6 +34,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <stdlib.h> #include <string.h> #include <gio/gio.h> +#include <common-defs.h> #define TYPE_PLAYER_CONTROLLER (player_controller_get_type ()) @@ -86,6 +87,16 @@ typedef struct _PlaylistsMenuitemClass PlaylistsMenuitemClass; typedef struct _PlayerItemPrivate PlayerItemPrivate; typedef struct _PlaylistsMenuitemPrivate PlaylistsMenuitemPrivate; +#define TYPE_TRANSPORT_MENUITEM (transport_menuitem_get_type ()) +#define TRANSPORT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TRANSPORT_MENUITEM, TransportMenuitem)) +#define TRANSPORT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TRANSPORT_MENUITEM, TransportMenuitemClass)) +#define IS_TRANSPORT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TRANSPORT_MENUITEM)) +#define IS_TRANSPORT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TRANSPORT_MENUITEM)) +#define TRANSPORT_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TRANSPORT_MENUITEM, TransportMenuitemClass)) + +typedef struct _TransportMenuitem TransportMenuitem; +typedef struct _TransportMenuitemClass TransportMenuitemClass; + #define TYPE_TITLE_MENUITEM (title_menuitem_get_type ()) #define TITLE_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TITLE_MENUITEM, TitleMenuitem)) #define TITLE_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TITLE_MENUITEM, TitleMenuitemClass)) @@ -106,16 +117,6 @@ typedef struct _TitleMenuitemClass TitleMenuitemClass; typedef struct _MetadataMenuitem MetadataMenuitem; typedef struct _MetadataMenuitemClass MetadataMenuitemClass; -#define TYPE_TRANSPORT_MENUITEM (transport_menuitem_get_type ()) -#define TRANSPORT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TRANSPORT_MENUITEM, TransportMenuitem)) -#define TRANSPORT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TRANSPORT_MENUITEM, TransportMenuitemClass)) -#define IS_TRANSPORT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TRANSPORT_MENUITEM)) -#define IS_TRANSPORT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TRANSPORT_MENUITEM)) -#define TRANSPORT_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TRANSPORT_MENUITEM, TransportMenuitemClass)) - -typedef struct _TransportMenuitem TransportMenuitem; -typedef struct _TransportMenuitemClass TransportMenuitemClass; - struct _PlayerController { GObject parent_instance; PlayerControllerPrivate * priv; @@ -211,12 +212,14 @@ void player_controller_remove_from_menu (PlayerController* self); static gboolean _bool_equal (const gboolean* s1, const gboolean* s2); GType playlists_menuitem_get_type (void) G_GNUC_CONST; void player_controller_hibernate (PlayerController* self); +GType transport_menuitem_get_type (void) G_GNUC_CONST; +void transport_menuitem_change_play_state (TransportMenuitem* self, TransportState update); void player_item_reset (PlayerItem* self, GeeHashSet* attrs); -GeeHashSet* transport_menuitem_attributes_format (void); GeeHashSet* metadata_menuitem_attributes_format (void); GType title_menuitem_get_type (void) G_GNUC_CONST; void title_menuitem_toggle_active_triangle (TitleMenuitem* self, gboolean update); gboolean player_item_populated (PlayerItem* self, GeeHashSet* attrs); +void transport_menuitem_handle_cached_action (TransportMenuitem* self); PlayerItem* player_item_new (const gchar* type); PlayerItem* player_item_construct (GType object_type, const gchar* type); TitleMenuitem* title_menuitem_new (PlayerController* parent); @@ -226,7 +229,6 @@ MetadataMenuitem* metadata_menuitem_construct (GType object_type); GType metadata_menuitem_get_type (void) G_GNUC_CONST; TransportMenuitem* transport_menuitem_new (PlayerController* parent); TransportMenuitem* transport_menuitem_construct (GType object_type, PlayerController* parent); -GType transport_menuitem_get_type (void) G_GNUC_CONST; PlaylistsMenuitem* playlists_menuitem_new (PlayerController* parent); PlaylistsMenuitem* playlists_menuitem_construct (GType object_type, PlayerController* parent); gint player_controller_get_menu_offset (PlayerController* self); @@ -469,38 +471,35 @@ void player_controller_remove_from_menu (PlayerController* self) { void player_controller_hibernate (PlayerController* self) { gpointer _tmp0_ = NULL; PlayerItem* _tmp1_; - GeeHashSet* _tmp2_ = NULL; - GeeHashSet* _tmp3_; - gpointer _tmp4_ = NULL; - PlayerItem* _tmp5_; - GeeHashSet* _tmp6_ = NULL; - GeeHashSet* _tmp7_; - gpointer _tmp8_ = NULL; - PlayerItem* _tmp9_; + TransportMenuitem* transport; + gpointer _tmp2_ = NULL; + PlayerItem* _tmp3_; + GeeHashSet* _tmp4_ = NULL; + GeeHashSet* _tmp5_; + gpointer _tmp6_ = NULL; + PlayerItem* _tmp7_; TitleMenuitem* title; g_return_if_fail (self != NULL); player_controller_update_state (self, PLAYER_CONTROLLER_STATE_OFFLINE); _tmp0_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); _tmp1_ = (PlayerItem*) _tmp0_; - _tmp2_ = transport_menuitem_attributes_format (); - _tmp3_ = _tmp2_; - player_item_reset (_tmp1_, _tmp3_); - _g_object_unref0 (_tmp3_); - _g_object_unref0 (_tmp1_); - _tmp4_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); - _tmp5_ = (PlayerItem*) _tmp4_; - _tmp6_ = metadata_menuitem_attributes_format (); - _tmp7_ = _tmp6_; - player_item_reset (_tmp5_, _tmp7_); - _g_object_unref0 (_tmp7_); + transport = IS_TRANSPORT_MENUITEM (_tmp1_) ? ((TransportMenuitem*) _tmp1_) : NULL; + transport_menuitem_change_play_state (transport, TRANSPORT_STATE_PAUSED); + _tmp2_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); + _tmp3_ = (PlayerItem*) _tmp2_; + _tmp4_ = metadata_menuitem_attributes_format (); + _tmp5_ = _tmp4_; + player_item_reset (_tmp3_, _tmp5_); _g_object_unref0 (_tmp5_); - _tmp8_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TITLE); - _tmp9_ = (PlayerItem*) _tmp8_; - title = IS_TITLE_MENUITEM (_tmp9_) ? ((TitleMenuitem*) _tmp9_) : NULL; + _g_object_unref0 (_tmp3_); + _tmp6_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TITLE); + _tmp7_ = (PlayerItem*) _tmp6_; + title = IS_TITLE_MENUITEM (_tmp7_) ? ((TitleMenuitem*) _tmp7_) : NULL; title_menuitem_toggle_active_triangle (title, FALSE); _g_object_unref0 (self->mpris_bridge); self->mpris_bridge = NULL; _g_object_unref0 (title); + _g_object_unref0 (transport); } @@ -508,15 +507,14 @@ void player_controller_update_layout (PlayerController* self) { gpointer _tmp0_ = NULL; PlayerItem* _tmp1_; PlaylistsMenuitem* playlists_menuitem; - gpointer _tmp6_ = NULL; - PlayerItem* _tmp7_; - gpointer _tmp8_ = NULL; - PlayerItem* _tmp9_; - GeeHashSet* _tmp10_ = NULL; - GeeHashSet* _tmp11_; - gboolean _tmp12_; - gpointer _tmp13_ = NULL; - PlayerItem* _tmp14_; + gpointer _tmp7_ = NULL; + PlayerItem* _tmp8_; + gpointer _tmp9_ = NULL; + PlayerItem* _tmp10_; + GeeHashSet* _tmp11_ = NULL; + GeeHashSet* _tmp12_; + gboolean _tmp13_; + const gchar* _tmp14_ = NULL; g_return_if_fail (self != NULL); _tmp0_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_PLAYLISTS); _tmp1_ = (PlayerItem*) _tmp0_; @@ -526,33 +524,49 @@ void player_controller_update_layout (PlayerController* self) { PlayerItem* _tmp3_; gpointer _tmp4_ = NULL; PlayerItem* _tmp5_; - _tmp2_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); + const gchar* _tmp6_ = NULL; + _tmp2_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); _tmp3_ = (PlayerItem*) _tmp2_; dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp3_, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); _g_object_unref0 (_tmp3_); - _tmp4_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); + dbusmenu_menuitem_property_set_bool (playlists_menuitem->root_item, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + _tmp4_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); _tmp5_ = (PlayerItem*) _tmp4_; - dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp5_, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + _tmp6_ = g_app_info_get_id (self->priv->_app_info); + dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp5_, DBUSMENU_MENUITEM_PROP_VISIBLE, g_strcmp0 (_tmp6_, "banshee.desktop") == 0); _g_object_unref0 (_tmp5_); - dbusmenu_menuitem_property_set_bool (playlists_menuitem->root_item, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); _g_object_unref0 (playlists_menuitem); return; } - _tmp6_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); - _tmp7_ = (PlayerItem*) _tmp6_; - _tmp8_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); - _tmp9_ = (PlayerItem*) _tmp8_; - _tmp10_ = metadata_menuitem_attributes_format (); - _tmp11_ = _tmp10_; - _tmp12_ = player_item_populated (_tmp9_, _tmp11_); - dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp7_, DBUSMENU_MENUITEM_PROP_VISIBLE, _tmp12_); - _g_object_unref0 (_tmp11_); - _g_object_unref0 (_tmp9_); - _g_object_unref0 (_tmp7_); - _tmp13_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); - _tmp14_ = (PlayerItem*) _tmp13_; - dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp14_, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - _g_object_unref0 (_tmp14_); + _tmp7_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); + _tmp8_ = (PlayerItem*) _tmp7_; + _tmp9_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_METADATA); + _tmp10_ = (PlayerItem*) _tmp9_; + _tmp11_ = metadata_menuitem_attributes_format (); + _tmp12_ = _tmp11_; + _tmp13_ = player_item_populated (_tmp10_, _tmp12_); + dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp8_, DBUSMENU_MENUITEM_PROP_VISIBLE, _tmp13_); + _g_object_unref0 (_tmp12_); + _g_object_unref0 (_tmp10_); + _g_object_unref0 (_tmp8_); + _tmp14_ = g_app_info_get_id (self->priv->_app_info); + if (g_strcmp0 (_tmp14_, "banshee.desktop") == 0) { + gpointer _tmp15_ = NULL; + PlayerItem* _tmp16_; + TransportMenuitem* transport; + _tmp15_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); + _tmp16_ = (PlayerItem*) _tmp15_; + transport = IS_TRANSPORT_MENUITEM (_tmp16_) ? ((TransportMenuitem*) _tmp16_) : NULL; + transport_menuitem_handle_cached_action (transport); + _g_object_unref0 (transport); + } else { + gpointer _tmp17_ = NULL; + PlayerItem* _tmp18_; + _tmp17_ = gee_abstract_list_get ((GeeAbstractList*) self->custom_items, (gint) PLAYER_CONTROLLER_WIDGET_ORDER_TRANSPORT); + _tmp18_ = (PlayerItem*) _tmp17_; + dbusmenu_menuitem_property_set_bool ((DbusmenuMenuitem*) _tmp18_, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + _g_object_unref0 (_tmp18_); + } dbusmenu_menuitem_property_set_bool (playlists_menuitem->root_item, DBUSMENU_MENUITEM_PROP_VISIBLE, *self->use_playlists); _g_object_unref0 (playlists_menuitem); } diff --git a/src/player-controller.vala b/src/player-controller.vala index 3ce121e..20479d9 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -133,7 +133,8 @@ public class PlayerController : GLib.Object public void hibernate() { update_state(PlayerController.state.OFFLINE); - this.custom_items[widget_order.TRANSPORT].reset(TransportMenuitem.attributes_format()); + TransportMenuitem transport = this.custom_items[widget_order.TRANSPORT] as TransportMenuitem; + transport.change_play_state (Transport.State.PAUSED); this.custom_items[widget_order.METADATA].reset(MetadataMenuitem.attributes_format()); TitleMenuitem title = this.custom_items[widget_order.TITLE] as TitleMenuitem; title.toggle_active_triangle(false); @@ -143,20 +144,25 @@ public class PlayerController : GLib.Object public void update_layout() { PlaylistsMenuitem playlists_menuitem = this.custom_items[widget_order.PLAYLISTS] as PlaylistsMenuitem; - if(this.current_state != state.CONNECTED){ - this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, + this.custom_items[widget_order.METADATA].property_set_bool (MENUITEM_PROP_VISIBLE, false); - this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, - false); - playlists_menuitem.root_item.property_set_bool ( MENUITEM_PROP_VISIBLE, - false ); + playlists_menuitem.root_item.property_set_bool (MENUITEM_PROP_VISIBLE, + false ); + this.custom_items[widget_order.TRANSPORT].property_set_bool (MENUITEM_PROP_VISIBLE, + this.app_info.get_id() == "banshee.desktop"); return; } - this.custom_items[widget_order.METADATA].property_set_bool(MENUITEM_PROP_VISIBLE, - this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format())); - this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE, - true); + this.custom_items[widget_order.METADATA].property_set_bool (MENUITEM_PROP_VISIBLE, + this.custom_items[widget_order.METADATA].populated(MetadataMenuitem.attributes_format())); + if (this.app_info.get_id() == "banshee.desktop"){ + TransportMenuitem transport = this.custom_items[widget_order.TRANSPORT] as TransportMenuitem; + transport.handle_cached_action(); + } + else{ + this.custom_items[widget_order.TRANSPORT].property_set_bool (MENUITEM_PROP_VISIBLE, + true); + } playlists_menuitem.root_item.property_set_bool ( MENUITEM_PROP_VISIBLE, this.use_playlists ); } diff --git a/src/player-item.c b/src/player-item.c index 6133279..f5d88d8 100644 --- a/src/player-item.c +++ b/src/player-item.c @@ -145,7 +145,6 @@ void player_item_reset (PlayerItem* self, GeeHashSet* attrs) { } _tmp2_ = gee_iterator_get (_s_it); s = (gchar*) _tmp2_; - g_debug ("player-item.vala:40: attempting to set prop %s to EMPTY", s); dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, s, PLAYER_ITEM_EMPTY); _g_free0 (s); } @@ -199,7 +198,6 @@ void player_item_update (PlayerItem* self, GHashTable* data, GeeHashSet* attribu g_return_if_fail (self != NULL); g_return_if_fail (data != NULL); g_return_if_fail (attributes != NULL); - g_debug ("player-item.vala:53: PlayerItem::update()"); if (data == NULL) { g_warning ("player-item.vala:55: PlayerItem::Update -> The hashtable was null - ju" \ "st leave it!"); diff --git a/src/player-item.vala b/src/player-item.vala index 9d07bf7..f71b166 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -37,7 +37,7 @@ public class PlayerItem : Dbusmenu.Menuitem public void reset(HashSet<string> attrs){ foreach(string s in attrs){ - debug("attempting to set prop %s to EMPTY", s); + //debug("attempting to set prop %s to EMPTY", s); this.property_set_int(s, EMPTY); } } @@ -50,7 +50,7 @@ public class PlayerItem : Dbusmenu.Menuitem */ public void update(HashTable<string, Variant?> data, HashSet<string> attributes) { - debug("PlayerItem::update()"); + //debug("PlayerItem::update()"); if(data == null){ warning("PlayerItem::Update -> The hashtable was null - just leave it!"); return; diff --git a/src/playlists-menu-item.c b/src/playlists-menu-item.c index ced54cf..ed78fc8 100644 --- a/src/playlists-menu-item.c +++ b/src/playlists-menu-item.c @@ -34,7 +34,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <stdlib.h> #include <string.h> #include <glib/gi18n-lib.h> -#include <gio/gio.h> #define TYPE_PLAYER_ITEM (player_item_get_type ()) @@ -155,7 +154,7 @@ void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playli static Block1Data* block1_data_ref (Block1Data* _data1_); static void block1_data_unref (Block1Data* _data1_); static gboolean playlists_menuitem_already_observed (PlaylistsMenuitem* self, PlaylistDetails* new_detail); -static gchar* playlists_menuitem_parse_icon_path (PlaylistsMenuitem* self, const gchar* path); +static gboolean playlists_menuitem_is_video_related (PlaylistsMenuitem* self, PlaylistDetails* new_detail); static void _lambda1_ (Block1Data* _data1_); static void playlists_menuitem_submenu_item_activated (PlaylistsMenuitem* self, gint menu_item_id); static void __lambda1__dbusmenu_menuitem_item_activated (DbusmenuMenuitem* _sender, guint timestamp, gpointer self); @@ -167,9 +166,6 @@ void mpris2_controller_activate_playlist (Mpris2Controller* self, const char* pa GeeHashSet* playlists_menuitem_attributes_format (void); static GObject * playlists_menuitem_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); static void playlists_menuitem_finalize (GObject* obj); -static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func); -static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func); -static gint _vala_array_length (gpointer array); PlaylistsMenuitem* playlists_menuitem_construct (GType object_type, PlayerController* parent) { @@ -231,37 +227,38 @@ void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playli detail = _tmp0_; { Block1Data* _data1_; - gboolean _tmp2_; - DbusmenuMenuitem* _tmp3_ = NULL; - gchar* _tmp4_ = NULL; - gchar* _result_; - gint _tmp5_; + gboolean _tmp2_ = FALSE; + gboolean _tmp3_; + DbusmenuMenuitem* _tmp5_ = NULL; + gint _tmp6_; _data1_ = g_slice_new0 (Block1Data); _data1_->_ref_count_ = 1; _data1_->self = g_object_ref (self); - _tmp2_ = playlists_menuitem_already_observed (self, &detail); + _tmp3_ = playlists_menuitem_already_observed (self, &detail); + if (_tmp3_) { + _tmp2_ = TRUE; + } else { + gboolean _tmp4_; + _tmp4_ = playlists_menuitem_is_video_related (self, &detail); + _tmp2_ = _tmp4_; + } if (_tmp2_) { playlist_details_destroy (&detail); block1_data_unref (_data1_); _data1_ = NULL; continue; } - _tmp3_ = dbusmenu_menuitem_new (); - _data1_->menuitem = _tmp3_; + _tmp5_ = dbusmenu_menuitem_new (); + _data1_->menuitem = _tmp5_; dbusmenu_menuitem_property_set (_data1_->menuitem, DBUSMENU_MENUITEM_PROP_LABEL, detail.name); - _tmp4_ = playlists_menuitem_parse_icon_path (self, detail.icon_path); - _result_ = _tmp4_; - if (_result_ != NULL) { - dbusmenu_menuitem_property_set (_data1_->menuitem, DBUSMENU_MENUITEM_PROP_ICON_NAME, (const gchar*) _result_); - } + dbusmenu_menuitem_property_set (_data1_->menuitem, DBUSMENU_MENUITEM_PROP_ICON_NAME, "playlist-symbolic"); dbusmenu_menuitem_property_set (_data1_->menuitem, DBUSMENU_PLAYLIST_MENUITEM_PATH, (const gchar*) detail.path); dbusmenu_menuitem_property_set_bool (_data1_->menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); dbusmenu_menuitem_property_set_bool (_data1_->menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); g_signal_connect_data (_data1_->menuitem, "item-activated", (GCallback) __lambda1__dbusmenu_menuitem_item_activated, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0); - _tmp5_ = dbusmenu_menuitem_get_id (_data1_->menuitem); - gee_abstract_map_set ((GeeAbstractMap*) self->priv->current_playlists, GINT_TO_POINTER (_tmp5_), _data1_->menuitem); + _tmp6_ = dbusmenu_menuitem_get_id (_data1_->menuitem); + gee_abstract_map_set ((GeeAbstractMap*) self->priv->current_playlists, GINT_TO_POINTER (_tmp6_), _data1_->menuitem); dbusmenu_menuitem_child_append (self->root_item, _data1_->menuitem); - _g_free0 (_result_); playlist_details_destroy (&detail); block1_data_unref (_data1_); _data1_ = NULL; @@ -269,28 +266,28 @@ void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playli } } { - GeeCollection* _tmp6_ = NULL; - GeeCollection* _tmp7_; - GeeIterator* _tmp8_ = NULL; - GeeIterator* _tmp9_; + GeeCollection* _tmp7_ = NULL; + GeeCollection* _tmp8_; + GeeIterator* _tmp9_ = NULL; + GeeIterator* _tmp10_; GeeIterator* _item_it; - _tmp6_ = gee_map_get_values ((GeeMap*) self->priv->current_playlists); - _tmp7_ = _tmp6_; - _tmp8_ = gee_iterable_iterator ((GeeIterable*) _tmp7_); - _tmp9_ = _tmp8_; - _g_object_unref0 (_tmp7_); - _item_it = _tmp9_; + _tmp7_ = gee_map_get_values ((GeeMap*) self->priv->current_playlists); + _tmp8_ = _tmp7_; + _tmp9_ = gee_iterable_iterator ((GeeIterable*) _tmp8_); + _tmp10_ = _tmp9_; + _g_object_unref0 (_tmp8_); + _item_it = _tmp10_; while (TRUE) { - gboolean _tmp10_; - gpointer _tmp11_ = NULL; + gboolean _tmp11_; + gpointer _tmp12_ = NULL; DbusmenuMenuitem* item; gboolean within; - _tmp10_ = gee_iterator_next (_item_it); - if (!_tmp10_) { + _tmp11_ = gee_iterator_next (_item_it); + if (!_tmp11_) { break; } - _tmp11_ = gee_iterator_get (_item_it); - item = (DbusmenuMenuitem*) _tmp11_; + _tmp12_ = gee_iterator_get (_item_it); + item = (DbusmenuMenuitem*) _tmp12_; within = FALSE; { PlaylistDetails* detail_collection; @@ -299,16 +296,16 @@ void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playli detail_collection = playlists; detail_collection_length1 = playlists_length1; for (detail_it = 0; detail_it < playlists_length1; detail_it = detail_it + 1) { - PlaylistDetails _tmp12_; - PlaylistDetails _tmp13_ = {0}; + PlaylistDetails _tmp13_; + PlaylistDetails _tmp14_ = {0}; PlaylistDetails detail; - playlist_details_copy (&detail_collection[detail_it], &_tmp13_); - _tmp12_ = _tmp13_; - detail = _tmp12_; + playlist_details_copy (&detail_collection[detail_it], &_tmp14_); + _tmp13_ = _tmp14_; + detail = _tmp13_; { - const gchar* _tmp14_ = NULL; - _tmp14_ = dbusmenu_menuitem_property_get (item, DBUSMENU_PLAYLIST_MENUITEM_PATH); - if (g_strcmp0 (detail.path, _tmp14_) == 0) { + const gchar* _tmp15_ = NULL; + _tmp15_ = dbusmenu_menuitem_property_get (item, DBUSMENU_PLAYLIST_MENUITEM_PATH); + if (g_strcmp0 (detail.path, _tmp15_) == 0) { within = TRUE; playlist_details_destroy (&detail); break; @@ -318,14 +315,14 @@ void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playli } } if (within == FALSE) { - const gchar* _tmp15_ = NULL; const gchar* _tmp16_ = NULL; - _tmp15_ = dbusmenu_menuitem_property_get (self->root_item, DBUSMENU_PLAYLIST_MENUITEM_PATH); - _tmp16_ = dbusmenu_menuitem_property_get (item, DBUSMENU_PLAYLIST_MENUITEM_PATH); - if (g_strcmp0 (_tmp15_, _tmp16_) == 0) { - const gchar* _tmp17_ = NULL; - _tmp17_ = _ ("Choose Playlist"); - dbusmenu_menuitem_property_set (self->root_item, DBUSMENU_MENUITEM_PROP_LABEL, _tmp17_); + const gchar* _tmp17_ = NULL; + _tmp16_ = dbusmenu_menuitem_property_get (self->root_item, DBUSMENU_PLAYLIST_MENUITEM_PATH); + _tmp17_ = dbusmenu_menuitem_property_get (item, DBUSMENU_PLAYLIST_MENUITEM_PATH); + if (g_strcmp0 (_tmp16_, _tmp17_) == 0) { + const gchar* _tmp18_ = NULL; + _tmp18_ = _ ("Choose Playlist"); + dbusmenu_menuitem_property_set (self->root_item, DBUSMENU_MENUITEM_PROP_LABEL, _tmp18_); } dbusmenu_menuitem_child_delete (self->root_item, item); } @@ -336,55 +333,8 @@ void playlists_menuitem_update (PlaylistsMenuitem* self, PlaylistDetails* playli } -static gchar* playlists_menuitem_parse_icon_path (PlaylistsMenuitem* self, const gchar* path) { - gchar* result = NULL; - GFile* _tmp0_ = NULL; - GFile* icon_file; - gchar* _tmp1_ = NULL; - gchar* _tmp2_; - gboolean _tmp3_; - gchar* _tmp4_ = NULL; - gchar* _tmp5_; - gchar** _tmp6_; - gchar** _tmp7_ = NULL; - gchar** _tmp8_; - gint _tmp8__length1; - gchar* _tmp9_; - gchar* _tmp10_; - g_return_val_if_fail (self != NULL, NULL); - g_return_val_if_fail (path != NULL, NULL); - if (g_strcmp0 (path, "") == 0) { - result = NULL; - return result; - } - _tmp0_ = g_file_new_for_path (path); - icon_file = _tmp0_; - _tmp1_ = g_file_get_path (icon_file); - _tmp2_ = _tmp1_; - _tmp3_ = _tmp2_ == NULL; - _g_free0 (_tmp2_); - if (_tmp3_) { - result = NULL; - _g_object_unref0 (icon_file); - return result; - } - _tmp4_ = g_file_get_basename (icon_file); - _tmp5_ = _tmp4_; - _tmp7_ = _tmp6_ = g_strsplit (_tmp5_, ".", 0); - _tmp8_ = _tmp7_; - _tmp8__length1 = _vala_array_length (_tmp6_); - _tmp9_ = g_strdup (_tmp8_[0]); - _tmp10_ = _tmp9_; - _tmp8_ = (_vala_array_free (_tmp8_, _tmp8__length1, (GDestroyNotify) g_free), NULL); - _g_free0 (_tmp5_); - result = _tmp10_; - _g_object_unref0 (icon_file); - return result; -} - - void playlists_menuitem_update_individual_playlist (PlaylistsMenuitem* self, PlaylistDetails* new_detail) { - const gchar* _tmp8_ = NULL; + const gchar* _tmp7_ = NULL; g_return_if_fail (self != NULL); { GeeCollection* _tmp0_ = NULL; @@ -411,22 +361,14 @@ void playlists_menuitem_update_individual_playlist (PlaylistsMenuitem* self, Pla item = (DbusmenuMenuitem*) _tmp5_; _tmp6_ = dbusmenu_menuitem_property_get (item, DBUSMENU_PLAYLIST_MENUITEM_PATH); if (g_strcmp0 ((*new_detail).path, _tmp6_) == 0) { - gchar* _tmp7_ = NULL; - gchar* _result_; dbusmenu_menuitem_property_set (item, DBUSMENU_MENUITEM_PROP_LABEL, (*new_detail).name); - _tmp7_ = playlists_menuitem_parse_icon_path (self, (*new_detail).icon_path); - _result_ = _tmp7_; - if (_result_ != NULL) { - dbusmenu_menuitem_property_set (item, DBUSMENU_MENUITEM_PROP_ICON_NAME, _result_); - } - _g_free0 (_result_); } _g_object_unref0 (item); } _g_object_unref0 (_item_it); } - _tmp8_ = dbusmenu_menuitem_property_get (self->root_item, DBUSMENU_PLAYLIST_MENUITEM_PATH); - if (g_strcmp0 (_tmp8_, (*new_detail).path) == 0) { + _tmp7_ = dbusmenu_menuitem_property_get (self->root_item, DBUSMENU_PLAYLIST_MENUITEM_PATH); + if (g_strcmp0 (_tmp7_, (*new_detail).path) == 0) { dbusmenu_menuitem_property_set (self->root_item, DBUSMENU_MENUITEM_PROP_LABEL, (*new_detail).name); } } @@ -480,6 +422,37 @@ static gboolean playlists_menuitem_already_observed (PlaylistsMenuitem* self, Pl } +static gboolean string_contains (const gchar* self, const gchar* needle) { + gboolean result = FALSE; + gchar* _tmp0_ = NULL; + g_return_val_if_fail (self != NULL, FALSE); + g_return_val_if_fail (needle != NULL, FALSE); + _tmp0_ = strstr ((gchar*) self, (gchar*) needle); + result = _tmp0_ != NULL; + return result; +} + + +static gboolean playlists_menuitem_is_video_related (PlaylistsMenuitem* self, PlaylistDetails* new_detail) { + gboolean result = FALSE; + gchar* _tmp0_; + gchar* location; + gboolean _tmp1_; + g_return_val_if_fail (self != NULL, FALSE); + _tmp0_ = g_strdup ((const gchar*) (*new_detail).path); + location = _tmp0_; + _tmp1_ = string_contains (location, "/VideoLibrarySource/"); + if (_tmp1_) { + result = TRUE; + _g_free0 (location); + return result; + } + result = FALSE; + _g_free0 (location); + return result; +} + + void playlists_menuitem_active_playlist_update (PlaylistsMenuitem* self, PlaylistDetails* detail) { gchar* _tmp0_; gchar* update; @@ -509,7 +482,7 @@ static void playlists_menuitem_submenu_item_activated (PlaylistsMenuitem* self, g_return_if_fail (self != NULL); _tmp0_ = gee_abstract_map_has_key ((GeeAbstractMap*) self->priv->current_playlists, GINT_TO_POINTER (menu_item_id)); if (!_tmp0_) { - g_warning ("playlists-menu-item.vala:133: item %i was activated but we don't have " \ + g_warning ("playlists-menu-item.vala:126: item %i was activated but we don't have " \ "a corresponding playlist", menu_item_id); return; } @@ -592,34 +565,4 @@ GType playlists_menuitem_get_type (void) { } -static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) { - if ((array != NULL) && (destroy_func != NULL)) { - int i; - for (i = 0; i < array_length; i = i + 1) { - if (((gpointer*) array)[i] != NULL) { - destroy_func (((gpointer*) array)[i]); - } - } - } -} - - -static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) { - _vala_array_destroy (array, array_length, destroy_func); - g_free (array); -} - - -static gint _vala_array_length (gpointer array) { - int length; - length = 0; - if (array) { - while (((gpointer*) array)[length]) { - length++; - } - } - return length; -} - - diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala index 79ab506..58c3875 100644 --- a/src/playlists-menu-item.vala +++ b/src/playlists-menu-item.vala @@ -46,15 +46,13 @@ public class PlaylistsMenuitem : PlayerItem public new void update (PlaylistDetails[] playlists) { foreach ( PlaylistDetails detail in playlists ){ - - if (this.already_observed(detail)) continue; + // We don't want to list playlists which are for videos)' + if (this.already_observed(detail) || this.is_video_related(detail)) + continue; Dbusmenu.Menuitem menuitem = new Menuitem(); menuitem.property_set (MENUITEM_PROP_LABEL, detail.name); - var result = this.parse_icon_path (detail.icon_path); - if (result != null) { - menuitem.property_set (MENUITEM_PROP_ICON_NAME, (string)result); - } + menuitem.property_set (MENUITEM_PROP_ICON_NAME, "playlist-symbolic"); menuitem.property_set (MENUITEM_PATH, (string)detail.path); menuitem.property_set_bool (MENUITEM_PROP_VISIBLE, true); @@ -80,28 +78,16 @@ public class PlaylistsMenuitem : PlayerItem if (this.root_item.property_get (MENUITEM_PATH) == item.property_get (MENUITEM_PATH)){ this.root_item.property_set (MENUITEM_PROP_LABEL, _("Choose Playlist")); } - this.root_item.child_delete (item); + this.root_item.child_delete (item); } } } - private string? parse_icon_path (string path) - { - if (path == "")return null; - var icon_file = File.new_for_path (path); - if (icon_file.get_path() == null)return null; - return icon_file.get_basename().split(".")[0]; - } - public void update_individual_playlist (PlaylistDetails new_detail) { foreach ( Dbusmenu.Menuitem item in this.current_playlists.values ){ if (new_detail.path == item.property_get (MENUITEM_PATH)){ item.property_set (MENUITEM_PROP_LABEL, new_detail.name); - var result = this.parse_icon_path (new_detail.icon_path); - if (result != null) { - item.property_set (MENUITEM_PROP_ICON_NAME, result); - } } } // If its active make sure the name is updated on the root item. @@ -119,6 +105,13 @@ public class PlaylistsMenuitem : PlayerItem return false; } + private bool is_video_related (PlaylistDetails new_detail) + { + var location = (string)new_detail.path; + if (location.contains ("/VideoLibrarySource/")) return true; + return false; + } + public void active_playlist_update (PlaylistDetails detail) { var update = detail.name; diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c index 974749f..8186fa3 100644 --- a/src/slider-menu-item.c +++ b/src/slider-menu-item.c @@ -69,7 +69,6 @@ slider_menu_item_class_init (SliderMenuItemClass *klass) static void slider_menu_item_init (SliderMenuItem *self) { - g_debug("Building new Slider Menu Item"); dbusmenu_menuitem_property_set( DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_VOLUME_MENUITEM_TYPE ); @@ -101,21 +100,20 @@ handle_event (DbusmenuMenuitem * mi, GVariant * value, guint timestamp) { - GVariant* input = NULL; - input = value; - if (g_variant_is_of_type(value, G_VARIANT_TYPE_VARIANT) == TRUE) { - input = g_variant_get_variant(value); - } + g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_DOUBLE)); + g_return_if_fail (IS_SLIDER_MENU_ITEM (mi)); - if (value != NULL){ - if (IS_SLIDER_MENU_ITEM (mi)) { - SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (SLIDER_MENU_ITEM (mi)); - gdouble volume_input = g_variant_get_double(input); - //g_debug ("slider menu item about to update volume %f", volume_input); - slider_menu_item_update_volume (SLIDER_MENU_ITEM (mi), volume_input); - device_ensure_sink_is_unmuted (priv->a_sink); - } - } + SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (SLIDER_MENU_ITEM (mi)); + gdouble volume_input = g_variant_get_double (value); + +/* + g_debug ("slider menu item handle event with value %f on name %s", + volume_input, + name); +*/ + + slider_menu_item_update_volume (SLIDER_MENU_ITEM (mi), volume_input); + device_ensure_sink_is_unmuted (priv->a_sink); } @@ -136,7 +134,7 @@ slider_menu_item_populate (SliderMenuItem* self, const pa_sink_info* update) dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self), DBUSMENU_VOLUME_MENUITEM_LEVEL, new_volume); - GVariant* new_mute_update = g_variant_new_int32 (update->mute); + GVariant* new_mute_update = g_variant_new_boolean (update->mute == 1); dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self), DBUSMENU_VOLUME_MENUITEM_MUTE, new_mute_update); @@ -148,6 +146,11 @@ slider_menu_item_populate (SliderMenuItem* self, const pa_sink_info* update) static void slider_menu_item_update_volume (SliderMenuItem* self, gdouble percent) { + +/* + g_debug ("slider menu item update volume - about to set the volume to %f", percent); +*/ + pa_cvolume new_volume; pa_cvolume_init(&new_volume); new_volume.channels = 1; @@ -174,13 +177,21 @@ slider_menu_item_update (SliderMenuItem* self, const pa_sink_info* update) gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM; GVariant* new_volume = g_variant_new_double (volume_percent); + +/* + g_debug ("slider menu item update - volume update to ui to %f", volume_percent); +*/ + dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self), DBUSMENU_VOLUME_MENUITEM_LEVEL, new_volume); + if (priv->mute != update->mute){ priv->mute = update->mute; - g_debug ("volume menu item - update - mute = %i", update->mute); - GVariant* new_mute_update = g_variant_new_int32 (update->mute); +/* + g_debug ("volume menu item - update - mute on ui = %i", update->mute); +*/ + GVariant* new_mute_update = g_variant_new_boolean (update->mute == 1); dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self), DBUSMENU_VOLUME_MENUITEM_MUTE, new_mute_update); @@ -233,4 +244,4 @@ slider_menu_item_new (Device* sink) SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self); priv->a_sink = sink; return self; -}
\ No newline at end of file +} diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 7c817af..1b9d29e 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -148,11 +148,8 @@ sound_service_dbus_create_root_item (SoundServiceDbus* self) { SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self); priv->root_menuitem = dbusmenu_menuitem_new(); - g_debug("Root ID: %d", dbusmenu_menuitem_get_id(priv->root_menuitem)); + //g_debug("Root ID: %d", dbusmenu_menuitem_get_id(priv->root_menuitem)); DbusmenuServer *server = dbusmenu_server_new (INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH); - const gchar* paths[] = {"/usr/share/banshee-1/icons", NULL}; - dbusmenu_server_set_icon_paths (server, - paths); dbusmenu_server_set_root (server, priv->root_menuitem); g_object_unref (priv->root_menuitem); priv->device = device_new (self); diff --git a/src/sound-service.c b/src/sound-service.c index 7e6426c..1324537 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -22,6 +22,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "sound-service-dbus.h" #include "music-player-bridge.h" +#include <locale.h> + static GMainLoop *mainloop = NULL; /**********************************************************************************************************************/ diff --git a/src/transport-menu-item.c b/src/transport-menu-item.c index df1cc14..7f24dc6 100644 --- a/src/transport-menu-item.c +++ b/src/transport-menu-item.c @@ -30,9 +30,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <libdbusmenu-glib/server.h> #include <libdbusmenu-glib/types.h> #include <common-defs.h> +#include <gee.h> #include <stdlib.h> #include <string.h> -#include <gee.h> #define TYPE_PLAYER_ITEM (player_item_get_type ()) @@ -66,7 +66,6 @@ typedef struct _TransportMenuitemPrivate TransportMenuitemPrivate; typedef struct _PlayerController PlayerController; typedef struct _PlayerControllerClass PlayerControllerClass; -#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL))) typedef struct _PlayerControllerPrivate PlayerControllerPrivate; #define TYPE_MPRIS2_CONTROLLER (mpris2_controller_get_type ()) @@ -78,8 +77,11 @@ typedef struct _PlayerControllerPrivate PlayerControllerPrivate; typedef struct _Mpris2Controller Mpris2Controller; typedef struct _Mpris2ControllerClass Mpris2ControllerClass; +#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL))) #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) +#define PLAYER_CONTROLLER_TYPE_STATE (player_controller_state_get_type ()) + struct _PlayerItem { DbusmenuMenuitem parent_instance; PlayerItemPrivate * priv; @@ -98,6 +100,10 @@ struct _TransportMenuitemClass { PlayerItemClass parent_class; }; +struct _TransportMenuitemPrivate { + TransportAction cached_action; +}; + struct _PlayerController { GObject parent_instance; PlayerControllerPrivate * priv; @@ -111,30 +117,47 @@ struct _PlayerControllerClass { GObjectClass parent_class; }; +typedef enum { + PLAYER_CONTROLLER_STATE_OFFLINE, + PLAYER_CONTROLLER_STATE_INSTANTIATING, + PLAYER_CONTROLLER_STATE_READY, + PLAYER_CONTROLLER_STATE_CONNECTED, + PLAYER_CONTROLLER_STATE_DISCONNECTED +} PlayerControllerstate; + static gpointer transport_menuitem_parent_class = NULL; GType player_item_get_type (void) G_GNUC_CONST; GType transport_menuitem_get_type (void) G_GNUC_CONST; +#define TRANSPORT_MENUITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_TRANSPORT_MENUITEM, TransportMenuitemPrivate)) enum { TRANSPORT_MENUITEM_DUMMY_PROPERTY }; GType player_controller_get_type (void) G_GNUC_CONST; TransportMenuitem* transport_menuitem_new (PlayerController* parent); TransportMenuitem* transport_menuitem_construct (GType object_type, PlayerController* parent); -void transport_menuitem_change_play_state (TransportMenuitem* self, TransportState update); -static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* name, GVariant* input_value, guint timestamp); +void transport_menuitem_handle_cached_action (TransportMenuitem* self); +static gboolean transport_menuitem_send_cached_action (TransportMenuitem* self); +static gboolean _transport_menuitem_send_cached_action_gsource_func (gpointer self); PlayerController* player_item_get_owner (PlayerItem* self); GType mpris2_controller_get_type (void) G_GNUC_CONST; void mpris2_controller_transport_update (Mpris2Controller* self, TransportAction command); +void transport_menuitem_change_play_state (TransportMenuitem* self, TransportState update); +static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const gchar* name, GVariant* input_value, guint timestamp); +static gboolean transport_menuitem_get_running (TransportMenuitem* self); +void player_controller_instantiate (PlayerController* self); GeeHashSet* transport_menuitem_attributes_format (void); +GType player_controller_state_get_type (void) G_GNUC_CONST; +static GObject * transport_menuitem_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties); +static void transport_menuitem_finalize (GObject* obj); +static void _vala_transport_menuitem_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); TransportMenuitem* transport_menuitem_construct (GType object_type, PlayerController* parent) { TransportMenuitem * self = NULL; g_return_val_if_fail (parent != NULL, NULL); self = (TransportMenuitem*) g_object_new (object_type, "item-type", DBUSMENU_TRANSPORT_MENUITEM_TYPE, "owner", parent, NULL); - dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE, 1); return self; } @@ -144,6 +167,37 @@ TransportMenuitem* transport_menuitem_new (PlayerController* parent) { } +/** + Please remove this timeout when the default player can handle mpris commands + immediately once it raises its dbus interface + **/ +static gboolean _transport_menuitem_send_cached_action_gsource_func (gpointer self) { + gboolean result; + result = transport_menuitem_send_cached_action (self); + return result; +} + + +void transport_menuitem_handle_cached_action (TransportMenuitem* self) { + g_return_if_fail (self != NULL); + if (self->priv->cached_action != TRANSPORT_ACTION_NO_ACTION) { + g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 1, _transport_menuitem_send_cached_action_gsource_func, g_object_ref (self), g_object_unref); + } +} + + +static gboolean transport_menuitem_send_cached_action (TransportMenuitem* self) { + gboolean result = FALSE; + PlayerController* _tmp0_ = NULL; + g_return_val_if_fail (self != NULL, FALSE); + _tmp0_ = player_item_get_owner ((PlayerItem*) self); + mpris2_controller_transport_update (_tmp0_->mpris_bridge, self->priv->cached_action); + self->priv->cached_action = TRANSPORT_ACTION_NO_ACTION; + result = FALSE; + return result; +} + + void transport_menuitem_change_play_state (TransportMenuitem* self, TransportState update) { gint temp; g_return_if_fail (self != NULL); @@ -164,7 +218,7 @@ static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const gboolean _tmp1_; gint32 _tmp3_; gint32 input; - PlayerController* _tmp4_ = NULL; + gboolean _tmp4_; self = (TransportMenuitem*) base; g_return_if_fail (name != NULL); g_return_if_fail (input_value != NULL); @@ -179,8 +233,18 @@ static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const } _tmp3_ = g_variant_get_int32 (v); input = _tmp3_; - _tmp4_ = player_item_get_owner ((PlayerItem*) self); - mpris2_controller_transport_update (_tmp4_->mpris_bridge, (TransportAction) input); + _tmp4_ = transport_menuitem_get_running (self); + if (_tmp4_ == TRUE) { + PlayerController* _tmp5_ = NULL; + _tmp5_ = player_item_get_owner ((PlayerItem*) self); + mpris2_controller_transport_update (_tmp5_->mpris_bridge, (TransportAction) input); + } else { + PlayerController* _tmp6_ = NULL; + self->priv->cached_action = (TransportAction) input; + _tmp6_ = player_item_get_owner ((PlayerItem*) self); + player_controller_instantiate (_tmp6_); + dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE, (gint) TRANSPORT_STATE_LAUNCHING); + } _g_variant_unref0 (v); } @@ -197,13 +261,48 @@ GeeHashSet* transport_menuitem_attributes_format (void) { } +static gboolean transport_menuitem_get_running (TransportMenuitem* self) { + gboolean result; + PlayerController* _tmp0_ = NULL; + g_return_val_if_fail (self != NULL, FALSE); + _tmp0_ = player_item_get_owner ((PlayerItem*) self); + result = _tmp0_->current_state == PLAYER_CONTROLLER_STATE_CONNECTED; + return result; +} + + +static GObject * transport_menuitem_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) { + GObject * obj; + GObjectClass * parent_class; + TransportMenuitem * self; + parent_class = G_OBJECT_CLASS (transport_menuitem_parent_class); + obj = parent_class->constructor (type, n_construct_properties, construct_properties); + self = TRANSPORT_MENUITEM (obj); + dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE, (gint) TRANSPORT_STATE_PAUSED); + self->priv->cached_action = TRANSPORT_ACTION_NO_ACTION; + return obj; +} + + static void transport_menuitem_class_init (TransportMenuitemClass * klass) { transport_menuitem_parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (TransportMenuitemPrivate)); DBUSMENU_MENUITEM_CLASS (klass)->handle_event = transport_menuitem_real_handle_event; + G_OBJECT_CLASS (klass)->get_property = _vala_transport_menuitem_get_property; + G_OBJECT_CLASS (klass)->constructor = transport_menuitem_constructor; + G_OBJECT_CLASS (klass)->finalize = transport_menuitem_finalize; } static void transport_menuitem_instance_init (TransportMenuitem * self) { + self->priv = TRANSPORT_MENUITEM_GET_PRIVATE (self); +} + + +static void transport_menuitem_finalize (GObject* obj) { + TransportMenuitem * self; + self = TRANSPORT_MENUITEM (obj); + G_OBJECT_CLASS (transport_menuitem_parent_class)->finalize (obj); } @@ -219,4 +318,15 @@ GType transport_menuitem_get_type (void) { } +static void _vala_transport_menuitem_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { + TransportMenuitem * self; + self = TRANSPORT_MENUITEM (object); + switch (property_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + diff --git a/src/transport-menu-item.vala b/src/transport-menu-item.vala index 67e9562..ec41dd7 100644 --- a/src/transport-menu-item.vala +++ b/src/transport-menu-item.vala @@ -23,18 +23,44 @@ using DbusmenuTransport; using Transport; public class TransportMenuitem : PlayerItem -{ - +{ + private Transport.Action cached_action; + + private bool running { + get{ + return this.owner.current_state == PlayerController.state.CONNECTED; + } + } + public TransportMenuitem(PlayerController parent) { Object(item_type: MENUITEM_TYPE, owner: parent); - this.property_set_int(MENUITEM_PLAY_STATE, 1); + } + construct{ + this.property_set_int(MENUITEM_PLAY_STATE, (int)Transport.State.PAUSED); + this.cached_action = Transport.Action.NO_ACTION; + } + + /** + Please remove this timeout when the default player can handle mpris commands + immediately once it raises its dbus interface + **/ + public void handle_cached_action() + { + if (this.cached_action != Transport.Action.NO_ACTION){ + Timeout.add_seconds (1, send_cached_action); + } + } + + private bool send_cached_action() + { + this.owner.mpris_bridge.transport_update(this.cached_action); + this.cached_action = Transport.Action.NO_ACTION; + return false; } - public void change_play_state(Transport.State update) + public void change_play_state (Transport.State update) { - //debug("UPDATING THE TRANSPORT DBUSMENUITEM PLAY STATE WITH VALUE %i", - // (int)update); int temp = (int)update; this.property_set_int(MENUITEM_PLAY_STATE, temp); } @@ -43,17 +69,21 @@ public class TransportMenuitem : PlayerItem Variant input_value, uint timestamp) { - /*debug ( "Handle event in transport menu item - input variant is of type %s", - input_value.get_type_string() );*/ Variant v = input_value; - if ( input_value.is_of_type ( VariantType.VARIANT) ){ + if ( input_value.is_of_type (VariantType.VARIANT)){ v = input_value.get_variant(); } int32 input = v.get_int32(); - //debug("transport menu item -> handle_event with value %s", input.to_string()); - //debug("transport owner name = %s", this.owner.app_info.get_name()); - this.owner.mpris_bridge.transport_update((Transport.Action)input); + + if (this.running == true){ + this.owner.mpris_bridge.transport_update((Transport.Action)input); + } + else{ + this.cached_action = (Transport.Action)input; + this.owner.instantiate(); + this.property_set_int (MENUITEM_PLAY_STATE, (int)Transport.State.LAUNCHING); + } } public static HashSet<string> attributes_format() @@ -63,4 +93,4 @@ public class TransportMenuitem : PlayerItem return attrs; } -}
\ No newline at end of file +} diff --git a/src/transport-widget.c b/src/transport-widget.c index ef2916d..f05c4c1 100644 --- a/src/transport-widget.c +++ b/src/transport-widget.c @@ -85,6 +85,9 @@ struct _TransportWidgetPrivate gboolean has_focus; gint hold_timer; gint skip_frequency; + gint launching_timer; + gdouble launching_transparency; + gboolean fade_out; }; // TODO refactor the UI handlers, consolidate functionality between key press /release @@ -136,6 +139,7 @@ static TransportAction transport_widget_collision_detection (gint x, gint y); static void transport_widget_start_timing (TransportWidget* widget); static gboolean transport_widget_trigger_seek (gpointer userdata); static gboolean transport_widget_seek (gpointer userdata); +static gboolean transport_widget_fade_playbutton (gpointer userdata); /// Init functions ////////////////////////////////////////////////////////// @@ -168,6 +172,9 @@ transport_widget_init (TransportWidget *self) priv->has_focus = FALSE; priv->hold_timer = 0; priv->skip_frequency = 0; + priv->launching_timer = 0; + priv->launching_transparency = 1.0f; + priv->fade_out = TRUE; priv->command_coordinates = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, @@ -1733,6 +1740,61 @@ draw (GtkWidget* button, cairo_t *cr) FALSE); _finalize (cr, &cr_surf, &surf, PAUSE_X-0.5f, PAUSE_Y); } + else if(priv->current_state == TRANSPORT_STATE_LAUNCHING) + { +/* + g_debug ("launching in draw"); +*/ + _setup (&cr_surf, &surf, PLAY_WIDTH+6, PLAY_HEIGHT+6); + _mask_play (cr_surf, + PLAY_PADDING, + PLAY_PADDING, + PLAY_WIDTH - (2*PLAY_PADDING), + PLAY_HEIGHT - (2*PLAY_PADDING)); + + double BUTTON_SHADOW_LAUNCHING[] = {color_button[3].r, + color_button[3].g, + color_button[3].b, + priv->launching_transparency}; + double BUTTON_LAUNCHING_END[] = {color_button[0].r, + color_button[0].g, + color_button[0].b, + priv->launching_transparency}; + double BUTTON_LAUNCHING_START[] = {color_button[1].r, + color_button[1].g, + color_button[1].b, + priv->launching_transparency}; + _fill (cr_surf, + PLAY_PADDING, + PLAY_PADDING, + PLAY_WIDTH - (2*PLAY_PADDING), + PLAY_HEIGHT - (2*PLAY_PADDING), + BUTTON_SHADOW_LAUNCHING, + BUTTON_SHADOW_LAUNCHING, + FALSE); + _surface_blur (surf, 3); + _finalize_repaint (cr, &cr_surf, &surf, PAUSE_X-0.5f, PAUSE_Y + 0.5f, 3); + + // draw play-button + _setup (&cr_surf, &surf, PLAY_WIDTH, PLAY_HEIGHT); + cairo_set_line_width (cr, 10.5); + cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND); + cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND); + _mask_play (cr_surf, + PLAY_PADDING, + PLAY_PADDING, + PLAY_WIDTH - (2*PLAY_PADDING), + PLAY_HEIGHT - (2*PLAY_PADDING)); + _fill (cr_surf, + PLAY_PADDING, + PLAY_PADDING, + PLAY_WIDTH - (2*PLAY_PADDING), + PLAY_HEIGHT - (2*PLAY_PADDING), + BUTTON_LAUNCHING_START, + BUTTON_LAUNCHING_END, + FALSE); + _finalize (cr, &cr_surf, &surf, PAUSE_X-0.5f, PAUSE_Y); + } } static void @@ -1750,6 +1812,30 @@ transport_widget_set_twin_item(TransportWidget* self, (TransportState)initial_state); } +static gboolean +transport_widget_fade_playbutton (gpointer userdata) +{ + TransportWidget* bar = (TransportWidget*)userdata; + g_return_val_if_fail(IS_TRANSPORT_WIDGET(bar), FALSE); +/* + g_debug ("fade in /out timeout"); +*/ + TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(bar); + if (priv->launching_transparency == 1.0f){ + priv->fade_out = TRUE; + } + else if (priv->launching_transparency <= 0.3F){ + priv->fade_out = FALSE; + } + if (priv->fade_out == TRUE){ + priv->launching_transparency -= 0.05f; + } + else{ + priv->launching_transparency += 0.05f; + } + gtk_widget_queue_draw (GTK_WIDGET(bar)); + return TRUE; +} /** * transport_widget_update_state() * Callback for updates from the other side of dbus @@ -1761,12 +1847,28 @@ transport_widget_property_update(DbusmenuMenuitem* item, gchar* property, //g_debug("transport_widget_update_state - with property %s", property); TransportWidget* bar = (TransportWidget*)userdata; g_return_if_fail(IS_TRANSPORT_WIDGET(bar)); + TransportWidgetPrivate* priv = TRANSPORT_WIDGET_GET_PRIVATE(bar); if(g_ascii_strcasecmp(DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE, property) == 0) { - int update_value = g_variant_get_int32(value); - //g_debug("transport_widget_update_state - with value %i", update_value); - transport_widget_toggle_play_pause(bar, (TransportState)update_value); + TransportState new_state = (TransportState)g_variant_get_int32(value); + //g_debug("transport_widget_update_state - with value %i", update_value); + if (new_state == TRANSPORT_STATE_LAUNCHING){ + priv->current_state = TRANSPORT_STATE_LAUNCHING; + priv->launching_timer = g_timeout_add (100, + transport_widget_fade_playbutton, + bar); + //g_debug("TransportWidget::toggle play state : %i", priv->current_state); + } + else{ + if (priv->launching_timer != 0){ + g_source_remove (priv->launching_timer); + priv->launching_timer = 0; + priv->fade_out = TRUE; + priv->launching_transparency = 1.0f; + } + transport_widget_toggle_play_pause(bar, new_state); + } } } diff --git a/src/voip-input-menu-item.c b/src/voip-input-menu-item.c index a92f91c..e645e69 100644 --- a/src/voip-input-menu-item.c +++ b/src/voip-input-menu-item.c @@ -73,7 +73,6 @@ voip_input_menu_item_class_init (VoipInputMenuItemClass *klass) static void voip_input_menu_item_init (VoipInputMenuItem *self) { - g_debug("Building new Slider Menu Item"); dbusmenu_menuitem_property_set( DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_VOIP_INPUT_MENUITEM_TYPE ); @@ -117,7 +116,9 @@ handle_event (DbusmenuMenuitem * mi, if (value != NULL){ if (IS_VOIP_INPUT_MENU_ITEM (mi)) { VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (VOIP_INPUT_MENU_ITEM (mi)); +/* g_debug ("Handle event in the voip input level backend instance - %f", percent); +*/ pa_cvolume new_volume; pa_cvolume_init(&new_volume); new_volume.channels = 1; @@ -167,7 +168,9 @@ voip_input_menu_item_update (VoipInputMenuItem* item, // Only send over the mute updates if the state has changed. // in this order - volume first mute last!! if (priv->mute != source->mute){ +/* g_debug ("voip menu item - update - mute = %i", priv->mute); +*/ GVariant* new_mute_update = g_variant_new_int32 (source->mute); dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(item), DBUSMENU_VOIP_INPUT_MENUITEM_MUTE, diff --git a/src/voip-input-widget.c b/src/voip-input-widget.c index 6878361..5f67fab 100644 --- a/src/voip-input-widget.c +++ b/src/voip-input-widget.c @@ -97,7 +97,7 @@ voip_input_widget_init (VoipInputWidget *self) g_signal_connect(priv->ido_voip_input_slider, "slider-released", G_CALLBACK(voip_input_widget_slider_released), self); GtkWidget* primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)priv->ido_voip_input_slider); - GIcon * primary_gicon = g_themed_icon_new_with_default_fallbacks("audio-input-microphone-zero-panel"); + GIcon * primary_gicon = g_themed_icon_new_with_default_fallbacks("audio-input-microphone-low-zero-panel"); gtk_image_set_from_gicon(GTK_IMAGE(primary_image), primary_gicon, GTK_ICON_SIZE_MENU); g_object_unref(primary_gicon); @@ -129,9 +129,9 @@ voip_input_widget_property_update (DbusmenuMenuitem* item, gchar* property, g_return_if_fail (IS_VOIP_INPUT_WIDGET (userdata)); VoipInputWidget* mitem = VOIP_INPUT_WIDGET(userdata); VoipInputWidgetPrivate * priv = VOIP_INPUT_WIDGET_GET_PRIVATE(mitem); - //g_debug("scrub-widget::property_update for prop %s", property); if(g_ascii_strcasecmp(DBUSMENU_VOIP_INPUT_MENUITEM_LEVEL, property) == 0){ - if(priv->grabbed == FALSE){ + g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_DOUBLE)); + if (priv->grabbed == FALSE){ GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_voip_input_slider); GtkRange *range = (GtkRange*)slider; gdouble update = g_variant_get_double (value); @@ -141,6 +141,7 @@ voip_input_widget_property_update (DbusmenuMenuitem* item, gchar* property, } if(g_ascii_strcasecmp(DBUSMENU_VOIP_INPUT_MENUITEM_MUTE, property) == 0){ if(priv->grabbed == FALSE){ + g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_INT32)); GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_voip_input_slider); GtkRange *range = (GtkRange*)slider; gint update = g_variant_get_int32 (value); @@ -149,8 +150,10 @@ voip_input_widget_property_update (DbusmenuMenuitem* item, gchar* property, level = 0; } else{ - level = g_variant_get_double (dbusmenu_menuitem_property_get_variant (priv->twin_item, - DBUSMENU_VOIP_INPUT_MENUITEM_LEVEL)); + GVariant* variant = dbusmenu_menuitem_property_get_variant (priv->twin_item, + DBUSMENU_VOIP_INPUT_MENUITEM_LEVEL); + g_return_if_fail (g_variant_is_of_type (variant, G_VARIANT_TYPE_DOUBLE)); + level = g_variant_get_double (variant); } gtk_range_set_value(range, level); diff --git a/src/volume-widget.c b/src/volume-widget.c index f638bd4..e8e7bae 100644 --- a/src/volume-widget.c +++ b/src/volume-widget.c @@ -128,7 +128,7 @@ static void volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, GVariant* value, gpointer userdata) { - g_return_if_fail (IS_VOLUME_WIDGET (userdata)); + g_return_if_fail (IS_VOLUME_WIDGET(userdata)); VolumeWidget* mitem = VOLUME_WIDGET(userdata); VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem); @@ -139,28 +139,37 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, GtkRange *range = (GtkRange*)slider; gdouble update = g_variant_get_double (value); gtk_range_set_value(range, update); +/* + g_debug ("volume-widget::volume_widget_property_update - volume - value %f", update); +*/ update_accessible_desc(priv->indicator); } } - if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_MUTE, property) == 0){ - g_debug ("volume widget - mute update "); + else if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_MUTE, property) == 0){ + g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)); if(priv->grabbed == FALSE){ GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider); GtkRange *range = (GtkRange*)slider; - gint update = g_variant_get_int32 (value); + gboolean update = g_variant_get_boolean (value); gdouble level; - g_debug ("volume widget - mute update %i", update); - - if (update == 1){ + if (update == TRUE){ level = 0; } else{ - level = g_variant_get_double (dbusmenu_menuitem_property_get_variant (priv->twin_item, - DBUSMENU_VOLUME_MENUITEM_LEVEL)); + GVariant* variant = dbusmenu_menuitem_property_get_variant (priv->twin_item, + DBUSMENU_VOLUME_MENUITEM_LEVEL); +/* + g_debug ("variant for the volume - is it null = %i", variant == NULL); +*/ + g_return_if_fail (g_variant_is_of_type (variant, G_VARIANT_TYPE_DOUBLE) ); + + level = g_variant_get_double (variant); } +/* + g_debug ("volume-widget::volume_widget_property_update - mute - value %i and level = %f", update, level); +*/ gtk_range_set_value(range, level); - g_debug ("volume-widget - update mute with value %i", update); } } } @@ -176,13 +185,13 @@ volume_widget_set_twin_item(VolumeWidget* self, G_CALLBACK(volume_widget_property_update), self); gdouble initial_level = g_variant_get_double (dbusmenu_menuitem_property_get_variant(twin_item, DBUSMENU_VOLUME_MENUITEM_LEVEL)); - gint initial_mute = g_variant_get_int32 (dbusmenu_menuitem_property_get_variant(twin_item, - DBUSMENU_VOLUME_MENUITEM_MUTE)); + gboolean initial_mute = g_variant_get_boolean (dbusmenu_menuitem_property_get_variant(twin_item, + DBUSMENU_VOLUME_MENUITEM_MUTE)); //g_debug("volume_widget_set_twin_item initial level = %f", initial_level); GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider); GtkRange *range = (GtkRange*)slider; - if(initial_mute == 1){ + if(initial_mute == TRUE){ initial_level = 0; } gtk_range_set_value(range, initial_level); @@ -197,8 +206,12 @@ volume_widget_change_value_cb (GtkRange *range, { g_return_val_if_fail (IS_VOLUME_WIDGET (user_data), FALSE); VolumeWidget* mitem = VOLUME_WIDGET(user_data); - //g_debug ("changed value %f", new_value); - volume_widget_update(mitem, new_value); + +/* + g_debug ("changed value %f", new_value); +*/ + + volume_widget_update(mitem, new_value, "change-value"); return FALSE; } @@ -211,28 +224,35 @@ volume_widget_value_changed_cb (GtkRange *range, gpointer user_data) { g_return_val_if_fail (IS_VOLUME_WIDGET (user_data), FALSE); - VolumeWidget* mitem = VOLUME_WIDGET(user_data); + VolumeWidget* mitem = VOLUME_WIDGET (user_data); VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem); GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider); gdouble current_value = CLAMP(gtk_range_get_value(GTK_RANGE(slider)), 0, 100); - //g_debug ("value changed %f", gtk_range_get_value(GTK_RANGE(slider))); - gint mute = g_variant_get_int32 (dbusmenu_menuitem_property_get_variant (priv->twin_item, - DBUSMENU_VOLUME_MENUITEM_MUTE)); - if((current_value == 0 && mute != 1) || current_value == 100){ - volume_widget_update(mitem, current_value); + gboolean mute = g_variant_get_boolean (dbusmenu_menuitem_property_get_variant (priv->twin_item, + DBUSMENU_VOLUME_MENUITEM_MUTE)); + if((current_value == 0 && mute == FALSE) || current_value == 100){ +/* + g_debug ("value changed - actual set %f", current_value); +*/ + volume_widget_update (mitem, current_value, "value-changed"); } return FALSE; } void -volume_widget_update(VolumeWidget* self, gdouble update) +volume_widget_update(VolumeWidget* self, gdouble update, gchar* label) { + gchar* source = NULL; + source = label; + if (label == NULL){ + source = "v widget update"; + } VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(self); gdouble clamped = CLAMP(update, 0, 100); GVariant* new_volume = g_variant_new_double(clamped); - dbusmenu_menuitem_handle_event (priv->twin_item, "update", new_volume, 0); + dbusmenu_menuitem_handle_event (priv->twin_item, source, new_volume, 0); } GtkWidget* diff --git a/src/volume-widget.h b/src/volume-widget.h index 50ef377..7012473 100644 --- a/src/volume-widget.h +++ b/src/volume-widget.h @@ -47,7 +47,7 @@ struct _VolumeWidget { GType volume_widget_get_type (void) G_GNUC_CONST; GtkWidget* volume_widget_new(DbusmenuMenuitem *item, IndicatorObject* io); GtkWidget* volume_widget_get_ido_slider(VolumeWidget* self); -void volume_widget_update(VolumeWidget* self, gdouble update); +void volume_widget_update(VolumeWidget* self, gdouble update, gchar* label); void volume_widget_tidy_up (GtkWidget *widget); gdouble volume_widget_get_current_volume ( GtkWidget *widget ); diff --git a/vapi/common-defs.vapi b/vapi/common-defs.vapi index 7cac0de..0d28cdb 100644 --- a/vapi/common-defs.vapi +++ b/vapi/common-defs.vapi @@ -59,10 +59,12 @@ namespace Transport{ PLAY_PAUSE, NEXT, REWIND, - FORWIND + FORWIND, + NO_ACTION } public enum State{ PLAYING, - PAUSED + PAUSED, + LAUNCHING } } |