[gnome-shell/gbsneto/custom-icon-positions: 60/60] appDisplay: Append new icons at the first available page after first



commit b7249b14fe4738eb44ca4708af4336b8d48d3781
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Jun 25 17:33:48 2020 -0300

    appDisplay: Append new icons at the first available page after first
    
    As per design discussion, the first page is a somewhat of a special
    page where we really don't want to change anything unless necessary.
    
    Append new icons at the first available slot after the first page.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1284

 js/ui/appDisplay.js | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 9dbd47c0f8..e78fdcab4e 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -533,10 +533,27 @@ var BaseAppView = GObject.registerClass({
         return true;
     }
 
+    _findBestPageToAppend() {
+        for (let i = 1; i < this._grid.nPages; i++) {
+            const pageItems =
+                this._grid.getItemsAtPage(i).filter(c => c.visible);
+
+            if (pageItems.length < this._grid.itemsPerPage)
+                return i;
+        }
+
+        return -1;
+    }
+
     _addItem(item, page, position) {
         let itemIndex = 0;
 
         if (this._grid.nPages > 0) {
+            // Append icons to the first page with empty slot, starting from
+            // the second page
+            if (this._grid.nPages > 1 && page === -1 && position === -1)
+                page = this._findBestPageToAppend();
+
             const realPage = page !== -1 ? page : Math.max(this._grid.nPages - 1, 0);
 
             itemIndex = position !== -1


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