[gnome-shell-extensions] workspace-indicator: Only show previews for up to six workspaces
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions] workspace-indicator: Only show previews for up to six workspaces
- Date: Wed, 10 Mar 2021 19:27:50 +0000 (UTC)
commit bb2b1204b47a26c0003b795dce3aff5a372ec97d
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Mar 10 00:14:17 2021 +0100
workspace-indicator: Only show previews for up to six workspaces
On request of GNOME Classic users, we add GNOME2-like workspace previews
when using a horizontal workspace layout. The previews scale a lot worse
than the menu though, with the risk that they take up all the available
width in extreme cases.
Address this by also taking the number of workspaces into account, and
switch to the menu when we have more than six.
This is particularly important now that we switched to a horizontal
layout by default.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/165>
extensions/workspace-indicator/extension.js | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/extensions/workspace-indicator/extension.js b/extensions/workspace-indicator/extension.js
index ad4e59b..b79af93 100644
--- a/extensions/workspace-indicator/extension.js
+++ b/extensions/workspace-indicator/extension.js
@@ -18,6 +18,8 @@ const WORKSPACE_KEY = 'workspace-names';
const TOOLTIP_OFFSET = 6;
const TOOLTIP_ANIMATION_TIME = 150;
+const MAX_THUMBNAILS = 6;
+
let WindowPreview = GObject.registerClass(
class WindowPreview extends St.Button {
_init(window) {
@@ -288,14 +290,14 @@ class WorkspaceIndicator extends PanelMenu.Button {
workspaceManager.connect_after('workspace-switched',
this._onWorkspaceSwitched.bind(this)),
workspaceManager.connect('notify::layout-rows',
- this._onWorkspaceOrientationChanged.bind(this)),
+ this._updateThumbnailVisibility.bind(this)),
];
this.connect('scroll-event', this._onScrollEvent.bind(this));
this._thumbnailsBox.connect('scroll-event', this._onScrollEvent.bind(this));
this._createWorkspacesSection();
this._updateThumbnails();
- this._onWorkspaceOrientationChanged();
+ this._updateThumbnailVisibility();
this._settings = new Gio.Settings({ schema_id: WORKSPACE_SCHEMA });
this._settingsChangedId = this._settings.connect(
@@ -317,16 +319,19 @@ class WorkspaceIndicator extends PanelMenu.Button {
super._onDestroy();
}
- _onWorkspaceOrientationChanged() {
- let vertical = global.workspace_manager.layout_rows === -1;
- this.reactive = vertical;
+ _updateThumbnailVisibility() {
+ const { workspaceManager } = global;
+ const vertical = workspaceManager.layout_rows === -1;
+ const useMenu =
+ vertical || workspaceManager.n_workspaces > MAX_THUMBNAILS;
+ this.reactive = useMenu;
- this._statusLabel.visible = vertical;
- this._thumbnailsBox.visible = !vertical;
+ this._statusLabel.visible = useMenu;
+ this._thumbnailsBox.visible = !useMenu;
// Disable offscreen-redirect when showing the workspace switcher
// so that clip-to-allocation works
- Main.panel.set_offscreen_redirect(vertical
+ Main.panel.set_offscreen_redirect(useMenu
? Clutter.OffscreenRedirect.ALWAYS
: Clutter.OffscreenRedirect.AUTOMATIC_FOR_OPACITY);
}
@@ -343,6 +348,7 @@ class WorkspaceIndicator extends PanelMenu.Button {
_nWorkspacesChanged() {
this._createWorkspacesSection();
this._updateThumbnails();
+ this._updateThumbnailVisibility();
}
_updateMenuOrnament() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]