diff options
author | charles kerr <charlesk@canonical.com> | 2015-12-19 23:09:49 -0600 |
---|---|---|
committer | charles kerr <charlesk@canonical.com> | 2015-12-19 23:09:49 -0600 |
commit | a5d0e139cbd332419d2e82f45e8656462e39d029 (patch) | |
tree | 89ba5668385bb26e9ec193635f3bebd3884c1989 /src | |
parent | ca18e99ee04c10fbc0baff2e836278f4f8817af0 (diff) | |
download | ayatana-indicator-sound-a5d0e139cbd332419d2e82f45e8656462e39d029.tar.gz ayatana-indicator-sound-a5d0e139cbd332419d2e82f45e8656462e39d029.tar.bz2 ayatana-indicator-sound-a5d0e139cbd332419d2e82f45e8656462e39d029.zip |
remove 'high_volume' property from volume-control
Diffstat (limited to 'src')
-rw-r--r-- | src/service.vala | 17 | ||||
-rw-r--r-- | src/volume-control-pulse.vala | 47 | ||||
-rw-r--r-- | src/volume-control.vala | 3 | ||||
-rw-r--r-- | src/volume-warning.vala | 10 |
4 files changed, 16 insertions, 61 deletions
diff --git a/src/service.vala b/src/service.vala index 51f5cb6..5f6b00e 100644 --- a/src/service.vala +++ b/src/service.vala @@ -617,7 +617,7 @@ public class IndicatorSound.Service: Object { notify_server_caps_checked = true; } - var loud = volume_control.high_volume; + var loud = _volume_warning.high_volume; bool ignore_warning_this_time = _volume_warning.ignore_high_volume; var warn = loud && this.notify_server_supports_actions @@ -821,12 +821,19 @@ public class IndicatorSound.Service: Object { return mic_volume_action; } + private Variant create_high_volume_action_state() { + return new Variant.boolean (_volume_warning.high_volume); + } + private void update_high_volume_action_state() { + high_volume_action.set_state(create_high_volume_action_state()); + } + SimpleAction high_volume_action; Action create_high_volume_action () { - high_volume_action = new SimpleAction.stateful("high-volume", null, new Variant.boolean (this.volume_control.high_volume)); + high_volume_action = new SimpleAction.stateful("high-volume", null, create_high_volume_action_state()); - this.volume_control.notify["high-volume"].connect( () => { - high_volume_action.set_state(new Variant.boolean (this.volume_control.high_volume)); + _volume_warning.notify["high-volume"].connect( () => { + update_high_volume_action_state(); update_notification(); }); @@ -982,7 +989,7 @@ public class IndicatorSound.Service: Object { private bool clamp_to_high_idle() { _clamp_to_high_timeout = 0; - volume_control.clamp_to_high_volume(); + _volume_warning.clamp_to_high_volume(); return false; // Source.REMOVE; } } diff --git a/src/volume-control-pulse.vala b/src/volume-control-pulse.vala index 8c09a6b..56cfba7 100644 --- a/src/volume-control-pulse.vala +++ b/src/volume-control-pulse.vala @@ -102,18 +102,11 @@ public class VolumeControlPulse : VolumeControl _mute_cancellable = new Cancellable (); _volume_cancellable = new Cancellable (); - init_all_properties(); - setup_accountsservice.begin (); this.reconnect_to_pulse (); } - private void init_all_properties() - { - init_high_volume(); - } - ~VolumeControlPulse () { stop_all_timers(); @@ -252,7 +245,6 @@ public class VolumeControlPulse : VolumeControl (active_output_now != VolumeControl.ActiveOutput.CALL_MODE && active_output_before != VolumeControl.ActiveOutput.CALL_MODE)) { this.active_output_changed (active_output_now); - update_high_volume(); } if (_pulse_use_stream_restore == false && @@ -686,45 +678,6 @@ public class VolumeControlPulse : VolumeControl && volume_changed) { start_local_volume_timer(); } - - update_high_volume(); - } - } - - /** HIGH VOLUME PROPERTY **/ - - private bool _high_volume = false; - public override bool high_volume { - get { return this._high_volume; } - private set { this._high_volume = value; } - } - private void init_high_volume() { - _options.loud_changed.connect(() => update_high_volume()); - update_high_volume(); - } - private void update_high_volume() { - var new_high_volume = calculate_high_volume(); - if (high_volume != new_high_volume) { - debug("changing high_volume from %d to %d", (int)high_volume, (int)new_high_volume); - high_volume = new_high_volume; - } - } - private bool calculate_high_volume() { - return calculate_high_volume_from_volume(_volume.volume); - } - private bool calculate_high_volume_from_volume(double volume) { - return _active_port_headphone - && _options.is_loud(_volume) - && (stream == "multimedia"); - } - - public override void clamp_to_high_volume() { - if (_high_volume && _options.is_loud(_volume)) { - var vol = new VolumeControl.Volume(); - vol.volume = _volume.volume.clamp(0, volume_to_double(_options.loud_volume())); - vol.reason = _volume.reason; - debug("Clamping from %f down to %f", _volume.volume, vol.volume); - volume = vol; } } diff --git a/src/volume-control.vala b/src/volume-control.vala index e59997c..53e4336 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -54,7 +54,6 @@ public abstract class VolumeControl : Object public virtual string stream { get { return ""; } } public bool ready { get; protected set; default = false; } public virtual bool active_mic { get { return false; } set { } } - public virtual bool high_volume { get { return false; } protected set { } } public virtual bool mute { get { return false; } } public bool is_playing { get; protected set; default = false; } public virtual VolumeControl.ActiveOutput active_output { get { return VolumeControl.ActiveOutput.SPEAKERS; } } @@ -63,8 +62,6 @@ public abstract class VolumeControl : Object public virtual Volume volume { get { return _volume; } set { } } public virtual double mic_volume { get { return 0.0; } set { } } - public virtual void clamp_to_high_volume() { } - public abstract void set_mute (bool mute); public void set_volume_clamp (double unclamped, VolumeControl.VolumeReasons reason) { diff --git a/src/volume-warning.vala b/src/volume-warning.vala index 5809f61..423f129 100644 --- a/src/volume-warning.vala +++ b/src/volume-warning.vala @@ -30,6 +30,9 @@ public class VolumeWarning : VolumeControl // true if the warning dialog is currently active public bool active { get; public set; default = false; } + // true iff we're playing unapproved loud multimedia over headphones + public bool high_volume { get; protected set; default = false; } + // FIXME: this is temporarily necessary while bootstrapping this // code because VolumeWarning is still subclassed from VolumeControl, // but TBH we don't need any concept of mute here. @@ -638,7 +641,6 @@ public class VolumeWarning : VolumeControl /** HIGH VOLUME PROPERTY **/ - private bool _high_volume = false; public bool ignore_high_volume { get { if (_ignore_warning_this_time) { @@ -650,10 +652,6 @@ public class VolumeWarning : VolumeControl } set { } } - public override bool high_volume { - get { return this._high_volume; } - private set { this._high_volume = value; } - } private void init_high_volume() { _options.loud_changed.connect(() => update_high_volume()); update_high_volume(); @@ -674,7 +672,7 @@ public class VolumeWarning : VolumeControl && (stream == "multimedia"); } - public override void clamp_to_high_volume() { + public void clamp_to_high_volume() { if (_high_volume && _options.is_loud(_volume)) { var vol = new VolumeControl.Volume(); vol.volume = _volume.volume.clamp(0, volume_to_double(_options.loud_volume())); |