[gnome-shell/gbsneto/custom-icon-positions: 32/40] appDisplay: Save pages after moving items



commit cfd3b86609781236b5ae4c5ddd2df9c6c537d86d
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue May 26 01:41:17 2020 -0300

    appDisplay: Save pages after moving items
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1284

 js/ui/appDisplay.js | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 72e293d59f..149ec7faa5 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -748,6 +748,26 @@ class AppDisplay extends BaseAppView {
         super._redisplay();
     }
 
+    _collectPages() {
+        const pages = [];
+
+        for (let i = 0; i < this._grid.nPages; i++) {
+            const pageItems =
+                this._grid.getItemsAtPage(i).filter(c => c.visible);
+            const pageData = {};
+
+            for (let itemIndex in pageItems) {
+                const item = pageItems[itemIndex];
+                pageData[item.id] = {
+                    position: GLib.Variant.new_int32(itemIndex),
+                };
+            }
+            pages.push(pageData);
+        }
+
+        return pages;
+    }
+
     _itemNameChanged(item) {
         // If an item's name changed, we can pluck it out of where it's
         // supposed to be and reinsert it where it's sorted.
@@ -836,6 +856,11 @@ class AppDisplay extends BaseAppView {
         return appIcons;
     }
 
+    moveItem(item, page, position) {
+        super.moveItem(item, page, position);
+        this._pageManager.pages = this._collectPages();
+    }
+
     // Overridden from BaseAppView
     animate(animationDirection, onComplete) {
         this._scrollView.reactive = false;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]