[gnome-shell] Update visibility of controls on view change.



commit 54168fcd31c09c42a51336c5e7b8a388a8deec4e
Author: Maxim Ermilov <zaspire rambler ru>
Date:   Fri Apr 16 17:38:21 2010 +0400

    Update visibility of controls on view change.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=610191

 js/ui/workspacesView.js |   39 +++++++++++++++++----------------------
 1 files changed, 17 insertions(+), 22 deletions(-)
---
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index 80081df..64a1438 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -1378,6 +1378,9 @@ WorkspacesControls.prototype = {
         this._nWorkspacesNotifyId =
             global.screen.connect('notify::n-workspaces',
                                   Lang.bind(this, this._workspacesChanged));
+        this._switchWorkspaceNotifyId =
+            global.window_manager.connect('switch-workspace',
+                                          Lang.bind(this, this.updateControlsSensitivity));
 
         this._workspacesChanged();
     },
@@ -1385,6 +1388,8 @@ WorkspacesControls.prototype = {
     updateControls: function(view) {
         this._currentView = view;
 
+        this.updateControlsSensitivity();
+
         let newControls = this._currentView.createControllerBar();
         if (newControls) {
             this._viewControls.child = newControls;
@@ -1425,19 +1430,15 @@ WorkspacesControls.prototype = {
         this._gconf.set_string(WORKSPACES_VIEW_KEY, view);
     },
 
-    setCanRemove: function(canRemove) {
-        this._setButtonSensitivity(this._removeButton, canRemove);
-    },
-
-    setCanAdd: function(canAdd) {
-        this._setButtonSensitivity(this._addButton, canAdd);
-    },
-
     _onDestroy: function() {
         if (this._nWorkspacesNotifyId > 0) {
             global.screen.disconnect(this._nWorkspacesNotifyId);
             this._nWorkspacesNotifyId = 0;
         }
+        if (this._switchWorkspaceNotifyId > 0) {
+            global.window_manager.disconnect(this._switchWorkspaceNotifyId);
+            this._switchWorkspaceNotifyId = 0;
+        }
     },
 
     _setButtonSensitivity: function(button, sensitive) {
@@ -1447,11 +1448,19 @@ WorkspacesControls.prototype = {
         button.opacity = sensitive ? 255 : 85;
     },
 
+    updateControlsSensitivity: function() {
+        if (this._currentView) {
+            this._setButtonSensitivity(this._removeButton, this._currentView.canRemoveWorkspace());
+            this._setButtonSensitivity(this._addButton, this._currentView.canAddWorkspace());
+        }
+    },
+
     _workspacesChanged: function() {
         if (global.screen.n_workspaces == 1)
             this._toggleViewButton.hide();
         else
             this._toggleViewButton.show();
+        this.updateControlsSensitivity();
     }
 };
 Signals.addSignalMethods(WorkspacesControls.prototype);
@@ -1485,10 +1494,6 @@ WorkspacesManager.prototype = {
         this._nWorkspacesNotifyId =
             global.screen.connect('notify::n-workspaces',
                                   Lang.bind(this, this._workspacesChanged));
-        this._switchWorkspaceNotifyId =
-            global.window_manager.connect('switch-workspace',
-                                          Lang.bind(this, this._updateControlsSensitivity));
-
     },
 
     _updateView: function() {
@@ -1566,21 +1571,11 @@ WorkspacesManager.prototype = {
         this.workspacesView.updateWorkspaces(oldNumWorkspaces,
                                              newNumWorkspaces,
                                              lostWorkspaces);
-
-        this.controlsBar.setCanAdd(this.workspacesView.canAddWorkspace());
-        this.controlsBar.setCanRemove(this.workspacesView.canRemoveWorkspace());
-    },
-
-    _updateControlsSensitivity: function() {
-        this.controlsBar.setCanAdd(this.workspacesView.canAddWorkspace());
-        this.controlsBar.setCanRemove(this.workspacesView.canRemoveWorkspace());
     },
 
     _onDestroy: function() {
         if (this._nWorkspacesNotifyId > 0)
             global.screen.disconnect(this._nWorkspacesNotifyId);
-        if (this._switchWorkspaceNotifyId > 0)
-            global.window_manager.disconnect(this._switchWorkspaceNotifyId);
         if (this._viewChangedId > 0)
             Shell.GConf.get_default().disconnect(this._viewChangedId);
         for (let w = 0; w < this._workspaces.length; w++) {



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