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 +++++++++++++++----- src/title-menu-item.vala | 14 ++++++++++++-- 2 files changed, 27 insertions(+), 7 deletions(-) (limited to 'src') 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 ){ diff --git a/src/title-menu-item.vala b/src/title-menu-item.vala index 6ed24d8..fd81f65 100644 --- a/src/title-menu-item.vala +++ b/src/title-menu-item.vala @@ -26,8 +26,12 @@ public class TitleMenuitem : PlayerItem public TitleMenuitem(PlayerController parent) { Object(item_type: MENUITEM_TYPE, owner: parent); - this.property_set(MENUITEM_NAME, parent.app_info.get_name()); - this.property_set(MENUITEM_ICON, parent.icon_name); + } + + construct + { + this.property_set(MENUITEM_NAME, this.owner.app_info.get_name()); + this.property_set(MENUITEM_ICON, this.owner.icon_name); this.property_set_bool(MENUITEM_RUNNING, false); } @@ -42,6 +46,12 @@ public class TitleMenuitem : PlayerItem } } + public void alter_label (string new_title) + { + if (new_title != null) return; + this.property_set(MENUITEM_NAME, new_title); + } + public void toggle_active_triangle(bool update) { this.property_set_bool(MENUITEM_RUNNING, update); -- 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') 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 2b6453d1a988eb4a82df18401b3ba9b3867a2f40 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 1 Feb 2011 14:40:51 -0600 Subject: fixes for the last two merge requests --- src/sound-service-dbus.c | 6 +++--- src/title-menu-item.vala | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 7f5afdc..637bee4 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -452,7 +452,7 @@ static gboolean sound_service_dbus_blacklist_player (SoundServiceDbus* self, g_debug ("we have this already blacklisted, no need to do anything"); g_variant_builder_clear (&builder); g_object_unref (our_settings); - g_object_unref (the_black_list); + g_variant_unref (the_black_list); return result; } } @@ -475,7 +475,7 @@ static gboolean sound_service_dbus_blacklist_player (SoundServiceDbus* self, g_debug ("it was not blacklisted ?, no need to do anything"); g_variant_builder_clear (&builder); g_object_unref (our_settings); - g_object_unref (the_black_list); + g_variant_unref (the_black_list); return result; } @@ -497,7 +497,7 @@ static gboolean sound_service_dbus_blacklist_player (SoundServiceDbus* self, value); g_object_unref (our_settings); - g_object_unref (the_black_list); + g_variant_unref (the_black_list); return result; } diff --git a/src/title-menu-item.vala b/src/title-menu-item.vala index fd81f65..ac93b89 100644 --- a/src/title-menu-item.vala +++ b/src/title-menu-item.vala @@ -48,7 +48,7 @@ public class TitleMenuitem : PlayerItem public void alter_label (string new_title) { - if (new_title != null) return; + if (new_title == null) return; this.property_set(MENUITEM_NAME, new_title); } -- cgit v1.2.3