[gnome-shell] osdWindow: Allow levels above 100%
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] osdWindow: Allow levels above 100%
- Date: Tue, 31 Jul 2018 18:21:00 +0000 (UTC)
commit aa75e892160872f30369d90bc0f622853a362292
Author: Didier Roche <didrocks ubuntu com>
Date: Tue Jul 31 16:47:05 2018 +0200
osdWindow: Allow levels above 100%
Allow osd representing levels that can be more than 100% by accepting
an optional parameter setting that maximum level.
gnome-settings-daemon will use this to indicate volume levels above 100%,
which our own volume indicator will soon support as well.
js/ui/osdWindow.js | 29 ++++++++++++++++++++++++-----
js/ui/shellDBus.js | 3 ++-
2 files changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/js/ui/osdWindow.js b/js/ui/osdWindow.js
index fe8cf780a..9021c22d2 100644
--- a/js/ui/osdWindow.js
+++ b/js/ui/osdWindow.js
@@ -22,6 +22,7 @@ var LevelBar = new Lang.Class({
_init() {
this._level = 0;
+ this._maxLevel = 100;
let params = {
styleClass: 'level',
@@ -38,9 +39,19 @@ var LevelBar = new Lang.Class({
},
set level(value) {
- this._level = Math.max(0, Math.min(value, 100));
+ this._level = Math.max(0, Math.min(value, this._maxLevel));
this.setValue(this._level / 100);
+ },
+
+ get maxLevel() {
+ return this._maxLevel;
+ },
+
+ set maxLevel(value) {
+ this._maxLevel = Math.max(100, value);
+
+ this.setMaximumValue(this._maxLevel / 100);
}
});
@@ -139,6 +150,12 @@ var OsdWindow = new Lang.Class({
}
},
+ setMaxLevel(maxLevel) {
+ if (maxLevel === undefined)
+ maxLevel = 100;
+ this._level.maxLevel = maxLevel;
+ },
+
show() {
if (!this._icon.gicon)
return;
@@ -188,6 +205,7 @@ var OsdWindow = new Lang.Class({
this.actor.hide();
this.setLabel(null);
this.setLevel(null);
+ this.setMaxLevel(null);
},
_relayout() {
@@ -232,24 +250,25 @@ var OsdWindowManager = new Lang.Class({
this._osdWindows.length = Main.layoutManager.monitors.length;
},
- _showOsdWindow(monitorIndex, icon, label, level) {
+ _showOsdWindow(monitorIndex, icon, label, level, maxLevel) {
this._osdWindows[monitorIndex].setIcon(icon);
this._osdWindows[monitorIndex].setLabel(label);
this._osdWindows[monitorIndex].setLevel(level);
+ this._osdWindows[monitorIndex].setMaxLevel(maxLevel);
this._osdWindows[monitorIndex].show();
},
- show(monitorIndex, icon, label, level) {
+ show(monitorIndex, icon, label, level, maxLevel) {
if (monitorIndex != -1) {
for (let i = 0; i < this._osdWindows.length; i++) {
if (i == monitorIndex)
- this._showOsdWindow(i, icon, label, level);
+ this._showOsdWindow(i, icon, label, level, maxLevel);
else
this._osdWindows[i].cancel();
}
} else {
for (let i = 0; i < this._osdWindows.length; i++)
- this._showOsdWindow(i, icon, label, level);
+ this._showOsdWindow(i, icon, label, level, maxLevel);
}
},
diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js
index c35e7f19c..55e1e5737 100644
--- a/js/ui/shellDBus.js
+++ b/js/ui/shellDBus.js
@@ -148,12 +148,13 @@ var GnomeShell = new Lang.Class({
let monitorIndex = params['monitor'] || -1;
let label = params['label'] || undefined;
let level = params['level'] || undefined;
+ let maxLevel = params['max_level'] || undefined;
let icon = null;
if (params['icon'])
icon = Gio.Icon.new_for_string(params['icon']);
- Main.osdWindowManager.show(monitorIndex, icon, label, level);
+ Main.osdWindowManager.show(monitorIndex, icon, label, level, maxLevel);
},
FocusApp(id) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]