From 8507423eb5b7acaf1089fdaa4fc57cdca554abeb Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 1 Feb 2011 12:24:38 -0600 Subject: the title on the player menu item can now be dynamically changed using the Identity prop on the root MPRIS interface --- src/mpris2-controller.vala | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/mpris2-controller.vala') diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 03571e6..b9e7551 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -103,6 +103,11 @@ public class Mpris2Controller : GLib.Object this.fetch_playlists.begin(); this.fetch_active_playlist(); } + Variant? identity_v = changed_properties.lookup("Identity"); + if (identity_v != null){ + TitleMenuitem title = this.owner.custom_items[PlayerController.widget_order.TITLE] as TitleMenuitem; + title.alter_label (identity_v.get_string()); + } } private bool ensure_correct_playback_status(){ @@ -144,15 +149,20 @@ public class Mpris2Controller : GLib.Object public void initial_update() { TransportMenuitem.state update; + if(this.player.PlaybackStatus == null){ update = TransportMenuitem.state.PAUSED; } - - update = determine_play_state(null); - - (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(TransportMenuitem.state.PAUSED); + else{ + update = determine_play_state (this.player.PlaybackStatus); + } + if (this.mpris2_root.Identity != null){ + TitleMenuitem title = this.owner.custom_items[PlayerController.widget_order.TITLE] as TitleMenuitem; + title.alter_label (this.mpris2_root.Identity); + } + (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state (update); GLib.HashTable? cleaned_metadata = this.clean_metadata(); - this.owner.custom_items[PlayerController.widget_order.METADATA].update(cleaned_metadata, + this.owner.custom_items[PlayerController.widget_order.METADATA].update (cleaned_metadata, MetadataMenuitem.attributes_format()); if ( this.owner.use_playlists == true ){ -- cgit v1.2.3 From ebf8fb61bea8de7d6d2df81015b538638207f2cf Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 1 Feb 2011 13:31:32 -0600 Subject: make sure it updates its own title --- src/mpris2-controller.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mpris2-controller.vala') diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index b9e7551..d4cdc0c 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -106,7 +106,7 @@ public class Mpris2Controller : GLib.Object Variant? identity_v = changed_properties.lookup("Identity"); if (identity_v != null){ TitleMenuitem title = this.owner.custom_items[PlayerController.widget_order.TITLE] as TitleMenuitem; - title.alter_label (identity_v.get_string()); + title.alter_label (this.mpris2_root.Identity); } } -- cgit v1.2.3 From 800023f7ab5854c19bdaf426ba86d24feea014ec Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 8 Feb 2011 18:58:10 +0000 Subject: work done around playlist changed --- src/mpris2-controller.vala | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/mpris2-controller.vala') diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index d4cdc0c..444bdf6 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -48,6 +48,7 @@ public class Mpris2Controller : GLib.Object this.playlists = Bus.get_proxy_sync ( BusType.SESSION, this.owner.dbus_name, "/org/mpris/MediaPlayer2" ); + this.playlists.PlaylistChanged.connect (on_playlistdetails_changed); } this.properties_interface = Bus.get_proxy_sync ( BusType.SESSION, "org.freedesktop.Properties.PropertiesChanged", @@ -109,7 +110,7 @@ public class Mpris2Controller : GLib.Object title.alter_label (this.mpris2_root.Identity); } } - + private bool ensure_correct_playback_status(){ debug("TEST playback status = %s", this.player.PlaybackStatus); TransportMenuitem.state p = (TransportMenuitem.state)this.determine_play_state(this.player.PlaybackStatus); @@ -185,7 +186,6 @@ public class Mpris2Controller : GLib.Object } } - public bool connected() { return (this.player != null && this.mpris2_root != null); @@ -198,6 +198,11 @@ public class Mpris2Controller : GLib.Object } } + private void on_playlistdetails_changed (PlaylistDetails details) + { + + } + public async void fetch_playlists() { PlaylistDetails[] current_playlists = null; -- cgit v1.2.3 From 17f01f35c7b474f4286dd55b129fcf72075760dc Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 9 Feb 2011 10:56:49 +0000 Subject: fixed racey active playlist property and commented some debugs --- src/mpris2-controller.vala | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/mpris2-controller.vala') diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 444bdf6..3e06487 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -64,7 +64,7 @@ public class Mpris2Controller : GLib.Object HashTable changed_properties, string[] invalid ) { - debug("properties-changed for interface %s and owner %s", interface_source, this.owner.dbus_name); + //debug("properties-changed for interface %s and owner %s", interface_source, this.owner.dbus_name); if ( changed_properties == null || interface_source.has_prefix ( MPRIS_PREFIX ) == false ){ warning("Property-changed hash is null or this is an interface that doesn't concerns us"); @@ -92,7 +92,9 @@ public class Mpris2Controller : GLib.Object } Variant? playlist_v = changed_properties.lookup("ActivePlaylist"); if ( playlist_v != null && this.owner.use_playlists == true ){ - this.fetch_active_playlist(); + // Once again GDBus race condition, the property_changed signal is sent + // before the value is set on the respective property. + Timeout.add (300, this.fetch_active_playlist); } Variant? playlist_count_v = changed_properties.lookup("PlaylistCount"); if ( playlist_count_v != null && this.owner.use_playlists == true ){ @@ -112,7 +114,7 @@ public class Mpris2Controller : GLib.Object } private bool ensure_correct_playback_status(){ - debug("TEST playback status = %s", this.player.PlaybackStatus); + //debug("TEST playback status = %s", this.player.PlaybackStatus); TransportMenuitem.state p = (TransportMenuitem.state)this.determine_play_state(this.player.PlaybackStatus); (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(p); return false; @@ -174,7 +176,7 @@ public class Mpris2Controller : GLib.Object public void transport_update(TransportMenuitem.action command) { - debug("transport_event input = %i", (int)command); + //debug("transport_event input = %i", (int)command); if(command == TransportMenuitem.action.PLAY_PAUSE){ this.player.PlayPause.begin(); } @@ -219,7 +221,7 @@ public class Mpris2Controller : GLib.Object } if( current_playlists != null ){ - debug( "Size of the playlist array = %i", current_playlists.length ); + //debug( "Size of the playlist array = %i", current_playlists.length ); PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem; playlists_item.update(current_playlists); } @@ -229,13 +231,14 @@ public class Mpris2Controller : GLib.Object } } - private void fetch_active_playlist() + private bool fetch_active_playlist() { if (this.playlists.ActivePlaylist.valid == false){ - debug("We don't have an active playlist"); - } + debug(" We don't have an active playlist"); + } PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem; playlists_item.update_active_playlist ( this.playlists.ActivePlaylist.details ); + return false; } public void activate_playlist (ObjectPath path) -- cgit v1.2.3 From f184a09b5f7691c350684e03461a9ab658686f2e Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 9 Feb 2011 11:02:31 +0000 Subject: tidy up --- src/mpris2-controller.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mpris2-controller.vala') diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 3e06487..b4d0fc4 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -92,7 +92,7 @@ public class Mpris2Controller : GLib.Object } Variant? playlist_v = changed_properties.lookup("ActivePlaylist"); if ( playlist_v != null && this.owner.use_playlists == true ){ - // Once again GDBus race condition, the property_changed signal is sent + // Once again A GDBus race condition, the property_changed signal is sent // before the value is set on the respective property. Timeout.add (300, this.fetch_active_playlist); } -- cgit v1.2.3 From 5347a41ef9a04cc52c4f25bddfac9cb8660348a4 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 9 Feb 2011 11:16:03 +0000 Subject: and plug it together --- src/mpris2-controller.vala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/mpris2-controller.vala') diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index b4d0fc4..bf930fc 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -202,7 +202,8 @@ public class Mpris2Controller : GLib.Object private void on_playlistdetails_changed (PlaylistDetails details) { - + PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem; + playlists_item.update_individual_playlist (details); } public async void fetch_playlists() -- cgit v1.2.3