From 78068166398ffaee0bb2d997673139168fdfee3b Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 6 Jun 2011 17:22:49 +0200 Subject: two new methods added the service interface inorder to handle track and player specific items --- src/music-player-bridge.vala | 2 +- src/sound-service-dbus.c | 34 +++++++++++++++++++++++++++++++++- src/sound-service.c | 18 +++++++++++++----- src/sound-service.xml | 9 ++++++++- 4 files changed, 55 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index b5932fa..2a85dd3 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -27,7 +27,7 @@ public class MusicPlayerBridge : GLib.Object private SettingsManager settings_manager; private Dbusmenu.Menuitem root_menu; - private HashMap registered_clients; + private HashMap registered_clients; private Mpris2Watcher watcher; public MusicPlayerBridge() diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index d0fd765..f99716a 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -58,6 +58,14 @@ struct _SoundServiceDbusPrivate { Device* device; }; +enum { + TRACK_SPECIFIC_ITEM, + PLAYER_SPECIFIC_ITEM, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + static GDBusNodeInfo * node_info = NULL; static GDBusInterfaceInfo * interface_info = NULL; @@ -110,6 +118,20 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass) g_error("Unable to find interface '" INDICATOR_SOUND_DBUS_INTERFACE "'"); } } + signals[TRACK_SPECIFIC_ITEM] = g_signal_new("track-specific-item-requested", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING); + signals[PLAYER_SPECIFIC_ITEM] = g_signal_new("player-specific-item-requested", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING); } static void @@ -185,7 +207,7 @@ sound_service_dbus_build_sound_menu ( SoundServiceDbus* self, DBUSMENU_MENUITEM_PROP_LABEL, _("Sound Preferences...")); dbusmenu_menuitem_child_append(priv->root_menuitem, settings_mi); - g_object_unref (settings_mi); + g_object_unref (settings_mi); g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_sound_settings_dialog), NULL); } @@ -297,6 +319,16 @@ bus_method_call (GDBusConnection * connection, player_name); retval = g_variant_new ("(b)", result); } + else if (g_strcmp0(method, "EnableTrackSpecificItems") == 0) { + gchar* player_name; + g_variant_get (params, "(s)", &player_name); + g_debug ("EnableTrackSpecificItems - name %s", player_name); + g_signal_emit (service, + signals[TRACK_SPECIFIC_ITEM], + 0, + player_name); + + } else { g_warning("Calling method '%s' on the sound service but it's unknown", method); } diff --git a/src/sound-service.c b/src/sound-service.c index 1324537..0a15921 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -21,15 +21,13 @@ with this program. If not, see . #include "pulseaudio-mgr.h" #include "sound-service-dbus.h" #include "music-player-bridge.h" - #include static GMainLoop *mainloop = NULL; - +static MusicPlayerBridge* server; /**********************************************************************************************************************/ // Init and exit functions /**********************************************************************************************************************/ - /** service_shutdown: When the service interface starts to shutdown, we @@ -47,13 +45,20 @@ service_shutdown (IndicatorService *service, gpointer user_data) return; } +void +on_track_specific_item_requested (SoundServiceDbus* sound_service, + const gchar* desktop_id, + gpointer userdata) +{ + g_debug ("ON TRACK SPECIFIC ITEM REQUESTED %s", desktop_id); +} + /** main: **/ int main (int argc, char ** argv) { - g_type_init(); textdomain (GETTEXT_PACKAGE); bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); @@ -66,9 +71,12 @@ main (int argc, char ** argv) G_CALLBACK(service_shutdown), NULL); SoundServiceDbus* sound_service = g_object_new(SOUND_SERVICE_DBUS_TYPE, NULL); + g_signal_connect(G_OBJECT(sound_service), + "track-specific-item-requested", + G_CALLBACK(on_track_specific_item_requested), NULL); DbusmenuMenuitem* root_menuitem = sound_service_dbus_create_root_item(sound_service); - MusicPlayerBridge* server = music_player_bridge_new(); + server = music_player_bridge_new(); music_player_bridge_set_root_menu_item(server, root_menuitem); // Run the loop diff --git a/src/sound-service.xml b/src/sound-service.xml index 517088e..aa9f229 100644 --- a/src/sound-service.xml +++ b/src/sound-service.xml @@ -12,11 +12,18 @@ - + + + + + + + + -- cgit v1.2.3 From a1192a69cfdba207fa3e6ece69363649d8813dcf Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 6 Jun 2011 20:42:22 +0200 Subject: track specific items outline implemented --- src/Makefile.am | 1 + src/common-defs.h | 2 ++ src/music-player-bridge.vala | 15 +++++++++++++++ src/player-controller.vala | 21 +++++++++++++++++---- src/sound-service-dbus.c | 1 - src/sound-service.c | 25 +++++++++++++++++++------ 6 files changed, 54 insertions(+), 11 deletions(-) (limited to 'src') 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 . #include static GMainLoop *mainloop = NULL; -static MusicPlayerBridge* server; +static MusicPlayerBridge* player_bridge; /**********************************************************************************************************************/ // Init and exit functions /**********************************************************************************************************************/ @@ -45,11 +45,21 @@ service_shutdown (IndicatorService *service, gpointer user_data) return; } +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); -- cgit v1.2.3 From 0681190881ea7e9cca176bd69ec00f2393c3ee56 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 6 Jun 2011 20:42:53 +0200 Subject: added the source for the track specific items --- src/track-specific-menu-item.vala | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/track-specific-menu-item.vala (limited to 'src') diff --git a/src/track-specific-menu-item.vala b/src/track-specific-menu-item.vala new file mode 100644 index 0000000..7bc390e --- /dev/null +++ b/src/track-specific-menu-item.vala @@ -0,0 +1,36 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +using Dbusmenu; +using Gee; +using DbusmenuTrackSpecific; + +public class TrackSpecificMenuitem : PlayerItem +{ + public TrackSpecificMenuitem (PlayerController parent) + { + Object(item_type: MENUITEM_TYPE, owner: parent); + } + construct + { + this.property_set_bool (MENUITEM_PROP_VISIBLE, false); + this.property_set_bool (MENUITEM_PROP_ENABLED, false); + this.property_set (MENUITEM_PROP_LABEL, "Like This"); + } +} -- cgit v1.2.3 From 4fc554dc87e61f4fa7c605236da86d05781f7496 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 6 Jun 2011 21:52:44 +0200 Subject: track specific items now appears when asked via the com.canonical.indicators.sound dbus interface --- src/player-controller.vala | 20 ++++++++++++-------- src/playlists-menu-item.vala | 2 -- src/track-specific-menu-item.vala | 10 +++++++--- 3 files changed, 19 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/player-controller.vala b/src/player-controller.vala index 4689a42..8a7bda5 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -109,10 +109,10 @@ public class PlayerController : GLib.Object 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); + debug ("enable_track_specific_items"); + TrackSpecificMenuitem menuitem = this.custom_items[widget_order.TRACK_SPECIFIC] as TrackSpecificMenuitem; + menuitem.root_item.property_set_bool (MENUITEM_PROP_VISIBLE, true); + menuitem.root_item.property_set_bool (MENUITEM_PROP_ENABLED, true); } private void establish_mpris_connection() @@ -202,12 +202,16 @@ public class PlayerController : GLib.Object this.custom_items.add(playlist_menuitem); foreach(PlayerItem item in this.custom_items){ - if (this.custom_items.index_of(item) != 5) { - root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item)); + if (this.custom_items.index_of(item) == 5) { + PlaylistsMenuitem playlists_menuitem = item as PlaylistsMenuitem; + root_menu.child_add_position(playlists_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item)); } + else if (this.custom_items.index_of(item) == 4) { + TrackSpecificMenuitem trackspecific_menuitem = item as TrackSpecificMenuitem; + root_menu.child_add_position(trackspecific_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item)); + } else{ - PlaylistsMenuitem playlists_menuitem = item as PlaylistsMenuitem; - root_menu.child_add_position(playlists_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item)); + root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item)); } } } diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala index 58c3875..452a586 100644 --- a/src/playlists-menu-item.vala +++ b/src/playlists-menu-item.vala @@ -37,10 +37,8 @@ public class PlaylistsMenuitem : PlayerItem construct{ this.current_playlists = new HashMap(); this.root_item = new Menuitem(); - this.root_item.property_set ( MENUITEM_PROP_LABEL, _("Choose Playlist") ); this.root_item.property_set ( MENUITEM_PATH, "" ); - } public new void update (PlaylistDetails[] playlists) diff --git a/src/track-specific-menu-item.vala b/src/track-specific-menu-item.vala index 7bc390e..718a564 100644 --- a/src/track-specific-menu-item.vala +++ b/src/track-specific-menu-item.vala @@ -20,17 +20,21 @@ with this program. If not, see . using Dbusmenu; using Gee; using DbusmenuTrackSpecific; +using Dbusmenu; public class TrackSpecificMenuitem : PlayerItem { + public Menuitem root_item{get; construct;} + public TrackSpecificMenuitem (PlayerController parent) { Object(item_type: MENUITEM_TYPE, owner: parent); } construct { - this.property_set_bool (MENUITEM_PROP_VISIBLE, false); - this.property_set_bool (MENUITEM_PROP_ENABLED, false); - this.property_set (MENUITEM_PROP_LABEL, "Like This"); + this.root_item = new Menuitem(); + this.root_item.property_set ( MENUITEM_PROP_LABEL, _("Like This") ); + this.root_item.property_set_bool (MENUITEM_PROP_VISIBLE, false); + this.root_item.property_set_bool (MENUITEM_PROP_ENABLED, false); } } -- cgit v1.2.3 From a3acb4947b7ae8c31e873befb24bebe64b36e49c Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 21 Jun 2011 10:12:12 +0200 Subject: expanded the signature on the dbus methods for player and track specific items to handle the object path on the other side --- src/sound-service-dbus.c | 17 +++++++++++++---- src/sound-service.c | 2 +- src/sound-service.xml | 6 ++++-- 3 files changed, 18 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 26477a1..afb4f04 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -319,15 +319,24 @@ bus_method_call (GDBusConnection * connection, retval = g_variant_new ("(b)", result); } else if (g_strcmp0(method, "EnableTrackSpecificItems") == 0) { - gchar* player_name; - g_variant_get (params, "(s)", &player_name); - g_debug ("EnableTrackSpecificItems - name %s", player_name); + gchar** player_object_path_and_id; + g_variant_get (params, "(ss)", &player_object_path_and_id); + /*g_debug ("EnableTrackSpecificItems - name %s", player_object_path); g_signal_emit (service, signals[TRACK_SPECIFIC_ITEM], 0, - player_name); + player_object_path);*/ } + else if (g_strcmp0(method, "EnablePlayerSpecificItems") == 0) { + /*gchar* player_object_path; + g_variant_get (params, "(s)", &player_object_path); + g_debug ("EnableTrackSpecificItems - name %s", player_object_path); + g_signal_emit (service, + signals[TRACK_SPECIFIC_ITEM], + 0, + player_object_path);*/ + } else { g_warning("Calling method '%s' on the sound service but it's unknown", method); } diff --git a/src/sound-service.c b/src/sound-service.c index 1f7ea73..918bde6 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -47,7 +47,7 @@ service_shutdown (IndicatorService *service, gpointer user_data) void on_player_specific_item_requested (SoundServiceDbus* sound_service, - const gchar* desktop_id, + const gchar* player_object_path, gpointer userdata) { music_player_bridge_enable_player_specific_items_for_client (player_bridge, desktop_id); diff --git a/src/sound-service.xml b/src/sound-service.xml index aa9f229..af0f136 100644 --- a/src/sound-service.xml +++ b/src/sound-service.xml @@ -18,11 +18,13 @@ - + + - + + -- cgit v1.2.3 From a6dee99edd1a3870c4dc4557f605578c52a4f0dc Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 21 Jun 2011 18:26:10 +0200 Subject: custom marshaller in place to handle the string string signature on our item specific dbus methods --- src/Makefile.am | 10 ++++++++++ src/sound-service-dbus.c | 31 ++++++++++++++++++++----------- src/sound-service.c | 3 ++- src/sound-service.xml | 4 ++-- 4 files changed, 34 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index fde333a..fedf5de 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,6 +30,7 @@ libsoundmenu_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Werror -DG_LOG_DOMAIN=\"Indicat libsoundmenu_la_LIBADD = $(APPLET_LIBS) libsoundmenu_la_LDFLAGS = -module -avoid-version + checkxml: $(srcdir)/sound-service.xml @xmllint -valid -noout $< @echo $< checks out ok @@ -39,6 +40,9 @@ checkxml: $(srcdir)/sound-service.xml # Sound Service #################################################################### +glib_marshal_list = sound-service-marshal.list +glib_marshal_prefix = _sound_service_marshal + ##################### # Sound service vala @@ -106,6 +110,8 @@ indicator_sound_service_SOURCES = \ mute-menu-item.c \ gen-sound-service.xml.h \ gen-sound-service.xml.c \ + sound-service-marshal.c \ + sound-service-marshal.h \ $(music_bridge_VALASOURCES:.vala=.c) indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) $(SOUNDSERVICE_CFLAGS) $(GCONF_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall @@ -146,3 +152,7 @@ BUILT_SOURCES = \ CLEANFILES = \ $(BUILT_SOURCES) + +DISTCLEANFILES = + +include $(top_srcdir)/Makefile.am.marshal diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 5d7c4cd..d546ceb 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -32,6 +32,7 @@ #include "device.h" #include "gen-sound-service.xml.h" #include "dbus-shared-names.h" +#include "sound-service-marshal.h" // DBUS methods static void bus_method_call (GDBusConnection * connection, @@ -123,7 +124,7 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass) G_SIGNAL_RUN_LAST, 0, NULL, NULL, - g_cclosure_marshal_VOID__STRING, + _sound_service_marshal_VOID__STRING_STRING, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); signals[PLAYER_SPECIFIC_ITEM] = g_signal_new("player-specific-item-requested", @@ -131,7 +132,7 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass) G_SIGNAL_RUN_LAST, 0, NULL, NULL, - g_cclosure_marshal_VOID__STRING, + _sound_service_marshal_VOID__STRING_STRING, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); } @@ -321,23 +322,31 @@ bus_method_call (GDBusConnection * connection, retval = g_variant_new ("(b)", result); } else if (g_strcmp0(method, "EnableTrackSpecificItems") == 0) { - gchar** player_object_path_and_id; - g_variant_get (params, "(ss)", &player_object_path_and_id); - /*g_debug ("EnableTrackSpecificItems - name %s", player_object_path); + gchar* player_object_path; + gchar* player_id; + g_variant_get (params, "(os)", &player_object_path, &player_id); + //g_debug ("object path = %s and id = %s", player_object_path, player_id); g_signal_emit (service, signals[TRACK_SPECIFIC_ITEM], 0, - player_object_path);*/ + player_object_path, + player_id); + g_free (player_object_path); + g_free (player_id); } else if (g_strcmp0(method, "EnablePlayerSpecificItems") == 0) { - /*gchar* player_object_path; - g_variant_get (params, "(s)", &player_object_path); - g_debug ("EnableTrackSpecificItems - name %s", player_object_path); + gchar* player_object_path; + gchar* player_id; + g_variant_get (params, "(os)", &player_object_path, &player_id); + //g_debug ("object path = %s and id = %s", player_object_path, player_id); g_signal_emit (service, - signals[TRACK_SPECIFIC_ITEM], + signals[PLAYER_SPECIFIC_ITEM], 0, - player_object_path);*/ + player_object_path, + player_id); + g_free (player_object_path); + g_free (player_id); } else { g_warning("Calling method '%s' on the sound service but it's unknown", method); diff --git a/src/sound-service.c b/src/sound-service.c index dd957a0..9e22485 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -17,11 +17,12 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include + #include "sound-service.h" #include "pulseaudio-mgr.h" #include "sound-service-dbus.h" #include "music-player-bridge.h" -#include static GMainLoop *mainloop = NULL; static MusicPlayerBridge* player_bridge; diff --git a/src/sound-service.xml b/src/sound-service.xml index af0f136..796fa22 100644 --- a/src/sound-service.xml +++ b/src/sound-service.xml @@ -18,13 +18,13 @@ - + + - -- cgit v1.2.3 From 01fc374f65b6c552891d3f0d2dad5c7eb8031596 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 22 Jun 2011 14:18:38 +0200 Subject: properly plug the track / player specific together --- src/music-player-bridge.vala | 11 ++++++----- src/player-controller.vala | 19 +++++++++++++------ src/sound-service-dbus.c | 2 +- src/sound-service.c | 8 ++++++-- 4 files changed, 26 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index 3cda638..727c36b 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -158,25 +158,26 @@ 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) + public void enable_player_specific_items_for_client (string object_path, + string desktop_id) { // TODO } - public void enable_track_specific_items_for_client (string desktop_id) + public void enable_track_specific_items_for_client (string object_path, + 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(); + this.registered_clients[mpris_key].enable_track_specific_items(object_path); } private static AppInfo? create_app_info ( string desktop ) { - DesktopAppInfo info = new DesktopAppInfo ( desktop ) ; - + DesktopAppInfo info = new DesktopAppInfo ( desktop ); if ( desktop == null || info == null ){ warning ( "Could not create a desktopappinfo instance from app: %s", desktop ); return null; diff --git a/src/player-controller.vala b/src/player-controller.vala index 52adb23..e988682 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -51,6 +51,7 @@ public class PlayerController : GLib.Object public int menu_offset { get; set;} public string icon_name { get; set; } public bool? use_playlists; + public Client track_specific_client; public PlayerController(Dbusmenu.Menuitem root, GLib.AppInfo app, @@ -107,12 +108,19 @@ public class PlayerController : GLib.Object } } - public void enable_track_specific_items() + public void enable_track_specific_items (string object_path) { debug ("enable_track_specific_items"); - TrackSpecificMenuitem menuitem = this.custom_items[widget_order.TRACK_SPECIFIC] as TrackSpecificMenuitem; + track_specific_client = new Client (this.dbus_name, object_path); + track_specific_client.new_menuitem.connect (on_new_track_specific_menuitem); + /*TrackSpecificMenuitem menuitem = this.custom_items[widget_order.TRACK_SPECIFIC] as TrackSpecificMenuitem; menuitem.root_item.property_set_bool (MENUITEM_PROP_VISIBLE, true); - menuitem.root_item.property_set_bool (MENUITEM_PROP_ENABLED, true); + menuitem.root_item.property_set_bool (MENUITEM_PROP_ENABLED, true);*/ + } + + private void on_new_track_specific_menuitem (GLib.Object item) + { + debug ("New track specific item for %s", this.app_info.get_name()); } private void establish_mpris_connection() @@ -123,9 +131,8 @@ public class PlayerController : GLib.Object } debug ( " establish mpris connection - use playlists value = %s ", this.use_playlists.to_string() ); - - this.mpris_bridge = new Mpris2Controller(this); - this.determine_state(); + this.mpris_bridge = new Mpris2Controller (this); + this.determine_state (); } public void remove_from_menu() diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index d546ceb..980fa05 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -325,7 +325,7 @@ bus_method_call (GDBusConnection * connection, gchar* player_object_path; gchar* player_id; g_variant_get (params, "(os)", &player_object_path, &player_id); - //g_debug ("object path = %s and id = %s", player_object_path, player_id); + g_debug ("object path = %s and id = %s", player_object_path, player_id); g_signal_emit (service, signals[TRACK_SPECIFIC_ITEM], 0, diff --git a/src/sound-service.c b/src/sound-service.c index 9e22485..da9b94e 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -52,7 +52,9 @@ on_player_specific_item_requested (SoundServiceDbus* sound_service, const gchar* player_object_path, gpointer userdata) { - music_player_bridge_enable_player_specific_items_for_client (player_bridge, desktop_id); + music_player_bridge_enable_player_specific_items_for_client (player_bridge, + desktop_id, + player_object_path); g_debug ("ON PLAYER SPECIFIC ITEM REQUESTED %s", desktop_id); } @@ -62,7 +64,9 @@ on_track_specific_item_requested (SoundServiceDbus* sound_service, const gchar* player_object_path, gpointer userdata) { - music_player_bridge_enable_track_specific_items_for_client (player_bridge, desktop_id); + music_player_bridge_enable_track_specific_items_for_client (player_bridge, + desktop_id, + player_object_path); g_debug ("ON TRACK SPECIFIC ITEM REQUESTED %s", desktop_id); } -- cgit v1.2.3 From e63dc6451177bc9d4c398849eda13ff880fc69c3 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 29 Jun 2011 10:24:23 +0200 Subject: new menu items manager - and removed the earlier attempt at a custom item for the same purpose --- src/mpris2-watcher.vala | 2 +- src/player-controller.vala | 10 ++++----- src/player-item.vala | 2 ++ src/sound-service-dbus.c | 1 + src/track-specific-items-manager.vala | 30 ++++++++++++++++++++++++++ src/track-specific-menu-item.vala | 40 ----------------------------------- 6 files changed, 39 insertions(+), 46 deletions(-) create mode 100644 src/track-specific-items-manager.vala delete mode 100644 src/track-specific-menu-item.vala (limited to 'src') diff --git a/src/mpris2-watcher.vala b/src/mpris2-watcher.vala index d508959..06ccb6e 100644 --- a/src/mpris2-watcher.vala +++ b/src/mpris2-watcher.vala @@ -38,7 +38,7 @@ public class Mpris2Watcher : GLib.Object this.fdesktop_obj = Bus.get_proxy_sync ( BusType.SESSION, FREEDESKTOP_SERVICE, FREEDESKTOP_OBJECT, - DBusProxyFlags.DO_NOT_LOAD_PROPERTIES ); + DBusProxyFlags.DO_NOT_LOAD_PROPERTIES ); this.fdesktop_obj.name_owner_changed.connect (this.name_changes_detected); this.check_for_active_clients.begin(); } diff --git a/src/player-controller.vala b/src/player-controller.vala index e988682..b1c0396 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -109,18 +109,18 @@ public class PlayerController : GLib.Object } public void enable_track_specific_items (string object_path) - { - debug ("enable_track_specific_items"); + { track_specific_client = new Client (this.dbus_name, object_path); - track_specific_client.new_menuitem.connect (on_new_track_specific_menuitem); + track_specific_client.root_changed.connect (on_new_track_specific_root_changed); /*TrackSpecificMenuitem menuitem = this.custom_items[widget_order.TRACK_SPECIFIC] as TrackSpecificMenuitem; menuitem.root_item.property_set_bool (MENUITEM_PROP_VISIBLE, true); menuitem.root_item.property_set_bool (MENUITEM_PROP_ENABLED, true);*/ } - private void on_new_track_specific_menuitem (GLib.Object item) + private void on_new_track_specific_root_changed (GLib.Object item) { - debug ("New track specific item for %s", this.app_info.get_name()); + debug ("!!!!!!!!!!!!!!!!!! - Root changed for track specific item %s", + this.app_info.get_name()); } private void establish_mpris_connection() diff --git a/src/player-item.vala b/src/player-item.vala index 162dbea..7867653 100644 --- a/src/player-item.vala +++ b/src/player-item.vala @@ -61,6 +61,8 @@ public class PlayerItem : Dbusmenu.Menuitem //debug("search key = %s", search_key); Variant? v = data.lookup(search_key); + if (v == null) continue; + if (v.is_of_type ( VariantType.STRING )){ string update = v.get_string().strip(); //debug("with value : %s", update); diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 980fa05..bad90ca 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -322,6 +322,7 @@ bus_method_call (GDBusConnection * connection, retval = g_variant_new ("(b)", result); } else if (g_strcmp0(method, "EnableTrackSpecificItems") == 0) { + g_debug ("EnableTrackSpecificItems"); gchar* player_object_path; gchar* player_id; g_variant_get (params, "(os)", &player_object_path, &player_id); diff --git a/src/track-specific-items-manager.vala b/src/track-specific-items-manager.vala new file mode 100644 index 0000000..3949727 --- /dev/null +++ b/src/track-specific-items-manager.vala @@ -0,0 +1,30 @@ +/* +This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel. +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +using Dbusmenu; +using Gee; + +public class TrackSpecificMenuitemsManager : GLib.Object +{ + public TrackSpecificMenuitemsManager() + { + } +} + diff --git a/src/track-specific-menu-item.vala b/src/track-specific-menu-item.vala deleted file mode 100644 index 718a564..0000000 --- a/src/track-specific-menu-item.vala +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright 2011 Canonical Ltd. - -Authors: - Conor Curran - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see . -*/ - -using Dbusmenu; -using Gee; -using DbusmenuTrackSpecific; -using Dbusmenu; - -public class TrackSpecificMenuitem : PlayerItem -{ - public Menuitem root_item{get; construct;} - - public TrackSpecificMenuitem (PlayerController parent) - { - Object(item_type: MENUITEM_TYPE, owner: parent); - } - construct - { - this.root_item = new Menuitem(); - this.root_item.property_set ( MENUITEM_PROP_LABEL, _("Like This") ); - this.root_item.property_set_bool (MENUITEM_PROP_VISIBLE, false); - this.root_item.property_set_bool (MENUITEM_PROP_ENABLED, false); - } -} -- cgit v1.2.3 From 14bcbdbedbe248b4274ae36287f20c8dddf6276f Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 29 Jun 2011 14:56:14 +0200 Subject: proxy items created --- src/Makefile.am | 3 ++- src/player-controller.vala | 32 +++++++--------------- src/track-specific-items-manager.vala | 51 +++++++++++++++++++++++++++++++---- 3 files changed, 57 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index fedf5de..1b01811 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,7 +50,8 @@ glib_marshal_prefix = _sound_service_marshal music_bridge_VALASOURCES = \ music-player-bridge.vala \ transport-menu-item.vala \ - track-specific-menu-item.vala \ + track-specific-items-manager.vala \ + player-specific-items-manager.vala \ metadata-menu-item.vala \ player-controller.vala \ mpris2-interfaces.vala \ diff --git a/src/player-controller.vala b/src/player-controller.vala index b1c0396..ce1d8c8 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -1,5 +1,4 @@ /* -This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel. Copyright 2010 Canonical Ltd. Authors: @@ -23,13 +22,12 @@ using Gee; public class PlayerController : GLib.Object { - public const int WIDGET_QUANTITY = 5; + public const int WIDGET_QUANTITY = 4; public static enum widget_order{ SEPARATOR, METADATA, TRANSPORT, - TRACK_SPECIFIC, PLAYLISTS } @@ -43,7 +41,7 @@ public class PlayerController : GLib.Object public int current_state = state.OFFLINE; - private Dbusmenu.Menuitem root_menu; + public Dbusmenu.Menuitem root_menu; public string dbus_name { get; set;} public ArrayList custom_items; public Mpris2Controller mpris_bridge; @@ -51,7 +49,8 @@ public class PlayerController : GLib.Object public int menu_offset { get; set;} public string icon_name { get; set; } public bool? use_playlists; - public Client track_specific_client; + private SpecificItemsManager track_specific_mgr; + private SpecificItemsManager player_specific_mgr; public PlayerController(Dbusmenu.Menuitem root, GLib.AppInfo app, @@ -110,19 +109,14 @@ public class PlayerController : GLib.Object public void enable_track_specific_items (string object_path) { - track_specific_client = new Client (this.dbus_name, object_path); - track_specific_client.root_changed.connect (on_new_track_specific_root_changed); - /*TrackSpecificMenuitem menuitem = this.custom_items[widget_order.TRACK_SPECIFIC] as TrackSpecificMenuitem; - menuitem.root_item.property_set_bool (MENUITEM_PROP_VISIBLE, true); - menuitem.root_item.property_set_bool (MENUITEM_PROP_ENABLED, true);*/ + track_specific_mgr = new SpecificItemsManager (this, object_path); } - private void on_new_track_specific_root_changed (GLib.Object item) - { - debug ("!!!!!!!!!!!!!!!!!! - Root changed for track specific item %s", - this.app_info.get_name()); + public void enable_player_specific_items (string object_path) + { + player_specific_mgr = new SpecificItemsManager (this, object_path); } - + private void establish_mpris_connection() { if(this.current_state != state.READY || this.dbus_name == null ){ @@ -196,10 +190,6 @@ 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); @@ -210,10 +200,6 @@ public class PlayerController : GLib.Object PlaylistsMenuitem playlists_menuitem = item as PlaylistsMenuitem; root_menu.child_add_position(playlists_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item)); } - else if (this.custom_items.index_of(item) == 3) { - TrackSpecificMenuitem trackspecific_menuitem = item as TrackSpecificMenuitem; - root_menu.child_add_position(trackspecific_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item)); - } else{ root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item)); } diff --git a/src/track-specific-items-manager.vala b/src/track-specific-items-manager.vala index 3949727..67b8bbf 100644 --- a/src/track-specific-items-manager.vala +++ b/src/track-specific-items-manager.vala @@ -1,6 +1,5 @@ /* -This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel. -Copyright 2010 Canonical Ltd. +Copyright 2011 Canonical Ltd. Authors: Conor Curran @@ -21,10 +20,52 @@ with this program. If not, see . using Dbusmenu; using Gee; -public class TrackSpecificMenuitemsManager : GLib.Object +public class SpecificItemsManager : GLib.Object { - public TrackSpecificMenuitemsManager() + private PlayerController owner {get; set;} + private string dbus_path; + private Dbusmenu.Client client; + private Gee.ArrayList proxy_items; + + public SpecificItemsManager (PlayerController controller, string path) { + this.proxy_items = new ArrayList(); + this.owner = controller; + this.dbus_path = path; + this.client = new Dbusmenu.Client (this.owner.dbus_name, this.dbus_path); + this.client.root_changed.connect (on_root_changed); } -} + + private void on_root_changed (GLib.Object newroot) + { + Dbusmenu.Menuitem root = this.client.get_root(); + root.child_added.connect (on_child_added); + root.child_removed.connect (on_child_removed); + + // Fetch what children are there already. + GLib.List children = root.get_children().copy(); + + debug ("on_root_changed - size of children list : %i", + (int)children.length()); + foreach (void* child in children) { + Dbusmenu.Menuitem* item = (Dbusmenu.Menuitem*)child; + Dbusmenu.MenuitemProxy proxy = new Dbusmenu.MenuitemProxy(*item); + proxy_items.add (proxy); + debug ("Proxy item of label = %s added to collection", + item->property_get (MENUITEM_PROP_LABEL)); + this.owner.root_menu.child_add_position (proxy.menu_item, + this.owner.menu_offset + 3); + } + } + + private void on_child_added (GLib.Object child, uint position) + { + debug ("On child added Specific root node"); + } + private void on_child_removed (GLib.Object child) + { + debug ("On child removed Specific root node"); + } + +} -- cgit v1.2.3 From 0892f485f96e827f9869656c2daa6ed8a165b15f Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 29 Jun 2011 16:34:22 +0200 Subject: track specific items proxying nicely --- src/specific-items-manager.vala | 71 +++++++++++++++++++++++++++++++++++ src/track-specific-items-manager.vala | 71 ----------------------------------- 2 files changed, 71 insertions(+), 71 deletions(-) create mode 100644 src/specific-items-manager.vala delete mode 100644 src/track-specific-items-manager.vala (limited to 'src') diff --git a/src/specific-items-manager.vala b/src/specific-items-manager.vala new file mode 100644 index 0000000..3fa7663 --- /dev/null +++ b/src/specific-items-manager.vala @@ -0,0 +1,71 @@ +/* +Copyright 2011 Canonical Ltd. + +Authors: + Conor Curran + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +using Dbusmenu; +using Gee; + +public class SpecificItemsManager : GLib.Object +{ + private PlayerController owner {get; set;} + private string dbus_path; + private Dbusmenu.Client client; + private Gee.ArrayList proxy_items; + + public SpecificItemsManager (PlayerController controller, string path) + { + this.proxy_items = new ArrayList(); + this.owner = controller; + this.dbus_path = path; + this.client = new Dbusmenu.Client (this.owner.dbus_name, this.dbus_path); + this.client.root_changed.connect (on_root_changed); + } + + private void on_root_changed (GLib.Object newroot) + { + Dbusmenu.Menuitem root = this.client.get_root(); + root.child_added.connect (on_child_added); + root.child_removed.connect (on_child_removed); + + // Fetch what children are there already. + GLib.List children = root.get_children().copy(); + + debug ("on_root_changed - size of children list : %i", + (int)children.length()); + foreach (void* child in children) { + unowned Dbusmenu.Menuitem item = (Dbusmenu.Menuitem)child; + Dbusmenu.MenuitemProxy proxy = new Dbusmenu.MenuitemProxy(item); + proxy_items.add (proxy); + debug ("Proxy item of label = %s added to collection", + item.property_get (MENUITEM_PROP_LABEL)); + this.owner.root_menu.child_add_position (proxy, + this.owner.menu_offset + 3); + } + } + + private void on_child_added (GLib.Object child, uint position) + { + debug ("On child added Specific root node"); + } + + private void on_child_removed (GLib.Object child) + { + debug ("On child removed Specific root node"); + } + +} diff --git a/src/track-specific-items-manager.vala b/src/track-specific-items-manager.vala deleted file mode 100644 index 67b8bbf..0000000 --- a/src/track-specific-items-manager.vala +++ /dev/null @@ -1,71 +0,0 @@ -/* -Copyright 2011 Canonical Ltd. - -Authors: - Conor Curran - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see . -*/ - -using Dbusmenu; -using Gee; - -public class SpecificItemsManager : GLib.Object -{ - private PlayerController owner {get; set;} - private string dbus_path; - private Dbusmenu.Client client; - private Gee.ArrayList proxy_items; - - public SpecificItemsManager (PlayerController controller, string path) - { - this.proxy_items = new ArrayList(); - this.owner = controller; - this.dbus_path = path; - this.client = new Dbusmenu.Client (this.owner.dbus_name, this.dbus_path); - this.client.root_changed.connect (on_root_changed); - } - - private void on_root_changed (GLib.Object newroot) - { - Dbusmenu.Menuitem root = this.client.get_root(); - root.child_added.connect (on_child_added); - root.child_removed.connect (on_child_removed); - - // Fetch what children are there already. - GLib.List children = root.get_children().copy(); - - debug ("on_root_changed - size of children list : %i", - (int)children.length()); - foreach (void* child in children) { - Dbusmenu.Menuitem* item = (Dbusmenu.Menuitem*)child; - Dbusmenu.MenuitemProxy proxy = new Dbusmenu.MenuitemProxy(*item); - proxy_items.add (proxy); - debug ("Proxy item of label = %s added to collection", - item->property_get (MENUITEM_PROP_LABEL)); - this.owner.root_menu.child_add_position (proxy.menu_item, - this.owner.menu_offset + 3); - } - } - - private void on_child_added (GLib.Object child, uint position) - { - debug ("On child added Specific root node"); - } - - private void on_child_removed (GLib.Object child) - { - debug ("On child removed Specific root node"); - } - -} -- cgit v1.2.3 From d0727964e78fd5174402e4732731ad11ad0d7ef3 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 29 Jun 2011 16:57:13 +0200 Subject: fixes for the makefile --- src/Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 1b01811..6917aee 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,8 +50,7 @@ glib_marshal_prefix = _sound_service_marshal music_bridge_VALASOURCES = \ music-player-bridge.vala \ transport-menu-item.vala \ - track-specific-items-manager.vala \ - player-specific-items-manager.vala \ + specific-items-manager.vala \ metadata-menu-item.vala \ player-controller.vala \ mpris2-interfaces.vala \ -- cgit v1.2.3 From a71045671c8681c900847af89afdf0f8b17c7189 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Wed, 3 Aug 2011 13:05:34 -0400 Subject: don't show player bridge and settings links when used in a greeter --- src/sound-service-dbus.c | 44 ++++++++++++++++++++++++-------------------- src/sound-service-dbus.h | 2 +- src/sound-service.c | 19 ++++++++++++++++--- 3 files changed, 41 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 6fb0a64..0db03d4 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -56,6 +56,7 @@ struct _SoundServiceDbusPrivate { GDBusConnection* connection; DbusmenuMenuitem* root_menuitem; Device* device; + gboolean greeter_mode; }; static GDBusNodeInfo * node_info = NULL; @@ -144,9 +145,10 @@ sound_service_dbus_init (SoundServiceDbus *self) } DbusmenuMenuitem* -sound_service_dbus_create_root_item (SoundServiceDbus* self) +sound_service_dbus_create_root_item (SoundServiceDbus* self, gboolean greeter_mode) { SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self); + priv->greeter_mode = greeter_mode; 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); @@ -169,25 +171,27 @@ sound_service_dbus_build_sound_menu ( SoundServiceDbus* self, dbusmenu_menuitem_child_add_position (priv->root_menuitem, slider_item, 1); dbusmenu_menuitem_child_add_position (priv->root_menuitem, voip_input_menu_item, 2); - // Separator - DbusmenuMenuitem* separator = dbusmenu_menuitem_new(); - - dbusmenu_menuitem_property_set (separator, - DBUSMENU_MENUITEM_PROP_TYPE, - DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_add_position (priv->root_menuitem, separator, 3); - g_object_unref (separator); - - // Sound preferences dialog - DbusmenuMenuitem* settings_mi = dbusmenu_menuitem_new(); - - dbusmenu_menuitem_property_set( settings_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Sound Settings...")); - dbusmenu_menuitem_child_append(priv->root_menuitem, settings_mi); - g_object_unref (settings_mi); - g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_sound_settings_dialog), NULL); + if (!priv->greeter_mode) { + // Separator + DbusmenuMenuitem* separator = dbusmenu_menuitem_new(); + + dbusmenu_menuitem_property_set (separator, + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_add_position (priv->root_menuitem, separator, 3); + g_object_unref (separator); + + // Sound preferences dialog + DbusmenuMenuitem* settings_mi = dbusmenu_menuitem_new(); + + dbusmenu_menuitem_property_set( settings_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Sound Settings...")); + dbusmenu_menuitem_child_append(priv->root_menuitem, settings_mi); + g_object_unref (settings_mi); + g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_sound_settings_dialog), NULL); + } } /** diff --git a/src/sound-service-dbus.h b/src/sound-service-dbus.h index 9b19a5e..1c15fc7 100644 --- a/src/sound-service-dbus.h +++ b/src/sound-service-dbus.h @@ -53,7 +53,7 @@ struct _SoundServiceDbusClass { GType sound_service_dbus_get_type (void) G_GNUC_CONST; -DbusmenuMenuitem* sound_service_dbus_create_root_item (SoundServiceDbus* self); +DbusmenuMenuitem* sound_service_dbus_create_root_item (SoundServiceDbus* self, gboolean greeter_mode); void sound_service_dbus_update_sound_state (SoundServiceDbus* self, SoundState new_state); void sound_service_dbus_build_sound_menu ( SoundServiceDbus* self, DbusmenuMenuitem* mute_item, diff --git a/src/sound-service.c b/src/sound-service.c index 1324537..a368081 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -47,12 +47,21 @@ service_shutdown (IndicatorService *service, gpointer user_data) return; } +static gboolean +get_greeter_mode (void) +{ + const gchar *var; + var = g_getenv("INDICATOR_GREETER_MODE"); + return (g_strcmp0(var, "1") == 0); +} + /** main: **/ int main (int argc, char ** argv) { + gboolean greeter_mode; g_type_init(); textdomain (GETTEXT_PACKAGE); @@ -67,9 +76,13 @@ main (int argc, char ** argv) SoundServiceDbus* sound_service = g_object_new(SOUND_SERVICE_DBUS_TYPE, NULL); - DbusmenuMenuitem* root_menuitem = sound_service_dbus_create_root_item(sound_service); - MusicPlayerBridge* server = music_player_bridge_new(); - music_player_bridge_set_root_menu_item(server, root_menuitem); + greeter_mode = get_greeter_mode(); + + DbusmenuMenuitem* root_menuitem = sound_service_dbus_create_root_item(sound_service, greeter_mode); + if (!greeter_mode) { + MusicPlayerBridge* server = music_player_bridge_new(); + music_player_bridge_set_root_menu_item(server, root_menuitem); + } // Run the loop mainloop = g_main_loop_new(NULL, FALSE); -- cgit v1.2.3 From 8594ebfd7953488650107625622cba9f343c051f Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 9 Aug 2011 21:41:22 +0100 Subject: track specific almost in place --- src/player-controller.vala | 11 ++++++++--- src/sound-service.c | 4 ++-- src/specific-items-manager.vala | 32 +++++++++++++++++++++++++++----- 3 files changed, 37 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/player-controller.vala b/src/player-controller.vala index ce1d8c8..bd8b6ad 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -109,12 +109,16 @@ public class PlayerController : GLib.Object public void enable_track_specific_items (string object_path) { - track_specific_mgr = new SpecificItemsManager (this, object_path); + track_specific_mgr = new SpecificItemsManager (this, + object_path, + SpecificItemsManager.category.TRACK); } public void enable_player_specific_items (string object_path) { - player_specific_mgr = new SpecificItemsManager (this, object_path); + player_specific_mgr = new SpecificItemsManager (this, + object_path, + SpecificItemsManager.category.PLAYER); } private void establish_mpris_connection() @@ -201,7 +205,8 @@ public class PlayerController : GLib.Object root_menu.child_add_position(playlists_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item)); } else{ - root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item)); + root_menu.child_add_position (item, + this.menu_offset + this.custom_items.index_of(item)); } } } diff --git a/src/sound-service.c b/src/sound-service.c index da9b94e..a9ca56c 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -40,8 +40,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) { if (mainloop != NULL) { g_debug("Service shutdown !"); - close_pulse_activites(); - g_main_loop_quit(mainloop); + /*close_pulse_activites(); + g_main_loop_quit(mainloop);*/ } return; } diff --git a/src/specific-items-manager.vala b/src/specific-items-manager.vala index 3fa7663..2755ee8 100644 --- a/src/specific-items-manager.vala +++ b/src/specific-items-manager.vala @@ -22,13 +22,22 @@ using Gee; public class SpecificItemsManager : GLib.Object { + public static enum category{ + TRACK, + PLAYER + } + private PlayerController owner {get; set;} private string dbus_path; private Dbusmenu.Client client; private Gee.ArrayList proxy_items; - - public SpecificItemsManager (PlayerController controller, string path) + private int of_type; + + public SpecificItemsManager (PlayerController controller, + string path, + category which_type) { + this.of_type = which_type; this.proxy_items = new ArrayList(); this.owner = controller; this.dbus_path = path; @@ -36,25 +45,38 @@ public class SpecificItemsManager : GLib.Object this.client.root_changed.connect (on_root_changed); } + private int figure_out_positioning() + { + int specific_item_count = this.proxy_items.size; + if (this.of_type == category.TRACK){ + return this.owner.menu_offset + 2 + specific_item_count; + } + return (int)this.owner.root_menu.get_children().length(); + } + private void on_root_changed (GLib.Object newroot) { - Dbusmenu.Menuitem root = this.client.get_root(); + Dbusmenu.Menuitem? root = this.client.get_root(); root.child_added.connect (on_child_added); root.child_removed.connect (on_child_removed); // Fetch what children are there already. + if (root == null){ + debug ("root disappeared -remove proxyitems"); + return; + } GLib.List children = root.get_children().copy(); debug ("on_root_changed - size of children list : %i", (int)children.length()); foreach (void* child in children) { + int pos = figure_out_positioning(); unowned Dbusmenu.Menuitem item = (Dbusmenu.Menuitem)child; Dbusmenu.MenuitemProxy proxy = new Dbusmenu.MenuitemProxy(item); proxy_items.add (proxy); debug ("Proxy item of label = %s added to collection", item.property_get (MENUITEM_PROP_LABEL)); - this.owner.root_menu.child_add_position (proxy, - this.owner.menu_offset + 3); + this.owner.root_menu.child_add_position (proxy, pos); } } -- cgit v1.2.3 From 023090260c73fad2f22c8937fad70215d56319d1 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 10 Aug 2011 13:41:08 +0100 Subject: track specific ordering correct, player specific under way --- src/player-controller.vala | 11 ++++++++++- src/sound-service-dbus.c | 6 ++++-- src/specific-items-manager.vala | 36 ++++++++++++++++++++++++++---------- 3 files changed, 40 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/player-controller.vala b/src/player-controller.vala index bd8b6ad..f46d36b 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -116,10 +116,19 @@ public class PlayerController : GLib.Object public void enable_player_specific_items (string object_path) { + debug ("Player specific item"); player_specific_mgr = new SpecificItemsManager (this, object_path, SpecificItemsManager.category.PLAYER); } + + public int track_specific_count () + { + if (this.track_specific_mgr == null) { + return 0; + } + return this.track_specific_mgr.proxy_items.size; + } private void establish_mpris_connection() { @@ -210,7 +219,7 @@ public class PlayerController : GLib.Object } } } - + private void determine_state() { if(this.mpris_bridge.connected() == true){ diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index bad90ca..9950302 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -326,7 +326,7 @@ bus_method_call (GDBusConnection * connection, gchar* player_object_path; gchar* player_id; g_variant_get (params, "(os)", &player_object_path, &player_id); - g_debug ("object path = %s and id = %s", player_object_path, player_id); + //g_debug ("object path = %s and id = %s", player_object_path, player_id); g_signal_emit (service, signals[TRACK_SPECIFIC_ITEM], 0, @@ -340,7 +340,9 @@ bus_method_call (GDBusConnection * connection, gchar* player_object_path; gchar* player_id; g_variant_get (params, "(os)", &player_object_path, &player_id); - //g_debug ("object path = %s and id = %s", player_object_path, player_id); + g_debug ("PLayer specific item - object path = %s and id = %s", + player_object_path, + player_id); g_signal_emit (service, signals[PLAYER_SPECIFIC_ITEM], 0, diff --git a/src/specific-items-manager.vala b/src/specific-items-manager.vala index 2755ee8..e3d17e5 100644 --- a/src/specific-items-manager.vala +++ b/src/specific-items-manager.vala @@ -30,7 +30,7 @@ public class SpecificItemsManager : GLib.Object private PlayerController owner {get; set;} private string dbus_path; private Dbusmenu.Client client; - private Gee.ArrayList proxy_items; + public Gee.ArrayList proxy_items {get; construct;} private int of_type; public SpecificItemsManager (PlayerController controller, @@ -38,33 +38,48 @@ public class SpecificItemsManager : GLib.Object category which_type) { this.of_type = which_type; - this.proxy_items = new ArrayList(); this.owner = controller; this.dbus_path = path; this.client = new Dbusmenu.Client (this.owner.dbus_name, this.dbus_path); this.client.root_changed.connect (on_root_changed); } + construct{ + this.proxy_items = new ArrayList(); + } private int figure_out_positioning() { - int specific_item_count = this.proxy_items.size; + int result = 0 ; if (this.of_type == category.TRACK){ - return this.owner.menu_offset + 2 + specific_item_count; + int specific_item_count = this.proxy_items.size; + result = this.owner.menu_offset + 4 + specific_item_count; + } + else if (this.of_type == category.PLAYER){ + int pos = this.owner.menu_offset + 4 + this.owner.track_specific_count(); + pos += this.owner.use_playlists == true ? 1 : 0; + result = pos; } - return (int)this.owner.root_menu.get_children().length(); + debug ("!!!!! Menu pos of type %i is = %i", this.of_type, result); + return result; } - private void on_root_changed (GLib.Object newroot) + private void on_root_changed (GLib.Object? newroot) { + if (newroot == null){ + debug ("root disappeared -remove proxyitems"); + foreach(var p in proxy_items){ + this.owner.root_menu.child_delete (p); + } + this.proxy_items.clear();// = null; + //this.proxy_items = new ArrayList(); + return; + } + Dbusmenu.Menuitem? root = this.client.get_root(); root.child_added.connect (on_child_added); root.child_removed.connect (on_child_removed); // Fetch what children are there already. - if (root == null){ - debug ("root disappeared -remove proxyitems"); - return; - } GLib.List children = root.get_children().copy(); debug ("on_root_changed - size of children list : %i", @@ -77,6 +92,7 @@ public class SpecificItemsManager : GLib.Object debug ("Proxy item of label = %s added to collection", item.property_get (MENUITEM_PROP_LABEL)); this.owner.root_menu.child_add_position (proxy, pos); + } } -- cgit v1.2.3 From f6de74585f8b091f360debb65f2548cd8bc6ea01 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 10 Aug 2011 16:18:51 +0100 Subject: track specific and player specific fixed --- src/music-player-bridge.vala | 7 ++++++- src/player-controller.vala | 17 ++++++++++------- src/specific-items-manager.vala | 8 +++----- 3 files changed, 19 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index 727c36b..72c9bdb 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -161,7 +161,12 @@ public class MusicPlayerBridge : GLib.Object public void enable_player_specific_items_for_client (string object_path, string desktop_id) { - // TODO + 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_player_specific_items(object_path); } public void enable_track_specific_items_for_client (string object_path, diff --git a/src/player-controller.vala b/src/player-controller.vala index f46d36b..ced7d96 100644 --- a/src/player-controller.vala +++ b/src/player-controller.vala @@ -109,17 +109,20 @@ public class PlayerController : GLib.Object public void enable_track_specific_items (string object_path) { - track_specific_mgr = new SpecificItemsManager (this, - object_path, - SpecificItemsManager.category.TRACK); + if (this.track_specific_mgr == null){ + track_specific_mgr = new SpecificItemsManager (this, + object_path, + SpecificItemsManager.category.TRACK); + } } public void enable_player_specific_items (string object_path) { - debug ("Player specific item"); - player_specific_mgr = new SpecificItemsManager (this, - object_path, - SpecificItemsManager.category.PLAYER); + if (this.player_specific_mgr == null){ + player_specific_mgr = new SpecificItemsManager (this, + object_path, + SpecificItemsManager.category.PLAYER); + } } public int track_specific_count () diff --git a/src/specific-items-manager.vala b/src/specific-items-manager.vala index e3d17e5..d26199f 100644 --- a/src/specific-items-manager.vala +++ b/src/specific-items-manager.vala @@ -51,8 +51,7 @@ public class SpecificItemsManager : GLib.Object { int result = 0 ; if (this.of_type == category.TRACK){ - int specific_item_count = this.proxy_items.size; - result = this.owner.menu_offset + 4 + specific_item_count; + result = this.owner.menu_offset + 4 + this.proxy_items.size; } else if (this.of_type == category.PLAYER){ int pos = this.owner.menu_offset + 4 + this.owner.track_specific_count(); @@ -70,7 +69,8 @@ public class SpecificItemsManager : GLib.Object foreach(var p in proxy_items){ this.owner.root_menu.child_delete (p); } - this.proxy_items.clear();// = null; + this.proxy_items.clear(); + debug ("array list size is now %i", this.proxy_items.size); //this.proxy_items = new ArrayList(); return; } @@ -82,8 +82,6 @@ public class SpecificItemsManager : GLib.Object // Fetch what children are there already. GLib.List children = root.get_children().copy(); - debug ("on_root_changed - size of children list : %i", - (int)children.length()); foreach (void* child in children) { int pos = figure_out_positioning(); unowned Dbusmenu.Menuitem item = (Dbusmenu.Menuitem)child; -- cgit v1.2.3 From 82a8f86a7088a2e144c89373174c8e03a597f277 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 10 Aug 2011 16:21:23 +0100 Subject: uncomment disconnect --- src/sound-service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sound-service.c b/src/sound-service.c index a9ca56c..da9b94e 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -40,8 +40,8 @@ service_shutdown (IndicatorService *service, gpointer user_data) { if (mainloop != NULL) { g_debug("Service shutdown !"); - /*close_pulse_activites(); - g_main_loop_quit(mainloop);*/ + close_pulse_activites(); + g_main_loop_quit(mainloop); } return; } -- cgit v1.2.3