aboutsummaryrefslogtreecommitdiff
path: root/src/service.vala
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2014-03-20 11:43:01 -0500
committerTed Gould <ted@gould.cx>2014-03-20 11:43:01 -0500
commit1680e2e1552575d66898de0e3d90be0bfa354b7a (patch)
tree70e3f7a195927e9d5f2a422fd28e89c6e4550e2f /src/service.vala
parent67d2b532117cc579d9589d228053042de68100b6 (diff)
parent831571ad497d790701d82305c57d8e69188a62ee (diff)
downloadayatana-indicator-sound-1680e2e1552575d66898de0e3d90be0bfa354b7a.tar.gz
ayatana-indicator-sound-1680e2e1552575d66898de0e3d90be0bfa354b7a.tar.bz2
ayatana-indicator-sound-1680e2e1552575d66898de0e3d90be0bfa354b7a.zip
Update to trunk and export updates
Diffstat (limited to 'src/service.vala')
-rw-r--r--src/service.vala53
1 files changed, 48 insertions, 5 deletions
diff --git a/src/service.vala b/src/service.vala
index 793a91a..1617887 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -47,9 +47,9 @@ public class IndicatorSound.Service: Object {
this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE);
});
- if (GLib.Environment.get_user_name() != "lightdm") {
- accounts_service = new AccountsServiceUser();
- }
+ /* Setup handling for the greeter-export setting */
+ this.settings.changed["greeter-export"].connect( () => this.build_accountsservice() );
+ build_accountsservice();
this.sync_preferred_players ();
this.settings.changed["interested-media-players"].connect ( () => {
@@ -67,6 +67,22 @@ public class IndicatorSound.Service: Object {
sharedsettings.bind ("allow-amplified-volume", this, "allow-amplified-volume", SettingsBindFlags.GET);
}
+ void build_accountsservice () {
+ this.accounts_service = null;
+
+ /* If we're not exporting, don't build anything */
+ if (!this.settings.get_boolean("greeter-export")) {
+ return;
+ }
+
+ /* If we're on the greeter, don't export */
+ if (GLib.Environment.get_user_name() == "lightdm") {
+ return;
+ }
+
+ this.accounts_service = new AccountsServiceUser();
+ }
+
public int run () {
if (this.loop != null) {
warning ("service is already running");
@@ -118,6 +134,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;
@@ -147,7 +165,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 ();
}
@@ -192,7 +210,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)
@@ -235,6 +253,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;
}