Merge lp:~cjcurran/indicator-sound/track-specific-ordering into lp:indicator-sound/fourth

Proposed by Conor Curran
Status: Merged
Approved by: Ted Gould
Approved revision: 260
Merged at revision: 261
Proposed branch: lp:~cjcurran/indicator-sound/track-specific-ordering
Merge into: lp:indicator-sound/fourth
Diff against target: 653 lines (+335/-28)
14 files modified
Makefile.am.marshal (+45/-0)
configure.ac (+3/-0)
src/Makefile.am (+11/-0)
src/common-defs.h (+2/-0)
src/mpris2-watcher.vala (+1/-1)
src/music-player-bridge.vala (+24/-3)
src/player-controller.vala (+35/-8)
src/playlists-menu-item.vala (+0/-1)
src/sound-service-dbus.c (+57/-3)
src/sound-service-marshal.list (+2/-0)
src/sound-service.c (+38/-10)
src/sound-service.xml (+10/-1)
src/specific-items-manager.vala (+107/-0)
vapi/common-defs.vapi (+0/-1)
To merge this branch: bzr merge lp:~cjcurran/indicator-sound/track-specific-ordering
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+71062@code.launchpad.net

Description of the change

Necessary changes to allow track and player specific items into the menu from libunity implementations

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'Makefile.am.marshal'
--- Makefile.am.marshal 1970-01-01 00:00:00 +0000
+++ Makefile.am.marshal 2011-08-10 15:26:18 +0000
@@ -0,0 +1,45 @@
1# Rules for generating marshal files using glib-genmarshal
2#
3# Define:
4# glib_marshal_list = marshal list file
5# glib_marshal_prefix = prefix for marshal functions
6#
7# before including Makefile.am.marshal. You will also need to have
8# the following targets already defined:
9#
10# CLEANFILES
11# DISTCLEANFILES
12# BUILT_SOURCES
13# EXTRA_DIST
14#
15# Author: Emmanuele Bassi <ebassi@linux.intel.com>
16
17marshal_h = $(glib_marshal_list:.list=.h)
18marshal_c = $(glib_marshal_list:.list=.c)
19
20CLEANFILES += stamp-marshal
21DISTCLEANFILES += $(marshal_h) $(marshal_c)
22BUILT_SOURCES += $(marshal_h) $(marshal_c)
23EXTRA_DIST += $(glib_marshal_list)
24
25stamp-marshal: $(glib_marshal_list)
26 $(QUIET_GEN)$(GLIB_GENMARSHAL) \
27 --prefix=$(glib_marshal_prefix) \
28 --header \
29 $(srcdir)/$(glib_marshal_list) > xgen-mh \
30 && (cmp -s xgen-mh $(marshal_h) || cp -f xgen-mh $(marshal_h)) \
31 && rm -f xgen-mh \
32 && echo timestamp > $(@F)
33
34$(marshal_h): stamp-marshal
35 @true
36
37$(marshal_c): $(marshal_h)
38 $(QUIET_GEN)(echo "#include \"$(marshal_h)\"" ; \
39 $(GLIB_GENMARSHAL) \
40 --prefix=$(glib_marshal_prefix) \
41 --body \
42 $(srcdir)/$(glib_marshal_list)) > xgen-mc \
43 && cp xgen-mc $(marshal_c) \
44 && rm -f xgen-mc
45
046
=== modified file 'configure.ac'
--- configure.ac 2011-07-29 16:18:02 +0000
+++ configure.ac 2011-08-10 15:26:18 +0000
@@ -23,6 +23,8 @@
2323
24m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])24m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
2525
26AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
27
26###########################28###########################
27# GTK+ version option29# GTK+ version option
28###########################30###########################
@@ -130,6 +132,7 @@
130###########################132###########################
131133
132GLIB_GSETTINGS134GLIB_GSETTINGS
135GLIB_GENMARSHAL
133136
134###########################137###########################
135# DBus Service Info138# DBus Service Info
136139
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2011-07-29 16:18:02 +0000
+++ src/Makefile.am 2011-08-10 15:26:18 +0000
@@ -32,6 +32,7 @@
32libsoundmenu_la_LIBADD = $(APPLET_LIBS)32libsoundmenu_la_LIBADD = $(APPLET_LIBS)
33libsoundmenu_la_LDFLAGS = -module -avoid-version33libsoundmenu_la_LDFLAGS = -module -avoid-version
3434
35
35checkxml: $(srcdir)/sound-service.xml36checkxml: $(srcdir)/sound-service.xml
36 @xmllint -valid -noout $<37 @xmllint -valid -noout $<
37 @echo $< checks out ok38 @echo $< checks out ok
@@ -41,6 +42,9 @@
41# Sound Service 42# Sound Service
42####################################################################43####################################################################
4344
45glib_marshal_list = sound-service-marshal.list
46glib_marshal_prefix = _sound_service_marshal
47
4448
45#####################49#####################
46# Sound service vala50# Sound service vala
@@ -48,6 +52,7 @@
48music_bridge_VALASOURCES = \52music_bridge_VALASOURCES = \
49 music-player-bridge.vala \53 music-player-bridge.vala \
50 transport-menu-item.vala \54 transport-menu-item.vala \
55 specific-items-manager.vala \
51 metadata-menu-item.vala \56 metadata-menu-item.vala \
52 player-controller.vala \57 player-controller.vala \
53 mpris2-interfaces.vala \58 mpris2-interfaces.vala \
@@ -107,6 +112,8 @@
107 mute-menu-item.c \112 mute-menu-item.c \
108 gen-sound-service.xml.h \113 gen-sound-service.xml.h \
109 gen-sound-service.xml.c \114 gen-sound-service.xml.c \
115 sound-service-marshal.c \
116 sound-service-marshal.h \
110 $(music_bridge_VALASOURCES:.vala=.c)117 $(music_bridge_VALASOURCES:.vala=.c)
111118
112indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) $(SOUNDSERVICE_CFLAGS) $(GCONF_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall119indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) $(SOUNDSERVICE_CFLAGS) $(GCONF_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall
@@ -147,3 +154,7 @@
147 154
148CLEANFILES = \155CLEANFILES = \
149 $(BUILT_SOURCES)156 $(BUILT_SOURCES)
157
158DISTCLEANFILES =
159
160include $(top_srcdir)/Makefile.am.marshal
150161
=== modified file 'src/common-defs.h'
--- src/common-defs.h 2011-06-10 09:38:54 +0000
+++ src/common-defs.h 2011-08-10 15:26:18 +0000
@@ -67,6 +67,8 @@
67#define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-sound-menu-player-transport-type"67#define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-sound-menu-player-transport-type"
68#define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-sound-menu-player-transport-state"68#define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-sound-menu-player-transport-state"
6969
70#define DBUSMENU_TRACK_SPECIFIC_MENUITEM_TYPE "x-canonical-sound-menu-player-track-specific-type"
71
70#define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-sound-menu-player-metadata-type"72#define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-sound-menu-player-metadata-type"
71#define DBUSMENU_METADATA_MENUITEM_ARTIST "x-canonical-sound-menu-player-metadata-xesam:artist"73#define DBUSMENU_METADATA_MENUITEM_ARTIST "x-canonical-sound-menu-player-metadata-xesam:artist"
72#define DBUSMENU_METADATA_MENUITEM_TITLE "x-canonical-sound-menu-player-metadata-xesam:title"74#define DBUSMENU_METADATA_MENUITEM_TITLE "x-canonical-sound-menu-player-metadata-xesam:title"
7375
=== modified file 'src/mpris2-watcher.vala'
--- src/mpris2-watcher.vala 2011-03-21 13:04:13 +0000
+++ src/mpris2-watcher.vala 2011-08-10 15:26:18 +0000
@@ -38,7 +38,7 @@
38 this.fdesktop_obj = Bus.get_proxy_sync ( BusType.SESSION,38 this.fdesktop_obj = Bus.get_proxy_sync ( BusType.SESSION,
39 FREEDESKTOP_SERVICE,39 FREEDESKTOP_SERVICE,
40 FREEDESKTOP_OBJECT,40 FREEDESKTOP_OBJECT,
41 DBusProxyFlags.DO_NOT_LOAD_PROPERTIES ); 41 DBusProxyFlags.DO_NOT_LOAD_PROPERTIES );
42 this.fdesktop_obj.name_owner_changed.connect (this.name_changes_detected); 42 this.fdesktop_obj.name_owner_changed.connect (this.name_changes_detected);
43 this.check_for_active_clients.begin();43 this.check_for_active_clients.begin();
44 }44 }
4545
=== modified file 'src/music-player-bridge.vala'
--- src/music-player-bridge.vala 2011-02-17 18:54:58 +0000
+++ src/music-player-bridge.vala 2011-08-10 15:26:18 +0000
@@ -27,7 +27,7 @@
2727
28 private SettingsManager settings_manager;28 private SettingsManager settings_manager;
29 private Dbusmenu.Menuitem root_menu;29 private Dbusmenu.Menuitem root_menu;
30 private HashMap<string, PlayerController> registered_clients; 30 private HashMap<string, PlayerController> registered_clients;
31 private Mpris2Watcher watcher;31 private Mpris2Watcher watcher;
3232
33 public MusicPlayerBridge()33 public MusicPlayerBridge()
@@ -158,10 +158,31 @@
158 this.watcher.client_disappeared.connect (this.client_has_vanished);158 this.watcher.client_disappeared.connect (this.client_has_vanished);
159 }159 }
160160
161 public void enable_player_specific_items_for_client (string object_path,
162 string desktop_id)
163 {
164 var mpris_key = determine_key ( desktop_id );
165 if (this.registered_clients.has_key (mpris_key) == false){
166 warning ("we don't have a client with desktop id %s registered", desktop_id);
167 return;
168 }
169 this.registered_clients[mpris_key].enable_player_specific_items(object_path);
170 }
171
172 public void enable_track_specific_items_for_client (string object_path,
173 string desktop_id)
174 {
175 var mpris_key = determine_key ( desktop_id );
176 if (this.registered_clients.has_key (mpris_key) == false){
177 warning ("we don't have a client with desktop id %s registered", desktop_id);
178 return;
179 }
180 this.registered_clients[mpris_key].enable_track_specific_items(object_path);
181 }
182
161 private static AppInfo? create_app_info ( string desktop )183 private static AppInfo? create_app_info ( string desktop )
162 {184 {
163 DesktopAppInfo info = new DesktopAppInfo ( desktop ) ;185 DesktopAppInfo info = new DesktopAppInfo ( desktop );
164
165 if ( desktop == null || info == null ){186 if ( desktop == null || info == null ){
166 warning ( "Could not create a desktopappinfo instance from app: %s", desktop );187 warning ( "Could not create a desktopappinfo instance from app: %s", desktop );
167 return null;188 return null;
168189
=== modified file 'src/player-controller.vala'
--- src/player-controller.vala 2011-07-28 17:49:48 +0000
+++ src/player-controller.vala 2011-08-10 15:26:18 +0000
@@ -1,5 +1,4 @@
1/*1/*
2This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel.
3Copyright 2010 Canonical Ltd.2Copyright 2010 Canonical Ltd.
43
5Authors:4Authors:
@@ -42,7 +41,7 @@
42 41
43 public int current_state = state.OFFLINE;42 public int current_state = state.OFFLINE;
44 43
45 private Dbusmenu.Menuitem root_menu;44 public Dbusmenu.Menuitem root_menu;
46 public string dbus_name { get; set;}45 public string dbus_name { get; set;}
47 public ArrayList<PlayerItem> custom_items;46 public ArrayList<PlayerItem> custom_items;
48 public Mpris2Controller mpris_bridge;47 public Mpris2Controller mpris_bridge;
@@ -50,6 +49,8 @@
50 public int menu_offset { get; set;}49 public int menu_offset { get; set;}
51 public string icon_name { get; set; }50 public string icon_name { get; set; }
52 public bool? use_playlists;51 public bool? use_playlists;
52 private SpecificItemsManager track_specific_mgr;
53 private SpecificItemsManager player_specific_mgr;
53 54
54 public PlayerController(Dbusmenu.Menuitem root,55 public PlayerController(Dbusmenu.Menuitem root,
55 GLib.AppInfo app,56 GLib.AppInfo app,
@@ -105,7 +106,33 @@
105 error.message );106 error.message );
106 }107 }
107 }108 }
109
110 public void enable_track_specific_items (string object_path)
111 {
112 if (this.track_specific_mgr == null){
113 track_specific_mgr = new SpecificItemsManager (this,
114 object_path,
115 SpecificItemsManager.category.TRACK);
116 }
117 }
118
119 public void enable_player_specific_items (string object_path)
120 {
121 if (this.player_specific_mgr == null){
122 player_specific_mgr = new SpecificItemsManager (this,
123 object_path,
124 SpecificItemsManager.category.PLAYER);
125 }
126 }
108 127
128 public int track_specific_count ()
129 {
130 if (this.track_specific_mgr == null) {
131 return 0;
132 }
133 return this.track_specific_mgr.proxy_items.size;
134 }
135
109 private void establish_mpris_connection()136 private void establish_mpris_connection()
110 { 137 {
111 if(this.current_state != state.READY || this.dbus_name == null ){138 if(this.current_state != state.READY || this.dbus_name == null ){
@@ -114,9 +141,8 @@
114 }141 }
115 debug ( " establish mpris connection - use playlists value = %s ",142 debug ( " establish mpris connection - use playlists value = %s ",
116 this.use_playlists.to_string() );143 this.use_playlists.to_string() );
117144 this.mpris_bridge = new Mpris2Controller (this);
118 this.mpris_bridge = new Mpris2Controller(this); 145 this.determine_state ();
119 this.determine_state();
120 }146 }
121 147
122 public void remove_from_menu()148 public void remove_from_menu()
@@ -186,16 +212,17 @@
186 this.custom_items.add(playlist_menuitem);212 this.custom_items.add(playlist_menuitem);
187 213
188 foreach(PlayerItem item in this.custom_items){214 foreach(PlayerItem item in this.custom_items){
189 if (this.custom_items.index_of(item) == 3) {215 if (this.custom_items.index_of(item) == 4) {
190 PlaylistsMenuitem playlists_menuitem = item as PlaylistsMenuitem;216 PlaylistsMenuitem playlists_menuitem = item as PlaylistsMenuitem;
191 root_menu.child_add_position(playlists_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item));217 root_menu.child_add_position(playlists_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item));
192 }218 }
193 else{219 else{
194 root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item));220 root_menu.child_add_position (item,
221 this.menu_offset + this.custom_items.index_of(item));
195 }222 }
196 }223 }
197 }224 }
198 225
199 private void determine_state()226 private void determine_state()
200 {227 {
201 if(this.mpris_bridge.connected() == true){228 if(this.mpris_bridge.connected() == true){
202229
=== modified file 'src/playlists-menu-item.vala'
--- src/playlists-menu-item.vala 2011-06-13 10:04:15 +0000
+++ src/playlists-menu-item.vala 2011-08-10 15:26:18 +0000
@@ -39,7 +39,6 @@
39 this.root_item = new Menuitem();39 this.root_item = new Menuitem();
40 this.root_item.property_set ( MENUITEM_PROP_LABEL, _("Choose Playlist") );40 this.root_item.property_set ( MENUITEM_PROP_LABEL, _("Choose Playlist") );
41 this.root_item.property_set ( MENUITEM_PATH, "" );41 this.root_item.property_set ( MENUITEM_PATH, "" );
42
43 }42 }
4443
45 public new void update (PlaylistDetails[] playlists)44 public new void update (PlaylistDetails[] playlists)
4645
=== modified file 'src/sound-service-dbus.c'
--- src/sound-service-dbus.c 2011-06-16 14:43:37 +0000
+++ src/sound-service-dbus.c 2011-08-10 15:26:18 +0000
@@ -32,6 +32,7 @@
32#include "device.h"32#include "device.h"
33#include "gen-sound-service.xml.h"33#include "gen-sound-service.xml.h"
34#include "dbus-shared-names.h"34#include "dbus-shared-names.h"
35#include "sound-service-marshal.h"
3536
36// DBUS methods37// DBUS methods
37static void bus_method_call (GDBusConnection * connection,38static void bus_method_call (GDBusConnection * connection,
@@ -58,6 +59,14 @@
58 Device* device;59 Device* device;
59};60};
6061
62enum {
63 TRACK_SPECIFIC_ITEM,
64 PLAYER_SPECIFIC_ITEM,
65 LAST_SIGNAL
66};
67
68static guint signals[LAST_SIGNAL] = { 0 };
69
61static GDBusNodeInfo * node_info = NULL;70static GDBusNodeInfo * node_info = NULL;
62static GDBusInterfaceInfo * interface_info = NULL;71static GDBusInterfaceInfo * interface_info = NULL;
6372
@@ -110,6 +119,22 @@
110 g_error("Unable to find interface '" INDICATOR_SOUND_DBUS_INTERFACE "'");119 g_error("Unable to find interface '" INDICATOR_SOUND_DBUS_INTERFACE "'");
111 }120 }
112 }121 }
122 signals[TRACK_SPECIFIC_ITEM] = g_signal_new("track-specific-item-requested",
123 G_TYPE_FROM_CLASS (klass),
124 G_SIGNAL_RUN_LAST,
125 0,
126 NULL, NULL,
127 _sound_service_marshal_VOID__STRING_STRING,
128 G_TYPE_NONE, 2, G_TYPE_STRING,
129 G_TYPE_STRING);
130 signals[PLAYER_SPECIFIC_ITEM] = g_signal_new("player-specific-item-requested",
131 G_TYPE_FROM_CLASS (klass),
132 G_SIGNAL_RUN_LAST,
133 0,
134 NULL, NULL,
135 _sound_service_marshal_VOID__STRING_STRING,
136 G_TYPE_NONE, 2, G_TYPE_STRING,
137 G_TYPE_STRING);
113}138}
114139
115static void140static void
@@ -148,7 +173,6 @@
148{173{
149 SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self);174 SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self);
150 priv->root_menuitem = dbusmenu_menuitem_new();175 priv->root_menuitem = dbusmenu_menuitem_new();
151 //g_debug("Root ID: %d", dbusmenu_menuitem_get_id(priv->root_menuitem));
152 DbusmenuServer *server = dbusmenu_server_new (INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH);176 DbusmenuServer *server = dbusmenu_server_new (INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH);
153 dbusmenu_server_set_root (server, priv->root_menuitem);177 dbusmenu_server_set_root (server, priv->root_menuitem);
154 g_object_unref (priv->root_menuitem);178 g_object_unref (priv->root_menuitem);
@@ -183,9 +207,9 @@
183207
184 dbusmenu_menuitem_property_set( settings_mi,208 dbusmenu_menuitem_property_set( settings_mi,
185 DBUSMENU_MENUITEM_PROP_LABEL,209 DBUSMENU_MENUITEM_PROP_LABEL,
186 _("Sound Settings..."));210 _("Sound Preferences..."));
187 dbusmenu_menuitem_child_append(priv->root_menuitem, settings_mi);211 dbusmenu_menuitem_child_append(priv->root_menuitem, settings_mi);
188 g_object_unref (settings_mi); 212 g_object_unref (settings_mi);
189 g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,213 g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
190 G_CALLBACK(show_sound_settings_dialog), NULL); 214 G_CALLBACK(show_sound_settings_dialog), NULL);
191}215}
@@ -297,6 +321,36 @@
297 player_name);321 player_name);
298 retval = g_variant_new ("(b)", result);322 retval = g_variant_new ("(b)", result);
299 }323 }
324 else if (g_strcmp0(method, "EnableTrackSpecificItems") == 0) {
325 g_debug ("EnableTrackSpecificItems");
326 gchar* player_object_path;
327 gchar* player_id;
328 g_variant_get (params, "(os)", &player_object_path, &player_id);
329 //g_debug ("object path = %s and id = %s", player_object_path, player_id);
330 g_signal_emit (service,
331 signals[TRACK_SPECIFIC_ITEM],
332 0,
333 player_object_path,
334 player_id);
335 g_free (player_object_path);
336 g_free (player_id);
337
338 }
339 else if (g_strcmp0(method, "EnablePlayerSpecificItems") == 0) {
340 gchar* player_object_path;
341 gchar* player_id;
342 g_variant_get (params, "(os)", &player_object_path, &player_id);
343 g_debug ("PLayer specific item - object path = %s and id = %s",
344 player_object_path,
345 player_id);
346 g_signal_emit (service,
347 signals[PLAYER_SPECIFIC_ITEM],
348 0,
349 player_object_path,
350 player_id);
351 g_free (player_object_path);
352 g_free (player_id);
353 }
300 else {354 else {
301 g_warning("Calling method '%s' on the sound service but it's unknown", method); 355 g_warning("Calling method '%s' on the sound service but it's unknown", method);
302 }356 }
303357
=== added file 'src/sound-service-marshal.list'
--- src/sound-service-marshal.list 1970-01-01 00:00:00 +0000
+++ src/sound-service-marshal.list 2011-08-10 15:26:18 +0000
@@ -0,0 +1,2 @@
1VOID:STRING,STRING
2
03
=== modified file 'src/sound-service.c'
--- src/sound-service.c 2011-03-22 19:53:19 +0000
+++ src/sound-service.c 2011-08-10 15:26:18 +0000
@@ -17,19 +17,18 @@
17with this program. If not, see <http://www.gnu.org/licenses/>.17with this program. If not, see <http://www.gnu.org/licenses/>.
18*/18*/
1919
20#include <locale.h>
21
20#include "sound-service.h"22#include "sound-service.h"
21#include "pulseaudio-mgr.h"23#include "pulseaudio-mgr.h"
22#include "sound-service-dbus.h"24#include "sound-service-dbus.h"
23#include "music-player-bridge.h"25#include "music-player-bridge.h"
2426
25#include <locale.h>
26
27static GMainLoop *mainloop = NULL;27static GMainLoop *mainloop = NULL;
2828static MusicPlayerBridge* player_bridge;
29/**********************************************************************************************************************/29/**********************************************************************************************************************/
30// Init and exit functions30// Init and exit functions
31/**********************************************************************************************************************/31/**********************************************************************************************************************/
32
33/**32/**
34service_shutdown:33service_shutdown:
35When the service interface starts to shutdown, we34When the service interface starts to shutdown, we
@@ -47,29 +46,58 @@
47 return;46 return;
48}47}
4948
49void
50on_player_specific_item_requested (SoundServiceDbus* sound_service,
51 const gchar* desktop_id,
52 const gchar* player_object_path,
53 gpointer userdata)
54{
55 music_player_bridge_enable_player_specific_items_for_client (player_bridge,
56 desktop_id,
57 player_object_path);
58 g_debug ("ON PLAYER SPECIFIC ITEM REQUESTED %s", desktop_id);
59}
60
61void
62on_track_specific_item_requested (SoundServiceDbus* sound_service,
63 const gchar* desktop_id,
64 const gchar* player_object_path,
65 gpointer userdata)
66{
67 music_player_bridge_enable_track_specific_items_for_client (player_bridge,
68 desktop_id,
69 player_object_path);
70 g_debug ("ON TRACK SPECIFIC ITEM REQUESTED %s", desktop_id);
71}
72
50/**73/**
51main:74main:
52**/75**/
53int76int
54main (int argc, char ** argv)77main (int argc, char ** argv)
55{78{
56
57 g_type_init();79 g_type_init();
58 textdomain (GETTEXT_PACKAGE);80 textdomain (GETTEXT_PACKAGE);
59 bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);81 bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
60 setlocale (LC_ALL, "");82 setlocale (LC_ALL, "");
6183
62 IndicatorService *service = indicator_service_new_version(INDICATOR_SOUND_DBUS_NAME,84 IndicatorService *service = indicator_service_new_version (INDICATOR_SOUND_DBUS_NAME,
63 INDICATOR_SOUND_DBUS_VERSION);85 INDICATOR_SOUND_DBUS_VERSION);
64 g_signal_connect(G_OBJECT(service),86 g_signal_connect(G_OBJECT(service),
65 INDICATOR_SERVICE_SIGNAL_SHUTDOWN,87 INDICATOR_SERVICE_SIGNAL_SHUTDOWN,
66 G_CALLBACK(service_shutdown), NULL);88 G_CALLBACK(service_shutdown), NULL);
6789
68 SoundServiceDbus* sound_service = g_object_new(SOUND_SERVICE_DBUS_TYPE, NULL);90 SoundServiceDbus* sound_service = g_object_new(SOUND_SERVICE_DBUS_TYPE, NULL);
91 g_signal_connect(G_OBJECT(sound_service),
92 "track-specific-item-requested",
93 G_CALLBACK(on_track_specific_item_requested), NULL);
94 g_signal_connect(G_OBJECT(sound_service),
95 "player-specific-item-requested",
96 G_CALLBACK(on_player_specific_item_requested), NULL);
69 97
70 DbusmenuMenuitem* root_menuitem = sound_service_dbus_create_root_item(sound_service);98 DbusmenuMenuitem* root_menuitem = sound_service_dbus_create_root_item (sound_service);
71 MusicPlayerBridge* server = music_player_bridge_new();99 player_bridge = music_player_bridge_new ();
72 music_player_bridge_set_root_menu_item(server, root_menuitem);100 music_player_bridge_set_root_menu_item (player_bridge, root_menuitem);
73101
74 // Run the loop102 // Run the loop
75 mainloop = g_main_loop_new(NULL, FALSE);103 mainloop = g_main_loop_new(NULL, FALSE);
76104
=== modified file 'src/sound-service.xml'
--- src/sound-service.xml 2011-03-07 11:48:56 +0000
+++ src/sound-service.xml 2011-08-10 15:26:18 +0000
@@ -12,11 +12,20 @@
12 <arg type='s' name='player_desktop_name' direction="in"/>12 <arg type='s' name='player_desktop_name' direction="in"/>
13 <arg type='b' name='result' direction="out"/>13 <arg type='b' name='result' direction="out"/>
14 </method>14 </method>
15
16 <method name = "GetSoundState">15 <method name = "GetSoundState">
17 <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>16 <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
18 <arg type='i' name='current_state' direction="out"/>17 <arg type='i' name='current_state' direction="out"/>
19 </method>18 </method>
19 <method name = "EnableTrackSpecificItems">
20 <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
21 <arg type='o' name='player_object_path' direction="in"/>
22 <arg type='s' name='player_desktop_id' direction="in"/>
23 </method>
24 <method name = "EnablePlayerSpecificItems">
25 <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
26 <arg type='o' name='player_object_path' direction="in"/>
27 <arg type='s' name='player_desktop_id' direction="in"/>
28 </method>
20 <signal name="SoundStateUpdate">29 <signal name="SoundStateUpdate">
21 <arg name="new_state" type="i" direction="out"/>30 <arg name="new_state" type="i" direction="out"/>
22 </signal>31 </signal>
2332
=== added file 'src/specific-items-manager.vala'
--- src/specific-items-manager.vala 1970-01-01 00:00:00 +0000
+++ src/specific-items-manager.vala 2011-08-10 15:26:18 +0000
@@ -0,0 +1,107 @@
1/*
2Copyright 2011 Canonical Ltd.
3
4Authors:
5 Conor Curran <conor.curran@canonical.com>
6
7This program is free software: you can redistribute it and/or modify it
8under the terms of the GNU General Public License version 3, as published
9by the Free Software Foundation.
10
11This program is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranties of
13MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14PURPOSE. See the GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License along
17with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20using Dbusmenu;
21using Gee;
22
23public class SpecificItemsManager : GLib.Object
24{
25 public static enum category{
26 TRACK,
27 PLAYER
28 }
29
30 private PlayerController owner {get; set;}
31 private string dbus_path;
32 private Dbusmenu.Client client;
33 public Gee.ArrayList<Dbusmenu.MenuitemProxy> proxy_items {get; construct;}
34 private int of_type;
35
36 public SpecificItemsManager (PlayerController controller,
37 string path,
38 category which_type)
39 {
40 this.of_type = which_type;
41 this.owner = controller;
42 this.dbus_path = path;
43 this.client = new Dbusmenu.Client (this.owner.dbus_name, this.dbus_path);
44 this.client.root_changed.connect (on_root_changed);
45 }
46 construct{
47 this.proxy_items = new ArrayList<Dbusmenu.MenuitemProxy>();
48 }
49
50 private int figure_out_positioning()
51 {
52 int result = 0 ;
53 if (this.of_type == category.TRACK){
54 result = this.owner.menu_offset + 4 + this.proxy_items.size;
55 }
56 else if (this.of_type == category.PLAYER){
57 int pos = this.owner.menu_offset + 4 + this.owner.track_specific_count();
58 pos += this.owner.use_playlists == true ? 1 : 0;
59 result = pos;
60 }
61 debug ("!!!!! Menu pos of type %i is = %i", this.of_type, result);
62 return result;
63 }
64
65 private void on_root_changed (GLib.Object? newroot)
66 {
67 if (newroot == null){
68 debug ("root disappeared -remove proxyitems");
69 foreach(var p in proxy_items){
70 this.owner.root_menu.child_delete (p);
71 }
72 this.proxy_items.clear();
73 debug ("array list size is now %i", this.proxy_items.size);
74 //this.proxy_items = new ArrayList<Dbusmenu.MenuitemProxy>();
75 return;
76 }
77
78 Dbusmenu.Menuitem? root = this.client.get_root();
79 root.child_added.connect (on_child_added);
80 root.child_removed.connect (on_child_removed);
81
82 // Fetch what children are there already.
83 GLib.List<weak void*> children = root.get_children().copy();
84
85 foreach (void* child in children) {
86 int pos = figure_out_positioning();
87 unowned Dbusmenu.Menuitem item = (Dbusmenu.Menuitem)child;
88 Dbusmenu.MenuitemProxy proxy = new Dbusmenu.MenuitemProxy(item);
89 proxy_items.add (proxy);
90 debug ("Proxy item of label = %s added to collection",
91 item.property_get (MENUITEM_PROP_LABEL));
92 this.owner.root_menu.child_add_position (proxy, pos);
93
94 }
95 }
96
97 private void on_child_added (GLib.Object child, uint position)
98 {
99 debug ("On child added Specific root node");
100 }
101
102 private void on_child_removed (GLib.Object child)
103 {
104 debug ("On child removed Specific root node");
105 }
106
107}
0108
=== modified file 'vapi/common-defs.vapi'
--- vapi/common-defs.vapi 2011-06-10 09:38:54 +0000
+++ vapi/common-defs.vapi 2011-08-10 15:26:18 +0000
@@ -52,7 +52,6 @@
52 public const string MENUITEM_PATH;52 public const string MENUITEM_PATH;
53}53}
5454
55
56[CCode (cprefix ="Transport", cheader_filename = "common-defs.h")]55[CCode (cprefix ="Transport", cheader_filename = "common-defs.h")]
57namespace Transport{56namespace Transport{
58 public enum Action{57 public enum Action{

Subscribers

People subscribed via source and target branches