[gnome-shell/gbsneto/pagination: 17/22] appDisplay: Actually destroy icons



commit acdae507fa069550d5bd4817210db4bacd1b8df6
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue May 19 17:49:09 2020 -0300

    appDisplay: Actually destroy icons
    
    AppDisplay currently adds all icons, and hides the ones inside
    a folder. Change that to only add the icons that are not inside
    folders. Adding an icon to a folder removes the icon from the
    main grid.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1271

 js/ui/appDisplay.js | 48 +++++++++++++-----------------------------------
 1 file changed, 13 insertions(+), 35 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index be368e058f..33b2edbdd4 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -462,7 +462,6 @@ class AppDisplay extends BaseAppView {
         });
 
         super._redisplay();
-        this._refilterApps();
     }
 
     _itemNameChanged(item) {
@@ -477,39 +476,6 @@ class AppDisplay extends BaseAppView {
         this.selectApp(item.id);
     }
 
-    _isItemInFolder(itemId) {
-        for (let folder of this._folderIcons) {
-            let folderApps = folder.getAppIds();
-            if (folderApps.some(appId => appId === itemId))
-                return true;
-        }
-
-        return false;
-    }
-
-    _refilterApps() {
-        let filteredApps = this._orderedItems.filter(icon => !icon.visible);
-
-        this._orderedItems.forEach(icon => {
-            if (icon instanceof AppIcon)
-                icon.visible = true;
-        });
-
-        this._folderIcons.forEach(folder => {
-            let folderApps = folder.getAppIds();
-            folderApps.forEach(appId => {
-                let appIcon = this._items.get(appId);
-                appIcon.visible = false;
-            });
-        });
-
-        // Scale in app icons that weren't visible, but now are
-        filteredApps.filter(icon => icon.visible).forEach(icon => {
-            if (icon instanceof AppIcon)
-                icon.scaleIn();
-        });
-    }
-
     getAppInfos() {
         return this._appInfoList;
     }
@@ -529,6 +495,7 @@ class AppDisplay extends BaseAppView {
 
         let appSys = Shell.AppSystem.get_default();
 
+        const appsInsideFolders = new Map();
         this._folderIcons = [];
 
         let folders = this._folderSettings.get_strv('folder-children');
@@ -540,8 +507,17 @@ class AppDisplay extends BaseAppView {
                 icon.connect('name-changed', this._itemNameChanged.bind(this));
                 icon.connect('apps-changed', this._redisplay.bind(this));
             }
+
+            // Don't try to display empty folders
+            if (!icon.visible) {
+                icon.destroy();
+                return;
+            }
+
             appIcons.push(icon);
             this._folderIcons.push(icon);
+
+            icon.getAppIds().forEach(appId => appsInsideFolders.set(appId));
         });
 
         // Allow dragging of the icon only if the Dash would accept a drop to
@@ -553,6 +529,9 @@ class AppDisplay extends BaseAppView {
         let favoritesWritable = global.settings.is_writable('favorite-apps');
 
         apps.forEach(appId => {
+            if (appsInsideFolders.has(appId))
+                return;
+
             let icon = this._items.get(appId);
             if (!icon) {
                 let app = appSys.lookup_app(appId);
@@ -562,7 +541,6 @@ class AppDisplay extends BaseAppView {
                 });
             }
 
-            icon.visible = !this._isItemInFolder(appId);
             appIcons.push(icon);
         });
 


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