status/powerProfiles: Set profile name as subtitle

Just like with network names, set the name of the power profile as
the subtitle of the quick settings pill. This allows more of the
power profile name to be visible, and reduces chances of ellipsing
the name.

Rename the 'title' variable to 'name', to be more semantic and
better represent what it is now.

Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5770
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2619>
This commit is contained in:
Georges Basile Stavracas Neto 2023-01-31 14:38:39 -03:00
parent 88dcf695c0
commit ec397cf604

View File

@ -17,17 +17,17 @@ const PowerProfilesProxy = Gio.DBusProxy.makeProxyWrapper(PowerProfilesIface);
const PROFILE_PARAMS = {
'performance': {
title: C_('Power profile', 'Performance'),
name: C_('Power profile', 'Performance'),
iconName: 'power-profile-performance-symbolic',
},
'balanced': {
title: C_('Power profile', 'Balanced'),
name: C_('Power profile', 'Balanced'),
iconName: 'power-profile-balanced-symbolic',
},
'power-saver': {
title: C_('Power profile', 'Power Saver'),
name: C_('Power profile', 'Power Saver'),
iconName: 'power-profile-power-saver-symbolic',
},
};
@ -37,7 +37,7 @@ const LAST_PROFILE_KEY = 'last-selected-power-profile';
const PowerProfilesToggle = GObject.registerClass(
class PowerProfilesToggle extends QuickMenuToggle {
_init() {
super._init();
super._init({title: _('Power Mode')});
this._profileItems = new Map();
@ -83,11 +83,11 @@ class PowerProfilesToggle extends QuickMenuToggle {
.map(p => p.Profile.unpack())
.reverse();
for (const profile of profiles) {
const {title, iconName} = PROFILE_PARAMS[profile];
if (!title)
const {name, iconName} = PROFILE_PARAMS[profile];
if (!name)
continue;
const item = new PopupMenu.PopupImageMenuItem(title, iconName);
const item = new PopupMenu.PopupImageMenuItem(name, iconName);
item.connect('activate',
() => (this._proxy.ActiveProfile = profile));
this._profileItems.set(profile, item);
@ -111,7 +111,9 @@ class PowerProfilesToggle extends QuickMenuToggle {
: PopupMenu.Ornament.NONE);
}
this.set(PROFILE_PARAMS[activeProfile]);
const {name: subtitle, iconName} = PROFILE_PARAMS[activeProfile];
this.set({subtitle, iconName});
this.checked = activeProfile !== 'balanced';
if (this.checked)