[gnome-shell/gbsneto/custom-icon-positions: 19/20] appDisplay: Add placeholder when moving from folder dialog
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/custom-icon-positions: 19/20] appDisplay: Add placeholder when moving from folder dialog
- Date: Tue, 23 Jun 2020 18:45:35 +0000 (UTC)
commit 014306d64c4d31b39e6b7f4e9e7860df9b7f85db
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Jun 23 12:05:27 2020 -0300
appDisplay: Add placeholder when moving from folder dialog
When moving an icon from a folder dialog, the app grid doesn't
really have an icon to move around.
Add a placeholder icon and hijack it in the various places.
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1284
js/ui/appDisplay.js | 49 +++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 45 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 7557d6a426..18dd2e130c 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -625,6 +625,7 @@ class AppDisplay extends BaseAppView {
this._delayedMoveId = 0;
this._targetDropPosition = null;
this._nudgedItem = null;
+ this._placeholder = null;
Main.overview.connect('hidden', () => this.goToPage(0));
@@ -713,17 +714,46 @@ class AppDisplay extends BaseAppView {
this._pageManager.pages = pages;
}
+ _ensurePlaceholder(source) {
+ if (this._placeholder)
+ return;
+
+ const appSys = Shell.AppSystem.get_default();
+ const app = appSys.lookup_app(source.id);
+
+ this._placeholder = new AppIcon(app, {
+ isDraggable: global.settings.is_writable('favorite-apps'),
+ });
+ this._placeholder.scaleAndFade();
+ this._redisplay();
+ }
+
+ _removePlaceholder() {
+ if (this._placeholder) {
+ this._placeholder.undoScaleAndFade();
+ this._placeholder = null;
+ this._redisplay();
+ }
+ }
+
getAppInfos() {
return this._appInfoList;
}
_getItemPosition(item) {
+ if (item === this._placeholder)
+ return this._grid.getItemPosition(item);
+
return this._pageManager.getAppPosition(item.id);
}
_compareItems(a, b) {
- const [aPage, aPosition] = this._pageManager.getAppPosition(a.id);
- const [bPage, bPosition] = this._pageManager.getAppPosition(b.id);
+ const [aPage, aPosition] = a === this._placeholder
+ ? this._grid.getItemPosition(a)
+ : this._pageManager.getAppPosition(a.id);
+ const [bPage, bPosition] = b === this._placeholder
+ ? this._grid.getItemPosition(b)
+ : this._pageManager.getAppPosition(b.id);
if (aPage === -1 && bPage === -1)
return a.name.localeCompare(b.name);
@@ -801,6 +831,10 @@ class AppDisplay extends BaseAppView {
appIcons.push(icon);
});
+ // At last, if there's a placeholder available, add it
+ if (this._placeholder)
+ appIcons.push(this._placeholder);
+
return appIcons;
}
@@ -944,7 +978,7 @@ class AppDisplay extends BaseAppView {
if (!success)
return;
- const { source } = dragEvent;
+ const source = this._placeholder ? this._placeholder : dragEvent.source;
const [item, dragLocation] = this.getDropTarget(x, y);
// Dragging over invalid parts of the grid cancels the timeout
@@ -1032,11 +1066,17 @@ class AppDisplay extends BaseAppView {
'[gnome-shell] this._lastOvershootTimeoutId');
}
- _onDragBegin() {
+ _onDragBegin(_overview, source) {
this._dragMonitor = {
dragMotion: this._onDragMotion.bind(this),
};
DND.addDragMonitor(this._dragMonitor);
+
+ // When dragging from a folder dialog, the dragged app icon
+ // doesn't exist in AppDisplay. We work around that hijacking
+ // a placeholder icon
+ if (_getViewFromIcon(source) instanceof FolderView)
+ this._ensurePlaceholder(source);
}
_onDragMotion(dragEvent) {
@@ -1061,6 +1101,7 @@ class AppDisplay extends BaseAppView {
this._resetOvershoot();
this._removeNudge();
+ this._removePlaceholder();
}
_onDragCancelled(_overview, source) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]