[gnome-shell] Make sure we have information about all applications returned by the AppMonitor



commit dd1c95b3ceed59c08c4ecd970cfda8a022fa14d7
Author: Marina Zhurakhinskaya <marinaz redhat com>
Date:   Wed Jun 17 18:42:05 2009 -0400

    Make sure we have information about all applications returned by the AppMonitor
    
    The list of all applications was based on the items that show up in
    the menus, and might not have contained all applications returned
    by the AppMonitor for the most used applications request. One example of
    such an application was Evince. This resulted in a crash when an
    application we did not prepare the info for was returned as one of the
    matches by the AppMonitor, so we now include all applications returned
    by the AppMonitor in the list, in addition to the ones from the menus.
    
    Also mark apps as stale when we catch a "changed" signal from the AppMonitor
    to ensure that the cache is refreshed.

 js/ui/appDisplay.js |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 8834215..3eefc50 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -208,6 +208,7 @@ AppDisplay.prototype = {
             this._redisplayMenus();
         }));
         this._appMonitor.connect('changed', Lang.bind(this, function(monitor) {
+            this._appsStale = true;
             this._redisplay(false);
         }));
 
@@ -316,18 +317,23 @@ AppDisplay.prototype = {
         }
     },
 
-    _addApp: function(appId) {
+    _addAppForId: function(appId) {
         let appInfo = AppInfo.getAppInfo(appId);
         if (appInfo != null) {
-            this._allItems[appId] = appInfo;
-            // [] is returned if we could not get the categories or the list of categories was empty
-            let categories = Shell.get_categories_for_desktop_file(appId);
-            this._appCategories[appId] = categories;
+            this._addApp(appInfo);
         } else {
             log("appInfo for " + appId + " was not found.");
         }
     },
 
+    _addApp: function(appInfo) {
+        let appId = appInfo.id;
+        this._allItems[appId] = appInfo;
+        // [] is returned if we could not get the categories or the list of categories was empty
+        let categories = Shell.get_categories_for_desktop_file(appId);
+        this._appCategories[appId] = categories;
+    },
+
     //// Protected method overrides //// 
 
     // Gets information about all applications by calling Gio.app_info_get_all().
@@ -347,7 +353,7 @@ AppDisplay.prototype = {
             let menuApps = this._appSystem.get_applications_for_menu(menu.id);
             for (let j = 0; j < menuApps.length; j++) {
                 let appId = menuApps[j];
-                this._addApp(appId);
+                this._addAppForId(appId);
             }
         }
 
@@ -356,9 +362,18 @@ AppDisplay.prototype = {
         let settings = this._appSystem.get_all_settings();
         for (let i = 0; i < settings.length; i++) {
             let appId = settings[i];
-            this._addApp(appId);
+            this._addAppForId(appId);
         }
 
+        // Some applications, such as Evince, might not be in the menus,
+        // but might be returned by the applications monitor as most used
+        // applications, in which case we include them.
+        let mostUsedAppInfos = AppInfo.getMostUsedApps(MAX_ITEMS);
+        for (let i = 0; i < mostUsedAppInfos.length; i++) {
+            let appInfo = mostUsedAppInfos[i];
+            this._addApp(appInfo);
+        }         
+
         this._appsStale = false;
     },
 



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