aboutsummaryrefslogtreecommitdiff
path: root/src/service.vala
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2014-03-18 10:00:51 +0000
committerCI bot <ps-jenkins@lists.canonical.com>2014-03-18 10:00:51 +0000
commit0ab738762734b30a264504283b7ae0fc9e941720 (patch)
treef92a28a3f8e1542d66d61d37bf2b6e7e76c195b4 /src/service.vala
parentb51fa335562a99e80ec30daf89d0715e084d50d0 (diff)
parent2ad60576f3975fab265bd44751c9af634f51a375 (diff)
downloadayatana-indicator-sound-0ab738762734b30a264504283b7ae0fc9e941720.tar.gz
ayatana-indicator-sound-0ab738762734b30a264504283b7ae0fc9e941720.tar.bz2
ayatana-indicator-sound-0ab738762734b30a264504283b7ae0fc9e941720.zip
Show a red icon in the panel when a sound is playing while mute is on Fixes: 1291530
Diffstat (limited to 'src/service.vala')
-rw-r--r--src/service.vala29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/service.vala b/src/service.vala
index 970867f..507a39e 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -113,6 +113,8 @@ public class IndicatorSound.Service: Object {
VolumeControl volume_control;
MediaPlayerList players;
uint player_action_update_id;
+ bool mute_blocks_sound;
+ uint sound_was_blocked_timeout_id;
Notify.Notification notification;
bool syncing_preferred_players = false;
@@ -186,7 +188,7 @@ public class IndicatorSound.Service: Object {
double volume = this.volume_control.get_volume ();
string icon;
if (this.volume_control.mute)
- icon = "audio-volume-muted-panel";
+ icon = this.mute_blocks_sound ? "audio-volume-muted-blocked-panel" : "audio-volume-muted-panel";
else if (volume <= 0.0)
icon = "audio-volume-low-zero-panel";
else if (volume <= 0.3)
@@ -229,6 +231,31 @@ public class IndicatorSound.Service: Object {
this.update_root_icon ();
});
+ this.volume_control.notify["is-playing"].connect( () => {
+ if (!this.volume_control.mute) {
+ this.mute_blocks_sound = false;
+ return;
+ }
+
+ if (this.volume_control.is_playing) {
+ this.mute_blocks_sound = true;
+ }
+ else if (this.mute_blocks_sound) {
+ /* Continue to show the blocking icon five seconds after a player has tried to play something */
+ if (this.sound_was_blocked_timeout_id > 0)
+ Source.remove (this.sound_was_blocked_timeout_id);
+
+ this.sound_was_blocked_timeout_id = Timeout.add_seconds (5, () => {
+ this.mute_blocks_sound = false;
+ this.sound_was_blocked_timeout_id = 0;
+ this.update_root_icon ();
+ return false;
+ });
+ }
+
+ this.update_root_icon ();
+ });
+
return mute_action;
}