diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2015-08-12 20:55:01 +0000 |
---|---|---|
committer | CI Train Bot <ci-train-bot@canonical.com> | 2015-08-12 20:55:01 +0000 |
commit | cd0495a9ef8beca52290b01c2df5c8ba2554e03b (patch) | |
tree | 677c774c380914e03c76646d22cf40200fe4803c /src/volume-control.vala | |
parent | de077cfdb0a73fc61218ee9f769a60e73499ebb9 (diff) | |
parent | 480d998efb8bcd94401ff2d7c40a1fb9b81d8db1 (diff) | |
download | ayatana-indicator-sound-cd0495a9ef8beca52290b01c2df5c8ba2554e03b.tar.gz ayatana-indicator-sound-cd0495a9ef8beca52290b01c2df5c8ba2554e03b.tar.bz2 ayatana-indicator-sound-cd0495a9ef8beca52290b01c2df5c8ba2554e03b.zip |
When showing a "Loud volumes can damage your hearing" confirmation warning, clamp the volume until the user hits "OK". Fixes: #1481913
Approved by: Antti Kaijanmäki, PS Jenkins bot
Diffstat (limited to 'src/volume-control.vala')
-rw-r--r-- | src/volume-control.vala | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/volume-control.vala b/src/volume-control.vala index 3f1c799..6efac35 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -36,12 +36,24 @@ public abstract class VolumeControl : Object public virtual string stream { get { return ""; } } public virtual bool ready { get { return false; } set { } } public virtual bool active_mic { get { return false; } set { } } - public virtual bool high_volume { get { return false; } } + public virtual bool high_volume { get { return false; } protected set { } } public virtual bool mute { get { return false; } } public virtual bool is_playing { get { return false; } } private Volume _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 { } } + + public virtual bool high_volume_approved { get { return false; } protected set { } } + public virtual void approve_high_volume() { } + public virtual void clamp_to_high_volume() { } public abstract void set_mute (bool mute); + + public void set_volume_clamp (double unclamped, VolumeControl.VolumeReasons reason) { + var v = new VolumeControl.Volume(); + v.volume = unclamped.clamp (0.0, this.max_volume); + v.reason = reason; + this.volume = v; + } } |