From f18d103f832c4f4fc1fb0efa93701d79b64b6952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sun, 24 Jul 2022 19:29:50 +0200 Subject: [PATCH] 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: --- js/ui/quickSettings.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/js/ui/quickSettings.js b/js/ui/quickSettings.js index 340d6a375..0858d6922 100644 --- a/js/ui/quickSettings.js +++ b/js/ui/quickSettings.js @@ -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; + } +});