aboutsummaryrefslogtreecommitdiff
path: root/src/sound-menu.vala
diff options
context:
space:
mode:
authorXavi Garcia Mena <xavi.garcia.mena@canonical.com>2016-03-02 14:50:43 +0100
committerXavi Garcia Mena <xavi.garcia.mena@canonical.com>2016-03-02 14:50:43 +0100
commit7604867025faaf3b015193ca89454b72d981bd58 (patch)
tree16daaf06f1b389fc9511582a2f8af62726efd7b9 /src/sound-menu.vala
parent0fe4ec98a470a992eee9f8ed7e404fe767a82076 (diff)
downloadayatana-indicator-sound-7604867025faaf3b015193ca89454b72d981bd58.tar.gz
ayatana-indicator-sound-7604867025faaf3b015193ca89454b72d981bd58.tar.bz2
ayatana-indicator-sound-7604867025faaf3b015193ca89454b72d981bd58.zip
Changed following Charles's suggestions
Diffstat (limited to 'src/sound-menu.vala')
-rw-r--r--src/sound-menu.vala23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/sound-menu.vala b/src/sound-menu.vala
index 5aa94fe..2ef089a 100644
--- a/src/sound-menu.vala
+++ b/src/sound-menu.vala
@@ -178,7 +178,17 @@ public class SoundMenu: Object
}
}
}
-
+
+ private void check_last_running_player () {
+ foreach (var player in notify_handlers.get_keys ()) {
+ if (player.is_running && number_of_running_players == 1) {
+ // this is the first or the last player running...
+ // store its id
+ this.last_player_updated (player.id);
+ }
+ }
+ }
+
public void add_player (MediaPlayer player) {
if (this.notify_handlers.contains (player))
return;
@@ -205,11 +215,15 @@ public class SoundMenu: Object
// we need to update the rest of players, because we might have
// a non running player still showing the playback controls
update_all_players_play_section();
+
+ check_last_running_player ();
});
this.notify_handlers.insert (player, handler_id);
player.playlists_changed.connect (this.update_playlists);
player.playbackstatus_changed.connect (this.update_playbackstatus);
+
+ check_last_running_player ();
}
public void remove_player (MediaPlayer player) {
@@ -224,6 +238,8 @@ public class SoundMenu: Object
/* this'll drop our ref to it */
this.notify_handlers.remove (player);
+
+ check_last_running_player ();
}
public void update_volume_slider (VolumeControl.ActiveOutput active_output) {
@@ -395,11 +411,6 @@ public class SoundMenu: Object
}
void update_player_section (MediaPlayer player, int index) {
- if (player.is_running && number_of_running_players == 1) {
- // this is the first or the last player running...
- // store its id
- this.last_player_updated (player.id);
- }
add_player_playback_controls (player, index, false);
}