aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2013-10-01 15:25:13 +0000
committerTarmac <Unknown>2013-10-01 15:25:13 +0000
commit84627ae7f3044a008e26fcf679a2f720a7da62e9 (patch)
tree09f9e431b65cce5cae145151b7c2dc6d38e7f0a6
parent91c06e1edbe3f7f25aaad1905733ae690e4fdf26 (diff)
parentd31be181a2c69c167bb61dbb9f1007f346920ac8 (diff)
downloadayatana-indicator-sound-84627ae7f3044a008e26fcf679a2f720a7da62e9.tar.gz
ayatana-indicator-sound-84627ae7f3044a008e26fcf679a2f720a7da62e9.tar.bz2
ayatana-indicator-sound-84627ae7f3044a008e26fcf679a2f720a7da62e9.zip
Show synchronous notification when changing the volume by scrolling over the indicator. Fixes: https://bugs.launchpad.net/bugs/1225335.
Approved by PS Jenkins bot, Sebastien Bacher.
-rw-r--r--CMakeLists.txt1
-rw-r--r--debian/control1
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/main.vala2
-rw-r--r--src/service.vala37
5 files changed, 36 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6ab96c9..c60dc97 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,6 +41,7 @@ pkg_check_modules(
gio-2.0>=${GIO_2_0_REQUIRED_VERSION}
gio-unix-2.0
libxml-2.0
+ libnotify
)
include_directories(${SOUNDSERVICE_INCLUDE_DIRS})
diff --git a/debian/control b/debian/control
index 0d1da18..ff4c041 100644
--- a/debian/control
+++ b/debian/control
@@ -13,6 +13,7 @@ Build-Depends: debhelper (>= 9.0),
liburl-dispatcher1-dev,
libpulse-dev (>= 0.9.18),
libpulse-mainloop-glib0 (>= 0.9.18),
+ libnotify-dev,
libgee-dev,
libxml2-dev,
Standards-Version: 3.9.4
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a61fb72..572befd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -14,6 +14,7 @@ vala_init(indicator-sound-service
libxml-2.0
libpulse
libpulse-mainloop-glib
+ libnotify
OPTIONS
--ccode
--thread
diff --git a/src/main.vala b/src/main.vala
index 97f311f..4da9e58 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -7,6 +7,8 @@ static int main (string[] args) {
Intl.setlocale (LocaleCategory.ALL, "");
Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.GNOMELOCALEDIR);
+ Notify.init ("indicator-sound");
+
var service = new IndicatorSound.Service ();
return service.run ();
}
diff --git a/src/service.vala b/src/service.vala
index 9c7bcc9..0d028ac 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -45,6 +45,14 @@ public class IndicatorSound.Service {
this.settings.changed["interested-media-players"].connect ( () => {
this.players.sync (settings.get_strv ("interested-media-players"));
});
+
+ if (settings.get_boolean ("show-notify-osd-on-scroll")) {
+ unowned List<string> caps = Notify.get_server_caps ();
+ if (caps.find_custom ("x-canonical-private-synchronous", strcmp) != null) {
+ this.notification = new Notify.Notification ("indicator-sound", "", "");
+ this.notification.set_hint_string ("x-canonical-private-synchronous", "indicator-sound");
+ }
+ }
}
public int run () {
@@ -76,18 +84,35 @@ public class IndicatorSound.Service {
VolumeControl volume_control;
MediaPlayerList players;
uint player_action_update_id;
+ Notify.Notification notification;
void activate_scroll_action (SimpleAction action, Variant? param) {
const double volume_step_percentage = 0.06;
int delta = param.get_int32(); /* positive for up, negative for down */
double v = this.volume_control.get_volume () + volume_step_percentage * delta;
- if (v > 1.0)
- v = 1.0;
- else if (v < 0.0)
- v = 0.0;
-
- this.volume_control.set_volume (v);
+ this.volume_control.set_volume (v.clamp (0.0, 1.0));
+
+ if (this.notification != null) {
+ string icon;
+ if (v <= 0.0)
+ icon = "notification-audio-volume-off";
+ else if (v <= 0.3)
+ icon = "notification-audio-volume-low";
+ else if (v <= 0.7)
+ icon = "notification-audio-volume-medium";
+ else
+ icon = "notification-audio-volume-high";
+
+ this.notification.update ("indicator-sound", "", icon);
+ this.notification.set_hint_int32 ("value", ((int32) (100 * v)).clamp (-1, 101));
+ try {
+ this.notification.show ();
+ }
+ catch (Error e) {
+ warning ("unable to show notification: %s", e.message);
+ }
+ }
}
void activate_desktop_settings (SimpleAction action, Variant? param) {