From e964fb77076144d577f85260896a18648b5b40f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mirco=20M=C3=BCller?= Date: Thu, 31 Jul 2014 16:46:43 +0200 Subject: Test use of synchronous notifications for volume-changes. --- src/volume-control.vala | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/volume-control.vala b/src/volume-control.vala index 2efa186..5a16621 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -19,6 +19,7 @@ */ using PulseAudio; +using Notify; [CCode(cname="pa_cvolume_set", cheader_filename = "pulse/volume.h")] extern unowned PulseAudio.CVolume? vol_set (PulseAudio.CVolume? cv, uint channels, PulseAudio.Volume v); @@ -51,6 +52,7 @@ public class VolumeControl : Object private uint _accountservice_volume_timer = 0; private bool _send_next_local_volume = false; private double _account_service_volume = 0.0; + private Notify.Notification _notification; public signal void volume_changed (double v); public signal void mic_volume_changed (double v); @@ -68,6 +70,13 @@ public class VolumeControl : Object _mute_cancellable = new Cancellable (); _volume_cancellable = new Cancellable (); + + Notify.init ("Volume"); + _notification = new Notify.Notification("Volume", "", "audio-volume-muted"); + _notification.set_hint ("value", 0); + _notification.set_hint ("x-canonical-private-synchronous", "true"); + _notification.set_hint ("x-canonical-non-shaped-icon", "true"); + setup_accountsservice.begin (); this.reconnect_to_pulse (); @@ -301,8 +310,12 @@ public class VolumeControl : Object private void set_volume_success_cb (Context c, int success) { - if ((bool)success) + if ((bool)success) { volume_changed (_volume); + _notification.update ("Volume", "", "audio-volume-medium"); + _notification.set_hint ("value", _volume); + _notification.show (); + } } private void sink_info_set_volume_cb (Context c, SinkInfo? i, int eol) -- cgit v1.2.3 From e6886725945a09d3f286d35b313e23c94c2a091b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mirco=20M=C3=BCller?= Date: Tue, 5 Aug 2014 11:13:51 +0200 Subject: Move the triggering of the volume up/down notification into set_volume(). --- src/volume-control.vala | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/volume-control.vala b/src/volume-control.vala index 5a16621..6148b79 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -310,12 +310,8 @@ public class VolumeControl : Object private void set_volume_success_cb (Context c, int success) { - if ((bool)success) { + if ((bool)success) volume_changed (_volume); - _notification.update ("Volume", "", "audio-volume-medium"); - _notification.set_hint ("value", _volume); - _notification.show (); - } } private void sink_info_set_volume_cb (Context c, SinkInfo? i, int eol) @@ -353,8 +349,20 @@ public class VolumeControl : Object public void set_volume (double volume) { - if (set_volume_internal (volume)) + if (set_volume_internal (volume)) { + if (_volume == 0.0) + _notification.update ("Volume", "", "audio-volume-muted"); + if (_volume > 0.0 && _volume <= 0.33) + _notification.update ("Volume", "", "audio-volume-low"); + if (_volume > 0.33 && _volume <= 0.66) + _notification.update ("Volume", "", "audio-volume-medium"); + if (_volume > 0.66 && _volume <= 1.0) + _notification.update ("Volume", "", "audio-volume-high"); + _notification.set_hint ("value", _volume * 100.0); + _notification.show (); + start_local_volume_timer(); + } } void set_mic_volume_success_cb (Context c, int success) -- cgit v1.2.3 From 965fdf8817d11d382f7012999d48fa702c91a628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mirco=20M=C3=BCller?= Date: Fri, 19 Sep 2014 00:08:57 +0200 Subject: Use a sound-file via the corresponding hint to play back while the volume is changed to give the user also an audible feedback. --- src/volume-control.vala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/volume-control.vala b/src/volume-control.vala index 6148b79..8de5d2f 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -76,6 +76,7 @@ public class VolumeControl : Object _notification.set_hint ("value", 0); _notification.set_hint ("x-canonical-private-synchronous", "true"); _notification.set_hint ("x-canonical-non-shaped-icon", "true"); + _notification.set_hint ("sound-file", "/usr/share/sounds/ubuntu/stereo/message.ogg"); setup_accountsservice.begin (); -- cgit v1.2.3 From 3297337f253efc9ae15b07b78d3e1e9a0611e5ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mirco=20M=C3=BCller?= Date: Fri, 19 Sep 2014 19:41:50 +0200 Subject: Trigger synchronous notification upon every volume-change attempt, thus the user gets to see visual and audible feedback every time a volume-key is pressed. --- src/volume-control.vala | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/volume-control.vala b/src/volume-control.vala index 8de5d2f..33ba878 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -76,7 +76,6 @@ public class VolumeControl : Object _notification.set_hint ("value", 0); _notification.set_hint ("x-canonical-private-synchronous", "true"); _notification.set_hint ("x-canonical-non-shaped-icon", "true"); - _notification.set_hint ("sound-file", "/usr/share/sounds/ubuntu/stereo/message.ogg"); setup_accountsservice.begin (); @@ -350,18 +349,19 @@ public class VolumeControl : Object public void set_volume (double volume) { - if (set_volume_internal (volume)) { - if (_volume == 0.0) - _notification.update ("Volume", "", "audio-volume-muted"); - if (_volume > 0.0 && _volume <= 0.33) - _notification.update ("Volume", "", "audio-volume-low"); - if (_volume > 0.33 && _volume <= 0.66) - _notification.update ("Volume", "", "audio-volume-medium"); - if (_volume > 0.66 && _volume <= 1.0) - _notification.update ("Volume", "", "audio-volume-high"); - _notification.set_hint ("value", _volume * 100.0); - _notification.show (); + if (_volume == 0.0) + _notification.update ("Volume", "", "audio-volume-muted"); + if (_volume > 0.0 && _volume <= 0.33) + _notification.update ("Volume", "", "audio-volume-low"); + if (_volume > 0.33 && _volume <= 0.66) + _notification.update ("Volume", "", "audio-volume-medium"); + if (_volume > 0.66 && _volume <= 1.0) + _notification.update ("Volume", "", "audio-volume-high"); + _notification.set_hint ("value", _volume * 100.0); + _notification.set_hint ("sound-file", "/usr/share/sounds/ubuntu/stereo/message.ogg"); + _notification.show (); + if (set_volume_internal (volume)) { start_local_volume_timer(); } } -- cgit v1.2.3