diff options
-rw-r--r-- | src/service.vala | 33 | ||||
-rw-r--r-- | src/volume-control-pulse.vala | 19 |
2 files changed, 26 insertions, 26 deletions
diff --git a/src/service.vala b/src/service.vala index 8da44da..f1c37a8 100644 --- a/src/service.vala +++ b/src/service.vala @@ -318,23 +318,26 @@ public class IndicatorSound.Service: Object { if (notify_server_supports_sync && !block_info_notifications) { /* Determine Label */ - string volume_label = ""; - if (loud) { - volume_label = _("High volume can damage your hearing."); - } + unowned string volume_label = loud + ? _("High volume can damage your hearing.") + : ""; /* Choose an icon */ - string icon = ""; - if (loud) - icon = "audio-volume-high"; - else if (volume_control.volume.volume <= 0.0) - icon = "audio-volume-muted"; - else if (volume_control.volume.volume <= 0.3) - icon = "audio-volume-low"; - else if (volume_control.volume.volume <= 0.7) - icon = "audio-volume-medium"; - else + unowned string icon; + if (loud) { icon = "audio-volume-high"; + } else { + var volume = volume_control.volume.volume; + + if (volume <= 0.0) + icon = "audio-volume-muted"; + else if (volume <= 0.3) + icon = "audio-volume-low"; + else if (volume <= 0.7) + icon = "audio-volume-medium"; + else + icon = "audio-volume-high"; + } /* Reset the notification */ var n = this.info_notification; @@ -634,7 +637,7 @@ public class IndicatorSound.Service: Object { } private void clamp_to_high_soon() { - const uint interval_msec = 200; /* arbitrary, but works */ + const uint interval_msec = 200; if (_clamp_to_high_timeout == 0) _clamp_to_high_timeout = Timeout.add(interval_msec, clamp_to_high_idle); } diff --git a/src/volume-control-pulse.vala b/src/volume-control-pulse.vala index 21e7a5c..81938fe 100644 --- a/src/volume-control-pulse.vala +++ b/src/volume-control-pulse.vala @@ -656,12 +656,9 @@ public class VolumeControlPulse : VolumeControl } } private double calculate_max_volume () { - string decibel_key; - if (_shared_settings.get_boolean("allow-amplified-volume")) - decibel_key = "amplified-volume-decibels"; - else - decibel_key = "normal-volume-decibels"; - + unowned string decibel_key = _shared_settings.get_boolean("allow-amplified-volume") + ? "amplified-volume-decibels" + : "normal-volume-decibels"; var volume_dB = _settings.get_double(decibel_key); var volume_sw = PulseAudio.Volume.sw_from_dB (volume_dB); return volume_to_double (volume_sw); @@ -670,7 +667,7 @@ public class VolumeControlPulse : VolumeControl /** HIGH VOLUME PROPERTY **/ private bool _warning_volume_enabled; - private double _warning_volume_norms; + private double _warning_volume_norms; /* 1.0 == PA_VOLUME_NORM */ private bool _high_volume = false; public override bool high_volume { get { return this._high_volume; } @@ -720,9 +717,9 @@ public class VolumeControlPulse : VolumeControl /** HIGH VOLUME APPROVED PROPERTY **/ private bool _high_volume_approved = false; + private uint _high_volume_approved_timer = 0; private int64 _high_volume_approved_at = 0; private int64 _high_volume_approved_ttl_usec = 0; - private uint _high_volume_approved_timer = 0; public override bool high_volume_approved { get { return this._high_volume_approved; } private set { this._high_volume_approved = value; } @@ -745,7 +742,7 @@ public class VolumeControlPulse : VolumeControl int64 now = GLib.get_monotonic_time(); if (expires_at > now) { var seconds_left = 1 + ((expires_at - now) / 1000000); - _high_volume_approved_timer = Timeout.add_seconds((uint)seconds_left, on_high_volume_timer); + _high_volume_approved_timer = Timeout.add_seconds((uint)seconds_left, on_high_volume_approved_timer); } } } @@ -755,7 +752,7 @@ public class VolumeControlPulse : VolumeControl _high_volume_approved_timer = 0; } } - private bool on_high_volume_timer() { + private bool on_high_volume_approved_timer() { _high_volume_approved_timer = 0; update_high_volume_approved(); return false; /* Source.REMOVE */ @@ -774,8 +771,8 @@ public class VolumeControlPulse : VolumeControl } public override void approve_high_volume() { _high_volume_approved_at = GLib.get_monotonic_time(); - update_high_volume_approved_timer(); update_high_volume_approved(); + update_high_volume_approved_timer(); } |