88 lines
3.3 KiB
Diff
88 lines
3.3 KiB
Diff
|
From 5455a97a04c6a2925f5113a85c2e09cff215941d Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
||
|
Date: Wed, 21 Feb 2024 16:13:00 +0100
|
||
|
Subject: [PATCH 14/28] workspace-indicator: Simplify getting status text
|
||
|
|
||
|
Currently the same method is used to get the label text for the
|
||
|
indicator itself and for the menu items.
|
||
|
|
||
|
A method that behaves significantly different depending on whether
|
||
|
a parameter is passed is confusing, so only deal with the indicator
|
||
|
label and directly use the mutter API to get the workspace names
|
||
|
for menu items.
|
||
|
|
||
|
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/307>
|
||
|
---
|
||
|
.../workspace-indicator/workspaceIndicator.js | 24 +++++++++----------
|
||
|
1 file changed, 12 insertions(+), 12 deletions(-)
|
||
|
|
||
|
diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js
|
||
|
index e04e93a4..0538e6b2 100644
|
||
|
--- a/extensions/workspace-indicator/workspaceIndicator.js
|
||
|
+++ b/extensions/workspace-indicator/workspaceIndicator.js
|
||
|
@@ -279,7 +279,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||
|
this._statusLabel = new St.Label({
|
||
|
style_class: 'status-label',
|
||
|
y_align: Clutter.ActorAlign.CENTER,
|
||
|
- text: this._labelText(),
|
||
|
+ text: this._getStatusText(),
|
||
|
});
|
||
|
|
||
|
container.add_child(this._statusLabel);
|
||
|
@@ -360,7 +360,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||
|
this._updateMenuOrnament();
|
||
|
this._updateActiveThumbnail();
|
||
|
|
||
|
- this._statusLabel.set_text(this._labelText());
|
||
|
+ this._statusLabel.set_text(this._getStatusText());
|
||
|
}
|
||
|
|
||
|
_nWorkspacesChanged() {
|
||
|
@@ -387,17 +387,16 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- _labelText(workspaceIndex) {
|
||
|
- if (workspaceIndex === undefined) {
|
||
|
- workspaceIndex = this._currentWorkspace;
|
||
|
- return (workspaceIndex + 1).toString();
|
||
|
- }
|
||
|
- return Meta.prefs_get_workspace_name(workspaceIndex);
|
||
|
+ _getStatusText() {
|
||
|
+ const current = this._currentWorkspace + 1;
|
||
|
+ return `${current}`;
|
||
|
}
|
||
|
|
||
|
_updateMenuLabels() {
|
||
|
- for (let i = 0; i < this._workspacesItems.length; i++)
|
||
|
- this._workspacesItems[i].label.text = this._labelText(i);
|
||
|
+ for (let i = 0; i < this._workspacesItems.length; i++) {
|
||
|
+ const item = this._workspacesItems[i];
|
||
|
+ item.label.text = Meta.prefs_get_workspace_name(i);
|
||
|
+ }
|
||
|
}
|
||
|
|
||
|
_updateMenu() {
|
||
|
@@ -408,7 +407,8 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||
|
this._currentWorkspace = workspaceManager.get_active_workspace_index();
|
||
|
|
||
|
for (let i = 0; i < workspaceManager.n_workspaces; i++) {
|
||
|
- const item = new PopupMenu.PopupMenuItem(this._labelText(i));
|
||
|
+ const name = Meta.prefs_get_workspace_name(i);
|
||
|
+ const item = new PopupMenu.PopupMenuItem(name);
|
||
|
|
||
|
item.connect('activate',
|
||
|
() => this._activate(i));
|
||
|
@@ -421,7 +421,7 @@ export class WorkspaceIndicator extends PanelMenu.Button {
|
||
|
this._workspacesItems[i] = item;
|
||
|
}
|
||
|
|
||
|
- this._statusLabel.set_text(this._labelText());
|
||
|
+ this._statusLabel.set_text(this._getStatusText());
|
||
|
}
|
||
|
|
||
|
_updateThumbnails() {
|
||
|
--
|
||
|
2.44.0
|
||
|
|