barLevel: Use setters instead of methods
Switching to getters/setters make the code suitable for using with Tweener and as GObject properties, both of which we'll do soon enough. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/385
This commit is contained in:
parent
5545e84430
commit
b970ee7293
@ -34,7 +34,11 @@ var BarLevel = class {
|
|||||||
this.connect('value-changed', this._valueChanged.bind(this));
|
this.connect('value-changed', this._valueChanged.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
setValue(value) {
|
get value() {
|
||||||
|
return this._value;
|
||||||
|
}
|
||||||
|
|
||||||
|
set value(value) {
|
||||||
if (isNaN(value))
|
if (isNaN(value))
|
||||||
throw TypeError('The bar level value must be a number');
|
throw TypeError('The bar level value must be a number');
|
||||||
|
|
||||||
@ -42,7 +46,13 @@ var BarLevel = class {
|
|||||||
this.actor.queue_repaint();
|
this.actor.queue_repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
setMaximumValue(value) {
|
// eslint-disable-next-line camelcase
|
||||||
|
get maximum_value() {
|
||||||
|
return this._maxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line camelcase
|
||||||
|
set maximum_value(value) {
|
||||||
if (isNaN(value))
|
if (isNaN(value))
|
||||||
throw TypeError('The bar level max value must be a number');
|
throw TypeError('The bar level max value must be a number');
|
||||||
|
|
||||||
@ -51,7 +61,13 @@ var BarLevel = class {
|
|||||||
this.actor.queue_repaint();
|
this.actor.queue_repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
setOverdriveStart(value) {
|
// eslint-disable-next-line camelcase
|
||||||
|
get overdrive_start() {
|
||||||
|
return this._overdriveStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line camelcase
|
||||||
|
set overdrive_start(value) {
|
||||||
if (isNaN(value))
|
if (isNaN(value))
|
||||||
throw TypeError('The overdrive limit value must be a number');
|
throw TypeError('The overdrive limit value must be a number');
|
||||||
if (value > this._maxValue)
|
if (value > this._maxValue)
|
||||||
@ -196,9 +212,5 @@ var BarLevel = class {
|
|||||||
_valueChanged() {
|
_valueChanged() {
|
||||||
this._customAccessible.notify("accessible-value");
|
this._customAccessible.notify("accessible-value");
|
||||||
}
|
}
|
||||||
|
|
||||||
get value() {
|
|
||||||
return this._value;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
Signals.addSignalMethods(BarLevel.prototype);
|
Signals.addSignalMethods(BarLevel.prototype);
|
||||||
|
@ -32,7 +32,7 @@ var LevelBar = class extends BarLevel.BarLevel {
|
|||||||
set level(value) {
|
set level(value) {
|
||||||
this._level = Math.max(0, Math.min(value, this._maxLevel));
|
this._level = Math.max(0, Math.min(value, this._maxLevel));
|
||||||
|
|
||||||
this.setValue(this._level / 100);
|
this.value = this._level / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
get maxLevel() {
|
get maxLevel() {
|
||||||
@ -42,7 +42,7 @@ var LevelBar = class extends BarLevel.BarLevel {
|
|||||||
set maxLevel(value) {
|
set maxLevel(value) {
|
||||||
this._maxLevel = Math.max(100, value);
|
this._maxLevel = Math.max(100, value);
|
||||||
|
|
||||||
this.setMaximumValue(this._maxLevel / 100);
|
this.maximum_level = this._maxLevel / 100;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -58,6 +58,6 @@ var Indicator = class extends PanelMenu.SystemIndicator {
|
|||||||
let visible = this._proxy.Brightness >= 0;
|
let visible = this._proxy.Brightness >= 0;
|
||||||
this._item.visible = visible;
|
this._item.visible = visible;
|
||||||
if (visible)
|
if (visible)
|
||||||
this._slider.setValue(this._proxy.Brightness / 100.0);
|
this._slider.value = this._proxy.Brightness / 100.0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -130,17 +130,16 @@ var StreamSlider = class {
|
|||||||
|
|
||||||
_updateVolume() {
|
_updateVolume() {
|
||||||
let muted = this._stream.is_muted;
|
let muted = this._stream.is_muted;
|
||||||
this._slider.setValue(muted ? 0 : (this._stream.volume / this._control.get_vol_max_norm()));
|
this._slider.value = muted
|
||||||
|
? 0 : (this._stream.volume / this._control.get_vol_max_norm());
|
||||||
this.emit('stream-updated');
|
this.emit('stream-updated');
|
||||||
}
|
}
|
||||||
|
|
||||||
_amplifySettingsChanged() {
|
_amplifySettingsChanged() {
|
||||||
this._allowAmplified = this._soundSettings.get_boolean(ALLOW_AMPLIFIED_VOLUME_KEY);
|
this._allowAmplified = this._soundSettings.get_boolean(ALLOW_AMPLIFIED_VOLUME_KEY);
|
||||||
|
|
||||||
if (this._allowAmplified)
|
this._slider.maximum_level = this._allowAmplified
|
||||||
this._slider.setMaximumValue(this.getMaxLevel() / 100);
|
? this.getMaxLevel() / 100 : 1;
|
||||||
else
|
|
||||||
this._slider.setMaximumValue(1);
|
|
||||||
|
|
||||||
if (this._stream)
|
if (this._stream)
|
||||||
this._updateVolume();
|
this._updateVolume();
|
||||||
|
Loading…
Reference in New Issue
Block a user