aboutsummaryrefslogtreecommitdiff
path: root/src/service.vala
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2014-03-20 11:37:34 -0500
committerTed Gould <ted@gould.cx>2014-03-20 11:37:34 -0500
commit05ea9196dfbb9ea2a2482625103e9cccbd13b0ec (patch)
treead372c10cb146cbfca352c343b2338c37999c0b1 /src/service.vala
parent006c044b3063c905a5c7aa8c31e91a4545acedae (diff)
parentb237767cb787f20e13fe564d0b07b33c38e58123 (diff)
downloadayatana-indicator-sound-05ea9196dfbb9ea2a2482625103e9cccbd13b0ec.tar.gz
ayatana-indicator-sound-05ea9196dfbb9ea2a2482625103e9cccbd13b0ec.tar.bz2
ayatana-indicator-sound-05ea9196dfbb9ea2a2482625103e9cccbd13b0ec.zip
Updating to trunk
Diffstat (limited to 'src/service.vala')
-rw-r--r--src/service.vala31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/service.vala b/src/service.vala
index 7f4982f..d94aa18 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -133,6 +133,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;
AccountsServiceUser? accounts_service = null;
@@ -162,7 +164,7 @@ public class IndicatorSound.Service: Object {
icon = "notification-audio-volume-high";
this.notification.update ("indicator-sound", "", icon);
- this.notification.set_hint_int32 ("value", ((int32) (100 * v)).clamp (-1, 101));
+ this.notification.set_hint_int32 ("value", ((int32) (100 * v / this.max_volume)).clamp (-1, 101));
try {
this.notification.show ();
}
@@ -207,7 +209,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-blocking-panel" : "audio-volume-muted-panel";
else if (volume <= 0.0)
icon = "audio-volume-low-zero-panel";
else if (volume <= 0.3)
@@ -250,6 +252,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;
}