diff options
author | charles kerr <charlesk@canonical.com> | 2015-12-21 17:18:09 -0600 |
---|---|---|
committer | charles kerr <charlesk@canonical.com> | 2015-12-21 17:18:09 -0600 |
commit | ccb78ba3fe467462eaa182625f965483ce331299 (patch) | |
tree | b4dd7a086d0ddad10174c4e080a45e7d1238fe90 /src/volume-warning.vala | |
parent | 312c160be7de600d6a110cd5ab5101dd9c0143d0 (diff) | |
download | ayatana-indicator-sound-ccb78ba3fe467462eaa182625f965483ce331299.tar.gz ayatana-indicator-sound-ccb78ba3fe467462eaa182625f965483ce331299.tar.bz2 ayatana-indicator-sound-ccb78ba3fe467462eaa182625f965483ce331299.zip |
call show() in an idle func to avoid callback cycles
Diffstat (limited to 'src/volume-warning.vala')
-rw-r--r-- | src/volume-warning.vala | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/volume-warning.vala b/src/volume-warning.vala index 95ba929..2ae3b9b 100644 --- a/src/volume-warning.vala +++ b/src/volume-warning.vala @@ -118,6 +118,7 @@ public class VolumeWarning : Object private void stop_all_timers() { stop_high_volume_approved_timer(); + stop_show_timeout(); } /*** @@ -350,17 +351,42 @@ public class VolumeWarning : Object private PulseAudio.Volume _ok_volume = PulseAudio.Volume.INVALID; + private uint _show_timeout = 0; + + private void stop_show_timeout() { + if (_show_timeout != 0) { + Source.remove(_show_timeout); + _show_timeout = 0; + } + } + + private void show_soon() { + const uint interval_msec = 200; + if (_show_timeout == 0) + _show_timeout = Timeout.add(interval_msec, show_idle); + } + + private bool show_idle() { + _show_timeout = 0; + this.show(); + return false; // Source.REMOVE; + } + private void show() { + GLib.message("in show()"); _ok_volume = multimedia_volume; + GLib.message("calling notification.show"); _notification.show(); + GLib.message("setting 'active' property to true"); this.active = true; // lower the volume to just under the warning level + GLib.message("setting multimedia volume to be just under the warning level"); set_pulse_multimedia_volume.begin (_options.loud_volume()-1); + GLib.message("leaving show()"); } private void on_user_response(IndicatorSound.WarnNotification.Response response) { - _notification.close(); if (response == IndicatorSound.WarnNotification.Response.OK) { approve_high_volume(); @@ -368,7 +394,6 @@ public class VolumeWarning : Object } _ok_volume = PulseAudio.Volume.INVALID; - this.active = false; } } |