aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2014-12-04 11:24:48 -0600
committerTed Gould <ted@gould.cx>2014-12-04 11:24:48 -0600
commit91b54a8a59cd51813d750efbe01203b7fe1d0e3c (patch)
treea784b5e0f50bbd4d8da7efedaf5ee5f46b09f1f7
parent66cd2203d5fcee99d3264bc6f23c8d4683c299bf (diff)
downloadayatana-indicator-sound-91b54a8a59cd51813d750efbe01203b7fe1d0e3c.tar.gz
ayatana-indicator-sound-91b54a8a59cd51813d750efbe01203b7fe1d0e3c.tar.bz2
ayatana-indicator-sound-91b54a8a59cd51813d750efbe01203b7fe1d0e3c.zip
Encapsulate high volume better
-rw-r--r--src/volume-control.vala21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/volume-control.vala b/src/volume-control.vala
index 22212d5..193e621 100644
--- a/src/volume-control.vala
+++ b/src/volume-control.vala
@@ -77,7 +77,11 @@ public class VolumeControl : Object
public bool active_mic { get; private set; default = false; }
/** true when high volume warnings should be shown */
- public bool high_volume { get; set; }
+ public bool high_volume {
+ get {
+ return this._volume > 0.75 && _active_port_headphone;
+ }
+ }
public VolumeControl ()
{
@@ -152,7 +156,7 @@ public class VolumeControl : Object
private void sink_info_cb_for_props (Context c, SinkInfo? i, int eol)
{
- bool old_active_port_headphone = this._active_port_headphone;
+ bool old_high_volume = this.high_volume;
if (i == null)
return;
@@ -189,8 +193,10 @@ public class VolumeControl : Object
_volume = volume_to_double (i.volume.max ());
this.notify_property("volume");
start_local_volume_timer();
- } else if (this._active_port_headphone != old_active_port_headphone) {
- this.notify_property("volume");
+ }
+
+ if (this.high_volume != old_high_volume) {
+ this.notify_property("high-volume");
}
}
@@ -579,13 +585,18 @@ public class VolumeControl : Object
return false;
if (_volume != volume) {
+ var old_high_volume = this.high_volume;
+
_volume = volume;
if (_pulse_use_stream_restore)
set_volume_active_role.begin ();
else
context.get_server_info (server_info_cb_for_set_volume);
- high_volume = volume > 0.75 && _active_port_headphone;
+ this.notify_property("volume");
+
+ if (this.high_volume != old_high_volume)
+ this.notify_property("high-volume");
return true;
} else {