[gnome-shell/gbsneto/icon-grid-dnd: 17/18] allView, folderView: Implement moving icons
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/icon-grid-dnd: 17/18] allView, folderView: Implement moving icons
- Date: Tue, 2 Jul 2019 20:50:13 +0000 (UTC)
commit 7581d7b9e781282c7b53cb88a8977d2fa871d222
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Jul 2 17:42:29 2019 -0300
allView, folderView: Implement moving icons
This makes use of the new BaseAppIcon.moveItem() API.
WIP: write a proper commit message
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/603
js/ui/appDisplay.js | 61 +++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 45 insertions(+), 16 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 1e02fd448..70446295d 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -785,38 +785,45 @@ var AllView = class AllView extends BaseAppView {
}
_onDragEnd() {
+ this.removeNudges();
+
if (this._dragMonitor) {
DND.removeDragMonitor(this._dragMonitor);
this._dragMonitor = null;
}
}
- _canDropAt(source) {
- if (!(source instanceof AppIcon))
- return false;
-
- if (!global.settings.is_writable('favorite-apps'))
- return false;
+ handleDragOver(source, actor, x, y, time) {
+ y += this._adjustment.value;
- if (!(source.parentView instanceof FolderView))
- return false;
+ let [index, dragLocation] = this.canDropAt(x, y);
- return true;
- }
+ this.removeNudges();
+ if (index != -1) {
+ if (dragLocation != IconGrid.DragLocation.ON_ICON)
+ this.nudgeItemsAtIndex(index, dragLocation);
- handleDragOver(source, actor, x, y, time) {
- if (!this._canDropAt(source))
- return DND.DragMotionResult.NO_DROP;
+ return DND.DragMotionResult.MOVE_DROP;
+ }
- return DND.DragMotionResult.MOVE_DROP;
+ return DND.DragMotionResult.NO_DROP;
}
acceptDrop(source, actor, x, y, time) {
- if (!this._canDropAt(source))
+ y += this._adjustment.value;
+
+ let [index, dragLocation] = this.canDropAt(x, y);
+
+ if (index == -1)
return false;
- source.parentView.folderIcon.removeApp(source.app);
+ if (source.parentView != this) {
+ source.parentView.folderIcon.removeApp(source.app);
+ source = this._items[source.id];
+ }
+ this.moveItem(source, index);
+ this.removeNudges();
return true;
}
@@ -1265,6 +1272,28 @@ var FolderView = class FolderView extends BaseAppView {
this.actor.set_height(this.usedHeight());
}
+ handleDragOver(source, actor, x, y, time) {
+ let [index, dragLocation] = this.canDropAt(x, y);
+
+ this._folderIcon._parentView.removeNudges();
+ this.removeNudges();
+ if (index != -1 && dragLocation != IconGrid.DragLocation.ON_ICON)
+ this.nudgeItemsAtIndex(index, dragLocation);
+
+ return DND.DragMotionResult.MOVE_DROP;
+ }
+
+ acceptDrop(source, actor, x, y, time) {
+ let [index, dragLocation] = this.canDropAt(x, y);
+ let success = index != -1;
+
+ if (success)
+ this.moveItem(source, index);
+
+ this.removeNudges();
+ return success;
+ }
+
_getPageAvailableSize() {
let pageBox = new Clutter.ActorBox();
pageBox.x1 = pageBox.y1 = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]