[gnome-shell] Move the add workspace button out of the Workspaces object, into Overview



commit 5e944c9a3b488fdab5fd297615e4e3311c1ee7a0
Author: Dan Winship <danw gnome org>
Date:   Tue Sep 1 11:56:41 2009 -0400

    Move the add workspace button out of the Workspaces object, into Overview
    
    http://bugzilla.gnome.org/show_bug.cgi?id=594049

 js/ui/overview.js   |   48 ++++++++++++++++++++++++++++++++++++++++---
 js/ui/workspaces.js |   56 +++++++-------------------------------------------
 2 files changed, 52 insertions(+), 52 deletions(-)
---
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 436d665..962e239 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -73,6 +73,7 @@ const NUMBER_OF_SECTIONS_IN_SEARCH = 2;
 let wideScreen = false;
 let displayGridColumnWidth = null;
 let displayGridRowHeight = null;
+let addRemoveButtonSize = null;
 
 function Overview() {
     this._init();
@@ -168,8 +169,8 @@ Overview.prototype = {
         this._dash.sectionArea.height = this._workspacesHeight;
 
         // place the 'Add Workspace' button in the bottom row of the grid
-        this._addButtonSize = Math.floor(displayGridRowHeight * 3/5);
-        this._addButtonX = this._workspacesX + this._workspacesWidth - this._addButtonSize;
+        addRemoveButtonSize = Math.floor(displayGridRowHeight * 3/5);
+        this._addButtonX = this._workspacesX + this._workspacesWidth - addRemoveButtonSize;
         this._addButtonY = screenHeight - Math.floor(displayGridRowHeight * 4/5);
 
         this._backOver.set_position(0, Panel.PANEL_HEIGHT);
@@ -275,8 +276,7 @@ Overview.prototype = {
 
         /* TODO: make this stuff dynamic */
         this._workspaces = new Workspaces.Workspaces(this._workspacesWidth, this._workspacesHeight,
-                                                     this._workspacesX, this._workspacesY,
-                                                     this._addButtonSize, this._addButtonX, this._addButtonY);
+                                                     this._workspacesX, this._workspacesY);
         this._group.add_actor(this._workspaces.actor);
 
         // The workspaces actor is as big as the screen, so we have to raise the dash above it
@@ -284,6 +284,12 @@ Overview.prototype = {
         // be as big as the screen.
         this._dash.actor.raise(this._workspaces.actor);
 
+        // Create (+) button
+        this._addButton = new AddWorkspaceButton(addRemoveButtonSize, this._addButtonX, this._addButtonY, Lang.bind(this, this._acceptNewWorkspaceDrop));
+        this._addButton.actor.connect('button-release-event', Lang.bind(this, this._addNewWorkspace));
+        this._group.add_actor(this._addButton.actor);
+        this._addButton.actor.raise(this._workspaces.actor);
+
         // All the the actors in the window group are completely obscured,
         // hiding the group holding them while the Overview is displayed greatly
         // increases performance of the Overview especially when there are many
@@ -429,6 +435,40 @@ Overview.prototype = {
 
         Main.endModal();
         this.emit('hidden');
+    },
+
+    _addNewWorkspace: function() {
+        let global = Shell.Global.get();
+
+        global.screen.append_new_workspace(false, global.screen.get_display().get_current_time());
+    },
+
+    _acceptNewWorkspaceDrop: function(source, dropActor, x, y, time) {
+        this._addNewWorkspace();
+        return this._workspaces.acceptNewWorkspaceDrop(source, dropActor, x, y, time);
     }
 };
 Signals.addSignalMethods(Overview.prototype);
+
+function AddWorkspaceButton(buttonSize, buttonX, buttonY, acceptDropCallback) {
+    this._init(buttonSize, buttonX, buttonY, acceptDropCallback);
+}
+
+AddWorkspaceButton.prototype = {
+    _init: function(buttonSize, buttonX, buttonY, acceptDropCallback) {
+        this.actor = new Clutter.Texture({ x: buttonX,
+                                           y: buttonY,
+                                           width: buttonSize,
+                                           height: buttonSize,
+                                           reactive: true });
+        this._acceptDropCallback = acceptDropCallback;
+        let global = Shell.Global.get();
+        this.actor._delegate = this;
+        this.actor.set_from_file(global.imagedir + 'add-workspace.svg');
+    },
+
+    // Draggable target interface
+    acceptDrop: function(source, actor, x, y, time) {
+        return this._acceptDropCallback(source, actor, x, y, time);
+    }
+};
diff --git a/js/ui/workspaces.js b/js/ui/workspaces.js
index c6c9a9a..5a3673b 100644
--- a/js/ui/workspaces.js
+++ b/js/ui/workspaces.js
@@ -61,8 +61,6 @@ function _clamp(value, min, max) {
 const GRID_SPACING = 15;
 const FRAME_SIZE = GRID_SPACING / 3;
 
-let buttonSize = false;
-
 function ScaledPoint(x, y, scaleX, scaleY) {
     [this.x, this.y, this.scaleX, this.scaleY] = arguments;
 }
@@ -513,8 +511,8 @@ Workspace.prototype = {
             if (this._removeButton)
                 return;
 
-            this._removeButton = new Clutter.Texture({ width: buttonSize,
-                                                       height: buttonSize,
+            this._removeButton = new Clutter.Texture({ width: Overview.addRemoveButtonSize,
+                                                       height: Overview.addRemoveButtonSize,
                                                        reactive: true
                                                      });
             this._removeButton.set_from_file(global.imagedir + "remove-workspace.svg");
@@ -1081,18 +1079,16 @@ Workspace.prototype = {
 
 Signals.addSignalMethods(Workspace.prototype);
 
-function Workspaces(width, height, x, y, addButtonSize, addButtonX, addButtonY) {
-    this._init(width, height, x, y, addButtonSize, addButtonX, addButtonY);
+function Workspaces(width, height, x, y) {
+    this._init(width, height, x, y);
 }
 
 Workspaces.prototype = {
-    _init : function(width, height, x, y, addButtonSize, addButtonX, addButtonY) {
+    _init : function(width, height, x, y) {
         this.actor = new Clutter.Group();
 
         this._appIdFilter = null;
 
-        let screenHeight = global.screen_height;
-
         this._width = width;
         this._height = height;
         this._x = x;
@@ -1116,16 +1112,6 @@ Workspaces.prototype = {
         activeWorkspace.actor.raise_top();
         this._positionWorkspaces(global);
 
-        // Save the button size as a global variable so we can us it to create 
-        // matching button sizes for workspace remove buttons.
-        buttonSize = addButtonSize;
-
-        // Create (+) button
-        this.addButton = new AddWorkspaceButton(addButtonSize, addButtonX, addButtonY, Lang.bind(this, this._addWorkspaceAcceptDrop));
-        this.addButton.actor.connect('button-release-event', Lang.bind(this, this._appendNewWorkspace));
-        this.actor.add_actor(this.addButton.actor);
-        this.addButton.actor.lower_bottom();
-
         let lastWorkspace = this._workspaces[this._workspaces.length - 1];
         lastWorkspace.updateRemovable(true);
 
@@ -1380,39 +1366,13 @@ Workspaces.prototype = {
         this.actor.add_actor(workspace.actor);
     },
 
-    _appendNewWorkspace : function() {
-        global.screen.append_new_workspace(false, global.screen.get_display().get_current_time());
-    },
-
-    // Creates a new workspace and drops the dropActor there
-    _addWorkspaceAcceptDrop : function(source, dropActor, x, y, time) {
-        this._appendNewWorkspace();
+    // Handles a drop onto the (+) button; assumes the new workspace
+    // has already been added
+    acceptNewWorkspaceDrop : function(source, dropActor, x, y, time) {
         return this._workspaces[this._workspaces.length - 1].acceptDrop(source, dropActor, x, y, time);
     }
 };
 
-function AddWorkspaceButton(buttonSize, buttonX, buttonY, acceptDropCallback) {
-    this._init(buttonSize, buttonX, buttonY, acceptDropCallback);
-}
-
-AddWorkspaceButton.prototype = {
-    _init : function(buttonSize, buttonX, buttonY, acceptDropCallback) {
-        this.actor = new Clutter.Texture({ x: buttonX,
-                                           y: buttonY,
-                                           width: buttonSize,
-                                           height: buttonSize,
-                                           reactive: true });
-        this._acceptDropCallback = acceptDropCallback;
-        this.actor._delegate = this;
-        this.actor.set_from_file(global.imagedir + 'add-workspace.svg');
-    },
-
-    // Draggable target interface
-    acceptDrop : function(source, actor, x, y, time) {
-        return this._acceptDropCallback(source, actor, x, y, time);
-    }
-};
-
 // Create a SpecialPropertyModifier to let us move windows in a
 // straight line on the screen even though their containing workspace
 // is also moving.



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