From 2ca950d57965ae39be3f39a6d23a86b9a09a2698 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Wed, 17 May 2023 01:50:46 +0900 Subject: [PATCH] Add color/name settings for the tag indicator --- ...g.gnome.shell.extensions.fairy.gschema.xml | 8 +++++++ sources/indicator.js | 23 ++++++++++--------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/schemas/org.gnome.shell.extensions.fairy.gschema.xml b/schemas/org.gnome.shell.extensions.fairy.gschema.xml index f037247..a682c08 100644 --- a/schemas/org.gnome.shell.extensions.fairy.gschema.xml +++ b/schemas/org.gnome.shell.extensions.fairy.gschema.xml @@ -15,6 +15,14 @@ true Show the tags icon on the panel + + '#ff0000' + The color of the active tags on the panel + + + [] + The name of the tags + true diff --git a/sources/indicator.js b/sources/indicator.js index 922c882..61723c5 100644 --- a/sources/indicator.js +++ b/sources/indicator.js @@ -29,6 +29,7 @@ var Indicator = GObject.registerClass( endInit(ext) { this._state = ext._state; + this._settings = ext._settings; this._renderer = ext._renderer; this._keybinds = ext._keybinds; } @@ -41,13 +42,9 @@ var Indicator = GObject.registerClass( } enable() { - this.settings = ExtensionUtils.getSettings( - "org.gnome.shell.extensions.fairy" - ); - const tagIndicatorName = `${Me.metadata.name} Tag Indicator`; this._tagIndicator = new PanelMenu.Button(0.0, tagIndicatorName); - this.settings.bind( + this._settings.bind( "show-tags", this._tagIndicator, "visible", @@ -88,7 +85,7 @@ var Indicator = GObject.registerClass( this._layoutIndicator.menu.addMenuItem(this._nmasterPanelItem); this._layoutIndicator.menu.addMenuItem(this._mfactPanelItem); - this.settings.bind( + this._settings.bind( "show-layout", this._layoutIndicator, "visible", @@ -107,33 +104,37 @@ var Indicator = GObject.registerClass( 1, "left" ); + this._destroyed = false; this.update(); + + this._settings.connect("changed", () => this.update()); } disable() { - this._tagIndicator.destroy_all_children(); + this._destroyed = true; this._tagIndicator.destroy(); this._tagIndicator = null; this._layoutPanelItems = {}; this._nmasterPanelItem = null; this._mfactPanelItem = nulll; - for (const item of this._layoutIndicator.menu) item.destroy(); this._layoutIndicator.destroy(); this._layoutIndicator = null; this._icon.destroy(); this._icon = null; - this.settings = null; + this._settings.disconnect("changed"); } update() { + if (this._destroyed) return; + const mon = global.display.get_primary_monitor(); const state = this._state.monitors[mon]; // TODO: Retrieve the following two from the settings. - const tagName = []; - const activeColor = "#ff0000"; + const tagName = this._settings.get_strv("tag-names"); + const activeColor = this._settings.get_string("active-tags-color"); this._tagIndicator.destroy_all_children(); let tagBox = new St.BoxLayout();