Move the add workspace button out of the Workspaces object, into Overview

http://bugzilla.gnome.org/show_bug.cgi?id=594049
This commit is contained in:
Dan Winship
2009-09-01 11:56:41 -04:00
parent b28b60b47b
commit 5e944c9a3b
2 changed files with 52 additions and 52 deletions

View File

@ -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.