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
This commit is contained in:
parent
241b4cd1c8
commit
74077b0f6e
@ -731,6 +731,38 @@ 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.view 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.view.removeApp(source.app);
|
||||
|
||||
if (this._currentPopup)
|
||||
this._currentPopup.popdown();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inhibitEventBlocker() {
|
||||
this._nEventBlockerInhibits++;
|
||||
this._eventBlocker.visible = this._nEventBlockerInhibits == 0;
|
||||
@ -1248,6 +1280,19 @@ var FolderView = class FolderView extends BaseAppView {
|
||||
|
||||
return apps;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
var FolderIcon = class FolderIcon {
|
||||
|
Loading…
Reference in New Issue
Block a user