From 326c571d5e20ff4781a1aac281fcd05a65a662ac Mon Sep 17 00:00:00 2001 From: Roman Suvorov Date: Thu, 10 Feb 2022 04:22:26 +0300 Subject: [PATCH 1/8] change the position on reboot --- Makefile | 23 ++++---- extension.js | 17 +++++- metadata.json | 1 + prefs.js | 50 ++++++++++++++++++ schemas/gschemas.compiled | Bin 0 -> 406 bytes ...horizontal-workspace-indicator.gschema.xml | 15 ++++++ 6 files changed, 92 insertions(+), 14 deletions(-) create mode 100644 prefs.js create mode 100644 schemas/gschemas.compiled create mode 100644 schemas/org.gnome.shell.extensions.horizontal-workspace-indicator.gschema.xml diff --git a/Makefile b/Makefile index 9c404d4..bb08eee 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,15 @@ -##@ Test -lint: ## Run linters only. - @echo -e "\033[2m→ Run linters...\033[0m" - -test: ## Run go tests for files with tests. - @echo -e "\033[2m→ Run tests for all files...\033[0m" - -check: lint test ## Run full check: lint and test. - ##@ Deploy -zip: ## Make zip file for deploy to https://extensions.gnome.org/upload/. +zip: compile-schemas ## Make zip file for deploy to https://extensions.gnome.org/upload/. @echo -e "\033[2m→ Making zip file...\033[0m" - zip horizontal-workspace-indicatortty2.io.zip metadata.json extension.js stylesheet.css LICENSE + zip horizontal-workspace-indicatortty2.io.zip metadata.json extension.js stylesheet.css LICENSE \ + schemas/gschemas.compiled \ + schemas/org.gnome.shell.extensions.nothing-to-say.gschema.xml + +compile-schemas: ## Compile all in schemas folder + glib-compile-schemas --strict schemas/ + +install: ## Copy to extensions directory for debug. + cp -r * ~/.local/share/gnome-shell/extensions/horizontal-workspace-indicator@tty2.io ##@ Other #------------------------------------------------------------------------------ @@ -19,4 +18,4 @@ help: ## Display help #------------- -------------- .DEFAULT_GOAL := help -.PHONY: help lint test check build install run \ No newline at end of file +.PHONY: help zip compile-schemas install \ No newline at end of file diff --git a/extension.js b/extension.js index 249065a..fbed1a5 100644 --- a/extension.js +++ b/extension.js @@ -2,6 +2,8 @@ const { Clutter, St, GObject } = imports.gi; const Main = imports.ui.main; const PanelMenu = imports.ui.panelMenu; +const ExtensionUtils = imports.misc.extensionUtils; + const bullet = "●"; const circle = "○"; const leftButton = 1; @@ -39,7 +41,7 @@ let WorkspaceIndicator = GObject.registerClass( this.connect('button-press-event', this._onButtonPress); } - _onDestroy() { + destroy() { for (let i = 0; i < this._workspaceManagerSignals.length; i++) global.workspace_manager.disconnect(this._workspaceManagerSignals[i]) super._onDestroy(); @@ -71,12 +73,15 @@ let WorkspaceIndicator = GObject.registerClass( class Extension { constructor(uuid) { + this._indicator = null; this._uuid = uuid; + this.settings = ExtensionUtils.getSettings(); } enable() { this._indicator = new WorkspaceIndicator(); - Main.panel.addToStatusArea(this._uuid, this._indicator); + let widgetPosition = this.settings.get_value("widget-position").unpack(); + Main.panel.addToStatusArea(this._uuid, this._indicator, getWidgetIndex(widgetPosition), widgetPosition); } disable() { @@ -85,6 +90,14 @@ class Extension { } } +function getWidgetIndex(position) { + if (position === "right") { + return 0 + } + + return 1 +} + function getWidgetText() { let txt = ""; let numberWorkspaces = global.workspace_manager.get_n_workspaces(); diff --git a/metadata.json b/metadata.json index 96a94b7..f0ee2e0 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,7 @@ { "description": "Workspace indicator shows the amount of opened workspaces and the current one", "name": "Workspace indicator", + "settings-schema": "org.gnome.shell.extensions.horizontal-workspace-indicator", "shell-version": ["3.38","40", "41"], "url": "https://github.com/tty2/horizontal-workspace-indicator", "uuid": "horizontal-workspace-indicator@tty2.io", diff --git a/prefs.js b/prefs.js new file mode 100644 index 0000000..626c943 --- /dev/null +++ b/prefs.js @@ -0,0 +1,50 @@ +"use strict"; + +const Gio = imports.gi.Gio; +const Gtk = imports.gi.Gtk; + +const ExtensionUtils = imports.misc.extensionUtils; +const Extension = ExtensionUtils.getCurrentExtension(); + +function init() {} + +function buildPrefsWidget() { + this.settings = ExtensionUtils.getSettings(); + + const prefsWidget = new Gtk.Grid({ + // margin: 18, + column_spacing: 12, + row_spacing: 12, + visible: true, + }); + + // Add a simple title and add it to the prefsWidget + let title = new Gtk.Label({ + label: `Preferences`, + halign: Gtk.Align.START, + use_markup: true, + visible: true + }); + prefsWidget.attach(title, 0, 0, 2, 1); + + const widgetPositionLabel = new Gtk.Label({ + label: "Widget position", + halign: Gtk.Align.START, + visible: true, + }); + prefsWidget.attach(widgetPositionLabel, 0, 1, 1, 1); + + const widgetPositionComboBox = new Gtk.ComboBoxText(); + widgetPositionComboBox.append("right", "Right corner | Status area"); + widgetPositionComboBox.append("center", "Center | Date time area"); + widgetPositionComboBox.append("left", "Left corner | Activities area"); + this.settings.bind( + "widget-position", + widgetPositionComboBox, + "active-id", + Gio.SettingsBindFlags.DEFAULT + ); + prefsWidget.attach(widgetPositionComboBox, 1, 1, 1, 1); + + return prefsWidget; +} \ No newline at end of file diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled new file mode 100644 index 0000000000000000000000000000000000000000..08082a1159c4cb1a12dc259fcbef928966c316b0 GIT binary patch literal 406 zcmaJ-Jxc^J5FM4XInY7`f5Kj|Nn>N7SO{8NEeG0!y>U0VCQB0URM6f(ApRVGl>Pc9 z@vw7X^5)}Z@-mm#CRpPV{n`<5QQ~TQQv^;9iAGrI%`@i~^@E$eccDpqLRa(&{DyDA zeP~td`~$1lao;O`O6;QbE~?H4`{G?PeZBVKJ`Seg+PbA}O!5JDVbxB-e9FA9*SD!? zkogl@Nymm=;{3~!_k0KLxJy;6p3UQI_5 + + + + + + + + + 'right' + Widget position + This specifies the position of widget on the left, center or right of top panel. + + + \ No newline at end of file From f6e93d4d92b6804d885ff022114d75bbddac24e2 Mon Sep 17 00:00:00 2001 From: Roman Suvorov Date: Thu, 10 Feb 2022 04:34:37 +0300 Subject: [PATCH 2/8] super destroy --- extension.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension.js b/extension.js index fbed1a5..f1d4e28 100644 --- a/extension.js +++ b/extension.js @@ -44,7 +44,7 @@ let WorkspaceIndicator = GObject.registerClass( destroy() { for (let i = 0; i < this._workspaceManagerSignals.length; i++) global.workspace_manager.disconnect(this._workspaceManagerSignals[i]) - super._onDestroy(); + super.destroy(); } _updateView() { From fa69ac6c12144541bc53aa8d1f2bc178afd06f5d Mon Sep 17 00:00:00 2001 From: Roman Suvorov Date: Thu, 10 Feb 2022 04:52:00 +0300 Subject: [PATCH 3/8] add margin --- prefs.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/prefs.js b/prefs.js index 626c943..226d0c8 100644 --- a/prefs.js +++ b/prefs.js @@ -12,7 +12,10 @@ function buildPrefsWidget() { this.settings = ExtensionUtils.getSettings(); const prefsWidget = new Gtk.Grid({ - // margin: 18, + margin_top: 20, + margin_bottom: 20, + margin_start: 20, + margin_end: 20, column_spacing: 12, row_spacing: 12, visible: true, From 38372ac68764566272d6d934d9c32bfb7ab03cd7 Mon Sep 17 00:00:00 2001 From: Roman Suvorov Date: Thu, 10 Feb 2022 10:20:00 +0300 Subject: [PATCH 4/8] change widget position --- Makefile | 4 ++-- prefs.js | 2 +- ...hell.extensions.horizontal-workspace-indicator.gschema.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index bb08eee..b39623d 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ zip: compile-schemas ## Make zip file for deploy to https://extensions.gnome.org compile-schemas: ## Compile all in schemas folder glib-compile-schemas --strict schemas/ -install: ## Copy to extensions directory for debug. +install: compile-schemas ## Copy to extensions directory for debug. cp -r * ~/.local/share/gnome-shell/extensions/horizontal-workspace-indicator@tty2.io ##@ Other @@ -18,4 +18,4 @@ help: ## Display help #------------- -------------- .DEFAULT_GOAL := help -.PHONY: help zip compile-schemas install \ No newline at end of file +.PHONY: help zip compile-schemas install diff --git a/prefs.js b/prefs.js index 226d0c8..b971a3c 100644 --- a/prefs.js +++ b/prefs.js @@ -50,4 +50,4 @@ function buildPrefsWidget() { prefsWidget.attach(widgetPositionComboBox, 1, 1, 1, 1); return prefsWidget; -} \ No newline at end of file +} diff --git a/schemas/org.gnome.shell.extensions.horizontal-workspace-indicator.gschema.xml b/schemas/org.gnome.shell.extensions.horizontal-workspace-indicator.gschema.xml index 7eb0f8f..cfcfbec 100644 --- a/schemas/org.gnome.shell.extensions.horizontal-workspace-indicator.gschema.xml +++ b/schemas/org.gnome.shell.extensions.horizontal-workspace-indicator.gschema.xml @@ -12,4 +12,4 @@ This specifies the position of widget on the left, center or right of top panel. - \ No newline at end of file + From a1cacd30ca5cb8b0d642efac1e9139bf8c30531f Mon Sep 17 00:00:00 2001 From: Roman Suvorov Date: Thu, 10 Feb 2022 22:24:21 +0300 Subject: [PATCH 5/8] align prefs in center --- metadata.json | 2 +- prefs.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/metadata.json b/metadata.json index f0ee2e0..6126ee9 100644 --- a/metadata.json +++ b/metadata.json @@ -5,5 +5,5 @@ "shell-version": ["3.38","40", "41"], "url": "https://github.com/tty2/horizontal-workspace-indicator", "uuid": "horizontal-workspace-indicator@tty2.io", - "version": "0.0.9" + "version": "0.1.0" } diff --git a/prefs.js b/prefs.js index b971a3c..baaf867 100644 --- a/prefs.js +++ b/prefs.js @@ -21,21 +21,28 @@ function buildPrefsWidget() { visible: true, }); - // Add a simple title and add it to the prefsWidget let title = new Gtk.Label({ label: `Preferences`, - halign: Gtk.Align.START, + halign: Gtk.Align.CENTER, use_markup: true, visible: true }); prefsWidget.attach(title, 0, 0, 2, 1); + let note = new Gtk.Label({ + label: `After any changes turn the extension off and on again.`, + halign: Gtk.Align.CENTER, + use_markup: true, + visible: true + }); + prefsWidget.attach(note, 0, 1, 2, 1); + const widgetPositionLabel = new Gtk.Label({ label: "Widget position", halign: Gtk.Align.START, visible: true, }); - prefsWidget.attach(widgetPositionLabel, 0, 1, 1, 1); + prefsWidget.attach(widgetPositionLabel, 0, 2, 1, 1); const widgetPositionComboBox = new Gtk.ComboBoxText(); widgetPositionComboBox.append("right", "Right corner | Status area"); @@ -47,7 +54,7 @@ function buildPrefsWidget() { "active-id", Gio.SettingsBindFlags.DEFAULT ); - prefsWidget.attach(widgetPositionComboBox, 1, 1, 1, 1); + prefsWidget.attach(widgetPositionComboBox, 1, 2, 1, 1); return prefsWidget; } From 16409b30f115ba0d72b04a0670b8eeabac0480fb Mon Sep 17 00:00:00 2001 From: Roman Suvorov Date: Fri, 11 Feb 2022 23:47:53 +0300 Subject: [PATCH 6/8] center prefs --- prefs.js | 1 + 1 file changed, 1 insertion(+) diff --git a/prefs.js b/prefs.js index baaf867..aa89efe 100644 --- a/prefs.js +++ b/prefs.js @@ -19,6 +19,7 @@ function buildPrefsWidget() { column_spacing: 12, row_spacing: 12, visible: true, + halign: Gtk.Align.CENTER, }); let title = new Gtk.Label({ From be2266a82f71e80755433db8e38410eef6553b90 Mon Sep 17 00:00:00 2001 From: Roman Suvorov Date: Fri, 11 Feb 2022 23:48:31 +0300 Subject: [PATCH 7/8] because of settings support only from gnome 40 > --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 6126ee9..f48baa5 100644 --- a/metadata.json +++ b/metadata.json @@ -2,7 +2,7 @@ "description": "Workspace indicator shows the amount of opened workspaces and the current one", "name": "Workspace indicator", "settings-schema": "org.gnome.shell.extensions.horizontal-workspace-indicator", - "shell-version": ["3.38","40", "41"], + "shell-version": ["40", "41"], "url": "https://github.com/tty2/horizontal-workspace-indicator", "uuid": "horizontal-workspace-indicator@tty2.io", "version": "0.1.0" From 81875075018a297932a6acdf0626ed4027c5a1e1 Mon Sep 17 00:00:00 2001 From: Roman Suvorov Date: Fri, 11 Feb 2022 23:52:25 +0300 Subject: [PATCH 8/8] add prefs to zip --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b39623d..c7eeb92 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ ##@ Deploy zip: compile-schemas ## Make zip file for deploy to https://extensions.gnome.org/upload/. @echo -e "\033[2m→ Making zip file...\033[0m" - zip horizontal-workspace-indicatortty2.io.zip metadata.json extension.js stylesheet.css LICENSE \ + zip horizontal-workspace-indicatortty2.io.zip metadata.json extension.js stylesheet.css prefs.js \ + LICENSE \ schemas/gschemas.compiled \ schemas/org.gnome.shell.extensions.nothing-to-say.gschema.xml