[gnome-shell/gbsneto/icon-grid-dnd: 11/18] allView: Remove icon from folder when dropping outside
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/icon-grid-dnd: 11/18] allView: Remove icon from folder when dropping outside
- Date: Sat, 29 Jun 2019 20:45:01 +0000 (UTC)
commit 9bdfaf7fdad6db5c302f8c2d813e9ac102b9368c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Jun 29 01:26:08 2019 -0300
allView: Remove icon from folder when dropping outside
When dropping an app icon to outside the folder, remove the
app from that folder. GNOME Shell is already smart enough
to figure out the setting changes and update the icons.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/603
js/ui/appDisplay.js | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index a5c7ddde7..a23b36932 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -705,6 +705,35 @@ var AllView = class AllView extends BaseAppView {
}
}
+ _canDropAt(source) {
+ if (!(source instanceof AppIcon))
+ return false;
+
+ if (!global.settings.is_writable('favorite-apps'))
+ return false;
+
+ if (!(source.parentView instanceof FolderView))
+ return false;
+
+ return true;
+ }
+
+ handleDragOver(source, actor, x, y, time) {
+ if (!this._canDropAt(source))
+ return DND.DragMotionResult.NO_DROP;
+
+ return DND.DragMotionResult.MOVE_DROP;
+ }
+
+ acceptDrop(source, actor, x, y, time) {
+ if (!this._canDropAt(source))
+ return false;
+
+ source.parentView.folderIcon.removeApp(source.app);
+
+ return true;
+ }
+
inhibitEventBlocker() {
this._nEventBlockerInhibits++;
this._eventBlocker.visible = this._nEventBlockerInhibits == 0;
@@ -1395,6 +1424,22 @@ var FolderIcon = class FolderIcon {
this.view.adaptToSize(width, height);
this._popupInvalidated = true;
}
+
+ removeApp(app) {
+ let folderApps = this._folder.get_strv('apps');
+ let index = folderApps.indexOf(app.id);
+ if (index < 0)
+ return false;
+
+ folderApps.splice(index, 1);
+
+ this._folder.set_strv('apps', folderApps);
+
+ if (this._popup)
+ this._popup.popdown();
+
+ return true;
+ }
};
Signals.addSignalMethods(FolderIcon.prototype);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]