aboutsummaryrefslogtreecommitdiff
path: root/src/volume-control.vala
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2014-10-10 12:43:29 -0500
committerTed Gould <ted@gould.cx>2014-10-10 12:43:29 -0500
commitf079f5a27a70a377b8787610f1bef62d8af7fe7c (patch)
treeb6c0dd2610c6fa5275c2945b5ede7129f0dee722 /src/volume-control.vala
parent3470d25af3a4b632d9a1960a05089fe2666b3f5a (diff)
downloadayatana-indicator-sound-f079f5a27a70a377b8787610f1bef62d8af7fe7c.tar.gz
ayatana-indicator-sound-f079f5a27a70a377b8787610f1bef62d8af7fe7c.tar.bz2
ayatana-indicator-sound-f079f5a27a70a377b8787610f1bef62d8af7fe7c.zip
Make notifications check for high volumes and change based on that
Diffstat (limited to 'src/volume-control.vala')
-rw-r--r--src/volume-control.vala42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/volume-control.vala b/src/volume-control.vala
index f9db556..0e5abbb 100644
--- a/src/volume-control.vala
+++ b/src/volume-control.vala
@@ -580,22 +580,42 @@ 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)
- _notification.update (_("Volume"), "", "audio-volume-muted");
+ /* Watch for extreme */
+ bool extreme_volume = false;
+ if (volume > 0.75) /* TODO: Also if headphones */
+ extreme_volume = true;
+
+ /* Determine Label */
+ string volume_label = _("Volume");
+ if (extreme_volume)
+ volume_label = _("High volume");
+
+ /* Choose an icon */
+ string icon = "audio-volume-muted";
if (volume > 0.0 && volume <= 0.33)
- _notification.update (_("Volume"), "", "audio-volume-low");
+ icon = "audio-volume-low";
if (volume > 0.33 && volume <= 0.66)
- _notification.update (_("Volume"), "", "audio-volume-medium");
+ icon = "audio-volume-medium";
if (volume > 0.66 && volume <= 1.0)
- _notification.update (_("Volume"), "", "audio-volume-high");
+ icon = "audio-volume-high";
+
+ /* Choose a sound */
+ string? sound = null;
+ if (_active_sink_input == -1 || _valid_roles[_active_sink_input] != "multimedia")
+ sound = "/usr/share/sounds/ubuntu/stereo/message.ogg";
+
+ /* Check tint */
+ string tint = "false";
+ if (extreme_volume)
+ tint = "true";
+
+ /* Put it all into the notification */
+ _notification.update (volume_label, "", icon);
_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);
- }
+ _notification.set_hint ("sound-file", sound);
+ _notification.set_hint ("x-canonical-value-bar-tint", tint);
+ /* Show it */
try {
_notification.show ();
} catch (GLib.Error e) {