aboutsummaryrefslogtreecommitdiff
path: root/src/service.vala
diff options
context:
space:
mode:
authorcharles kerr <charlesk@canonical.com>2015-12-20 16:18:57 -0600
committercharles kerr <charlesk@canonical.com>2015-12-20 16:18:57 -0600
commitace782578de3c7d895070d20d61d5fbf5b869633 (patch)
tree4d5589908157431235fa8f9cd82f50feb67298d9 /src/service.vala
parent60cd7ac64849bfc21be1a85063f5730ad22f9d72 (diff)
downloadayatana-indicator-sound-ace782578de3c7d895070d20d61d5fbf5b869633.tar.gz
ayatana-indicator-sound-ace782578de3c7d895070d20d61d5fbf5b869633.tar.bz2
ayatana-indicator-sound-ace782578de3c7d895070d20d61d5fbf5b869633.zip
remove code duplication between volume-warning and volume-control-pulse
let volume-warning's 'multimedia_active' and 'headphones_active' be bound to volume-control's 'active-stream' and 'active-output' properties. Service manages the bindings. This lets us remove all the pacontext code from volume-warning.
Diffstat (limited to 'src/service.vala')
-rw-r--r--src/service.vala22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/service.vala b/src/service.vala
index acaf639..fbeb886 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -49,8 +49,26 @@ public class IndicatorSound.Service: Object {
this.notify["visible"].connect ( () => this.update_root_icon () );
this.volume_control = volume;
- this.volume_control.active_output_changed.connect(() => this.update_root_icon());
- this.volume_control.active_output_changed.connect(() => this.update_notification());
+ this.volume_control.notify["active-stream"].connect(() => {
+ _volume_warning.multimedia_active =
+ VolumeControl.Stream.MULTIMEDIA == volume_control.active_stream;
+ });
+ this.volume_control.active_output_changed.connect(() => {
+ switch(volume_control.active_output) {
+ case VolumeControl.ActiveOutput.HEADPHONES:
+ case VolumeControl.ActiveOutput.USB_HEADPHONES:
+ case VolumeControl.ActiveOutput.HDMI_HEADPHONES:
+ case VolumeControl.ActiveOutput.BLUETOOTH_HEADPHONES:
+ _volume_warning.headphones_active = true;
+ break;
+
+ default:
+ _volume_warning.headphones_active = false;
+ break;
+ }
+ update_root_icon();
+ update_notification();
+ });
this.accounts_service = accounts;
/* If we're on the greeter, don't export */