From a50d64e8e97b123f1e13a5f34098dcefbf7ff25f Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 18 Jan 2010 14:56:02 -0500 Subject: [PATCH] [overview] disable the AddWorkspaceButton if there are >= 16 workspaces https://bugzilla.gnome.org/show_bug.cgi?id=606460 --- js/ui/overview.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/js/ui/overview.js b/js/ui/overview.js index 43ff6d75d..6281dbfe4 100644 --- a/js/ui/overview.js +++ b/js/ui/overview.js @@ -467,6 +467,9 @@ Overview.prototype = { }; Signals.addSignalMethods(Overview.prototype); +// Note that mutter has a compile-time limit of 36 +const MAX_WORKSPACES = 16; + function AddWorkspaceButton(buttonSize, buttonX, buttonY, acceptDropCallback) { this._init(buttonSize, buttonX, buttonY, acceptDropCallback); } @@ -487,6 +490,21 @@ AddWorkspaceButton.prototype = { height: buttonSize }); plus.set_from_file(global.imagedir + 'add-workspace.svg'); this.actor.add_actor(plus); + + global.screen.connect('notify::n-workspaces', Lang.bind(this, this._nWorkspacesChanged)); + this._nWorkspacesChanged(); + }, + + _nWorkspacesChanged: function() { + let canAddAnother = global.screen.n_workspaces < MAX_WORKSPACES; + + if (canAddAnother && !this.actor.reactive) { + this.actor.reactive = true; + this.actor.opacity = 255; + } else if (!canAddAnother && this.actor.reactive) { + this.actor.reactive = false; + this.actor.opacity = 85; + } }, // Draggable target interface