From 03a879f644d27ec45a97caa7681e4428f7b341fd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 8 Oct 2014 13:40:04 -0500 Subject: Make volume string translatable --- src/volume-control.vala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/volume-control.vala') diff --git a/src/volume-control.vala b/src/volume-control.vala index 5a8bbe2..a4c97b6 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -578,13 +578,13 @@ public class VolumeControl : Object public void set_volume (double volume) { if (_volume == 0.0) - _notification.update ("Volume", "", "audio-volume-muted"); + _notification.update (_("Volume"), "", "audio-volume-muted"); if (_volume > 0.0 && _volume <= 0.33) - _notification.update ("Volume", "", "audio-volume-low"); + _notification.update (_("Volume"), "", "audio-volume-low"); if (_volume > 0.33 && _volume <= 0.66) - _notification.update ("Volume", "", "audio-volume-medium"); + _notification.update (_("Volume"), "", "audio-volume-medium"); if (_volume > 0.66 && _volume <= 1.0) - _notification.update ("Volume", "", "audio-volume-high"); + _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 (); -- cgit v1.2.3 From 27e2a3618ac09e9ca3dbbc30ed4d8ebec71feba9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 9 Oct 2014 09:47:01 -0500 Subject: No audio ping if we're doing multimedia, and no notification if we're not on phone --- src/volume-control.vala | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src/volume-control.vala') diff --git a/src/volume-control.vala b/src/volume-control.vala index a4c97b6..17367e8 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -577,17 +577,22 @@ public class VolumeControl : Object public void set_volume (double 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.set_hint ("sound-file", "/usr/share/sounds/ubuntu/stereo/message.ogg"); - _notification.show (); + /* Using this to detect whether we're on the phone or not */ + if (_pulse_use_stream_restore) { + 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); + if (_active_sink_input == -1 || _valid_roles[_active_sink_input] != "multimedia") + /* No audio ping if we're playing multimedia */ + _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 From 228153f72649485111052f5f13a84fd73f290b94 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 9 Oct 2014 21:52:03 -0500 Subject: Make sure to clear the sound hint --- src/volume-control.vala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/volume-control.vala') diff --git a/src/volume-control.vala b/src/volume-control.vala index 17367e8..86b976e 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -588,9 +588,12 @@ public class VolumeControl : Object if (_volume > 0.66 && _volume <= 1.0) _notification.update (_("Volume"), "", "audio-volume-high"); _notification.set_hint ("value", _volume * 100.0); - if (_active_sink_input == -1 || _valid_roles[_active_sink_input] != "multimedia") + if (_active_sink_input == -1 || _valid_roles[_active_sink_input] != "multimedia") { /* No audio ping if we're playing multimedia */ _notification.set_hint ("sound-file", "/usr/share/sounds/ubuntu/stereo/message.ogg"); + } else { + _notification.set_hint ("sound-file", null); + } _notification.show (); } -- cgit v1.2.3 From 365f0a5af2b6327531f49a0fa3754359063dfea1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 9 Oct 2014 21:54:40 -0500 Subject: Catch the error that show can throw and present a warning --- src/volume-control.vala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/volume-control.vala') diff --git a/src/volume-control.vala b/src/volume-control.vala index 86b976e..dbc1797 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -594,7 +594,12 @@ public class VolumeControl : Object } else { _notification.set_hint ("sound-file", null); } - _notification.show (); + + try { + _notification.show (); + } catch (GLib.Error e) { + warning("Unable to send volume change notification: %s", e.message); + } } if (set_volume_internal (volume)) { -- cgit v1.2.3 From 70601ef284279d6db7b8add3c50cd0350fdfb707 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 9 Oct 2014 21:58:20 -0500 Subject: Make sure to use the passed parameter for the volume. --- src/volume-control.vala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/volume-control.vala') diff --git a/src/volume-control.vala b/src/volume-control.vala index dbc1797..e35b3e5 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -579,15 +579,15 @@ public class VolumeControl : Object { /* Using this to detect whether we're on the phone or not */ if (_pulse_use_stream_restore) { - if (_volume == 0.0) + if (volume == 0.0) _notification.update (_("Volume"), "", "audio-volume-muted"); - if (_volume > 0.0 && _volume <= 0.33) + if (volume > 0.0 && volume <= 0.33) _notification.update (_("Volume"), "", "audio-volume-low"); - if (_volume > 0.33 && _volume <= 0.66) + if (volume > 0.33 && volume <= 0.66) _notification.update (_("Volume"), "", "audio-volume-medium"); - if (_volume > 0.66 && _volume <= 1.0) + if (volume > 0.66 && volume <= 1.0) _notification.update (_("Volume"), "", "audio-volume-high"); - _notification.set_hint ("value", _volume * 100.0); + _notification.set_hint ("value", volume * 100.0); if (_active_sink_input == -1 || _valid_roles[_active_sink_input] != "multimedia") { /* No audio ping if we're playing multimedia */ _notification.set_hint ("sound-file", "/usr/share/sounds/ubuntu/stereo/message.ogg"); -- cgit v1.2.3 From a0dc1f66614ac40bc527ccad537ff607a4bef642 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 9 Oct 2014 22:06:15 -0500 Subject: Didn't make initial string translated --- src/volume-control.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/volume-control.vala') diff --git a/src/volume-control.vala b/src/volume-control.vala index e35b3e5..aee670e 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -88,7 +88,7 @@ public class VolumeControl : Object _volume_cancellable = new Cancellable (); Notify.init ("Volume"); - _notification = new Notify.Notification("Volume", "", "audio-volume-muted"); + _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"); -- cgit v1.2.3 From 4da707591f393735ed3306421e2c1518eff4d3e5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 9 Oct 2014 22:15:35 -0500 Subject: Ensure we send an integer to the notification service --- src/volume-control.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/volume-control.vala') diff --git a/src/volume-control.vala b/src/volume-control.vala index aee670e..0541397 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -587,7 +587,7 @@ public class VolumeControl : Object _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 ("value", (int32)(volume * 100.0)); if (_active_sink_input == -1 || _valid_roles[_active_sink_input] != "multimedia") { /* No audio ping if we're playing multimedia */ _notification.set_hint ("sound-file", "/usr/share/sounds/ubuntu/stereo/message.ogg"); -- cgit v1.2.3