aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-12-04 11:46:27 +0100
committerXavi Garcia Mena <xavi.garcia.mena@canonical.com>2015-12-04 11:46:27 +0100
commit7ec5db7e050505bbcb04a70edacec4075389a2df (patch)
treeca842f2e33bd8ee264a58db2c7e08bfcf8a555a4
parentc61e4c4f2c5e24f374c0d6e3c90c318443403c94 (diff)
downloadayatana-indicator-sound-7ec5db7e050505bbcb04a70edacec4075389a2df.tar.gz
ayatana-indicator-sound-7ec5db7e050505bbcb04a70edacec4075389a2df.tar.bz2
ayatana-indicator-sound-7ec5db7e050505bbcb04a70edacec4075389a2df.zip
Setting user selected volume when pressing OK in the high volume dialog
-rw-r--r--src/service.vala12
-rw-r--r--src/volume-control.vala6
2 files changed, 13 insertions, 5 deletions
diff --git a/src/service.vala b/src/service.vala
index 923aba2..312fec5 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -629,11 +629,13 @@ public class IndicatorSound.Service: Object {
warn_notification.add_action ("ok", _("OK"), (n, a) => {
stop_clamp_to_high_timeout();
volume_control.approve_high_volume ();
- if (_pre_warn_volume != null) {
- var tmp = _pre_warn_volume;
- _pre_warn_volume = null;
- volume_control.volume = tmp;
- }
+ // restore the volume the user introduced
+ VolumeControl.Volume vol = new VolumeControl.Volume();
+ vol.volume = volume_control.get_pre_clamped_volume();
+ vol.reason = VolumeControl.VolumeReasons.USER_KEYPRESS;
+ _pre_warn_volume = null;
+ volume_control.volume = vol;
+
waiting_user_approve_warn = false;
});
warn_notification.add_action ("cancel", _("Cancel"), (n, a) => {
diff --git a/src/volume-control.vala b/src/volume-control.vala
index 30dcfcf..7117990 100644
--- a/src/volume-control.vala
+++ b/src/volume-control.vala
@@ -54,6 +54,7 @@ public abstract class VolumeControl : Object
public virtual bool is_playing { get { return false; } }
public virtual VolumeControl.ActiveOutput active_output { get { return VolumeControl.ActiveOutput.SPEAKERS; } }
private Volume _volume;
+ private double _pre_clamp_volume;
public virtual Volume volume { get { return _volume; } set { } }
public virtual double mic_volume { get { return 0.0; } set { } }
public virtual double max_volume { get { return 1.0; } protected set { } }
@@ -70,6 +71,11 @@ public abstract class VolumeControl : Object
v.volume = unclamped.clamp (0.0, this.max_volume);
v.reason = reason;
this.volume = v;
+ _pre_clamp_volume = unclamped;
+ }
+
+ public double get_pre_clamped_volume () {
+ return _pre_clamp_volume;
}
public signal void active_output_changed (VolumeControl.ActiveOutput active_output);