quickSettings: Add SystemIndicator

This serves the exact same purpose as the existing SystemIndicator
class from PanelMenu, except that it exposes a quickSettingsItems
array instead of a menu.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2392>
This commit is contained in:
Florian Müllner 2022-07-24 19:29:50 +02:00 committed by Marge Bot
parent e5d4984c1b
commit f18d103f83

View File

@ -1,4 +1,4 @@
/* exported QuickToggle, QuickSettingsMenu */
/* exported QuickToggle, QuickSettingsMenu, SystemIndicator */
const {Atk, Clutter, Gio, GLib, GObject, Pango, St} = imports.gi;
const Main = imports.ui.main;
@ -268,3 +268,28 @@ var QuickSettingsMenu = class extends PopupMenu.PopupMenu {
this._grid, item, 'column-span', colSpan);
}
};
var SystemIndicator = GObject.registerClass(
class SystemIndicator extends St.BoxLayout {
_init() {
super._init({
style_class: 'panel-status-indicators-box',
reactive: true,
visible: false,
});
this.quickSettingsItems = [];
}
_syncIndicatorsVisible() {
this.visible = this.get_children().some(a => a.visible);
}
_addIndicator() {
const icon = new St.Icon({style_class: 'system-status-icon'});
this.add_actor(icon);
icon.connect('notify::visible', () => this._syncIndicatorsVisible());
this._syncIndicatorsVisible();
return icon;
}
});