aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2014-10-15 16:18:44 +0000
committerCI bot <ps-jenkins@lists.canonical.com>2014-10-15 16:18:44 +0000
commit793ca099b8ce34d87596dfbb4bce48c6f3d197a8 (patch)
tree7df8ac0c1c3ea06065ca696a195b34071a2c6191
parentfe008a1d624ae54ae95df3aa4bb0b53bd757721d (diff)
parent4da707591f393735ed3306421e2c1518eff4d3e5 (diff)
downloadayatana-indicator-sound-793ca099b8ce34d87596dfbb4bce48c6f3d197a8.tar.gz
ayatana-indicator-sound-793ca099b8ce34d87596dfbb4bce48c6f3d197a8.tar.bz2
ayatana-indicator-sound-793ca099b8ce34d87596dfbb4bce48c6f3d197a8.zip
Show notifications on volume change Fixes: 1378564, 1378961
-rw-r--r--src/volume-control.vala37
-rw-r--r--tests/manual17
2 files changed, 53 insertions, 1 deletions
diff --git a/src/volume-control.vala b/src/volume-control.vala
index ba87de5..0541397 100644
--- a/src/volume-control.vala
+++ b/src/volume-control.vala
@@ -19,6 +19,7 @@
*/
using PulseAudio;
+using Notify;
using Gee;
[CCode(cname="pa_cvolume_set", cheader_filename = "pulse/volume.h")]
@@ -67,6 +68,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);
@@ -84,6 +86,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 ();
@@ -568,8 +577,34 @@ public class VolumeControl : Object
public void set_volume (double volume)
{
- if (set_volume_internal (volume))
+ /* 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", (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");
+ } else {
+ _notification.set_hint ("sound-file", null);
+ }
+
+ try {
+ _notification.show ();
+ } catch (GLib.Error e) {
+ warning("Unable to send volume change notification: %s", e.message);
+ }
+ }
+
+ if (set_volume_internal (volume)) {
start_local_volume_timer();
+ }
}
void set_mic_volume_success_cb (Context c, int success)
diff --git a/tests/manual b/tests/manual
index 201465c..d9fb7d5 100644
--- a/tests/manual
+++ b/tests/manual
@@ -22,3 +22,20 @@ Test-case indicator-sound/unity8-items-check
<dd>The menu is populated with items</dd>
</dl>
+Test-case indicator-sound/unity8-sound-notifications
+<dl>
+ <dt>Adjust volume using HW keys if available</dt>
+ <dd>A notification bubble should appear with the sound volume</dd>
+ <dd>An audibule sound should play at the level of the audio</dd>
+ <dt>Adjust volume with slider in sound indicator</dt>
+ <dd>A notification bubble should appear with the sound volume</dd>
+ <dd>An audibule sound should play at the level of the audio</dd>
+ <dt>Open a video with sound and play in media player</dt>
+ <dd>The video should play and the sound should be audible</dd>
+ <dt>Adjust volume using HW keys if available</dt>
+ <dd>A notification bubble should appear with the sound volume</dd>
+ <dd>No notification sound should be heard</dd>
+ <dt>Adjust volume with slider in sound indicator</dt>
+ <dd>A notification bubble should appear with the sound volume</dd>
+ <dd>No notification sound should be heard</dd>
+</dl>