[gnome-shell] volume: Show OSD popup when changing volume via scroll



commit 79aa404c144768712d91f580ffe90ffb70fa2617
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Jun 9 16:06:39 2017 +0200

    volume: Show OSD popup when changing volume via scroll
    
    It is possible to use the scroll wheel to adjust the volume without
    opening the system menu, but there is no feedback other than the
    icon itself in that case. To provide a less coarse indication for
    the volume level, display the OSD window when adjusting the volume
    while the slider isn't visible.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=781028

 js/ui/status/volume.js |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/status/volume.js b/js/ui/status/volume.js
index 831b001..1922c3a 100644
--- a/js/ui/status/volume.js
+++ b/js/ui/status/volume.js
@@ -7,6 +7,7 @@ const Gvc = imports.gi.Gvc;
 const St = imports.gi.St;
 const Signals = imports.signals;
 
+const Main = imports.ui.main;
 const PanelMenu = imports.ui.panelMenu;
 const PopupMenu = imports.ui.popupMenu;
 const Slider = imports.ui.slider;
@@ -149,6 +150,13 @@ const StreamSlider = new Lang.Class({
                 return 'audio-volume-high-symbolic';
             return 'audio-volume-medium-symbolic';
         }
+    },
+
+    getLevel: function() {
+        if (!this._stream)
+            return null;
+
+        return 100 * this._stream.volume / this._control.get_vol_max_norm();
     }
 });
 Signals.addSignalMethods(StreamSlider.prototype);
@@ -298,6 +306,10 @@ const VolumeMenu = new Lang.Class({
 
     getIcon: function() {
         return this._output.getIcon();
+    },
+
+    getLevel: function() {
+        return this._output.getLevel();
     }
 });
 
@@ -329,6 +341,13 @@ const Indicator = new Lang.Class({
     },
 
     _onScrollEvent: function(actor, event) {
-        return this._volumeMenu.scroll(event);
+        let result = this._volumeMenu.scroll(event);
+        if (result == Clutter.EVENT_PROPAGATE || this.menu.actor.mapped)
+            return result;
+
+        let gicon = new Gio.ThemedIcon({ name: this._volumeMenu.getIcon() });
+        let level = this._volumeMenu.getLevel();
+        Main.osdWindowManager.show(-1, gicon, null, level);
+        return result;
     }
 });


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