aboutsummaryrefslogtreecommitdiff
path: root/src/volume-warning.vala
diff options
context:
space:
mode:
authorcharles kerr <charlesk@canonical.com>2015-12-30 16:03:02 -0600
committercharles kerr <charlesk@canonical.com>2015-12-30 16:03:02 -0600
commit521915475eb73ae22e2c270c687f1f4d5c7c0465 (patch)
tree7cdb4c2a75f06ef6b1558c12557800684b55d0fe /src/volume-warning.vala
parent812e71f004272f635ba9217ef2f16aa9567196b3 (diff)
downloadayatana-indicator-sound-521915475eb73ae22e2c270c687f1f4d5c7c0465.tar.gz
ayatana-indicator-sound-521915475eb73ae22e2c270c687f1f4d5c7c0465.tar.bz2
ayatana-indicator-sound-521915475eb73ae22e2c270c687f1f4d5c7c0465.zip
simplify the Options class' properties
Diffstat (limited to 'src/volume-warning.vala')
-rw-r--r--src/volume-warning.vala28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/volume-warning.vala b/src/volume-warning.vala
index 49ed3a8..d475570 100644
--- a/src/volume-warning.vala
+++ b/src/volume-warning.vala
@@ -105,27 +105,29 @@ public abstract class VolumeWarning : Object
**/
private void init_high_volume () {
- _options.loud_changed.connect(() => update_high_volume());
this.notify["multimedia-volume"].connect(() => update_high_volume());
this.notify["multimedia-active"].connect(() => update_high_volume());
this.notify["headphones-active"].connect(() => update_high_volume());
this.notify["high-volume-approved"].connect(() => update_high_volume());
+ _options.notify["loud-volume"].connect(() => update_high_volume());
+ _options.notify["loud-warning-enabled"].connect(() => update_high_volume());
update_high_volume();
}
private void update_high_volume () {
- PulseAudio.Volume mm_vol = multimedia_volume;
- var approved = high_volume_approved;
- var hp_active = headphones_active;
- var mm_active = multimedia_active;
- GLib.message("calculating high volume... headphones_active %d high_volume_approved %d multimedia_active %d multimedia_volume %d is_invalid %d, is_loud %d", (int)hp_active, (int)approved, (int)mm_active, (int)mm_vol, (int)(mm_vol == PulseAudio.Volume.INVALID), (int)_options.is_loud_pulse(mm_vol));
- var new_high_volume = hp_active && !approved && mm_active && (mm_vol != PulseAudio.Volume.INVALID) && _options.is_loud_pulse(mm_vol);
- GLib.message("so the new high_volume is %d, was %d", (int)new_high_volume, (int)high_volume);
- if (high_volume != new_high_volume) {
- debug("changing high_volume from %d to %d", (int)high_volume, (int)new_high_volume);
- if (new_high_volume && !active)
+
+ var newval = _options.loud_warning_enabled
+ && headphones_active
+ && multimedia_active
+ && !high_volume_approved
+ && (multimedia_volume != PulseAudio.Volume.INVALID)
+ && (multimedia_volume >= _options.loud_volume);
+
+ if (high_volume != newval) {
+ debug("changing high_volume from %d to %d", (int)high_volume, (int)newval);
+ if (newval && !active)
show();
- high_volume = new_high_volume;
+ high_volume = newval;
}
}
@@ -202,7 +204,7 @@ public abstract class VolumeWarning : Object
this.active = true;
// lower the volume to just under the warning level
- sound_system_set_multimedia_volume (_options.loud_volume()-1);
+ sound_system_set_multimedia_volume (_options.loud_volume-1);
}
private void on_user_response(IndicatorSound.WarnNotification.Response response) {