diff options
author | Ted Gould <ted@gould.cx> | 2014-10-15 16:19:02 +0000 |
---|---|---|
committer | CI bot <ps-jenkins@lists.canonical.com> | 2014-10-15 16:19:02 +0000 |
commit | d3a1ccfea08bf5fec62b4e49834d06d79423ae03 (patch) | |
tree | 8758043e3064043a115d653c130bf876d2b39a18 /src/service.vala | |
parent | 793ca099b8ce34d87596dfbb4bce48c6f3d197a8 (diff) | |
parent | 59fbca3a976b8725d5f7c9b05088b60c87333773 (diff) | |
download | ayatana-indicator-sound-d3a1ccfea08bf5fec62b4e49834d06d79423ae03.tar.gz ayatana-indicator-sound-d3a1ccfea08bf5fec62b4e49834d06d79423ae03.tar.bz2 ayatana-indicator-sound-d3a1ccfea08bf5fec62b4e49834d06d79423ae03.zip |
Warn on high audio levels when using headphones Fixes: 1373404
Approved by: Mirco Müller
Diffstat (limited to 'src/service.vala')
-rw-r--r-- | src/service.vala | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/service.vala b/src/service.vala index 4e02769..bd44b0d 100644 --- a/src/service.vala +++ b/src/service.vala @@ -36,6 +36,7 @@ public class IndicatorSound.Service: Object { this.actions.add_action (this.create_mute_action ()); this.actions.add_action (this.create_volume_action ()); this.actions.add_action (this.create_mic_volume_action ()); + this.actions.add_action (this.create_high_volume_actions ()); this.menus = new HashTable<string, SoundMenu> (str_hash, str_equal); this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS)); @@ -47,6 +48,10 @@ public class IndicatorSound.Service: Object { this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE); }); + this.menus.@foreach ( (profile, menu) => { + this.volume_control.bind_property ("high-volume", menu, "show-high-volume-warning", BindingFlags.SYNC_CREATE); + }); + /* Setup handling for the greeter-export setting */ this.settings.changed["greeter-export"].connect( () => this.build_accountsservice() ); build_accountsservice(); @@ -181,6 +186,8 @@ public class IndicatorSound.Service: Object { double v = this.volume_control.get_volume () + volume_step_percentage * delta; this.volume_control.set_volume (v.clamp (0.0, this.max_volume)); + /* TODO: Don't want to mess up the desktop today, but we should remove this + scrolling change and merge that into volume control's notification */ if (this.notification != null) { string icon; if (v <= 0.0) @@ -365,6 +372,15 @@ public class IndicatorSound.Service: Object { return volume_action; } + Action create_high_volume_actions () { + var high_volume_action = new SimpleAction.stateful("high-volume", null, new Variant.boolean (this.volume_control.high_volume)); + + this.volume_control.notify["high-volume"].connect( () => + high_volume_action.set_state(new Variant.boolean (this.volume_control.high_volume))); + + return high_volume_action; + } + void bus_acquired (DBusConnection connection, string name) { try { connection.export_action_group ("/com/canonical/indicator/sound", this.actions); |