[gnome-shell/app-picker-refresh: 11/16] appDisplay: Separate app loading from filling the grid



commit 3c74571cf3eae13630f894484af86d37c8c47a54
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Feb 19 21:31:05 2013 +0100

    appDisplay: Separate app loading from filling the grid
    
    At the moment when loading the applications, each app is inserted
    at its correct (alphabetical) position. Avoid this overhead by
    loading all apps first, then sort them once and fill the grid with
    the sorted actors.

 js/ui/appDisplay.js |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 57182c2..616d7cf 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -100,17 +100,12 @@ const AlphabeticalView = new Lang.Class({
     },
 
     addApp: function(app) {
-        var id = app.get_id();
+        let id = app.get_id();
         if (this._appIcons[id] !== undefined)
             return;
 
         let appIcon = new AppIcon(app);
-        let pos = Util.insertSorted(this._allApps, app, function(a, b) {
-            return a.compare_by_name(b);
-        });
-        this._grid.addItem(appIcon.actor, pos);
-        appIcon.actor.connect('key-focus-in', Lang.bind(this, this._ensureIconVisible));
-
+        this._allApps.push(app);
         this._appIcons[id] = appIcon;
     },
 
@@ -123,6 +118,18 @@ const AlphabeticalView = new Lang.Class({
             }));
     },
 
+    loadGrid: function() {
+        this._allApps.sort(function(a, b) { return a.compare_by_name(b); });
+
+        for (let i = 0; i < this._allApps.length; i++) {
+            let id = this._allApps[i].get_id();
+            if (!id)
+                continue;
+            this._grid.addItem(this._appIcons[id].actor);
+            this._appIcons[id].actor.connect('key-focus-in', Lang.bind(this, this._ensureIconVisible));
+        }
+    },
+
     _ensureIconVisible: function(icon) {
         let adjustment = this.actor.vscroll.adjustment;
         let [value, lower, upper, stepIncrement, pageIncrement, pageSize] = adjustment.get_values();
@@ -216,6 +223,7 @@ const AppDisplay = new Lang.Class({
                 _loadCategory(dir, this._view);
             }
         }
+        this._view.loadGrid();
 
         if (this._focusDummy) {
             let focused = this._focusDummy.has_key_focus();
@@ -306,6 +314,7 @@ const FolderIcon = new Lang.Class({
 
         this.view = new AlphabeticalView();
         _loadCategory(dir, this.view);
+        this.view.loadGrid();
 
         this.actor.connect('notify::checked', Lang.bind(this,
             function() {


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