[gnome-shell/gbsneto/icon-grid-dnd: 3/18] 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-dnd: 3/18] folderIcon: Allow dropping application icons
- Date: Sat, 29 Jun 2019 20:44:20 +0000 (UTC)
commit 440bd8e299b8778a6d2988bc475761d029af3c5b
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/603
js/ui/appDisplay.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 5221444db..998a11739 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -1141,6 +1141,11 @@ var FolderIcon = class FolderIcon {
this.view = new FolderView();
+ 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._ensurePopup();
this.view.actor.vscroll.adjustment.value = 0;
@@ -1159,6 +1164,48 @@ var FolderIcon = class FolderIcon {
return this.view.getAllItems().map(item => item.id);
}
+ _onDragBegin() {
+ this._parentView.inhibitEventBlocker();
+ }
+
+ _onDragEnd() {
+ this._parentView.uninhibitEventBlocker();
+ }
+
+ _canDropAt(source) {
+ if (!(source instanceof AppIcon))
+ return false;
+
+ if (!global.settings.is_writable('favorite-apps'))
+ return false;
+
+ return true;
+ }
+
+ handleDragOver(source, actor, x, y, time) {
+ if (!this._canDropAt(source))
+ return DND.DragMotionResult.NO_DROP;
+
+ let folderApps = this._folder.get_strv('apps');
+ if (folderApps.indexOf(source.app.id) > -1)
+ return DND.DragMotionResult.NO_DROP;
+
+ return DND.DragMotionResult.MOVE_DROP;
+ }
+
+ acceptDrop(source, actor, x, y, time) {
+ if (!this._canDropAt(source))
+ return false;
+
+ 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]