system: Track buttonGroup visibility using a group of actors

Cleanup the visibility check on actions by using an array of actors to
track, so that we don't repeat the same variables multiple times.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/700
This commit is contained in:
Marco Trevisan (Treviño) 2019-08-31 23:09:04 +02:00 committed by Florian Müllner
parent 15c252c11d
commit a497afe695

View File

@ -137,15 +137,6 @@ var Indicator = class extends PanelMenu.SystemIndicator {
this._sessionUpdated();
}
_updateActionsVisibility() {
let visible = (this._settingsAction.visible ||
this._orientationLockAction.visible ||
this._lockScreenAction.visible ||
this._altSwitcher.actor.visible);
this.buttonGroup.visible = visible;
}
_sessionUpdated() {
this._settingsAction.visible = Main.sessionMode.allowSettings;
}
@ -302,15 +293,18 @@ var Indicator = class extends PanelMenu.SystemIndicator {
this.menu.addMenuItem(item);
let visibilityGroup = [
this._settingsAction,
this._orientationLockAction,
this._lockScreenAction,
this._altSwitcher.actor,
];
this._settingsAction.connect('notify::visible',
() => this._updateActionsVisibility());
this._orientationLockAction.connect('notify::visible',
() => this._updateActionsVisibility());
this._lockScreenAction.connect('notify::visible',
() => this._updateActionsVisibility());
this._altSwitcher.actor.connect('notify::visible',
() => this._updateActionsVisibility());
for (let actor of visibilityGroup) {
actor.connect('notify::visible', () => {
this.buttonGroup.visible = visibilityGroup.some(a => a.visible);
});
}
}
_onSettingsClicked() {