[gnome-shell] VolumeStatus: play notification on scroll



commit a1e019b41aa78911cbfa3d5a34f8ff83dcbdce38
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Tue Feb 15 19:23:36 2011 +0100

    VolumeStatus: play notification on scroll
    
    Add the machinery to cancel the notification when a new playing a
    new one (wrapping ca_context_cancel), then use it when scrolling
    the status icon.
    Not doing it for the slider because it causes noise, either with the
    keyboard, with mouse drag or with mouse wheel.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=633667

 js/ui/status/volume.js |    7 ++++++-
 src/shell-global.c     |   18 +++++++++++++++++-
 src/shell-global.h     |    3 +++
 3 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/status/volume.js b/js/ui/status/volume.js
index f347607..7538fa3 100644
--- a/js/ui/status/volume.js
+++ b/js/ui/status/volume.js
@@ -19,6 +19,8 @@ const _ = Gettext.gettext;
 const VOLUME_MAX = 65536.0; /* PA_VOLUME_NORM */
 const VOLUME_ADJUSTMENT_STEP = 0.05; /* Volume adjustment step in % */
 
+const VOLUME_NOTIFY_ID = 1;
+
 function Indicator() {
     this._init.apply(this, arguments);
 }
@@ -87,6 +89,8 @@ Indicator.prototype = {
             this._output.change_is_muted(false);
             this._output.push_volume();
         }
+
+        this._notifyVolumeChange();
     },
 
     _onControlReady: function() {
@@ -193,7 +197,8 @@ Indicator.prototype = {
     },
 
     _notifyVolumeChange: function() {
-        global.play_theme_sound('audio-volume-change');
+        global.cancel_theme_sound(VOLUME_NOTIFY_ID);
+        global.play_theme_sound(VOLUME_NOTIFY_ID, 'audio-volume-change');
     },
 
     _mutedChanged: function(object, param_spec, property) {
diff --git a/src/shell-global.c b/src/shell-global.c
index de17526..14347ac 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -1889,6 +1889,7 @@ shell_global_run_at_leisure (ShellGlobal         *global,
 /**
  * shell_global_play_theme_sound:
  * @global: the #ShellGlobal
+ * @id: an id, used to cancel later (0 if not needed)
  * @name: the sound name
  *
  * Plays a simple sound picked according to Freedesktop sound theme.
@@ -1896,9 +1897,24 @@ shell_global_run_at_leisure (ShellGlobal         *global,
  */
 void
 shell_global_play_theme_sound (ShellGlobal *global,
+                               guint        id,
                                const char  *name)
 {
-  ca_context_play (global->sound_context, 0, CA_PROP_EVENT_ID, name, NULL);
+  ca_context_play (global->sound_context, id, CA_PROP_EVENT_ID, name, NULL);
+}
+
+/**
+ * shell_global_cancel_theme_sound:
+ * @global: the #ShellGlobal
+ * @id: the id previously passed to shell_global_play_theme_sound()
+ *
+ * Cancels a sound notification.
+ */
+void
+shell_global_cancel_theme_sound (ShellGlobal *global,
+                                 guint id)
+{
+  ca_context_cancel (global->sound_context, id);
 }
 
 /*
diff --git a/src/shell-global.h b/src/shell-global.h
index 5d1e13d..1f8eddf 100644
--- a/src/shell-global.h
+++ b/src/shell-global.h
@@ -140,7 +140,10 @@ void shell_global_run_at_leisure (ShellGlobal         *global,
                                   GDestroyNotify       notify);
 
 void shell_global_play_theme_sound (ShellGlobal       *global,
+                                    guint              id,
                                     const char        *name);
+void shell_global_cancel_theme_sound (ShellGlobal     *global,
+                                      guint            id);
 
 void shell_global_init_xdnd (ShellGlobal *global);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]