app-cache: add ShellAppCache for GAppInfo caching
This caches GAppInfo so that the compositor thread does not have to perform costly disk access to load them. Instead, they are loaded from a worker thread and the ShellAppCache notifies of changes. To simplfy maintenace, ShellAppCache manages this directly and the existing ShellAppSystem wraps the cache. We may want to graft these together in the future, but now it provides the easiest way to backport changes to older Shell releases. Another source of compositor thread disk access was in determining the name for an application directory. Translations are provided via GKeyFile installed in "desktop-directories". Each time we would build the name for a label (or update it) we would have to load all of these files. Instead, the ShellAppCache caches that information and updates the cache in bulk when those change. We can reduce this in the future to do less work, but chances are these will come together anyway so that is probably worth fixing if we every come across it. https://gitlab.gnome.org/GNOME/gnome-shell/issues/2282
This commit is contained in:

committed by
Jonas Ådahl

parent
92cfb9ab1b
commit
7f7965d622
@ -92,17 +92,8 @@ function _listsIntersect(a, b) {
|
||||
function _getFolderName(folder) {
|
||||
let name = folder.get_string('name');
|
||||
|
||||
if (folder.get_boolean('translate')) {
|
||||
let keyfile = new GLib.KeyFile();
|
||||
let path = 'desktop-directories/' + name;
|
||||
|
||||
try {
|
||||
keyfile.load_from_data_dirs(path, GLib.KeyFileFlags.NONE);
|
||||
name = keyfile.get_locale_string('Desktop Entry', 'Name', null);
|
||||
} catch(e) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
if (folder.get_boolean('translate'))
|
||||
return Shell.AppCache.get_default().translate_folder(name);
|
||||
|
||||
return name;
|
||||
}
|
||||
@ -499,7 +490,7 @@ var AllView = new Lang.Class({
|
||||
},
|
||||
|
||||
_loadApps() {
|
||||
let apps = Gio.AppInfo.get_all().filter(appInfo => {
|
||||
let apps = Shell.AppCache.get_default().get_all().filter(appInfo => {
|
||||
try {
|
||||
let id = appInfo.get_id(); // catch invalid file encodings
|
||||
} catch(e) {
|
||||
@ -1329,7 +1320,7 @@ var FolderIcon = new Lang.Class({
|
||||
folderApps.forEach(addAppId);
|
||||
|
||||
let folderCategories = this._folder.get_strv('categories');
|
||||
Gio.AppInfo.get_all().forEach(appInfo => {
|
||||
Shell.AppCache.get_default().get_all().forEach(appInfo => {
|
||||
let appCategories = _getCategories(appInfo);
|
||||
if (!_listsIntersect(folderCategories, appCategories))
|
||||
return;
|
||||
|
Reference in New Issue
Block a user