From 9fb9f5077869c6e30d305ec7cb21d0129567e10e Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Wed, 30 Oct 2013 07:48:46 -0700 Subject: Make player menu item insensitive when player can't be raised --- src/media-player.vala | 10 ++++++++++ src/service.vala | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/media-player.vala b/src/media-player.vala index 49fe387..bdcea35 100644 --- a/src/media-player.vala +++ b/src/media-player.vala @@ -84,6 +84,12 @@ public class MediaPlayer: Object { get; set; } + public bool can_raise { + get { + return this.root != null ? this.root.CanRaise : true; + } + } + public signal void playlists_changed (); /** @@ -98,6 +104,8 @@ public class MediaPlayer: Object { return_if_fail (this._dbus_name == null && this.proxy == null); this.root = root; + this.notify_property ("can-raise"); + this._dbus_name = dbus_name; Bus.get_proxy.begin (BusType.SESSION, dbus_name, "/org/mpris/MediaPlayer2", DBusProxyFlags.GET_INVALIDATED_PROPERTIES, null, got_proxy); @@ -111,9 +119,11 @@ public class MediaPlayer: Object { * See also: attach() */ public void detach () { + this.root = null; this.proxy = null; this._dbus_name = null; this.notify_property ("is-running"); + this.notify_property ("can-raise"); this.state = "Paused"; this.current_track = null; } diff --git a/src/service.vala b/src/service.vala index 9a82e8b..14d4893 100644 --- a/src/service.vala +++ b/src/service.vala @@ -266,8 +266,10 @@ public class IndicatorSound.Service { bool update_player_actions () { foreach (var player in this.players) { SimpleAction? action = this.actions.lookup_action (player.id) as SimpleAction; - if (action != null) + if (action != null) { action.set_state (this.action_state_for_player (player)); + action.set_enabled (player.can_raise); + } } this.player_action_update_id = 0; -- cgit v1.2.3