cleanup: Use method syntax

Modern javascript has a short-hand for function properties, embrace
it for better readability and to prepare for an eventual port to
ES6 classes.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
This commit is contained in:
Florian Müllner
2017-10-31 01:03:21 +01:00
committed by Florian Müllner
parent cff0b81f32
commit 76f09b1e49
116 changed files with 3140 additions and 3140 deletions

View File

@ -30,7 +30,7 @@ function getMixerControl() {
var StreamSlider = new Lang.Class({
Name: 'StreamSlider',
_init: function(control) {
_init(control) {
this._control = control;
this.item = new PopupMenu.PopupBaseMenuItem({ activate: false });
@ -73,37 +73,37 @@ var StreamSlider = new Lang.Class({
this._updateVisibility();
},
_disconnectStream: function(stream) {
_disconnectStream(stream) {
stream.disconnect(this._mutedChangedId);
this._mutedChangedId = 0;
stream.disconnect(this._volumeChangedId);
this._volumeChangedId = 0;
},
_connectStream: function(stream) {
_connectStream(stream) {
this._mutedChangedId = stream.connect('notify::is-muted', Lang.bind(this, this._updateVolume));
this._volumeChangedId = stream.connect('notify::volume', Lang.bind(this, this._updateVolume));
},
_shouldBeVisible: function() {
_shouldBeVisible() {
return this._stream != null;
},
_updateVisibility: function() {
_updateVisibility() {
let visible = this._shouldBeVisible();
this.item.actor.visible = visible;
},
scroll: function(event) {
scroll(event) {
return this._slider.scroll(event);
},
setValue: function(value) {
setValue(value) {
// piggy-back off of sliderChanged
this._slider.setValue(value);
},
_sliderChanged: function(slider, value, property) {
_sliderChanged(slider, value, property) {
if (!this._stream)
return;
@ -121,7 +121,7 @@ var StreamSlider = new Lang.Class({
this._stream.push_volume();
},
_notifyVolumeChange: function() {
_notifyVolumeChange() {
global.cancel_theme_sound(VOLUME_NOTIFY_ID);
global.play_theme_sound(VOLUME_NOTIFY_ID,
'audio-volume-change',
@ -129,13 +129,13 @@ var StreamSlider = new Lang.Class({
Clutter.get_current_event ());
},
_updateVolume: function() {
_updateVolume() {
let muted = this._stream.is_muted;
this._slider.setValue(muted ? 0 : (this._stream.volume / this._control.get_vol_max_norm()));
this.emit('stream-updated');
},
getIcon: function() {
getIcon() {
if (!this._stream)
return null;
@ -152,7 +152,7 @@ var StreamSlider = new Lang.Class({
}
},
getLevel: function() {
getLevel() {
if (!this._stream)
return null;
@ -165,18 +165,18 @@ var OutputStreamSlider = new Lang.Class({
Name: 'OutputStreamSlider',
Extends: StreamSlider,
_init: function(control) {
_init(control) {
this.parent(control);
this._slider.actor.accessible_name = _("Volume");
},
_connectStream: function(stream) {
_connectStream(stream) {
this.parent(stream);
this._portChangedId = stream.connect('notify::port', Lang.bind(this, this._portChanged));
this._portChanged();
},
_findHeadphones: function(sink) {
_findHeadphones(sink) {
// This only works for external headphones (e.g. bluetooth)
if (sink.get_form_factor() == 'headset' ||
sink.get_form_factor() == 'headphone')
@ -191,19 +191,19 @@ var OutputStreamSlider = new Lang.Class({
return false;
},
_disconnectStream: function(stream) {
_disconnectStream(stream) {
this.parent(stream);
stream.disconnect(this._portChangedId);
this._portChangedId = 0;
},
_updateSliderIcon: function() {
_updateSliderIcon() {
this._icon.icon_name = (this._hasHeadphones ?
'audio-headphones-symbolic' :
'audio-speakers-symbolic');
},
_portChanged: function() {
_portChanged() {
let hasHeadphones = this._findHeadphones(this._stream);
if (hasHeadphones != this._hasHeadphones) {
this._hasHeadphones = hasHeadphones;
@ -216,7 +216,7 @@ var InputStreamSlider = new Lang.Class({
Name: 'InputStreamSlider',
Extends: StreamSlider,
_init: function(control) {
_init(control) {
this.parent(control);
this._slider.actor.accessible_name = _("Microphone");
this._control.connect('stream-added', Lang.bind(this, this._maybeShowInput));
@ -224,12 +224,12 @@ var InputStreamSlider = new Lang.Class({
this._icon.icon_name = 'audio-input-microphone-symbolic';
},
_connectStream: function(stream) {
_connectStream(stream) {
this.parent(stream);
this._maybeShowInput();
},
_maybeShowInput: function() {
_maybeShowInput() {
// only show input widgets if any application is recording audio
let showInput = false;
let recordingApps = this._control.get_source_outputs();
@ -250,7 +250,7 @@ var InputStreamSlider = new Lang.Class({
this._updateVisibility();
},
_shouldBeVisible: function() {
_shouldBeVisible() {
return this.parent() && this._showInput;
}
});
@ -259,7 +259,7 @@ var VolumeMenu = new Lang.Class({
Name: 'VolumeMenu',
Extends: PopupMenu.PopupMenuSection,
_init: function(control) {
_init(control) {
this.parent();
this.hasHeadphones = false;
@ -283,11 +283,11 @@ var VolumeMenu = new Lang.Class({
this._onControlStateChanged();
},
scroll: function(event) {
scroll(event) {
return this._output.scroll(event);
},
_onControlStateChanged: function() {
_onControlStateChanged() {
if (this._control.get_state() == Gvc.MixerControlState.READY) {
this._readInput();
this._readOutput();
@ -296,19 +296,19 @@ var VolumeMenu = new Lang.Class({
}
},
_readOutput: function() {
_readOutput() {
this._output.stream = this._control.get_default_sink();
},
_readInput: function() {
_readInput() {
this._input.stream = this._control.get_default_source();
},
getIcon: function() {
getIcon() {
return this._output.getIcon();
},
getLevel: function() {
getLevel() {
return this._output.getLevel();
}
});
@ -317,7 +317,7 @@ var Indicator = new Lang.Class({
Name: 'VolumeIndicator',
Extends: PanelMenu.SystemIndicator,
_init: function() {
_init() {
this.parent();
this._primaryIndicator = this._addIndicator();
@ -340,7 +340,7 @@ var Indicator = new Lang.Class({
this.indicators.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
},
_onScrollEvent: function(actor, event) {
_onScrollEvent(actor, event) {
let result = this._volumeMenu.scroll(event);
if (result == Clutter.EVENT_PROPAGATE || this.menu.actor.mapped)
return result;