status/powerProfiles: Add image to menu items
We want the icons when we move to quick settings: https://gitlab.gnome.org/Teams/Design/os-mockups/-/raw/master/system-status/quick-settings/quick-toggles-mvp.png Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2389>
This commit is contained in:
parent
7647e5590a
commit
d555be0a64
@ -15,15 +15,21 @@ const OBJECT_PATH = '/net/hadess/PowerProfiles';
|
|||||||
const PowerProfilesIface = loadInterfaceXML('net.hadess.PowerProfiles');
|
const PowerProfilesIface = loadInterfaceXML('net.hadess.PowerProfiles');
|
||||||
const PowerProfilesProxy = Gio.DBusProxy.makeProxyWrapper(PowerProfilesIface);
|
const PowerProfilesProxy = Gio.DBusProxy.makeProxyWrapper(PowerProfilesIface);
|
||||||
|
|
||||||
const PROFILE_LABELS = {
|
const PROFILE_PARAMS = {
|
||||||
'performance': C_('Power profile', 'Performance'),
|
'performance': {
|
||||||
'balanced': C_('Power profile', 'Balanced'),
|
label: C_('Power profile', 'Performance'),
|
||||||
'power-saver': C_('Power profile', 'Power Saver'),
|
iconName: 'power-profile-performance-symbolic',
|
||||||
};
|
},
|
||||||
const PROFILE_ICONS = {
|
|
||||||
'performance': 'power-profile-performance-symbolic',
|
'balanced': {
|
||||||
'balanced': 'power-profile-balanced-symbolic',
|
label: C_('Power profile', 'Balanced'),
|
||||||
'power-saver': 'power-profile-power-saver-symbolic',
|
iconName: 'power-profile-balanced-symbolic',
|
||||||
|
},
|
||||||
|
|
||||||
|
'power-saver': {
|
||||||
|
label: C_('Power profile', 'Power Saver'),
|
||||||
|
iconName: 'power-profile-power-saver-symbolic',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
var Indicator = GObject.registerClass(
|
var Indicator = GObject.registerClass(
|
||||||
@ -77,11 +83,11 @@ class Indicator extends PanelMenu.SystemIndicator {
|
|||||||
.map(p => p.Profile.unpack())
|
.map(p => p.Profile.unpack())
|
||||||
.reverse();
|
.reverse();
|
||||||
for (const profile of profiles) {
|
for (const profile of profiles) {
|
||||||
const label = PROFILE_LABELS[profile];
|
const {label, iconName} = PROFILE_PARAMS[profile];
|
||||||
if (!label)
|
if (!label)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const item = new PopupMenu.PopupMenuItem(label);
|
const item = new PopupMenu.PopupImageMenuItem(label, iconName);
|
||||||
item.connect('activate',
|
item.connect('activate',
|
||||||
() => (this._proxy.ActiveProfile = profile));
|
() => (this._proxy.ActiveProfile = profile));
|
||||||
this._profileItems.set(profile, item);
|
this._profileItems.set(profile, item);
|
||||||
@ -101,7 +107,8 @@ class Indicator extends PanelMenu.SystemIndicator {
|
|||||||
: PopupMenu.Ornament.NONE);
|
: PopupMenu.Ornament.NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._item.label.text = PROFILE_LABELS[this._proxy.ActiveProfile];
|
const {label, iconName} = PROFILE_PARAMS[this._proxy.ActiveProfile];
|
||||||
this._item.icon.icon_name = PROFILE_ICONS[this._proxy.ActiveProfile];
|
this._item.label.text = label;
|
||||||
|
this._item.icon.icon_name = iconName;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user