2011-09-28 13:16:26 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2019-01-31 14:07:06 +00:00
|
|
|
/* exported Indicator */
|
2010-07-23 00:39:44 +00:00
|
|
|
|
2019-02-09 03:21:36 +00:00
|
|
|
const { Clutter, Gio, Gvc, St } = imports.gi;
|
2012-12-20 02:57:26 +00:00
|
|
|
const Signals = imports.signals;
|
2010-07-23 00:39:44 +00:00
|
|
|
|
2017-06-09 14:06:39 +00:00
|
|
|
const Main = imports.ui.main;
|
2010-07-23 00:39:44 +00:00
|
|
|
const PanelMenu = imports.ui.panelMenu;
|
|
|
|
const PopupMenu = imports.ui.popupMenu;
|
2013-04-23 20:57:43 +00:00
|
|
|
const Slider = imports.ui.slider;
|
2010-07-23 00:39:44 +00:00
|
|
|
|
2018-07-31 06:02:04 +00:00
|
|
|
const ALLOW_AMPLIFIED_VOLUME_KEY = 'allow-volume-above-100-percent';
|
|
|
|
|
2012-08-26 14:05:46 +00:00
|
|
|
// Each Gvc.MixerControl is a connection to PulseAudio,
|
|
|
|
// so it's better to make it a singleton
|
|
|
|
let _mixerControl;
|
|
|
|
function getMixerControl() {
|
|
|
|
if (_mixerControl)
|
|
|
|
return _mixerControl;
|
2010-07-23 00:39:44 +00:00
|
|
|
|
2012-08-26 14:05:46 +00:00
|
|
|
_mixerControl = new Gvc.MixerControl({ name: 'GNOME Shell Volume Control' });
|
|
|
|
_mixerControl.open();
|
|
|
|
|
|
|
|
return _mixerControl;
|
|
|
|
}
|
2010-07-23 00:39:44 +00:00
|
|
|
|
2017-10-31 01:19:44 +00:00
|
|
|
var StreamSlider = class {
|
|
|
|
constructor(control) {
|
2012-12-20 02:57:26 +00:00
|
|
|
this._control = control;
|
2012-08-26 14:05:46 +00:00
|
|
|
|
2013-04-23 20:57:43 +00:00
|
|
|
this.item = new PopupMenu.PopupBaseMenuItem({ activate: false });
|
2012-10-18 17:42:17 +00:00
|
|
|
|
2013-04-23 20:57:43 +00:00
|
|
|
this._slider = new Slider.Slider(0);
|
2018-07-31 06:02:04 +00:00
|
|
|
|
|
|
|
this._soundSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.sound' });
|
2019-01-30 00:18:24 +00:00
|
|
|
this._soundSettings.connect(`changed::${ALLOW_AMPLIFIED_VOLUME_KEY}`, this._amplifySettingsChanged.bind(this));
|
2018-07-31 06:02:04 +00:00
|
|
|
this._amplifySettingsChanged();
|
|
|
|
|
2017-12-02 00:27:35 +00:00
|
|
|
this._slider.connect('value-changed', this._sliderChanged.bind(this));
|
|
|
|
this._slider.connect('drag-end', this._notifyVolumeChange.bind(this));
|
2010-07-23 00:39:44 +00:00
|
|
|
|
2013-04-23 20:57:43 +00:00
|
|
|
this._icon = new St.Icon({ style_class: 'popup-menu-icon' });
|
2019-04-12 21:00:49 +00:00
|
|
|
this.item.add(this._icon);
|
|
|
|
this.item.add(this._slider.actor, { expand: true });
|
|
|
|
this.item.connect('button-press-event', (actor, event) => {
|
2013-11-29 18:17:34 +00:00
|
|
|
return this._slider.startDragging(event);
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2019-04-12 21:00:49 +00:00
|
|
|
this.item.connect('key-press-event', (actor, event) => {
|
2013-08-22 11:15:00 +00:00
|
|
|
return this._slider.onKeyPressEvent(actor, event);
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2013-06-12 03:39:56 +00:00
|
|
|
|
2012-12-20 02:57:26 +00:00
|
|
|
this._stream = null;
|
2018-12-13 19:33:45 +00:00
|
|
|
this._volumeCancellable = null;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-07-23 00:39:44 +00:00
|
|
|
|
2012-12-20 02:57:26 +00:00
|
|
|
get stream() {
|
|
|
|
return this._stream;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-09-04 15:55:26 +00:00
|
|
|
|
2012-12-20 02:57:26 +00:00
|
|
|
set stream(stream) {
|
|
|
|
if (this._stream) {
|
|
|
|
this._disconnectStream(this._stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._stream = stream;
|
|
|
|
|
|
|
|
if (this._stream) {
|
|
|
|
this._connectStream(this._stream);
|
|
|
|
this._updateVolume();
|
|
|
|
} else {
|
|
|
|
this.emit('stream-updated');
|
|
|
|
}
|
|
|
|
|
|
|
|
this._updateVisibility();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-20 02:57:26 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_disconnectStream(stream) {
|
2012-12-20 02:57:26 +00:00
|
|
|
stream.disconnect(this._mutedChangedId);
|
|
|
|
this._mutedChangedId = 0;
|
|
|
|
stream.disconnect(this._volumeChangedId);
|
|
|
|
this._volumeChangedId = 0;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-20 02:57:26 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_connectStream(stream) {
|
2017-12-02 00:27:35 +00:00
|
|
|
this._mutedChangedId = stream.connect('notify::is-muted', this._updateVolume.bind(this));
|
|
|
|
this._volumeChangedId = stream.connect('notify::volume', this._updateVolume.bind(this));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-20 02:57:26 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_shouldBeVisible() {
|
2012-12-20 02:57:26 +00:00
|
|
|
return this._stream != null;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-20 02:57:26 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateVisibility() {
|
2012-12-20 02:57:26 +00:00
|
|
|
let visible = this._shouldBeVisible();
|
2019-04-12 21:00:49 +00:00
|
|
|
this.item.visible = visible;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-22 22:27:06 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
scroll(event) {
|
2013-11-29 18:17:34 +00:00
|
|
|
return this._slider.scroll(event);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-10-20 19:53:23 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
setValue(value) {
|
2012-12-20 02:57:26 +00:00
|
|
|
// piggy-back off of sliderChanged
|
|
|
|
this._slider.setValue(value);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-20 02:57:26 +00:00
|
|
|
|
2019-02-04 11:30:53 +00:00
|
|
|
_sliderChanged(slider, value) {
|
2012-12-20 02:57:26 +00:00
|
|
|
if (!this._stream)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let volume = value * this._control.get_vol_max_norm();
|
|
|
|
let prevMuted = this._stream.is_muted;
|
|
|
|
if (volume < 1) {
|
|
|
|
this._stream.volume = 0;
|
|
|
|
if (!prevMuted)
|
|
|
|
this._stream.change_is_muted(true);
|
2011-03-28 14:10:11 +00:00
|
|
|
} else {
|
2012-12-20 02:57:26 +00:00
|
|
|
this._stream.volume = volume;
|
|
|
|
if (prevMuted)
|
|
|
|
this._stream.change_is_muted(false);
|
|
|
|
}
|
|
|
|
this._stream.push_volume();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-20 02:57:26 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_notifyVolumeChange() {
|
2018-12-13 19:33:45 +00:00
|
|
|
if (this._volumeCancellable)
|
|
|
|
this._volumeCancellable.cancel();
|
|
|
|
|
|
|
|
this._volumeCancellable = new Gio.Cancellable();
|
|
|
|
let player = global.display.get_sound_player();
|
|
|
|
player.play_from_theme('audio-volume-change',
|
|
|
|
_("Volume changed"),
|
|
|
|
this._volumeCancellable);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-21 18:28:40 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateVolume() {
|
2012-12-20 02:57:26 +00:00
|
|
|
let muted = this._stream.is_muted;
|
|
|
|
this._slider.setValue(muted ? 0 : (this._stream.volume / this._control.get_vol_max_norm()));
|
|
|
|
this.emit('stream-updated');
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-20 02:57:26 +00:00
|
|
|
|
2018-07-31 06:02:04 +00:00
|
|
|
_amplifySettingsChanged() {
|
|
|
|
this._allowAmplified = this._soundSettings.get_boolean(ALLOW_AMPLIFIED_VOLUME_KEY);
|
|
|
|
|
|
|
|
if (this._allowAmplified)
|
|
|
|
this._slider.setMaximumValue(this.getMaxLevel() / 100);
|
|
|
|
else
|
|
|
|
this._slider.setMaximumValue(1);
|
|
|
|
|
|
|
|
if (this._stream)
|
|
|
|
this._updateVolume();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2018-07-31 06:02:04 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
getIcon() {
|
2012-12-20 02:57:26 +00:00
|
|
|
if (!this._stream)
|
|
|
|
return null;
|
|
|
|
|
2018-02-09 14:10:16 +00:00
|
|
|
let icons = ["audio-volume-muted-symbolic",
|
|
|
|
"audio-volume-low-symbolic",
|
|
|
|
"audio-volume-medium-symbolic",
|
|
|
|
"audio-volume-high-symbolic",
|
|
|
|
"audio-volume-overamplified-symbolic"];
|
|
|
|
|
2012-12-20 02:57:26 +00:00
|
|
|
let volume = this._stream.volume;
|
2018-02-09 14:10:16 +00:00
|
|
|
let n;
|
2012-12-20 02:57:26 +00:00
|
|
|
if (this._stream.is_muted || volume <= 0) {
|
2018-02-09 14:10:16 +00:00
|
|
|
n = 0;
|
2012-12-20 02:57:26 +00:00
|
|
|
} else {
|
2018-02-09 14:10:16 +00:00
|
|
|
n = Math.ceil(3 * volume / this._control.get_vol_max_norm());
|
|
|
|
if (n < 1)
|
|
|
|
n = 1;
|
|
|
|
else if (n > 3)
|
|
|
|
n = 4;
|
2011-03-28 14:10:11 +00:00
|
|
|
}
|
2018-02-09 14:10:16 +00:00
|
|
|
return icons[n];
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2017-06-09 14:06:39 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
getLevel() {
|
2017-06-09 14:06:39 +00:00
|
|
|
if (!this._stream)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
return 100 * this._stream.volume / this._control.get_vol_max_norm();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2018-07-31 06:02:04 +00:00
|
|
|
|
|
|
|
getMaxLevel() {
|
|
|
|
let maxVolume = this._control.get_vol_max_norm();
|
|
|
|
if (this._allowAmplified)
|
|
|
|
maxVolume = this._control.get_vol_max_amplified();
|
|
|
|
|
|
|
|
return 100 * maxVolume / this._control.get_vol_max_norm();
|
2012-12-20 02:57:26 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
};
|
2012-12-20 02:57:26 +00:00
|
|
|
Signals.addSignalMethods(StreamSlider.prototype);
|
|
|
|
|
2017-10-31 01:19:44 +00:00
|
|
|
var OutputStreamSlider = class extends StreamSlider {
|
|
|
|
constructor(control) {
|
|
|
|
super(control);
|
2013-08-21 16:24:30 +00:00
|
|
|
this._slider.actor.accessible_name = _("Volume");
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-08-21 16:24:30 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_connectStream(stream) {
|
2017-10-31 01:19:44 +00:00
|
|
|
super._connectStream(stream);
|
2017-12-02 00:27:35 +00:00
|
|
|
this._portChangedId = stream.connect('notify::port', this._portChanged.bind(this));
|
2012-12-20 02:57:26 +00:00
|
|
|
this._portChanged();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-07-23 00:39:44 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_findHeadphones(sink) {
|
2012-10-18 17:42:17 +00:00
|
|
|
// This only works for external headphones (e.g. bluetooth)
|
|
|
|
if (sink.get_form_factor() == 'headset' ||
|
|
|
|
sink.get_form_factor() == 'headphone')
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// a bit hackish, but ALSA/PulseAudio have a number
|
|
|
|
// of different identifiers for headphones, and I could
|
|
|
|
// not find the complete list
|
2013-02-01 19:19:02 +00:00
|
|
|
if (sink.get_ports().length > 0)
|
2018-07-14 20:56:22 +00:00
|
|
|
return sink.get_port().port.includes('headphone');
|
2012-10-18 17:42:17 +00:00
|
|
|
|
|
|
|
return false;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-10-18 17:42:17 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_disconnectStream(stream) {
|
2017-10-31 01:19:44 +00:00
|
|
|
super._disconnectStream(stream);
|
2012-12-20 02:57:26 +00:00
|
|
|
stream.disconnect(this._portChangedId);
|
|
|
|
this._portChangedId = 0;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-10-18 17:42:17 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateSliderIcon() {
|
2013-04-23 20:57:43 +00:00
|
|
|
this._icon.icon_name = (this._hasHeadphones ?
|
|
|
|
'audio-headphones-symbolic' :
|
|
|
|
'audio-speakers-symbolic');
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-04-23 20:57:43 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_portChanged() {
|
2012-12-20 02:57:26 +00:00
|
|
|
let hasHeadphones = this._findHeadphones(this._stream);
|
|
|
|
if (hasHeadphones != this._hasHeadphones) {
|
|
|
|
this._hasHeadphones = hasHeadphones;
|
2013-04-23 20:57:43 +00:00
|
|
|
this._updateSliderIcon();
|
2010-07-23 00:39:44 +00:00
|
|
|
}
|
2012-12-20 02:57:26 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
};
|
2012-12-20 02:57:26 +00:00
|
|
|
|
2017-10-31 01:19:44 +00:00
|
|
|
var InputStreamSlider = class extends StreamSlider {
|
|
|
|
constructor(control) {
|
|
|
|
super(control);
|
2013-08-21 16:24:30 +00:00
|
|
|
this._slider.actor.accessible_name = _("Microphone");
|
2017-12-02 00:27:35 +00:00
|
|
|
this._control.connect('stream-added', this._maybeShowInput.bind(this));
|
|
|
|
this._control.connect('stream-removed', this._maybeShowInput.bind(this));
|
2013-04-23 20:57:43 +00:00
|
|
|
this._icon.icon_name = 'audio-input-microphone-symbolic';
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-07-23 00:39:44 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_connectStream(stream) {
|
2017-10-31 01:19:44 +00:00
|
|
|
super._connectStream(stream);
|
2012-12-20 02:57:26 +00:00
|
|
|
this._maybeShowInput();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-07-23 00:39:44 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_maybeShowInput() {
|
2010-07-23 00:39:44 +00:00
|
|
|
// only show input widgets if any application is recording audio
|
|
|
|
let showInput = false;
|
|
|
|
let recordingApps = this._control.get_source_outputs();
|
2012-12-20 02:57:26 +00:00
|
|
|
if (this._stream && recordingApps) {
|
2010-10-20 19:15:24 +00:00
|
|
|
for (let i = 0; i < recordingApps.length; i++) {
|
|
|
|
let outputStream = recordingApps[i];
|
2010-07-23 00:39:44 +00:00
|
|
|
let id = outputStream.get_application_id();
|
|
|
|
// but skip gnome-volume-control and pavucontrol
|
|
|
|
// (that appear as recording because they show the input level)
|
|
|
|
if (!id || (id != 'org.gnome.VolumeControl' && id != 'org.PulseAudio.pavucontrol')) {
|
|
|
|
showInput = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-16 22:53:14 +00:00
|
|
|
|
2012-12-20 02:57:26 +00:00
|
|
|
this._showInput = showInput;
|
|
|
|
this._updateVisibility();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-07-23 00:39:44 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_shouldBeVisible() {
|
2017-10-31 01:19:44 +00:00
|
|
|
return super._shouldBeVisible() && this._showInput;
|
2012-12-20 02:57:26 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
};
|
2012-12-20 02:57:26 +00:00
|
|
|
|
2017-10-31 01:19:44 +00:00
|
|
|
var VolumeMenu = class extends PopupMenu.PopupMenuSection {
|
|
|
|
constructor(control) {
|
|
|
|
super();
|
2012-12-20 02:57:26 +00:00
|
|
|
|
|
|
|
this.hasHeadphones = false;
|
|
|
|
|
|
|
|
this._control = control;
|
2017-12-02 00:27:35 +00:00
|
|
|
this._control.connect('state-changed', this._onControlStateChanged.bind(this));
|
|
|
|
this._control.connect('default-sink-changed', this._readOutput.bind(this));
|
|
|
|
this._control.connect('default-source-changed', this._readInput.bind(this));
|
2012-12-20 02:57:26 +00:00
|
|
|
|
2013-04-23 20:57:43 +00:00
|
|
|
this._output = new OutputStreamSlider(this._control);
|
2017-10-31 00:38:18 +00:00
|
|
|
this._output.connect('stream-updated', () => {
|
2012-12-20 02:57:26 +00:00
|
|
|
this.emit('icon-changed');
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2012-12-20 02:57:26 +00:00
|
|
|
this.addMenuItem(this._output.item);
|
|
|
|
|
2013-04-23 20:57:43 +00:00
|
|
|
this._input = new InputStreamSlider(this._control);
|
2012-12-20 02:57:26 +00:00
|
|
|
this.addMenuItem(this._input.item);
|
|
|
|
|
|
|
|
this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
|
|
|
|
|
|
|
this._onControlStateChanged();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2010-07-23 00:39:44 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
scroll(event) {
|
2013-11-29 18:17:34 +00:00
|
|
|
return this._output.scroll(event);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-20 03:02:04 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onControlStateChanged() {
|
2012-12-20 02:57:26 +00:00
|
|
|
if (this._control.get_state() == Gvc.MixerControlState.READY) {
|
|
|
|
this._readInput();
|
|
|
|
this._readOutput();
|
2012-12-20 03:02:04 +00:00
|
|
|
} else {
|
2012-12-20 02:57:26 +00:00
|
|
|
this.emit('icon-changed');
|
2012-12-20 03:02:04 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-20 03:02:04 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_readOutput() {
|
2012-12-20 02:57:26 +00:00
|
|
|
this._output.stream = this._control.get_default_sink();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-20 02:57:26 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_readInput() {
|
2012-12-20 02:57:26 +00:00
|
|
|
this._input.stream = this._control.get_default_source();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-20 02:57:26 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
getIcon() {
|
2012-12-20 02:57:26 +00:00
|
|
|
return this._output.getIcon();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2017-06-09 14:06:39 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
getLevel() {
|
2017-06-09 14:06:39 +00:00
|
|
|
return this._output.getLevel();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2018-07-31 06:02:04 +00:00
|
|
|
|
|
|
|
getMaxLevel() {
|
|
|
|
return this._output.getMaxLevel();
|
2012-08-26 14:05:46 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
};
|
2012-08-26 14:05:46 +00:00
|
|
|
|
2017-10-31 01:19:44 +00:00
|
|
|
var Indicator = class extends PanelMenu.SystemIndicator {
|
|
|
|
constructor() {
|
|
|
|
super();
|
2013-06-06 21:27:25 +00:00
|
|
|
|
2013-07-19 10:05:47 +00:00
|
|
|
this._primaryIndicator = this._addIndicator();
|
2012-08-26 14:05:46 +00:00
|
|
|
|
|
|
|
this._control = getMixerControl();
|
|
|
|
this._volumeMenu = new VolumeMenu(this._control);
|
2019-02-04 11:30:53 +00:00
|
|
|
this._volumeMenu.connect('icon-changed', () => {
|
2012-12-20 03:02:04 +00:00
|
|
|
let icon = this._volumeMenu.getIcon();
|
2013-06-06 21:27:25 +00:00
|
|
|
|
|
|
|
if (icon != null) {
|
|
|
|
this.indicators.show();
|
|
|
|
this._primaryIndicator.icon_name = icon;
|
|
|
|
} else {
|
|
|
|
this.indicators.hide();
|
|
|
|
}
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2012-08-26 14:05:46 +00:00
|
|
|
|
|
|
|
this.menu.addMenuItem(this._volumeMenu);
|
|
|
|
|
2017-12-02 00:27:35 +00:00
|
|
|
this.indicators.connect('scroll-event', this._onScrollEvent.bind(this));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-08-26 14:05:46 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onScrollEvent(actor, event) {
|
2017-06-09 14:06:39 +00:00
|
|
|
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() });
|
2018-07-31 06:02:04 +00:00
|
|
|
let level = parseInt(this._volumeMenu.getLevel());
|
|
|
|
let maxLevel = parseInt(this._volumeMenu.getMaxLevel());
|
|
|
|
Main.osdWindowManager.show(-1, gicon, null, level, maxLevel);
|
2017-06-09 14:06:39 +00:00
|
|
|
return result;
|
2010-07-23 00:39:44 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
};
|