[gnome-shell/gbsneto/icon-grid-part2: 42/48] folderIcon: Allow dropping application icons
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/icon-grid-part2: 42/48] folderIcon: Allow dropping application icons
- Date: Wed, 7 Aug 2019 18:35:36 +0000 (UTC)
commit 2122e0dc006313c6711ff61327a1632187ccec03
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Jun 28 19:47:32 2019 -0300
folderIcon: Allow dropping application icons
Connect to the overview signals related to Drag n' Drop, and
allow dropping application icons in it. Dropping an icon
appends the application id to the folder's GSettings key.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/664
js/ui/appDisplay.js | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 6bd3b1398..e6b599a75 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -1220,6 +1220,11 @@ var FolderIcon = class FolderIcon {
this.view = new FolderView(this._folder, parentView);
+ Main.overview.connect('item-drag-begin',
+ this._onDragBegin.bind(this));
+ Main.overview.connect('item-drag-end',
+ this._onDragEnd.bind(this));
+
this.actor.connect('clicked', this.open.bind(this));
this.actor.connect('destroy', this.onDestroy.bind(this));
this.actor.connect('notify::mapped', () => {
@@ -1253,6 +1258,44 @@ var FolderIcon = class FolderIcon {
return this.view.getAllItems().map(item => item.id);
}
+ _onDragBegin() {
+ this._parentView.inhibitEventBlocker();
+ }
+
+ _onDragEnd() {
+ this._parentView.uninhibitEventBlocker();
+ }
+
+ _canAccept(source) {
+ if (!(source instanceof AppIcon))
+ return false;
+
+ if (this._folder.get_strv('apps').includes(source.id))
+ return false;
+
+ return true;
+ }
+
+ handleDragOver(source) {
+ if (!this._canAccept(source))
+ return DND.DragMotionResult.NO_DROP;
+
+ return DND.DragMotionResult.MOVE_DROP;
+ }
+
+ acceptDrop(source) {
+ if (!this._canAccept(source))
+ return true;
+
+ let app = source.app;
+ let folderApps = this._folder.get_strv('apps');
+ folderApps.push(app.id);
+
+ this._folder.set_strv('apps', folderApps);
+
+ return true;
+ }
+
_updateName() {
let name = _getFolderName(this._folder);
if (this.name == name)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]