[gnome-shell] [overview] disable the AddWorkspaceButton if there are >= 16 workspaces



commit a50d64e8e97b123f1e13a5f34098dcefbf7ff25f
Author: Dan Winship <danw gnome org>
Date:   Mon Jan 18 14:56:02 2010 -0500

    [overview] disable the AddWorkspaceButton if there are >= 16 workspaces
    
    https://bugzilla.gnome.org/show_bug.cgi?id=606460

 js/ui/overview.js |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 43ff6d7..6281dbf 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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]