diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 94a7c7474..f62b94176 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -1221,6 +1221,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', () => { @@ -1254,6 +1259,47 @@ 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; + + if (this._folder.get_strv('apps').includes(source.id)) + 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 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)