osdWindow: Use float values as input for osdWindow
Using the same type/interval as BarLevel means we can cut out the intermediate LevelBar class in a follow-up cleanup. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/385
This commit is contained in:
parent
86c3909908
commit
cb0d28770f
@ -18,7 +18,7 @@ var LevelBar = class extends BarLevel.BarLevel {
|
|||||||
super(0, { styleClass: 'level' });
|
super(0, { styleClass: 'level' });
|
||||||
|
|
||||||
this._level = 0;
|
this._level = 0;
|
||||||
this._maxLevel = 100;
|
this._maxLevel = 1;
|
||||||
|
|
||||||
this.actor.accessible_name = _("Volume");
|
this.actor.accessible_name = _("Volume");
|
||||||
|
|
||||||
@ -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.value = this._level / 100;
|
this.value = this._level;
|
||||||
}
|
}
|
||||||
|
|
||||||
get maxLevel() {
|
get maxLevel() {
|
||||||
@ -40,9 +40,9 @@ var LevelBar = class extends BarLevel.BarLevel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set maxLevel(value) {
|
set maxLevel(value) {
|
||||||
this._maxLevel = Math.max(100, value);
|
this._maxLevel = Math.max(1, value);
|
||||||
|
|
||||||
this.maximum_level = this._maxLevel / 100;
|
this.maximum_level = this._maxLevel;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ var OsdWindow = class {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setMaxLevel(maxLevel = 100) {
|
setMaxLevel(maxLevel = 1) {
|
||||||
this._level.maxLevel = maxLevel;
|
this._level.maxLevel = maxLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +94,12 @@ var GnomeShell = class {
|
|||||||
if (serializedIcon)
|
if (serializedIcon)
|
||||||
icon = Gio.Icon.new_for_string(serializedIcon);
|
icon = Gio.Icon.new_for_string(serializedIcon);
|
||||||
|
|
||||||
|
// Translate from percentages in the D-Bus API to floats
|
||||||
|
if (!isNaN(level))
|
||||||
|
level /= 100;
|
||||||
|
if (!isNaN(maxLevel))
|
||||||
|
maxLevel /= 100;
|
||||||
|
|
||||||
Main.osdWindowManager.show(monitorIndex, icon, label, level, maxLevel);
|
Main.osdWindowManager.show(monitorIndex, icon, label, level, maxLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ var StreamSlider = class {
|
|||||||
this._allowAmplified = this._soundSettings.get_boolean(ALLOW_AMPLIFIED_VOLUME_KEY);
|
this._allowAmplified = this._soundSettings.get_boolean(ALLOW_AMPLIFIED_VOLUME_KEY);
|
||||||
|
|
||||||
this._slider.maximum_level = this._allowAmplified
|
this._slider.maximum_level = this._allowAmplified
|
||||||
? this.getMaxLevel() / 100 : 1;
|
? this.getMaxLevel() : 1;
|
||||||
|
|
||||||
if (this._stream)
|
if (this._stream)
|
||||||
this._updateVolume();
|
this._updateVolume();
|
||||||
@ -173,7 +173,7 @@ var StreamSlider = class {
|
|||||||
if (!this._stream)
|
if (!this._stream)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return 100 * this._stream.volume / this._control.get_vol_max_norm();
|
return this._stream.volume / this._control.get_vol_max_norm();
|
||||||
}
|
}
|
||||||
|
|
||||||
getMaxLevel() {
|
getMaxLevel() {
|
||||||
@ -181,7 +181,7 @@ var StreamSlider = class {
|
|||||||
if (this._allowAmplified)
|
if (this._allowAmplified)
|
||||||
maxVolume = this._control.get_vol_max_amplified();
|
maxVolume = this._control.get_vol_max_amplified();
|
||||||
|
|
||||||
return 100 * maxVolume / this._control.get_vol_max_norm();
|
return maxVolume / this._control.get_vol_max_norm();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Signals.addSignalMethods(StreamSlider.prototype);
|
Signals.addSignalMethods(StreamSlider.prototype);
|
||||||
@ -363,8 +363,8 @@ var Indicator = class extends PanelMenu.SystemIndicator {
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
let gicon = new Gio.ThemedIcon({ name: this._volumeMenu.getIcon() });
|
let gicon = new Gio.ThemedIcon({ name: this._volumeMenu.getIcon() });
|
||||||
let level = parseInt(this._volumeMenu.getLevel());
|
let level = this._volumeMenu.getLevel();
|
||||||
let maxLevel = parseInt(this._volumeMenu.getMaxLevel());
|
let maxLevel = this._volumeMenu.getMaxLevel();
|
||||||
Main.osdWindowManager.show(-1, gicon, null, level, maxLevel);
|
Main.osdWindowManager.show(-1, gicon, null, level, maxLevel);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user