Merge lp:~cjcurran/indicator-sound/playlist-changed-signal into lp:~indicator-applet-developers/indicator-sound/trunk_3

Proposed by Conor Curran
Status: Merged
Merged at revision: 126
Proposed branch: lp:~cjcurran/indicator-sound/playlist-changed-signal
Merge into: lp:~indicator-applet-developers/indicator-sound/trunk_3
Diff against target: 307 lines (+65/-30)
7 files modified
src/common-defs.h (+2/-0)
src/mpris2-controller.vala (+19/-10)
src/mpris2-interfaces.vala (+3/-0)
src/player-item.vala (+8/-8)
src/playlists-menu-item.vala (+26/-9)
src/transport-menu-item.vala (+3/-3)
vapi/common-defs.vapi (+4/-0)
To merge this branch: bzr merge lp:~cjcurran/indicator-sound/playlist-changed-signal
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Review via email: mp+49041@code.launchpad.net

Description of the change

Fixes both bugs attached

To post a comment you must log in.
Revision history for this message
Neil J. Patel (njpatel) wrote :

Worried about the timeout, but that's an issue bigger than this merge (something we need to figure out with GDBus), so approving.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/common-defs.h'
--- src/common-defs.h 2011-01-24 22:26:21 +0000
+++ src/common-defs.h 2011-02-09 11:18:30 +0000
@@ -64,4 +64,6 @@
64#define DBUSMENU_PLAYLISTS_MENUITEM_TITLE "x-canonical-sound-menu-player-playlists-title"64#define DBUSMENU_PLAYLISTS_MENUITEM_TITLE "x-canonical-sound-menu-player-playlists-title"
65#define DBUSMENU_PLAYLISTS_MENUITEM_PLAYLISTS "x-canonical-sound-menu-player-playlists-playlists"65#define DBUSMENU_PLAYLISTS_MENUITEM_PLAYLISTS "x-canonical-sound-menu-player-playlists-playlists"
6666
67#define DBUSMENU_PLAYLIST_MENUITEM_PATH "x-canonical-sound-menu-player-playlist-path"
68
67#endif69#endif
6870
=== modified file 'src/mpris2-controller.vala'
--- src/mpris2-controller.vala 2011-02-01 19:31:32 +0000
+++ src/mpris2-controller.vala 2011-02-09 11:18:30 +0000
@@ -48,6 +48,7 @@
48 this.playlists = Bus.get_proxy_sync ( BusType.SESSION,48 this.playlists = Bus.get_proxy_sync ( BusType.SESSION,
49 this.owner.dbus_name,49 this.owner.dbus_name,
50 "/org/mpris/MediaPlayer2" );50 "/org/mpris/MediaPlayer2" );
51 this.playlists.PlaylistChanged.connect (on_playlistdetails_changed);
51 }52 }
52 this.properties_interface = Bus.get_proxy_sync ( BusType.SESSION,53 this.properties_interface = Bus.get_proxy_sync ( BusType.SESSION,
53 "org.freedesktop.Properties.PropertiesChanged",54 "org.freedesktop.Properties.PropertiesChanged",
@@ -63,7 +64,7 @@
63 HashTable<string, Variant?> changed_properties,64 HashTable<string, Variant?> changed_properties,
64 string[] invalid )65 string[] invalid )
65 {66 {
66 debug("properties-changed for interface %s and owner %s", interface_source, this.owner.dbus_name);67 //debug("properties-changed for interface %s and owner %s", interface_source, this.owner.dbus_name);
67 if ( changed_properties == null ||68 if ( changed_properties == null ||
68 interface_source.has_prefix ( MPRIS_PREFIX ) == false ){69 interface_source.has_prefix ( MPRIS_PREFIX ) == false ){
69 warning("Property-changed hash is null or this is an interface that doesn't concerns us");70 warning("Property-changed hash is null or this is an interface that doesn't concerns us");
@@ -91,7 +92,9 @@
91 }92 }
92 Variant? playlist_v = changed_properties.lookup("ActivePlaylist");93 Variant? playlist_v = changed_properties.lookup("ActivePlaylist");
93 if ( playlist_v != null && this.owner.use_playlists == true ){94 if ( playlist_v != null && this.owner.use_playlists == true ){
94 this.fetch_active_playlist();95 // Once again A GDBus race condition, the property_changed signal is sent
96 // before the value is set on the respective property.
97 Timeout.add (300, this.fetch_active_playlist);
95 }98 }
96 Variant? playlist_count_v = changed_properties.lookup("PlaylistCount");99 Variant? playlist_count_v = changed_properties.lookup("PlaylistCount");
97 if ( playlist_count_v != null && this.owner.use_playlists == true ){100 if ( playlist_count_v != null && this.owner.use_playlists == true ){
@@ -109,9 +112,9 @@
109 title.alter_label (this.mpris2_root.Identity);112 title.alter_label (this.mpris2_root.Identity);
110 }113 }
111 }114 }
112 115
113 private bool ensure_correct_playback_status(){116 private bool ensure_correct_playback_status(){
114 debug("TEST playback status = %s", this.player.PlaybackStatus);117 //debug("TEST playback status = %s", this.player.PlaybackStatus);
115 TransportMenuitem.state p = (TransportMenuitem.state)this.determine_play_state(this.player.PlaybackStatus);118 TransportMenuitem.state p = (TransportMenuitem.state)this.determine_play_state(this.player.PlaybackStatus);
116 (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(p);119 (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(p);
117 return false;120 return false;
@@ -173,7 +176,7 @@
173176
174 public void transport_update(TransportMenuitem.action command)177 public void transport_update(TransportMenuitem.action command)
175 {178 {
176 debug("transport_event input = %i", (int)command);179 //debug("transport_event input = %i", (int)command);
177 if(command == TransportMenuitem.action.PLAY_PAUSE){180 if(command == TransportMenuitem.action.PLAY_PAUSE){
178 this.player.PlayPause.begin(); 181 this.player.PlayPause.begin();
179 }182 }
@@ -185,7 +188,6 @@
185 }188 }
186 }189 }
187190
188
189 public bool connected()191 public bool connected()
190 {192 {
191 return (this.player != null && this.mpris2_root != null);193 return (this.player != null && this.mpris2_root != null);
@@ -198,6 +200,12 @@
198 }200 }
199 }201 }
200202
203 private void on_playlistdetails_changed (PlaylistDetails details)
204 {
205 PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem;
206 playlists_item.update_individual_playlist (details);
207 }
208
201 public async void fetch_playlists()209 public async void fetch_playlists()
202 {210 {
203 PlaylistDetails[] current_playlists = null;211 PlaylistDetails[] current_playlists = null;
@@ -214,7 +222,7 @@
214 }222 }
215 223
216 if( current_playlists != null ){224 if( current_playlists != null ){
217 debug( "Size of the playlist array = %i", current_playlists.length );225 //debug( "Size of the playlist array = %i", current_playlists.length );
218 PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem;226 PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem;
219 playlists_item.update(current_playlists);227 playlists_item.update(current_playlists);
220 }228 }
@@ -224,13 +232,14 @@
224 }232 }
225 }233 }
226234
227 private void fetch_active_playlist()235 private bool fetch_active_playlist()
228 { 236 {
229 if (this.playlists.ActivePlaylist.valid == false){237 if (this.playlists.ActivePlaylist.valid == false){
230 debug("We don't have an active playlist");238 debug(" We don't have an active playlist");
231 }239 }
232 PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem;240 PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem;
233 playlists_item.update_active_playlist ( this.playlists.ActivePlaylist.details );241 playlists_item.update_active_playlist ( this.playlists.ActivePlaylist.details );
242 return false;
234 }243 }
235244
236 public void activate_playlist (ObjectPath path)245 public void activate_playlist (ObjectPath path)
237246
=== modified file 'src/mpris2-interfaces.vala'
--- src/mpris2-interfaces.vala 2011-01-27 23:08:08 +0000
+++ src/mpris2-interfaces.vala 2011-02-09 11:18:30 +0000
@@ -72,4 +72,7 @@
72 uint32 max_count,72 uint32 max_count,
73 string order,73 string order,
74 bool reverse_order ) throws IOError;74 bool reverse_order ) throws IOError;
75 //signals
76 public signal void PlaylistChanged (PlaylistDetails details);
77
75}78}
76\ No newline at end of file79\ No newline at end of file
7780
=== modified file 'src/player-item.vala'
--- src/player-item.vala 2010-12-20 16:55:31 +0000
+++ src/player-item.vala 2011-02-09 11:18:30 +0000
@@ -52,19 +52,19 @@
52 {52 {
53 debug("PlayerItem::update()");53 debug("PlayerItem::update()");
54 if(data == null){54 if(data == null){
55 debug("PlayerItem::Update -> The hashtable was null - just leave it!");55 warning("PlayerItem::Update -> The hashtable was null - just leave it!");
56 return;56 return;
57 }57 }
58 58
59 foreach(string property in attributes){59 foreach(string property in attributes){
60 string[] input_keys = property.split("-");60 string[] input_keys = property.split("-");
61 string search_key = input_keys[input_keys.length-1 : input_keys.length][0];61 string search_key = input_keys[input_keys.length-1 : input_keys.length][0];
62 debug("search key = %s", search_key);62 //debug("search key = %s", search_key);
63 Variant? v = data.lookup(search_key);63 Variant? v = data.lookup(search_key);
64 64
65 if (v.is_of_type ( VariantType.STRING )){65 if (v.is_of_type ( VariantType.STRING )){
66 string update = v.get_string().strip();66 string update = v.get_string().strip();
67 debug("with value : %s", update);67 //debug("with value : %s", update);
68 if(property.contains("mpris:artUrl")){ 68 if(property.contains("mpris:artUrl")){
69 // We know its a metadata instance because thats the only69 // We know its a metadata instance because thats the only
70 // object with the arturl prop 70 // object with the arturl prop
@@ -75,15 +75,15 @@
75 this.property_set(property, update); 75 this.property_set(property, update);
76 } 76 }
77 else if (v.is_of_type (VariantType.INT32 )){77 else if (v.is_of_type (VariantType.INT32 )){
78 debug("with value : %i", v.get_int32());78 //debug("with value : %i", v.get_int32());
79 this.property_set_int(property, v.get_int32());79 this.property_set_int(property, v.get_int32());
80 }80 }
81 else if (v.is_of_type (VariantType.INT64 )){81 else if (v.is_of_type (VariantType.INT64 )){
82 debug("with value : %i", (int)v.get_int64());82 //debug("with value : %i", (int)v.get_int64());
83 this.property_set_int(property, (int)v.get_int64());83 this.property_set_int(property, (int)v.get_int64());
84 }84 }
85 else if(v.is_of_type ( VariantType.BOOLEAN )){85 else if(v.is_of_type ( VariantType.BOOLEAN )){
86 debug("with value : %s", v.get_boolean().to_string()); 86 //debug("with value : %s", v.get_boolean().to_string());
87 this.property_set_bool(property, v.get_boolean());87 this.property_set_bool(property, v.get_boolean());
88 }88 }
89 }89 }
@@ -93,10 +93,10 @@
93 public bool populated(HashSet<string> attrs)93 public bool populated(HashSet<string> attrs)
94 {94 {
95 foreach(string prop in attrs){95 foreach(string prop in attrs){
96 debug("populated ? - prop: %s", prop);96 //debug("populated ? - prop: %s", prop);
97 int value_int = property_get_int(prop);97 int value_int = property_get_int(prop);
98 if(property_get_int(prop) != EMPTY){98 if(property_get_int(prop) != EMPTY){
99 debug("populated - prop %s and value %i", prop, value_int); 99 //debug("populated - prop %s and value %i", prop, value_int);
100 return true;100 return true;
101 }101 }
102 }102 }
103103
=== modified file 'src/playlists-menu-item.vala'
--- src/playlists-menu-item.vala 2011-02-01 01:33:46 +0000
+++ src/playlists-menu-item.vala 2011-02-09 11:18:30 +0000
@@ -19,18 +19,20 @@
1919
20using Dbusmenu;20using Dbusmenu;
21using DbusmenuPlaylists;21using DbusmenuPlaylists;
22using DbusmenuPlaylist;
22using Gee;23using Gee;
2324
24public class PlaylistsMenuitem : PlayerItem25public class PlaylistsMenuitem : PlayerItem
25{26{
26 private HashMap<int, PlaylistDetails?> current_playlists; 27 private HashMap<int, Dbusmenu.Menuitem> current_playlists;
27 public Menuitem root_item;28 public Menuitem root_item;
29
28 public PlaylistsMenuitem ( PlayerController parent )30 public PlaylistsMenuitem ( PlayerController parent )
29 {31 {
30 Object ( item_type: MENUITEM_TYPE, owner: parent );32 Object ( item_type: MENUITEM_TYPE, owner: parent );
31 }33 }
32 construct{34 construct{
33 this.current_playlists = new HashMap<int, PlaylistDetails?>();35 this.current_playlists = new HashMap<int, Dbusmenu.Menuitem>();
34 this.root_item = new Menuitem();36 this.root_item = new Menuitem();
35 this.root_item.property_set ( MENUITEM_PROP_LABEL, "Choose Playlist" );37 this.root_item.property_set ( MENUITEM_PROP_LABEL, "Choose Playlist" );
36 }38 }
@@ -38,23 +40,38 @@
38 public new void update (PlaylistDetails[] playlists)40 public new void update (PlaylistDetails[] playlists)
39 {41 {
40 foreach ( PlaylistDetails detail in playlists ){42 foreach ( PlaylistDetails detail in playlists ){
43
41 if (this.already_observed(detail)) continue;44 if (this.already_observed(detail)) continue;
45
42 Dbusmenu.Menuitem menuitem = new Menuitem();46 Dbusmenu.Menuitem menuitem = new Menuitem();
43 menuitem.property_set (MENUITEM_PROP_LABEL, detail.name);47 menuitem.property_set (MENUITEM_PROP_LABEL, detail.name);
44 menuitem.property_set (MENUITEM_PROP_ICON_NAME, "source-smart-playlist");48 menuitem.property_set (MENUITEM_PROP_ICON_NAME, detail.icon_path);
49 menuitem.property_set (MENUITEM_PATH, (string)detail.path);
45 menuitem.property_set_bool (MENUITEM_PROP_VISIBLE, true);50 menuitem.property_set_bool (MENUITEM_PROP_VISIBLE, true);
46 menuitem.property_set_bool (MENUITEM_PROP_ENABLED, true);51 menuitem.property_set_bool (MENUITEM_PROP_ENABLED, true);
47 this.current_playlists.set( menuitem.id, detail );52
48 menuitem.item_activated.connect(() => {53 menuitem.item_activated.connect(() => {
49 submenu_item_activated (menuitem.id );});54 submenu_item_activated (menuitem.id );});
55 this.current_playlists.set( menuitem.id, menuitem );
50 this.root_item.child_append( menuitem );56 this.root_item.child_append( menuitem );
51 }57 }
52 }58 }
53 59
60 public void update_individual_playlist (PlaylistDetails new_detail)
61 {
62 foreach ( Dbusmenu.Menuitem item in this.current_playlists.values ){
63 if (new_detail.path == item.property_get (MENUITEM_PATH)){
64 item.property_set (MENUITEM_PROP_LABEL, new_detail.name);
65 item.property_set (MENUITEM_PROP_ICON_NAME, new_detail.icon_path);
66 }
67 }
68 }
69
54 private bool already_observed (PlaylistDetails new_detail)70 private bool already_observed (PlaylistDetails new_detail)
55 {71 {
56 foreach ( PlaylistDetails detail in this.current_playlists.values ){72 foreach ( Dbusmenu.Menuitem item in this.current_playlists.values ){
57 if (new_detail.path == detail.path) return true;73 var path = item.property_get (MENUITEM_PATH);
74 if (new_detail.path == path) return true;
58 }75 }
59 return false;76 return false;
60 }77 }
@@ -68,12 +85,12 @@
68 85
69 private void submenu_item_activated (int menu_item_id)86 private void submenu_item_activated (int menu_item_id)
70 {87 {
71 if(!this.current_playlists.has_key(menu_item_id)){88 if (!this.current_playlists.has_key(menu_item_id)) {
72 warning( "item %i was activated but we don't have a corresponding playlist",89 warning( "item %i was activated but we don't have a corresponding playlist",
73 menu_item_id );90 menu_item_id );
74 return;91 return;
75 }92 }
76 this.owner.mpris_bridge.activate_playlist ( this.current_playlists[menu_item_id].path );93 this.owner.mpris_bridge.activate_playlist ( (GLib.ObjectPath)this.current_playlists[menu_item_id].property_get (MENUITEM_PATH) );
77 }94 }
78 95
79 public static HashSet<string> attributes_format()96 public static HashSet<string> attributes_format()
8097
=== modified file 'src/transport-menu-item.vala'
--- src/transport-menu-item.vala 2011-01-25 20:55:25 +0000
+++ src/transport-menu-item.vala 2011-02-09 11:18:30 +0000
@@ -42,8 +42,8 @@
4242
43 public void change_play_state(state update)43 public void change_play_state(state update)
44 {44 {
45 debug("UPDATING THE TRANSPORT DBUSMENUITEM PLAY STATE WITH VALUE %i",45 //debug("UPDATING THE TRANSPORT DBUSMENUITEM PLAY STATE WITH VALUE %i",
46 (int)update);46 // (int)update);
47 int temp = (int)update;47 int temp = (int)update;
48 this.property_set_int(MENUITEM_PLAY_STATE, temp); 48 this.property_set_int(MENUITEM_PLAY_STATE, temp);
49 }49 }
@@ -60,7 +60,7 @@
60 }60 }
61 61
62 int32 input = v.get_int32();62 int32 input = v.get_int32();
63 debug("transport menu item -> handle_event with value %s", input.to_string());63 //debug("transport menu item -> handle_event with value %s", input.to_string());
64 //debug("transport owner name = %s", this.owner.app_info.get_name());64 //debug("transport owner name = %s", this.owner.app_info.get_name());
65 this.owner.mpris_bridge.transport_update((action)input);65 this.owner.mpris_bridge.transport_update((action)input);
66 } 66 }
6767
=== modified file 'vapi/common-defs.vapi'
--- vapi/common-defs.vapi 2010-12-09 11:36:33 +0000
+++ vapi/common-defs.vapi 2011-02-09 11:18:30 +0000
@@ -53,4 +53,8 @@
53 public const string MENUITEM_TYPE;53 public const string MENUITEM_TYPE;
54 public const string MENUITEM_TITLE;54 public const string MENUITEM_TITLE;
55 public const string MENUITEM_PLAYLISTS;55 public const string MENUITEM_PLAYLISTS;
56}
57[CCode (cheader_filename = "common-defs.h")]
58namespace DbusmenuPlaylist{
59 public const string MENUITEM_PATH;
56}60}
57\ No newline at end of file61\ No newline at end of file

Subscribers

People subscribed via source and target branches