aboutsummaryrefslogtreecommitdiff
path: root/src/sound-menu.vala
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2014-03-24 15:02:45 +0000
committerCI bot <ps-jenkins@lists.canonical.com>2014-03-24 15:02:45 +0000
commit3cd9a899d19e4ece80844fe300a5d79ccbcbc2b6 (patch)
tree223b54f0dc2ab38d6edbe65a3bd778cbc4219739 /src/sound-menu.vala
parent7a312f2f03a0bc0c52ce8a6f834849d70233cf61 (diff)
parentd114c16f06803c8619d652b3a9dda31da3f1699a (diff)
downloadayatana-indicator-sound-3cd9a899d19e4ece80844fe300a5d79ccbcbc2b6.tar.gz
ayatana-indicator-sound-3cd9a899d19e4ece80844fe300a5d79ccbcbc2b6.tar.bz2
ayatana-indicator-sound-3cd9a899d19e4ece80844fe300a5d79ccbcbc2b6.zip
Create players on the phone greeter based on the accounts service data
Diffstat (limited to 'src/sound-menu.vala')
-rw-r--r--src/sound-menu.vala34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/sound-menu.vala b/src/sound-menu.vala
index 3fdfc36..e37c4e9 100644
--- a/src/sound-menu.vala
+++ b/src/sound-menu.vala
@@ -17,7 +17,7 @@
* Lars Uebernickel <lars.uebernickel@canonical.com>
*/
-class SoundMenu: Object
+public class SoundMenu: Object
{
public enum DisplayFlags {
NONE = 0,
@@ -97,12 +97,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);
@@ -112,11 +113,20 @@ 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;
@@ -126,16 +136,20 @@ class SoundMenu: Object
/* 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;
}
@@ -146,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");