From 6f4e615999afed93d502315570d73a8ea2060469 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Mon, 28 Nov 2011 19:35:38 +0100 Subject: [PATCH] workspace-indicator: fix removing the last workspace When closing the last workspace, we could access an invalid item, causing a TypeError and therefore leaving a stale "Workspace 2" label. --- extensions/workspace-indicator/extension.js | 32 ++++++++++++--------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/extensions/workspace-indicator/extension.js b/extensions/workspace-indicator/extension.js index 7f5ca46c..3236eca5 100644 --- a/extensions/workspace-indicator/extension.js +++ b/extensions/workspace-indicator/extension.js @@ -55,22 +55,26 @@ WorkspaceIndicator.prototype = { }, _createWorkspacesSection : function() { - this._workspaceSection.removeAll(); - this.workspacesItems = []; + this._workspaceSection.removeAll(); + this.workspacesItems = []; + this._currentWorkspace = global.screen.get_active_workspace().index(); - let i = 0; - for(; i < global.screen.n_workspaces; i++) { - this.workspacesItems[i] = new PopupMenu.PopupMenuItem(this._labelText(i)); - this._workspaceSection.addMenuItem(this.workspacesItems[i]); - this.workspacesItems[i].workspaceId = i; - this.workspacesItems[i].label_actor = this.statusLabel; - let self = this; - this.workspacesItems[i].connect('activate', Lang.bind(this, function(actor, event) { - this._activate(actor.workspaceId); - })); - } + let i = 0; + for(; i < global.screen.n_workspaces; i++) { + this.workspacesItems[i] = new PopupMenu.PopupMenuItem(this._labelText(i)); + this._workspaceSection.addMenuItem(this.workspacesItems[i]); + this.workspacesItems[i].workspaceId = i; + this.workspacesItems[i].label_actor = this.statusLabel; + let self = this; + this.workspacesItems[i].connect('activate', Lang.bind(this, function(actor, event) { + this._activate(actor.workspaceId); + })); - this._updateIndicator(); + if (i == this._currentWorkspace) + this.workspacesItems[i].setShowDot(true); + } + + this.statusLabel.set_text(this._labelText()); }, _activate : function (index) {