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