volumeIndicator: Add mousewheel support
Allow changing the volume by moving the mousewheel over the volume indicato to restore the old gnome-volume-control-applet behaviour. https://bugzilla.gnome.org/show_bug.cgi?id=632733
This commit is contained in:
parent
fe1a9c2b4b
commit
10e59c0840
@ -1,5 +1,6 @@
|
|||||||
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
||||||
|
|
||||||
|
const Clutter = imports.gi.Clutter;
|
||||||
const DBus = imports.dbus;
|
const DBus = imports.dbus;
|
||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
const Mainloop = imports.mainloop;
|
const Mainloop = imports.mainloop;
|
||||||
@ -15,6 +16,7 @@ const Gettext = imports.gettext.domain('gnome-shell');
|
|||||||
const _ = Gettext.gettext;
|
const _ = Gettext.gettext;
|
||||||
|
|
||||||
const VOLUME_MAX = 65536.0; /* PA_VOLUME_NORM */
|
const VOLUME_MAX = 65536.0; /* PA_VOLUME_NORM */
|
||||||
|
const VOLUME_ADJUSTMENT_STEP = 0.05; /* Volume adjustment step in % */
|
||||||
|
|
||||||
function Indicator() {
|
function Indicator() {
|
||||||
this._init.apply(this, arguments);
|
this._init.apply(this, arguments);
|
||||||
@ -64,9 +66,24 @@ Indicator.prototype = {
|
|||||||
p.run();
|
p.run();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.actor.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
|
||||||
this._control.open();
|
this._control.open();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_onScrollEvent: function(actor, event) {
|
||||||
|
let direction = event.get_scroll_direction();
|
||||||
|
let currentVolume = this._output.volume;
|
||||||
|
|
||||||
|
if (direction == Clutter.ScrollDirection.DOWN) {
|
||||||
|
this._output.volume = Math.max(0, currentVolume - VOLUME_MAX * VOLUME_ADJUSTMENT_STEP);
|
||||||
|
this._output.push_volume();
|
||||||
|
}
|
||||||
|
else if (direction == Clutter.ScrollDirection.UP) {
|
||||||
|
this._output.volume = Math.min(VOLUME_MAX, currentVolume + VOLUME_MAX * VOLUME_ADJUSTMENT_STEP);
|
||||||
|
this._output.push_volume();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_onControlReady: function() {
|
_onControlReady: function() {
|
||||||
this._readOutput();
|
this._readOutput();
|
||||||
this._readInput();
|
this._readInput();
|
||||||
|
Loading…
Reference in New Issue
Block a user