gnome-shell-extensions/more-ws-previews-0027-workspace-indicator-Make-previews-configurable.patch

216 lines
8.1 KiB
Diff
Raw Normal View History

From 8d2b24290204be98423b3a952939895133bdc036 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Tue, 20 Feb 2024 22:00:57 +0100
Subject: [PATCH 27/28] workspace-indicator: Make previews configurable
Now that previews scroll when there are too many workspaces,
there is no longer a reason for the 6-workspace limit.
However some users do prefer the menu, so rather than drop it,
turn it into a proper preference.
Closes
https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/issues/336
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/316>
---
extensions/window-list/extension.js | 1 +
...e.shell.extensions.window-list.gschema.xml | 4 +++
extensions/workspace-indicator/extension.js | 4 ++-
extensions/workspace-indicator/meson.build | 1 +
extensions/workspace-indicator/prefs.js | 26 +++++++++++++++++--
...extensions.workspace-indicator.gschema.xml | 15 +++++++++++
.../workspace-indicator/workspaceIndicator.js | 11 ++++----
po/POTFILES.in | 1 +
8 files changed, 55 insertions(+), 8 deletions(-)
create mode 100644 extensions/workspace-indicator/schemas/org.gnome.shell.extensions.workspace-indicator.gschema.xml
diff --git a/extensions/window-list/extension.js b/extensions/window-list/extension.js
index 3950c535..227625e5 100644
--- a/extensions/window-list/extension.js
+++ b/extensions/window-list/extension.js
@@ -769,6 +769,7 @@ class WindowList extends St.Widget {
this._workspaceIndicator = new BottomWorkspaceIndicator({
baseStyleClass: 'window-list-workspace-indicator',
+ settings,
});
indicatorsBox.add_child(this._workspaceIndicator.container);
diff --git a/extensions/window-list/org.gnome.shell.extensions.window-list.gschema.xml b/extensions/window-list/org.gnome.shell.extensions.window-list.gschema.xml
index 2ed680a5..46ff25cb 100644
--- a/extensions/window-list/org.gnome.shell.extensions.window-list.gschema.xml
+++ b/extensions/window-list/org.gnome.shell.extensions.window-list.gschema.xml
@@ -36,5 +36,9 @@ SPDX-License-Identifier: GPL-2.0-or-later
only on the primary one.
</description>
</key>
+ <key name="embed-previews" type="b">
+ <default>true</default>
+ <summary>Show workspace previews in window list</summary>
+ </key>
</schema>
</schemalist>
diff --git a/extensions/workspace-indicator/extension.js b/extensions/workspace-indicator/extension.js
index b383c919..ef24a750 100644
--- a/extensions/workspace-indicator/extension.js
+++ b/extensions/workspace-indicator/extension.js
@@ -12,7 +12,9 @@ import {WorkspaceIndicator} from './workspaceIndicator.js';
export default class WorkspaceIndicatorExtension extends Extension {
enable() {
- this._indicator = new WorkspaceIndicator();
+ this._indicator = new WorkspaceIndicator({
+ settings: this.getSettings(),
+ });
Main.panel.addToStatusArea('workspace-indicator', this._indicator);
}
diff --git a/extensions/workspace-indicator/meson.build b/extensions/workspace-indicator/meson.build
index dada5408..9388085c 100644
--- a/extensions/workspace-indicator/meson.build
+++ b/extensions/workspace-indicator/meson.build
@@ -11,5 +11,6 @@ extension_data += files(
'stylesheet-dark.css',
'stylesheet-light.css',
)
+extension_schemas += files('schemas/' + metadata_conf.get('gschemaname') + '.gschema.xml')
extension_sources += files('prefs.js', 'workspaceIndicator.js')
diff --git a/extensions/workspace-indicator/prefs.js b/extensions/workspace-indicator/prefs.js
index ea0546bf..b828ab8f 100644
--- a/extensions/workspace-indicator/prefs.js
+++ b/extensions/workspace-indicator/prefs.js
@@ -18,6 +18,25 @@ const N_ = e => e;
const WORKSPACE_SCHEMA = 'org.gnome.desktop.wm.preferences';
const WORKSPACE_KEY = 'workspace-names';
+class GeneralGroup extends Adw.PreferencesGroup {
+ static {
+ GObject.registerClass(this);
+ }
+
+ constructor(settings) {
+ super();
+
+ const row = new Adw.SwitchRow({
+ title: _('Show Previews In Top Bar'),
+ });
+ this.add(row);
+
+ settings.bind('embed-previews',
+ row, 'active',
+ Gio.SettingsBindFlags.DEFAULT);
+ }
+}
+
class NewItem extends GObject.Object {}
GObject.registerClass(NewItem);
@@ -119,7 +138,7 @@ class WorkspacesList extends GObject.Object {
}
}
-class WorkspaceSettingsWidget extends Adw.PreferencesGroup {
+class WorkspacesGroup extends Adw.PreferencesGroup {
static {
GObject.registerClass(this);
@@ -265,6 +284,9 @@ class NewWorkspaceRow extends Adw.PreferencesRow {
export default class WorkspaceIndicatorPrefs extends ExtensionPreferences {
getPreferencesWidget() {
- return new WorkspaceSettingsWidget();
+ const page = new Adw.PreferencesPage();
+ page.add(new GeneralGroup(this.getSettings()));
+ page.add(new WorkspacesGroup());
+ return page;
}
}
diff --git a/extensions/workspace-indicator/schemas/org.gnome.shell.extensions.workspace-indicator.gschema.xml b/extensions/workspace-indicator/schemas/org.gnome.shell.extensions.workspace-indicator.gschema.xml
new file mode 100644
index 00000000..c7c634ca
--- /dev/null
+++ b/extensions/workspace-indicator/schemas/org.gnome.shell.extensions.workspace-indicator.gschema.xml
@@ -0,0 +1,15 @@
+<!--
+SPDX-FileCopyrightText: 2024 Florian Müllner <fmuellner@gnome.org>
+
+SPDX-License-Identifier: GPL-2.0-or-later
+-->
+
+<schemalist gettext-domain="gnome-shell-extensions">
+ <schema id="org.gnome.shell.extensions.workspace-indicator"
+ path="/org/gnome/shell/extensions/workspace-indicator/">
+ <key name="embed-previews" type="b">
+ <default>true</default>
+ <summary>Show workspace previews in top bar</summary>
+ </key>
+ </schema>
+</schemalist>
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
index a4d3bbee..20d4caa2 100644
--- a/extensions/workspace-indicator/workspaceIndicator.js
+++ b/extensions/workspace-indicator/workspaceIndicator.js
@@ -22,8 +22,6 @@ const TOOLTIP_ANIMATION_TIME = 150;
const SCROLL_TIME = 100;
-const MAX_THUMBNAILS = 6;
-
let baseStyleClassName = '';
class WindowPreview extends St.Button {
@@ -433,8 +431,11 @@ export class WorkspaceIndicator extends PanelMenu.Button {
const {
baseStyleClass = 'workspace-indicator',
+ settings,
} = params;
+ this._settings = settings;
+
baseStyleClassName = baseStyleClass;
this.add_style_class_name(baseStyleClassName);
@@ -461,7 +462,6 @@ export class WorkspaceIndicator extends PanelMenu.Button {
this._workspacesItems = [];
workspaceManager.connectObject(
- 'notify::n-workspaces', this._updateThumbnailVisibility.bind(this), GObject.ConnectFlags.AFTER,
'workspace-switched', this._onWorkspaceSwitched.bind(this), GObject.ConnectFlags.AFTER,
this);
@@ -477,6 +477,8 @@ export class WorkspaceIndicator extends PanelMenu.Button {
this._updateTopBarRedirect();
});
+ this._settings.connect('changed::embed-previews',
+ () => this._updateThumbnailVisibility());
this._updateThumbnailVisibility();
}
@@ -489,8 +491,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
}
_updateThumbnailVisibility() {
- const {workspaceManager} = global;
- const useMenu = workspaceManager.n_workspaces > MAX_THUMBNAILS;
+ const useMenu = !this._settings.get_boolean('embed-previews');
this.reactive = useMenu;
this._statusLabel.visible = useMenu;
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 182b2be0..e6e76039 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -21,4 +21,5 @@ extensions/window-list/prefs.js
extensions/window-list/workspaceIndicator.js
extensions/windowsNavigator/extension.js
extensions/workspace-indicator/prefs.js
+extensions/workspace-indicator/schemas/org.gnome.shell.extensions.workspace-indicator.gschema.xml
extensions/workspace-indicator/workspaceIndicator.js
--
2.44.0