[gnome-shell] Make dragging an item to the Add Workspace button launch it on a new workspace
- From: Marina Zhurakhinskaya <marinaz src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-shell] Make dragging an item to the Add Workspace button launch it on a new workspace
- Date: Thu, 13 Aug 2009 03:23:23 +0000 (UTC)
commit fb0ca1ba9de709a0911f34bb1687a2eb5ff3450a
Author: Marina Zhurakhinskaya <marinaz redhat com>
Date: Wed Aug 12 20:02:59 2009 -0400
Make dragging an item to the Add Workspace button launch it on a new workspace
It is convenient to drag an item to the Add Workspace button and
have it be launched on a new workspace.
Based on a patch from Josh Adams.
js/ui/workspaces.js | 52 ++++++++++++++++++++++++++++++++++++++------------
1 files changed, 39 insertions(+), 13 deletions(-)
---
diff --git a/js/ui/workspaces.js b/js/ui/workspaces.js
index 0618518..7802505 100644
--- a/js/ui/workspaces.js
+++ b/js/ui/workspaces.js
@@ -894,18 +894,15 @@ Workspaces.prototype = {
activeWorkspace.actor.raise_top();
this._positionWorkspaces(global, activeWorkspace);
- // Create (+) button
+ // Save the button size as a global variable so we can us it to create
+ // matching button sizes for workspace remove buttons.
buttonSize = addButtonSize;
- this.addButton = new Clutter.Texture({ x: addButtonX,
- y: addButtonY,
- width: buttonSize,
- height: buttonSize,
- reactive: true
- });
- this.addButton.set_from_file(global.imagedir + "add-workspace.svg");
- this.addButton.connect('button-release-event', this._appendNewWorkspace);
- this.actor.add_actor(this.addButton);
- this.addButton.lower_bottom();
+
+ // 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);
@@ -1132,10 +1129,39 @@ Workspaces.prototype = {
this.actor.add_actor(workspace.actor);
},
- _appendNewWorkspace : function(actor, event) {
+ _appendNewWorkspace : function() {
+ let global = Shell.Global.get();
+
+ 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();
+ 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;
let global = Shell.Global.get();
+ this.actor._delegate = this;
+ this.actor.set_from_file(global.imagedir + 'add-workspace.svg');
+ },
- global.screen.append_new_workspace(false, event.get_time());
+ // Draggable target interface
+ acceptDrop : function(source, actor, x, y, time) {
+ return this._acceptDropCallback(source, actor, x, y, time);
}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]