[gnome-shell/gbsneto/custom-icon-positions: 25/25] appDisplay: Allow reordering folders
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/custom-icon-positions: 25/25] appDisplay: Allow reordering folders
- Date: Wed, 24 Jun 2020 19:46:36 +0000 (UTC)
commit 5b1b7bf7e34d0bfd2d3158de8f43697534989fc2
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Jun 24 15:37:42 2020 -0300
appDisplay: Allow reordering folders
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1284
js/ui/appDisplay.js | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 83f77981d1..e1e74d18f1 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -1607,6 +1607,33 @@ class FolderView extends BaseAppView {
return appIds;
}
+ _getItemPosition(item) {
+ const appIds = this._getFolderApps();
+ const appIndex = appIds.indexOf(item.id);
+
+ if (appIndex === -1)
+ return [-1, -1];
+
+ const { itemsPerPage } = this._grid;
+ return [Math.floor(appIndex / itemsPerPage), appIndex % itemsPerPage];
+ }
+
+ _compareItems(a, b) {
+ const appIds = this._getFolderApps();
+
+ const aPosition = appIds.indexOf(a.id);
+ const bPosition = appIds.indexOf(b.id);
+
+ if (aPosition === -1 && bPosition === -1)
+ return a.name.localeCompare(b.name);
+ else if (aPosition === -1)
+ return 1;
+ else if (bPosition === -1)
+ return -1;
+
+ return aPosition - bPosition;
+ }
+
// Overridden from BaseAppView
animate(animationDirection) {
this._grid.animatePulse(animationDirection);
@@ -1667,6 +1694,16 @@ class FolderView extends BaseAppView {
return apps;
}
+ acceptDrop(source) {
+ if (!super.acceptDrop(source))
+ return false;
+
+ const folderApps = this._orderedItems.map(item => item.id);
+ this._folder.set_strv('apps', folderApps);
+
+ return true;
+ }
+
addApp(app) {
let folderApps = this._folder.get_strv('apps');
folderApps.push(app.id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]