status/powerProfiles: Split updating profiles from sync
Calling the split out code where necessary seems cleaner than calling it conditionally as part of the general sync(). Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2389>
This commit is contained in:
parent
9e40e14c34
commit
d03a94dab1
@ -32,7 +32,6 @@ class Indicator extends PanelMenu.SystemIndicator {
|
|||||||
super._init();
|
super._init();
|
||||||
|
|
||||||
this._profileItems = new Map();
|
this._profileItems = new Map();
|
||||||
this._updateProfiles = true;
|
|
||||||
|
|
||||||
this._proxy = new PowerProfilesProxy(Gio.DBus.system, BUS_NAME, OBJECT_PATH,
|
this._proxy = new PowerProfilesProxy(Gio.DBus.system, BUS_NAME, OBJECT_PATH,
|
||||||
(proxy, error) => {
|
(proxy, error) => {
|
||||||
@ -42,9 +41,11 @@ class Indicator extends PanelMenu.SystemIndicator {
|
|||||||
this._proxy.connect('g-properties-changed',
|
this._proxy.connect('g-properties-changed',
|
||||||
(p, properties) => {
|
(p, properties) => {
|
||||||
const propertyNames = properties.deep_unpack();
|
const propertyNames = properties.deep_unpack();
|
||||||
this._updateProfiles = 'Profiles' in propertyNames;
|
if ('Profiles' in propertyNames)
|
||||||
|
this._syncProfiles();
|
||||||
this._sync();
|
this._sync();
|
||||||
});
|
});
|
||||||
|
this._syncProfiles();
|
||||||
}
|
}
|
||||||
this._sync();
|
this._sync();
|
||||||
});
|
});
|
||||||
@ -68,13 +69,7 @@ class Indicator extends PanelMenu.SystemIndicator {
|
|||||||
this.menu.setSensitive(sensitive);
|
this.menu.setSensitive(sensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
_sync() {
|
_syncProfiles() {
|
||||||
this._item.visible = this._proxy.g_name_owner !== null;
|
|
||||||
|
|
||||||
if (!this._item.visible)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (this._updateProfiles) {
|
|
||||||
this._profileSection.removeAll();
|
this._profileSection.removeAll();
|
||||||
this._profileItems.clear();
|
this._profileItems.clear();
|
||||||
|
|
||||||
@ -92,9 +87,14 @@ class Indicator extends PanelMenu.SystemIndicator {
|
|||||||
this._profileItems.set(profile, item);
|
this._profileItems.set(profile, item);
|
||||||
this._profileSection.addMenuItem(item);
|
this._profileSection.addMenuItem(item);
|
||||||
}
|
}
|
||||||
this._updateProfiles = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_sync() {
|
||||||
|
this._item.visible = this._proxy.g_name_owner !== null;
|
||||||
|
|
||||||
|
if (!this._item.visible)
|
||||||
|
return;
|
||||||
|
|
||||||
for (const [profile, item] of this._profileItems) {
|
for (const [profile, item] of this._profileItems) {
|
||||||
item.setOrnament(profile === this._proxy.ActiveProfile
|
item.setOrnament(profile === this._proxy.ActiveProfile
|
||||||
? PopupMenu.Ornament.DOT
|
? PopupMenu.Ornament.DOT
|
||||||
|
Loading…
Reference in New Issue
Block a user