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
1=== added file 'Makefile.am.marshal'
2--- Makefile.am.marshal 1970-01-01 00:00:00 +0000
3+++ Makefile.am.marshal 2011-08-10 15:26:18 +0000
4@@ -0,0 +1,45 @@
5+# Rules for generating marshal files using glib-genmarshal
6+#
7+# Define:
8+# glib_marshal_list = marshal list file
9+# glib_marshal_prefix = prefix for marshal functions
10+#
11+# before including Makefile.am.marshal. You will also need to have
12+# the following targets already defined:
13+#
14+# CLEANFILES
15+# DISTCLEANFILES
16+# BUILT_SOURCES
17+# EXTRA_DIST
18+#
19+# Author: Emmanuele Bassi <ebassi@linux.intel.com>
20+
21+marshal_h = $(glib_marshal_list:.list=.h)
22+marshal_c = $(glib_marshal_list:.list=.c)
23+
24+CLEANFILES += stamp-marshal
25+DISTCLEANFILES += $(marshal_h) $(marshal_c)
26+BUILT_SOURCES += $(marshal_h) $(marshal_c)
27+EXTRA_DIST += $(glib_marshal_list)
28+
29+stamp-marshal: $(glib_marshal_list)
30+ $(QUIET_GEN)$(GLIB_GENMARSHAL) \
31+ --prefix=$(glib_marshal_prefix) \
32+ --header \
33+ $(srcdir)/$(glib_marshal_list) > xgen-mh \
34+ && (cmp -s xgen-mh $(marshal_h) || cp -f xgen-mh $(marshal_h)) \
35+ && rm -f xgen-mh \
36+ && echo timestamp > $(@F)
37+
38+$(marshal_h): stamp-marshal
39+ @true
40+
41+$(marshal_c): $(marshal_h)
42+ $(QUIET_GEN)(echo "#include \"$(marshal_h)\"" ; \
43+ $(GLIB_GENMARSHAL) \
44+ --prefix=$(glib_marshal_prefix) \
45+ --body \
46+ $(srcdir)/$(glib_marshal_list)) > xgen-mc \
47+ && cp xgen-mc $(marshal_c) \
48+ && rm -f xgen-mc
49+
50
51=== modified file 'configure.ac'
52--- configure.ac 2011-07-29 16:18:02 +0000
53+++ configure.ac 2011-08-10 15:26:18 +0000
54@@ -23,6 +23,8 @@
55
56 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
57
58+AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
59+
60 ###########################
61 # GTK+ version option
62 ###########################
63@@ -130,6 +132,7 @@
64 ###########################
65
66 GLIB_GSETTINGS
67+GLIB_GENMARSHAL
68
69 ###########################
70 # DBus Service Info
71
72=== modified file 'src/Makefile.am'
73--- src/Makefile.am 2011-07-29 16:18:02 +0000
74+++ src/Makefile.am 2011-08-10 15:26:18 +0000
75@@ -32,6 +32,7 @@
76 libsoundmenu_la_LIBADD = $(APPLET_LIBS)
77 libsoundmenu_la_LDFLAGS = -module -avoid-version
78
79+
80 checkxml: $(srcdir)/sound-service.xml
81 @xmllint -valid -noout $<
82 @echo $< checks out ok
83@@ -41,6 +42,9 @@
84 # Sound Service
85 ####################################################################
86
87+glib_marshal_list = sound-service-marshal.list
88+glib_marshal_prefix = _sound_service_marshal
89+
90
91 #####################
92 # Sound service vala
93@@ -48,6 +52,7 @@
94 music_bridge_VALASOURCES = \
95 music-player-bridge.vala \
96 transport-menu-item.vala \
97+ specific-items-manager.vala \
98 metadata-menu-item.vala \
99 player-controller.vala \
100 mpris2-interfaces.vala \
101@@ -107,6 +112,8 @@
102 mute-menu-item.c \
103 gen-sound-service.xml.h \
104 gen-sound-service.xml.c \
105+ sound-service-marshal.c \
106+ sound-service-marshal.h \
107 $(music_bridge_VALASOURCES:.vala=.c)
108
109 indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) $(SOUNDSERVICE_CFLAGS) $(GCONF_CFLAGS) -DLIBEXECDIR=\"$(libexecdir)\" -Wall
110@@ -147,3 +154,7 @@
111
112 CLEANFILES = \
113 $(BUILT_SOURCES)
114+
115+DISTCLEANFILES =
116+
117+include $(top_srcdir)/Makefile.am.marshal
118
119=== modified file 'src/common-defs.h'
120--- src/common-defs.h 2011-06-10 09:38:54 +0000
121+++ src/common-defs.h 2011-08-10 15:26:18 +0000
122@@ -67,6 +67,8 @@
123 #define DBUSMENU_TRANSPORT_MENUITEM_TYPE "x-canonical-sound-menu-player-transport-type"
124 #define DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE "x-canonical-sound-menu-player-transport-state"
125
126+#define DBUSMENU_TRACK_SPECIFIC_MENUITEM_TYPE "x-canonical-sound-menu-player-track-specific-type"
127+
128 #define DBUSMENU_METADATA_MENUITEM_TYPE "x-canonical-sound-menu-player-metadata-type"
129 #define DBUSMENU_METADATA_MENUITEM_ARTIST "x-canonical-sound-menu-player-metadata-xesam:artist"
130 #define DBUSMENU_METADATA_MENUITEM_TITLE "x-canonical-sound-menu-player-metadata-xesam:title"
131
132=== modified file 'src/mpris2-watcher.vala'
133--- src/mpris2-watcher.vala 2011-03-21 13:04:13 +0000
134+++ src/mpris2-watcher.vala 2011-08-10 15:26:18 +0000
135@@ -38,7 +38,7 @@
136 this.fdesktop_obj = Bus.get_proxy_sync ( BusType.SESSION,
137 FREEDESKTOP_SERVICE,
138 FREEDESKTOP_OBJECT,
139- DBusProxyFlags.DO_NOT_LOAD_PROPERTIES );
140+ DBusProxyFlags.DO_NOT_LOAD_PROPERTIES );
141 this.fdesktop_obj.name_owner_changed.connect (this.name_changes_detected);
142 this.check_for_active_clients.begin();
143 }
144
145=== modified file 'src/music-player-bridge.vala'
146--- src/music-player-bridge.vala 2011-02-17 18:54:58 +0000
147+++ src/music-player-bridge.vala 2011-08-10 15:26:18 +0000
148@@ -27,7 +27,7 @@
149
150 private SettingsManager settings_manager;
151 private Dbusmenu.Menuitem root_menu;
152- private HashMap<string, PlayerController> registered_clients;
153+ private HashMap<string, PlayerController> registered_clients;
154 private Mpris2Watcher watcher;
155
156 public MusicPlayerBridge()
157@@ -158,10 +158,31 @@
158 this.watcher.client_disappeared.connect (this.client_has_vanished);
159 }
160
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+
183 private static AppInfo? create_app_info ( string desktop )
184 {
185- DesktopAppInfo info = new DesktopAppInfo ( desktop ) ;
186-
187+ DesktopAppInfo info = new DesktopAppInfo ( desktop );
188 if ( desktop == null || info == null ){
189 warning ( "Could not create a desktopappinfo instance from app: %s", desktop );
190 return null;
191
192=== modified file 'src/player-controller.vala'
193--- src/player-controller.vala 2011-07-28 17:49:48 +0000
194+++ src/player-controller.vala 2011-08-10 15:26:18 +0000
195@@ -1,5 +1,4 @@
196 /*
197-This service primarily controls PulseAudio and is driven by the sound indicator menu on the panel.
198 Copyright 2010 Canonical Ltd.
199
200 Authors:
201@@ -42,7 +41,7 @@
202
203 public int current_state = state.OFFLINE;
204
205- private Dbusmenu.Menuitem root_menu;
206+ public Dbusmenu.Menuitem root_menu;
207 public string dbus_name { get; set;}
208 public ArrayList<PlayerItem> custom_items;
209 public Mpris2Controller mpris_bridge;
210@@ -50,6 +49,8 @@
211 public int menu_offset { get; set;}
212 public string icon_name { get; set; }
213 public bool? use_playlists;
214+ private SpecificItemsManager track_specific_mgr;
215+ private SpecificItemsManager player_specific_mgr;
216
217 public PlayerController(Dbusmenu.Menuitem root,
218 GLib.AppInfo app,
219@@ -105,7 +106,33 @@
220 error.message );
221 }
222 }
223+
224+ public void enable_track_specific_items (string object_path)
225+ {
226+ if (this.track_specific_mgr == null){
227+ track_specific_mgr = new SpecificItemsManager (this,
228+ object_path,
229+ SpecificItemsManager.category.TRACK);
230+ }
231+ }
232+
233+ public void enable_player_specific_items (string object_path)
234+ {
235+ if (this.player_specific_mgr == null){
236+ player_specific_mgr = new SpecificItemsManager (this,
237+ object_path,
238+ SpecificItemsManager.category.PLAYER);
239+ }
240+ }
241
242+ public int track_specific_count ()
243+ {
244+ if (this.track_specific_mgr == null) {
245+ return 0;
246+ }
247+ return this.track_specific_mgr.proxy_items.size;
248+ }
249+
250 private void establish_mpris_connection()
251 {
252 if(this.current_state != state.READY || this.dbus_name == null ){
253@@ -114,9 +141,8 @@
254 }
255 debug ( " establish mpris connection - use playlists value = %s ",
256 this.use_playlists.to_string() );
257-
258- this.mpris_bridge = new Mpris2Controller(this);
259- this.determine_state();
260+ this.mpris_bridge = new Mpris2Controller (this);
261+ this.determine_state ();
262 }
263
264 public void remove_from_menu()
265@@ -186,16 +212,17 @@
266 this.custom_items.add(playlist_menuitem);
267
268 foreach(PlayerItem item in this.custom_items){
269- if (this.custom_items.index_of(item) == 3) {
270+ if (this.custom_items.index_of(item) == 4) {
271 PlaylistsMenuitem playlists_menuitem = item as PlaylistsMenuitem;
272 root_menu.child_add_position(playlists_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item));
273 }
274 else{
275- root_menu.child_add_position(item, this.menu_offset + this.custom_items.index_of(item));
276+ root_menu.child_add_position (item,
277+ this.menu_offset + this.custom_items.index_of(item));
278 }
279 }
280 }
281-
282+
283 private void determine_state()
284 {
285 if(this.mpris_bridge.connected() == true){
286
287=== modified file 'src/playlists-menu-item.vala'
288--- src/playlists-menu-item.vala 2011-06-13 10:04:15 +0000
289+++ src/playlists-menu-item.vala 2011-08-10 15:26:18 +0000
290@@ -39,7 +39,6 @@
291 this.root_item = new Menuitem();
292 this.root_item.property_set ( MENUITEM_PROP_LABEL, _("Choose Playlist") );
293 this.root_item.property_set ( MENUITEM_PATH, "" );
294-
295 }
296
297 public new void update (PlaylistDetails[] playlists)
298
299=== modified file 'src/sound-service-dbus.c'
300--- src/sound-service-dbus.c 2011-06-16 14:43:37 +0000
301+++ src/sound-service-dbus.c 2011-08-10 15:26:18 +0000
302@@ -32,6 +32,7 @@
303 #include "device.h"
304 #include "gen-sound-service.xml.h"
305 #include "dbus-shared-names.h"
306+#include "sound-service-marshal.h"
307
308 // DBUS methods
309 static void bus_method_call (GDBusConnection * connection,
310@@ -58,6 +59,14 @@
311 Device* device;
312 };
313
314+enum {
315+ TRACK_SPECIFIC_ITEM,
316+ PLAYER_SPECIFIC_ITEM,
317+ LAST_SIGNAL
318+};
319+
320+static guint signals[LAST_SIGNAL] = { 0 };
321+
322 static GDBusNodeInfo * node_info = NULL;
323 static GDBusInterfaceInfo * interface_info = NULL;
324
325@@ -110,6 +119,22 @@
326 g_error("Unable to find interface '" INDICATOR_SOUND_DBUS_INTERFACE "'");
327 }
328 }
329+ signals[TRACK_SPECIFIC_ITEM] = g_signal_new("track-specific-item-requested",
330+ G_TYPE_FROM_CLASS (klass),
331+ G_SIGNAL_RUN_LAST,
332+ 0,
333+ NULL, NULL,
334+ _sound_service_marshal_VOID__STRING_STRING,
335+ G_TYPE_NONE, 2, G_TYPE_STRING,
336+ G_TYPE_STRING);
337+ signals[PLAYER_SPECIFIC_ITEM] = g_signal_new("player-specific-item-requested",
338+ G_TYPE_FROM_CLASS (klass),
339+ G_SIGNAL_RUN_LAST,
340+ 0,
341+ NULL, NULL,
342+ _sound_service_marshal_VOID__STRING_STRING,
343+ G_TYPE_NONE, 2, G_TYPE_STRING,
344+ G_TYPE_STRING);
345 }
346
347 static void
348@@ -148,7 +173,6 @@
349 {
350 SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self);
351 priv->root_menuitem = dbusmenu_menuitem_new();
352- //g_debug("Root ID: %d", dbusmenu_menuitem_get_id(priv->root_menuitem));
353 DbusmenuServer *server = dbusmenu_server_new (INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH);
354 dbusmenu_server_set_root (server, priv->root_menuitem);
355 g_object_unref (priv->root_menuitem);
356@@ -183,9 +207,9 @@
357
358 dbusmenu_menuitem_property_set( settings_mi,
359 DBUSMENU_MENUITEM_PROP_LABEL,
360- _("Sound Settings..."));
361+ _("Sound Preferences..."));
362 dbusmenu_menuitem_child_append(priv->root_menuitem, settings_mi);
363- g_object_unref (settings_mi);
364+ g_object_unref (settings_mi);
365 g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
366 G_CALLBACK(show_sound_settings_dialog), NULL);
367 }
368@@ -297,6 +321,36 @@
369 player_name);
370 retval = g_variant_new ("(b)", result);
371 }
372+ else if (g_strcmp0(method, "EnableTrackSpecificItems") == 0) {
373+ g_debug ("EnableTrackSpecificItems");
374+ gchar* player_object_path;
375+ gchar* player_id;
376+ g_variant_get (params, "(os)", &player_object_path, &player_id);
377+ //g_debug ("object path = %s and id = %s", player_object_path, player_id);
378+ g_signal_emit (service,
379+ signals[TRACK_SPECIFIC_ITEM],
380+ 0,
381+ player_object_path,
382+ player_id);
383+ g_free (player_object_path);
384+ g_free (player_id);
385+
386+ }
387+ else if (g_strcmp0(method, "EnablePlayerSpecificItems") == 0) {
388+ gchar* player_object_path;
389+ gchar* player_id;
390+ g_variant_get (params, "(os)", &player_object_path, &player_id);
391+ g_debug ("PLayer specific item - object path = %s and id = %s",
392+ player_object_path,
393+ player_id);
394+ g_signal_emit (service,
395+ signals[PLAYER_SPECIFIC_ITEM],
396+ 0,
397+ player_object_path,
398+ player_id);
399+ g_free (player_object_path);
400+ g_free (player_id);
401+ }
402 else {
403 g_warning("Calling method '%s' on the sound service but it's unknown", method);
404 }
405
406=== added file 'src/sound-service-marshal.list'
407--- src/sound-service-marshal.list 1970-01-01 00:00:00 +0000
408+++ src/sound-service-marshal.list 2011-08-10 15:26:18 +0000
409@@ -0,0 +1,2 @@
410+VOID:STRING,STRING
411+
412
413=== modified file 'src/sound-service.c'
414--- src/sound-service.c 2011-03-22 19:53:19 +0000
415+++ src/sound-service.c 2011-08-10 15:26:18 +0000
416@@ -17,19 +17,18 @@
417 with this program. If not, see <http://www.gnu.org/licenses/>.
418 */
419
420+#include <locale.h>
421+
422 #include "sound-service.h"
423 #include "pulseaudio-mgr.h"
424 #include "sound-service-dbus.h"
425 #include "music-player-bridge.h"
426
427-#include <locale.h>
428-
429 static GMainLoop *mainloop = NULL;
430-
431+static MusicPlayerBridge* player_bridge;
432 /**********************************************************************************************************************/
433 // Init and exit functions
434 /**********************************************************************************************************************/
435-
436 /**
437 service_shutdown:
438 When the service interface starts to shutdown, we
439@@ -47,29 +46,58 @@
440 return;
441 }
442
443+void
444+on_player_specific_item_requested (SoundServiceDbus* sound_service,
445+ const gchar* desktop_id,
446+ const gchar* player_object_path,
447+ gpointer userdata)
448+{
449+ music_player_bridge_enable_player_specific_items_for_client (player_bridge,
450+ desktop_id,
451+ player_object_path);
452+ g_debug ("ON PLAYER SPECIFIC ITEM REQUESTED %s", desktop_id);
453+}
454+
455+void
456+on_track_specific_item_requested (SoundServiceDbus* sound_service,
457+ const gchar* desktop_id,
458+ const gchar* player_object_path,
459+ gpointer userdata)
460+{
461+ music_player_bridge_enable_track_specific_items_for_client (player_bridge,
462+ desktop_id,
463+ player_object_path);
464+ g_debug ("ON TRACK SPECIFIC ITEM REQUESTED %s", desktop_id);
465+}
466+
467 /**
468 main:
469 **/
470 int
471 main (int argc, char ** argv)
472 {
473-
474 g_type_init();
475 textdomain (GETTEXT_PACKAGE);
476 bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
477 setlocale (LC_ALL, "");
478
479- IndicatorService *service = indicator_service_new_version(INDICATOR_SOUND_DBUS_NAME,
480- INDICATOR_SOUND_DBUS_VERSION);
481+ IndicatorService *service = indicator_service_new_version (INDICATOR_SOUND_DBUS_NAME,
482+ INDICATOR_SOUND_DBUS_VERSION);
483 g_signal_connect(G_OBJECT(service),
484 INDICATOR_SERVICE_SIGNAL_SHUTDOWN,
485 G_CALLBACK(service_shutdown), NULL);
486
487 SoundServiceDbus* sound_service = g_object_new(SOUND_SERVICE_DBUS_TYPE, NULL);
488+ g_signal_connect(G_OBJECT(sound_service),
489+ "track-specific-item-requested",
490+ G_CALLBACK(on_track_specific_item_requested), NULL);
491+ g_signal_connect(G_OBJECT(sound_service),
492+ "player-specific-item-requested",
493+ G_CALLBACK(on_player_specific_item_requested), NULL);
494
495- DbusmenuMenuitem* root_menuitem = sound_service_dbus_create_root_item(sound_service);
496- MusicPlayerBridge* server = music_player_bridge_new();
497- music_player_bridge_set_root_menu_item(server, root_menuitem);
498+ DbusmenuMenuitem* root_menuitem = sound_service_dbus_create_root_item (sound_service);
499+ player_bridge = music_player_bridge_new ();
500+ music_player_bridge_set_root_menu_item (player_bridge, root_menuitem);
501
502 // Run the loop
503 mainloop = g_main_loop_new(NULL, FALSE);
504
505=== modified file 'src/sound-service.xml'
506--- src/sound-service.xml 2011-03-07 11:48:56 +0000
507+++ src/sound-service.xml 2011-08-10 15:26:18 +0000
508@@ -12,11 +12,20 @@
509 <arg type='s' name='player_desktop_name' direction="in"/>
510 <arg type='b' name='result' direction="out"/>
511 </method>
512-
513 <method name = "GetSoundState">
514 <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
515 <arg type='i' name='current_state' direction="out"/>
516 </method>
517+ <method name = "EnableTrackSpecificItems">
518+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
519+ <arg type='o' name='player_object_path' direction="in"/>
520+ <arg type='s' name='player_desktop_id' direction="in"/>
521+ </method>
522+ <method name = "EnablePlayerSpecificItems">
523+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
524+ <arg type='o' name='player_object_path' direction="in"/>
525+ <arg type='s' name='player_desktop_id' direction="in"/>
526+ </method>
527 <signal name="SoundStateUpdate">
528 <arg name="new_state" type="i" direction="out"/>
529 </signal>
530
531=== added file 'src/specific-items-manager.vala'
532--- src/specific-items-manager.vala 1970-01-01 00:00:00 +0000
533+++ src/specific-items-manager.vala 2011-08-10 15:26:18 +0000
534@@ -0,0 +1,107 @@
535+/*
536+Copyright 2011 Canonical Ltd.
537+
538+Authors:
539+ Conor Curran <conor.curran@canonical.com>
540+
541+This program is free software: you can redistribute it and/or modify it
542+under the terms of the GNU General Public License version 3, as published
543+by the Free Software Foundation.
544+
545+This program is distributed in the hope that it will be useful, but
546+WITHOUT ANY WARRANTY; without even the implied warranties of
547+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
548+PURPOSE. See the GNU General Public License for more details.
549+
550+You should have received a copy of the GNU General Public License along
551+with this program. If not, see <http://www.gnu.org/licenses/>.
552+*/
553+
554+using Dbusmenu;
555+using Gee;
556+
557+public class SpecificItemsManager : GLib.Object
558+{
559+ public static enum category{
560+ TRACK,
561+ PLAYER
562+ }
563+
564+ private PlayerController owner {get; set;}
565+ private string dbus_path;
566+ private Dbusmenu.Client client;
567+ public Gee.ArrayList<Dbusmenu.MenuitemProxy> proxy_items {get; construct;}
568+ private int of_type;
569+
570+ public SpecificItemsManager (PlayerController controller,
571+ string path,
572+ category which_type)
573+ {
574+ this.of_type = which_type;
575+ this.owner = controller;
576+ this.dbus_path = path;
577+ this.client = new Dbusmenu.Client (this.owner.dbus_name, this.dbus_path);
578+ this.client.root_changed.connect (on_root_changed);
579+ }
580+ construct{
581+ this.proxy_items = new ArrayList<Dbusmenu.MenuitemProxy>();
582+ }
583+
584+ private int figure_out_positioning()
585+ {
586+ int result = 0 ;
587+ if (this.of_type == category.TRACK){
588+ result = this.owner.menu_offset + 4 + this.proxy_items.size;
589+ }
590+ else if (this.of_type == category.PLAYER){
591+ int pos = this.owner.menu_offset + 4 + this.owner.track_specific_count();
592+ pos += this.owner.use_playlists == true ? 1 : 0;
593+ result = pos;
594+ }
595+ debug ("!!!!! Menu pos of type %i is = %i", this.of_type, result);
596+ return result;
597+ }
598+
599+ private void on_root_changed (GLib.Object? newroot)
600+ {
601+ if (newroot == null){
602+ debug ("root disappeared -remove proxyitems");
603+ foreach(var p in proxy_items){
604+ this.owner.root_menu.child_delete (p);
605+ }
606+ this.proxy_items.clear();
607+ debug ("array list size is now %i", this.proxy_items.size);
608+ //this.proxy_items = new ArrayList<Dbusmenu.MenuitemProxy>();
609+ return;
610+ }
611+
612+ Dbusmenu.Menuitem? root = this.client.get_root();
613+ root.child_added.connect (on_child_added);
614+ root.child_removed.connect (on_child_removed);
615+
616+ // Fetch what children are there already.
617+ GLib.List<weak void*> children = root.get_children().copy();
618+
619+ foreach (void* child in children) {
620+ int pos = figure_out_positioning();
621+ unowned Dbusmenu.Menuitem item = (Dbusmenu.Menuitem)child;
622+ Dbusmenu.MenuitemProxy proxy = new Dbusmenu.MenuitemProxy(item);
623+ proxy_items.add (proxy);
624+ debug ("Proxy item of label = %s added to collection",
625+ item.property_get (MENUITEM_PROP_LABEL));
626+ this.owner.root_menu.child_add_position (proxy, pos);
627+
628+ }
629+ }
630+
631+ private void on_child_added (GLib.Object child, uint position)
632+ {
633+ debug ("On child added Specific root node");
634+ }
635+
636+ private void on_child_removed (GLib.Object child)
637+ {
638+ debug ("On child removed Specific root node");
639+ }
640+
641+}
642
643=== modified file 'vapi/common-defs.vapi'
644--- vapi/common-defs.vapi 2011-06-10 09:38:54 +0000
645+++ vapi/common-defs.vapi 2011-08-10 15:26:18 +0000
646@@ -52,7 +52,6 @@
647 public const string MENUITEM_PATH;
648 }
649
650-
651 [CCode (cprefix ="Transport", cheader_filename = "common-defs.h")]
652 namespace Transport{
653 public enum Action{

Subscribers

People subscribed via source and target branches