[linearView] Zoom out when dragging an item from the dash

When dragging windows in linear view, the workspace zooms out to
allow moving the window to other workspaces. Enable the same
behaviour for items dragged from the dash.

https://bugzilla.gnome.org/show_bug.cgi?id=618055
This commit is contained in:
Florian Müllner 2010-05-08 16:06:28 +02:00
parent b3794f1c17
commit a57a34c540
7 changed files with 69 additions and 23 deletions

View File

@ -42,17 +42,17 @@ AllAppView.prototype = {
},
_addApp: function(app) {
let App = new AppWellIcon(this._appSystem.get_app(app.get_id()));
App.connect('launching', Lang.bind(this, function() {
let appIcon = new AppWellIcon(this._appSystem.get_app(app.get_id()));
appIcon.connect('launching', Lang.bind(this, function() {
this.emit('launching');
}));
App._draggable.connect('drag-begin', Lang.bind(this, function() {
appIcon._draggable.connect('drag-begin', Lang.bind(this, function() {
this.emit('drag-begin');
}));
this._grid.addItem(App.actor);
this._grid.addItem(appIcon.actor);
this._apps.push(App);
this._apps.push(appIcon);
},
refresh: function(apps) {
@ -402,6 +402,11 @@ AppWellIcon.prototype = {
this._draggable.connect('drag-begin', Lang.bind(this,
function () {
this._removeMenuTimeout();
Main.overview.beginItemDrag(this);
}));
this._draggable.connect('drag-end', Lang.bind(this,
function () {
Main.overview.endItemDrag(this);
}));
this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress));

View File

@ -351,6 +351,14 @@ SearchResult.prototype = {
this.actor.connect('clicked', Lang.bind(this, this._onResultClicked));
let draggable = DND.makeDraggable(this.actor);
draggable.connect('drag-begin',
Lang.bind(this, function() {
Main.overview.beginItemDrag(this);
}));
draggable.connect('drag-end',
Lang.bind(this, function() {
Main.overview.endItemDrag(this);
}));
},
setSelected: function(selected) {

View File

@ -287,6 +287,14 @@ DashDocDisplayItem.prototype = {
this.actor._delegate = this;
let draggable = DND.makeDraggable(this.actor);
draggable.connect('drag-begin',
Lang.bind(this, function() {
Main.overview.beginItemDrag(this);
}));
draggable.connect('drag-end',
Lang.bind(this, function() {
Main.overview.endItemDrag(this);
}));
},
getUri: function() {

View File

@ -47,6 +47,14 @@ GenericDisplayItem.prototype = {
}));
let draggable = DND.makeDraggable(this.actor);
draggable.connect('drag-begin',
Lang.bind(this, function() {
Main.overview.beginItemDrag(this);
}));
draggable.connect('drag-end',
Lang.bind(this, function() {
Main.overview.endItemDrag(this);
}));
this._iconBin = new St.Bin();
this.actor.add(this._iconBin);

View File

@ -376,23 +376,20 @@ Overview.prototype = {
}));
},
//// Draggable target interface ////
//// Public methods ////
// Closes any active panes if a GenericDisplayItem is being
// dragged over the Overview, i.e. as soon as it starts being dragged.
// This allows the user to place the item on any workspace.
handleDragOver : function(source, actor, x, y, time) {
if (source instanceof GenericDisplay.GenericDisplayItem
|| source instanceof AppDisplay.AppIcon) {
beginItemDrag: function(source) {
// Close any active panes if @source is a GenericDisplayItem.
// This allows the user to place the item on any workspace.
if (source instanceof GenericDisplay.GenericDisplayItem)
if (this._activeDisplayPane != null)
this._activeDisplayPane.close();
return true;
}
return false;
this.emit('item-drag-begin');
},
//// Public methods ////
endItemDrag: function(source) {
this.emit('item-drag-end');
},
// Returns the scale the Overview has when we just start zooming out
// to overview mode. That is, when just the active workspace is showing.

View File

@ -443,6 +443,14 @@ DashPlaceDisplayItem.prototype = {
this.actor._delegate = this;
this._draggable = DND.makeDraggable(this.actor);
this._draggable.connect('drag-begin',
Lang.bind(this, function() {
Main.overview.beginItemDrag(this);
}));
this._draggable.connect('drag-end',
Lang.bind(this, function() {
Main.overview.endItemDrag(this);
}));
},
_onClicked: function(b) {

View File

@ -639,11 +639,15 @@ SingleView.prototype = {
GenericWorkspacesView.prototype._init.call(this, width, height, x, y, workspaces);
this._itemDragBeginId = Main.overview.connect('item-drag-begin',
Lang.bind(this, this._dragBegin));
this._itemDragEndId = Main.overview.connect('item-drag-end',
Lang.bind(this, this._dragEnd));
for (let i = 0; i < this._workspaces.length; i++) {
this._workspaces[i]._windowDragBeginId = this._workspaces[i].connect('window-drag-begin',
Lang.bind(this, this._onWindowDragBegin));
Lang.bind(this, this._dragBegin));
this._workspaces[i]._windowDragEndId = this._workspaces[i].connect('window-drag-end',
Lang.bind(this, this._onWindowDragEnd));
Lang.bind(this, this._dragEnd));
}
this.actor.add_actor(this._newWorkspaceArea.actor);
@ -1085,9 +1089,9 @@ SingleView.prototype = {
for (let w = oldNumWorkspaces; w < newNumWorkspaces; w++) {
this.actor.add_actor(this._workspaces[w].actor);
this._workspaces[w]._windowDragBeginId = this._workspaces[w].connect('window-drag-begin',
Lang.bind(this, this._onWindowDragBegin));
Lang.bind(this, this._dragBegin));
this._workspaces[w]._windowDragEndId = this._workspaces[w].connect('window-drag-end',
Lang.bind(this, this._onWindowDragEnd));
Lang.bind(this, this._dragEnd));
}
this._computeWorkspacePositions();
@ -1117,6 +1121,14 @@ SingleView.prototype = {
Mainloop.source_remove(this._timeoutId);
this._timeoutId = 0;
}
if (this._itemDragBeginId > 0) {
Main.overview.disconnect(this._itemDragBeginId);
this._itemDragBeginId = 0;
}
if (this._itemDragEndId > 0) {
Main.overview.disconnect(this._itemDragEndId);
this._itemDragEndId = 0;
}
for (let w = 0; w < this._workspaces.length; w++) {
if (this._workspaces[w]._windowDragBeginId) {
this._workspaces[w].disconnect(this._workspaces[w]._windowDragBeginId);
@ -1170,7 +1182,7 @@ SingleView.prototype = {
return false;
},
_onWindowDragBegin: function(w, actor) {
_dragBegin: function() {
if (!this._scroll || this._scrolling)
return;
@ -1242,7 +1254,7 @@ SingleView.prototype = {
}
},
_onWindowDragEnd: function(w, actor) {
_dragEnd: function() {
if (this._timeoutId) {
Mainloop.source_remove(this._timeoutId);
this._timeoutId = 0;