From 49bfa46b5981e94b240780240115fcdabd46a178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 21 Feb 2024 16:13:00 +0100 Subject: [PATCH 13/28] workspace-indicator: Small cleanup The code to update the menu labels is a bit cleaner in the window-list extension, so use that. Part-of: --- .../workspace-indicator/workspaceIndicator.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/extensions/workspace-indicator/workspaceIndicator.js b/extensions/workspace-indicator/workspaceIndicator.js index f118654e..e04e93a4 100644 --- a/extensions/workspace-indicator/workspaceIndicator.js +++ b/extensions/workspace-indicator/workspaceIndicator.js @@ -407,19 +407,18 @@ export class WorkspaceIndicator extends PanelMenu.Button { this._workspacesItems = []; this._currentWorkspace = workspaceManager.get_active_workspace_index(); - let i = 0; - for (; i < workspaceManager.n_workspaces; i++) { - this._workspacesItems[i] = new PopupMenu.PopupMenuItem(this._labelText(i)); - this.menu.addMenuItem(this._workspacesItems[i]); - this._workspacesItems[i].workspaceId = i; - this._workspacesItems[i].label_actor = this._statusLabel; - this._workspacesItems[i].connect('activate', (actor, _event) => { - this._activate(actor.workspaceId); - }); + for (let i = 0; i < workspaceManager.n_workspaces; i++) { + const item = new PopupMenu.PopupMenuItem(this._labelText(i)); - this._workspacesItems[i].setOrnament(i === this._currentWorkspace + item.connect('activate', + () => this._activate(i)); + + item.setOrnament(i === this._currentWorkspace ? PopupMenu.Ornament.DOT : PopupMenu.Ornament.NO_DOT); + + this.menu.addMenuItem(item); + this._workspacesItems[i] = item; } this._statusLabel.set_text(this._labelText()); -- 2.44.0