folderView: Allow moving to specific position

As of now, the only way to add an app icon to a folder is
by dragging it to the folder icon itself. Even though we
allow opening the folder popup when hovering the icon,
dropping an app icon there wouldn't work.

Make the folder view add the app icon to it's GSettings
key (which will trigger _redisplay() and will show the
new icon) when dropping to a specific position.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/603
This commit is contained in:
Georges Basile Stavracas Neto 2019-07-05 11:05:29 -03:00
parent 854922866b
commit 717ec0f8a4
No known key found for this signature in database
GPG Key ID: 886C17EE170D1385

View File

@ -1440,13 +1440,28 @@ var FolderView = class FolderView extends BaseAppView {
acceptDrop(source, actor, x, y, time) { acceptDrop(source, actor, x, y, time) {
let [index, dragLocation] = this.canDropAt(x, y); let [index, dragLocation] = this.canDropAt(x, y);
let sourceIndex = this._allItems.indexOf(source);
let success = index != -1; let success = index != -1;
source.undoScaleAndFade(); source.undoScaleAndFade();
if (success) if (success) {
this.moveItem(source, index); // If we're dragging from another folder, remove from the old folder
if (source.view != this &&
(source instanceof AppIcon) &&
(source.view instanceof FolderView)) {
source.view.removeApp(source.app);
}
// If the new app icon is not in this folder yet, add it; otherwise,
// just move the icon to the new position
let folderApps = this._folder.get_strv('apps');
if (!folderApps.includes(source.id)) {
folderApps.splice(index, 0, source.id);
this._folder.set_strv('apps', folderApps);
} else {
this.moveItem(source, index);
}
}
this.removeNudges(); this.removeNudges();
return success; return success;