diff options
author | Ted Gould <ted@gould.cx> | 2014-03-04 15:40:28 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2014-03-04 15:40:28 -0600 |
commit | e6fab6c96fe0e9414f214d47c8b762c8a435cc51 (patch) | |
tree | 25569bade0f178b7ce44205acb2e5c7ec82c8994 /src | |
parent | f06b9ff784c15e9e1c0ad0840299ed70b5616a74 (diff) | |
parent | e9f0b68ab8b9afec9466011b8a8bae3b202b4bf9 (diff) | |
download | ayatana-indicator-sound-e6fab6c96fe0e9414f214d47c8b762c8a435cc51.tar.gz ayatana-indicator-sound-e6fab6c96fe0e9414f214d47c8b762c8a435cc51.tar.bz2 ayatana-indicator-sound-e6fab6c96fe0e9414f214d47c8b762c8a435cc51.zip |
Update to the latest player
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/media-player-list-greeter.vala | 12 | ||||
-rw-r--r-- | src/media-player-user.vala | 10 | ||||
-rw-r--r-- | src/service.vala | 11 | ||||
-rw-r--r-- | src/sound-menu.vala | 42 |
5 files changed, 56 insertions, 20 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 55c5fba..98bc7c4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -96,7 +96,6 @@ vala_add(indicator-sound-service sound-menu.vala DEPENDS media-player - mpris2-interfaces ) vala_add(indicator-sound-service accounts-service-user.vala diff --git a/src/media-player-list-greeter.vala b/src/media-player-list-greeter.vala index 2f1962e..15e4c55 100644 --- a/src/media-player-list-greeter.vala +++ b/src/media-player-list-greeter.vala @@ -63,12 +63,15 @@ public class MediaPlayerListGreeter : MediaPlayerList { return; } + debug(@"Active user changed to: $active_user"); + var old_user = selected_user; /* Protect against a null user */ - if (active_user != "") { + if (active_user != "" && active_user[0] != '*') { selected_user = active_user; } else { + debug(@"Blocking active user change for '$active_user'"); selected_user = null; } @@ -78,12 +81,17 @@ public class MediaPlayerListGreeter : MediaPlayerList { if (old_user != null) { var old_player = players.lookup(old_user); + debug("Removing player for user: %s", old_user); player_removed(old_player); } if (selected_user != null) { var new_player = players.lookup(selected_user); - player_added(new_player); + + if (new_player != null) { + debug("Adding player for user: %s", selected_user); + player_added(new_player); + } } } diff --git a/src/media-player-user.vala b/src/media-player-user.vala index c48c39b..11678d5 100644 --- a/src/media-player-user.vala +++ b/src/media-player-user.vala @@ -69,9 +69,12 @@ public class MediaPlayerUser : MediaPlayer { properties_timeout = 0; properties_queued.@foreach((key, value) => { + debug("Notifying '%s' changed", key); this.notify_property(key); }); + properties_queued.remove_all(); + /* Remove source */ return false; } @@ -88,6 +91,7 @@ public class MediaPlayerUser : MediaPlayer { properties_queued.insert("icon", true); properties_queued.insert("state", true); properties_queued.insert("current-track", true); + properties_queued.insert("is-running", true); break; case "PlayerName": properties_queued.insert("name", true); @@ -126,8 +130,8 @@ public class MediaPlayerUser : MediaPlayer { } }); - /* Update all of them -- we've got a proxy! */ - queue_property_notification("Timestamp"); + debug("Notifying player is ready for user: %s", this.username); + this.notify_property("is-running"); } catch (Error e) { this.proxy = null; warning("Unable to get proxy to user '%s' sound settings: %s", username, e.message); @@ -195,7 +199,7 @@ public class MediaPlayerUser : MediaPlayer { /* If it's shown externally it's running */ public override bool is_running { get { return proxy_is_valid(); } } /* A bit weird. Not sure how we should handle this. */ - public override bool can_raise { get { return false; } } + public override bool can_raise { get { return true; } } /* Fill out the track based on the values in the proxy */ MediaPlayer.Track track_cache; diff --git a/src/service.vala b/src/service.vala index be0164d..ca00caa 100644 --- a/src/service.vala +++ b/src/service.vala @@ -35,7 +35,8 @@ public class IndicatorSound.Service: Object { this.actions.add_action (this.create_mic_volume_action ()); this.menus = new HashTable<string, SoundMenu> (str_hash, str_equal); - this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE)); + this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.DONT_SHOW_PLAYERS)); + this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS)); this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE)); this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS)); @@ -366,15 +367,15 @@ public class IndicatorSound.Service: Object { this.menus.@foreach ( (profile, menu) => menu.add_player (player)); SimpleAction action = new SimpleAction.stateful (player.id, null, this.action_state_for_player (player)); + action.set_enabled (player.can_raise); action.activate.connect ( () => { player.activate (); }); this.actions.add_action (action); var play_action = new SimpleAction.stateful ("play." + player.id, null, player.state); play_action.activate.connect ( () => player.play_pause () ); this.actions.add_action (play_action); - player.notify.connect ( (object, pspec) => { - if (pspec.name == "state") - play_action.set_state (player.state); + player.notify["state"].connect ( (object, pspec) => { + play_action.set_state (player.state); }); var next_action = new SimpleAction ("next." + player.id, null); @@ -401,6 +402,8 @@ public class IndicatorSound.Service: Object { this.actions.remove_action ("previous." + player.id); this.actions.remove_action ("play-playlist." + player.id); + player.notify.disconnect (this.eventually_update_player_actions); + this.menus.@foreach ( (profile, menu) => menu.remove_player (player)); this.update_preferred_players (); diff --git a/src/sound-menu.vala b/src/sound-menu.vala index 480e1cf..ebb7632 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -17,12 +17,13 @@ * Lars Uebernickel <lars.uebernickel@canonical.com> */ -class SoundMenu: Object +public class SoundMenu: Object { public enum DisplayFlags { NONE = 0, SHOW_MUTE = 1, - HIDE_INACTIVE_PLAYERS = 2 + HIDE_INACTIVE_PLAYERS = 2, + DONT_SHOW_PLAYERS = 4 } public SoundMenu (string? settings_action, DisplayFlags flags) { @@ -31,6 +32,8 @@ class SoundMenu: Object * it has a dynamic amount of player sections, one for each registered player. */ + this.no_players = ((flags & DisplayFlags.DONT_SHOW_PLAYERS) != 0); + this.volume_section = new Menu (); if ((flags & DisplayFlags.SHOW_MUTE) != 0) volume_section.append (_("Mute"), "indicator.mute"); @@ -87,6 +90,8 @@ class SoundMenu: Object } public void add_player (MediaPlayer player) { + if (this.no_players) + return; if (this.notify_handlers.contains (player)) return; @@ -95,12 +100,13 @@ class SoundMenu: Object this.update_playlists (player); var handler_id = player.notify["is-running"].connect ( () => { - if (this.hide_inactive) { - if (player.is_running) + if (player.is_running) + if (this.find_player_section(player) == -1) this.insert_player_section (player); - else + else + if (this.hide_inactive) this.remove_player_section (player); - } + this.update_playlists (player); }); this.notify_handlers.insert (player, handler_id); @@ -110,29 +116,43 @@ class SoundMenu: Object public void remove_player (MediaPlayer player) { this.remove_player_section (player); + + var id = this.notify_handlers.lookup(player); + if (id != 0) { + player.disconnect(id); + } + + player.playlists_changed.disconnect (this.update_playlists); + + /* this'll drop our ref to it */ this.notify_handlers.remove (player); } - Menu root; - Menu menu; + public Menu root; + public Menu menu; Menu volume_section; bool mic_volume_shown; bool settings_shown = false; bool hide_inactive; + bool no_players; HashTable<MediaPlayer, ulong> notify_handlers; /* returns the position in this.menu of the section that's associated with @player */ int find_player_section (MediaPlayer player) { + debug("Looking for player: %s", player.id); string action_name = @"indicator.$(player.id)"; - int n = this.menu.get_n_items () -1; - for (int i = 1; i < n; i++) { + int n = this.menu.get_n_items (); + for (int i = 0; i < n; i++) { var section = this.menu.get_item_link (i, Menu.LINK_SECTION); + if (section == null) continue; + string action; section.get_item_attribute (0, "action", "s", out action); if (action == action_name) return i; } + debug("Unable to find section for player: %s", player.id); return -1; } @@ -140,6 +160,8 @@ class SoundMenu: Object var section = new Menu (); Icon icon; + debug("Adding section for player: %s (%s)", player.id, player.is_running ? "running" : "not running"); + icon = player.icon; if (icon == null) icon = new ThemedIcon.with_default_fallbacks ("application-default-icon"); |