[gnome-shell/gbsneto/icon-grid-dnd: 27/35] 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: 27/35] allView, folderView: Implement moving icons
- Date: Thu, 4 Jul 2019 19:59:11 +0000 (UTC)
commit 0e0ec29e97b7e4905061c0ffd0beaf2566b2db25
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 | 63 ++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 48 insertions(+), 15 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 2a9a3bd18..245982a04 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -785,38 +785,48 @@ 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;
+ handleDragOver(source, actor, x, y, time) {
+ let sourceIndex = -1;
+ if (source.parentView == this)
+ sourceIndex = this._allItems.indexOf(source);
- if (!global.settings.is_writable('favorite-apps'))
- return false;
+ let [index, dragLocation] = this.canDropAt(x, y);
- if (!(source.parentView instanceof FolderView))
- return false;
+ this.removeNudges();
+ if (source.parentView != this)
+ source.parentView.removeNudges();
- return true;
- }
+ if (index != -1) {
+ if (sourceIndex == -1 || (index != sourceIndex && index != sourceIndex + 1))
+ 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))
+ 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 +1275,29 @@ 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);
+ let sourceIndex = this._allItems.indexOf(source);
+
+ this._folderIcon._parentView.removeNudges();
+ this.removeNudges();
+ if (index != -1 && index != sourceIndex && index != sourceIndex + 1)
+ 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]