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.
This commit is contained in:
Marina Zhurakhinskaya 2009-06-17 18:42:05 -04:00
parent 71cad8cd3f
commit dd1c95b3ce

View File

@ -208,6 +208,7 @@ AppDisplay.prototype = {
this._redisplayMenus(); this._redisplayMenus();
})); }));
this._appMonitor.connect('changed', Lang.bind(this, function(monitor) { this._appMonitor.connect('changed', Lang.bind(this, function(monitor) {
this._appsStale = true;
this._redisplay(false); this._redisplay(false);
})); }));
@ -316,18 +317,23 @@ AppDisplay.prototype = {
} }
}, },
_addApp: function(appId) { _addAppForId: function(appId) {
let appInfo = AppInfo.getAppInfo(appId); let appInfo = AppInfo.getAppInfo(appId);
if (appInfo != null) { if (appInfo != null) {
this._allItems[appId] = appInfo; this._addApp(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;
} else { } else {
log("appInfo for " + appId + " was not found."); 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 //// //// Protected method overrides ////
// Gets information about all applications by calling Gio.app_info_get_all(). // 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); let menuApps = this._appSystem.get_applications_for_menu(menu.id);
for (let j = 0; j < menuApps.length; j++) { for (let j = 0; j < menuApps.length; j++) {
let appId = menuApps[j]; let appId = menuApps[j];
this._addApp(appId); this._addAppForId(appId);
} }
} }
@ -356,9 +362,18 @@ AppDisplay.prototype = {
let settings = this._appSystem.get_all_settings(); let settings = this._appSystem.get_all_settings();
for (let i = 0; i < settings.length; i++) { for (let i = 0; i < settings.length; i++) {
let appId = settings[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; this._appsStale = false;
}, },