[gnome-shell] appDisplay: Only reload frequently used data when mapping the frequent view



commit bdad4db9ec4e08f2376144253f883dc060e14a3f
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Jan 28 11:06:21 2014 -0500

    appDisplay: Only reload frequently used data when mapping the frequent view
    
    If the user mostly uses the All Apps view and uses it as his default view,
    we shouldn't reload frequent data after a timeout. Simply do it when the
    view is mapped.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=723179

 js/ui/appDisplay.js |   27 +++++++++++----------------
 1 files changed, 11 insertions(+), 16 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 921d83b..21cf56b 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -561,17 +561,18 @@ const FrequentView = new Lang.Class({
         this._noFrequentAppsLabel.hide();
 
         this._usage = Shell.AppUsage.get_default();
+
+        this.actor.connect('notify::mapped', Lang.bind(this, function() {
+            if (this.actor.mapped)
+                this._redisplay();
+        }));
     },
 
     hasUsefulData: function() {
         return this._usage.get_most_used("").length >= MIN_FREQUENT_APPS_COUNT;
     },
 
-    removeAll: function() {
-        this._grid.destroyAll();
-    },
-
-    loadApps: function() {
+    _loadApps: function() {
         let mostUsed = this._usage.get_most_used ("");
         let hasUsefulData = this.hasUsefulData();
         this._noFrequentAppsLabel.visible = !hasUsefulData;
@@ -586,6 +587,11 @@ const FrequentView = new Lang.Class({
         }
     },
 
+    _redisplay: function() {
+        this.removeAll();
+        this._loadApps();
+    },
+
     // Called before allocation to calculate dynamic spacing
     adaptToSize: function(width, height) {
         let box = new Clutter.ActorBox();
@@ -652,9 +658,6 @@ const AppDisplay = new Lang.Class({
         Shell.AppSystem.get_default().connect('installed-changed', Lang.bind(this, function() {
             Main.queueDeferredWork(this._allAppsWorkId);
         }));
-        Main.overview.connect('showing', Lang.bind(this, function() {
-            Main.queueDeferredWork(this._frequentAppsWorkId);
-        }));
         this._folderSettings = new Gio.Settings({ schema: 'org.gnome.desktop.app-folders' });
         this._folderSettings.connect('changed::folder-children', Lang.bind(this, function() {
             Main.queueDeferredWork(this._allAppsWorkId);
@@ -720,7 +723,6 @@ const AppDisplay = new Lang.Class({
         this._viewStack.add_actor(this._focusDummy);
 
         this._allAppsWorkId = Main.initializeDeferredWork(this.actor, Lang.bind(this, 
this._redisplayAllApps));
-        this._frequentAppsWorkId = Main.initializeDeferredWork(this.actor, Lang.bind(this, 
this._redisplayFrequentApps));
     },
 
     _showView: function(activeIndex) {
@@ -754,13 +756,6 @@ const AppDisplay = new Lang.Class({
             this._showView(Views.ALL);
     },
 
-    _redisplayFrequentApps: function() {
-        let view = this._views[Views.FREQUENT].view;
-
-        view.removeAll();
-        view.loadApps();
-    },
-
     _redisplayAllApps: function() {
         let view = this._views[Views.ALL].view;
         view.removeAll();


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