diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/common-defs.h | 2 | ||||
-rw-r--r-- | src/music-player-bridge.vala | 15 | ||||
-rw-r--r-- | src/player-controller.vala | 21 | ||||
-rw-r--r-- | src/sound-service-dbus.c | 1 | ||||
-rw-r--r-- | src/sound-service.c | 25 |
6 files changed, 54 insertions, 11 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index bafd6be..59c8f14 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -48,6 +48,7 @@ checkxml: $(srcdir)/sound-service.xml music_bridge_VALASOURCES = \ music-player-bridge.vala \ transport-menu-item.vala \ + track-specific-menu-item.vala \ metadata-menu-item.vala \ title-menu-item.vala \ player-controller.vala \ diff --git a/src/common-defs.h b/src/common-defs.h index b118d4b..65829a3 100644 --- a/src/common-defs.h +++ b/src/common-defs.h @@ -67,6 +67,8 @@ typedef enum { #define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-sound-menu-player-transport-type" #define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-sound-menu-player-transport-state" +#define DBUSMENU_TRACK_SPECIFIC_MENUITEM_TYPE "x-canonical-sound-menu-player-track-specific-type" + #define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-sound-menu-player-metadata-type" #define DBUSMENU_METADATA_MENUITEM_ARTIST "x-canonical-sound-menu-player-metadata-xesam:artist" #define DBUSMENU_METADATA_MENUITEM_TITLE "x-canonical-sound-menu-player-metadata-xesam:title" diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index 2a85dd3..3cda638 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -158,6 +158,21 @@ public class MusicPlayerBridge : GLib.Object this.watcher.client_disappeared.connect (this.client_has_vanished); } + public void enable_player_specific_items_for_client (string desktop_id) + { + // TODO + } + + public void enable_track_specific_items_for_client (string desktop_id) + { + var mpris_key = determine_key ( desktop_id ); + if (this.registered_clients.has_key (mpris_key) == false){ + warning ("we don't have a client with desktop id %s registered", desktop_id); + return; + } + this.registered_clients[mpris_key].enable_track_specific_items(); + } + private static AppInfo? create_app_info ( string desktop ) { DesktopAppInfo info = new DesktopAppInfo ( desktop ) ; diff --git a/src/player-controller.vala b/src/player-controller.vala index 20479d9..4689a42 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -23,13 +23,14 @@ using Gee; public class PlayerController : GLib.Object { - public const int WIDGET_QUANTITY = 5; + public const int WIDGET_QUANTITY = 6; public static enum widget_order{ SEPARATOR, TITLE, METADATA, TRANSPORT, + TRACK_SPECIFIC, PLAYLISTS } @@ -105,16 +106,24 @@ public class PlayerController : GLib.Object error.message ); } } + + public void enable_track_specific_items() + { + this.custom_items[widget_order.TRACK_SPECIFIC].property_set_bool (MENUITEM_PROP_VISIBLE, + true); + this.custom_items[widget_order.TRACK_SPECIFIC].property_set_bool (MENUITEM_PROP_ENABLED, + true); + } private void establish_mpris_connection() { if(this.current_state != state.READY || this.dbus_name == null ){ debug("establish_mpris_connection - Not ready to connect"); return; - } + } debug ( " establish mpris connection - use playlists value = %s ", this.use_playlists.to_string() ); - + this.mpris_bridge = new Mpris2Controller(this); this.determine_state(); } @@ -183,13 +192,17 @@ public class PlayerController : GLib.Object // Transport item TransportMenuitem transport_item = new TransportMenuitem(this); this.custom_items.add(transport_item); + + // Track Specific item + TrackSpecificMenuitem track_specific_item = new TrackSpecificMenuitem(this); + this.custom_items.add(track_specific_item); // Playlist item PlaylistsMenuitem playlist_menuitem = new PlaylistsMenuitem(this); this.custom_items.add(playlist_menuitem); foreach(PlayerItem item in this.custom_items){ - if (this.custom_items.index_of(item) != 4) { + if (this.custom_items.index_of(item) != 5) { root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item)); } else{ diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index f99716a..26477a1 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -170,7 +170,6 @@ 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)); DbusmenuServer *server = dbusmenu_server_new (INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH); dbusmenu_server_set_root (server, priv->root_menuitem); g_object_unref (priv->root_menuitem); diff --git a/src/sound-service.c b/src/sound-service.c index 0a15921..1f7ea73 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -24,7 +24,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <locale.h> static GMainLoop *mainloop = NULL; -static MusicPlayerBridge* server; +static MusicPlayerBridge* player_bridge; /**********************************************************************************************************************/ // Init and exit functions /**********************************************************************************************************************/ @@ -46,10 +46,20 @@ service_shutdown (IndicatorService *service, gpointer user_data) } void +on_player_specific_item_requested (SoundServiceDbus* sound_service, + const gchar* desktop_id, + gpointer userdata) +{ + music_player_bridge_enable_player_specific_items_for_client (player_bridge, desktop_id); + g_debug ("ON PLAYER SPECIFIC ITEM REQUESTED %s", desktop_id); +} + +void on_track_specific_item_requested (SoundServiceDbus* sound_service, const gchar* desktop_id, gpointer userdata) { + music_player_bridge_enable_track_specific_items_for_client (player_bridge, desktop_id); g_debug ("ON TRACK SPECIFIC ITEM REQUESTED %s", desktop_id); } @@ -64,8 +74,8 @@ main (int argc, char ** argv) bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); setlocale (LC_ALL, ""); - IndicatorService *service = indicator_service_new_version(INDICATOR_SOUND_DBUS_NAME, - INDICATOR_SOUND_DBUS_VERSION); + IndicatorService *service = indicator_service_new_version (INDICATOR_SOUND_DBUS_NAME, + INDICATOR_SOUND_DBUS_VERSION); g_signal_connect(G_OBJECT(service), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, G_CALLBACK(service_shutdown), NULL); @@ -74,10 +84,13 @@ main (int argc, char ** argv) g_signal_connect(G_OBJECT(sound_service), "track-specific-item-requested", G_CALLBACK(on_track_specific_item_requested), NULL); + g_signal_connect(G_OBJECT(sound_service), + "player-specific-item-requested", + G_CALLBACK(on_player_specific_item_requested), NULL); - DbusmenuMenuitem* root_menuitem = sound_service_dbus_create_root_item(sound_service); - server = music_player_bridge_new(); - music_player_bridge_set_root_menu_item(server, root_menuitem); + DbusmenuMenuitem* root_menuitem = sound_service_dbus_create_root_item (sound_service); + player_bridge = music_player_bridge_new (); + music_player_bridge_set_root_menu_item (player_bridge, root_menuitem); // Run the loop mainloop = g_main_loop_new(NULL, FALSE); |