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:
parent
b28b60b47b
commit
5e944c9a3b
@ -73,6 +73,7 @@ const NUMBER_OF_SECTIONS_IN_SEARCH = 2;
|
|||||||
let wideScreen = false;
|
let wideScreen = false;
|
||||||
let displayGridColumnWidth = null;
|
let displayGridColumnWidth = null;
|
||||||
let displayGridRowHeight = null;
|
let displayGridRowHeight = null;
|
||||||
|
let addRemoveButtonSize = null;
|
||||||
|
|
||||||
function Overview() {
|
function Overview() {
|
||||||
this._init();
|
this._init();
|
||||||
@ -168,8 +169,8 @@ Overview.prototype = {
|
|||||||
this._dash.sectionArea.height = this._workspacesHeight;
|
this._dash.sectionArea.height = this._workspacesHeight;
|
||||||
|
|
||||||
// place the 'Add Workspace' button in the bottom row of the grid
|
// place the 'Add Workspace' button in the bottom row of the grid
|
||||||
this._addButtonSize = Math.floor(displayGridRowHeight * 3/5);
|
addRemoveButtonSize = Math.floor(displayGridRowHeight * 3/5);
|
||||||
this._addButtonX = this._workspacesX + this._workspacesWidth - this._addButtonSize;
|
this._addButtonX = this._workspacesX + this._workspacesWidth - addRemoveButtonSize;
|
||||||
this._addButtonY = screenHeight - Math.floor(displayGridRowHeight * 4/5);
|
this._addButtonY = screenHeight - Math.floor(displayGridRowHeight * 4/5);
|
||||||
|
|
||||||
this._backOver.set_position(0, Panel.PANEL_HEIGHT);
|
this._backOver.set_position(0, Panel.PANEL_HEIGHT);
|
||||||
@ -275,8 +276,7 @@ Overview.prototype = {
|
|||||||
|
|
||||||
/* TODO: make this stuff dynamic */
|
/* TODO: make this stuff dynamic */
|
||||||
this._workspaces = new Workspaces.Workspaces(this._workspacesWidth, this._workspacesHeight,
|
this._workspaces = new Workspaces.Workspaces(this._workspacesWidth, this._workspacesHeight,
|
||||||
this._workspacesX, this._workspacesY,
|
this._workspacesX, this._workspacesY);
|
||||||
this._addButtonSize, this._addButtonX, this._addButtonY);
|
|
||||||
this._group.add_actor(this._workspaces.actor);
|
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
|
// 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.
|
// be as big as the screen.
|
||||||
this._dash.actor.raise(this._workspaces.actor);
|
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,
|
// All the the actors in the window group are completely obscured,
|
||||||
// hiding the group holding them while the Overview is displayed greatly
|
// hiding the group holding them while the Overview is displayed greatly
|
||||||
// increases performance of the Overview especially when there are many
|
// increases performance of the Overview especially when there are many
|
||||||
@ -429,6 +435,40 @@ Overview.prototype = {
|
|||||||
|
|
||||||
Main.endModal();
|
Main.endModal();
|
||||||
this.emit('hidden');
|
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);
|
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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@ -61,8 +61,6 @@ function _clamp(value, min, max) {
|
|||||||
const GRID_SPACING = 15;
|
const GRID_SPACING = 15;
|
||||||
const FRAME_SIZE = GRID_SPACING / 3;
|
const FRAME_SIZE = GRID_SPACING / 3;
|
||||||
|
|
||||||
let buttonSize = false;
|
|
||||||
|
|
||||||
function ScaledPoint(x, y, scaleX, scaleY) {
|
function ScaledPoint(x, y, scaleX, scaleY) {
|
||||||
[this.x, this.y, this.scaleX, this.scaleY] = arguments;
|
[this.x, this.y, this.scaleX, this.scaleY] = arguments;
|
||||||
}
|
}
|
||||||
@ -513,8 +511,8 @@ Workspace.prototype = {
|
|||||||
if (this._removeButton)
|
if (this._removeButton)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this._removeButton = new Clutter.Texture({ width: buttonSize,
|
this._removeButton = new Clutter.Texture({ width: Overview.addRemoveButtonSize,
|
||||||
height: buttonSize,
|
height: Overview.addRemoveButtonSize,
|
||||||
reactive: true
|
reactive: true
|
||||||
});
|
});
|
||||||
this._removeButton.set_from_file(global.imagedir + "remove-workspace.svg");
|
this._removeButton.set_from_file(global.imagedir + "remove-workspace.svg");
|
||||||
@ -1081,18 +1079,16 @@ Workspace.prototype = {
|
|||||||
|
|
||||||
Signals.addSignalMethods(Workspace.prototype);
|
Signals.addSignalMethods(Workspace.prototype);
|
||||||
|
|
||||||
function Workspaces(width, height, x, y, addButtonSize, addButtonX, addButtonY) {
|
function Workspaces(width, height, x, y) {
|
||||||
this._init(width, height, x, y, addButtonSize, addButtonX, addButtonY);
|
this._init(width, height, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Workspaces.prototype = {
|
Workspaces.prototype = {
|
||||||
_init : function(width, height, x, y, addButtonSize, addButtonX, addButtonY) {
|
_init : function(width, height, x, y) {
|
||||||
this.actor = new Clutter.Group();
|
this.actor = new Clutter.Group();
|
||||||
|
|
||||||
this._appIdFilter = null;
|
this._appIdFilter = null;
|
||||||
|
|
||||||
let screenHeight = global.screen_height;
|
|
||||||
|
|
||||||
this._width = width;
|
this._width = width;
|
||||||
this._height = height;
|
this._height = height;
|
||||||
this._x = x;
|
this._x = x;
|
||||||
@ -1116,16 +1112,6 @@ Workspaces.prototype = {
|
|||||||
activeWorkspace.actor.raise_top();
|
activeWorkspace.actor.raise_top();
|
||||||
this._positionWorkspaces(global);
|
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];
|
let lastWorkspace = this._workspaces[this._workspaces.length - 1];
|
||||||
lastWorkspace.updateRemovable(true);
|
lastWorkspace.updateRemovable(true);
|
||||||
|
|
||||||
@ -1380,39 +1366,13 @@ Workspaces.prototype = {
|
|||||||
this.actor.add_actor(workspace.actor);
|
this.actor.add_actor(workspace.actor);
|
||||||
},
|
},
|
||||||
|
|
||||||
_appendNewWorkspace : function() {
|
// Handles a drop onto the (+) button; assumes the new workspace
|
||||||
global.screen.append_new_workspace(false, global.screen.get_display().get_current_time());
|
// has already been added
|
||||||
},
|
acceptNewWorkspaceDrop : function(source, dropActor, x, y, time) {
|
||||||
|
|
||||||
// Creates a new workspace and drops the dropActor there
|
|
||||||
_addWorkspaceAcceptDrop : function(source, dropActor, x, y, time) {
|
|
||||||
this._appendNewWorkspace();
|
|
||||||
return this._workspaces[this._workspaces.length - 1].acceptDrop(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
|
// Create a SpecialPropertyModifier to let us move windows in a
|
||||||
// straight line on the screen even though their containing workspace
|
// straight line on the screen even though their containing workspace
|
||||||
// is also moving.
|
// is also moving.
|
||||||
|
Loading…
Reference in New Issue
Block a user