From bc91b7dcaec48f69d51685b41dec0f79c1b194a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 22 Jun 2012 17:44:15 +0200 Subject: [PATCH] remoteSearch: Parse 'DesktopId' field in key file We strongly expect applications to use the same values for the 'Title'/'Icon' fields in their search provider .ini file as the 'Name'/'Icon' fields in their .desktop file. Rather than requiring applications to duplicate those fields, allow them to specify a 'DesktopId' field instead to point to the corresponding .desktop file, which makes it possible to ship search provider files without translatable strings (which is nice given that merging translations into search provider files lacks a standard rule). https://bugzilla.gnome.org/show_bug.cgi?id=678816 --- js/ui/remoteSearch.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/js/ui/remoteSearch.js b/js/ui/remoteSearch.js index 6a03607ee..bf391d24c 100644 --- a/js/ui/remoteSearch.js +++ b/js/ui/remoteSearch.js @@ -62,12 +62,26 @@ function loadRemoteSearchProvidersFromDir(dir, addProviderCallback) { let remoteProvider, title; try { let group = KEY_FILE_GROUP; - let iconName = keyfile.get_string(group, 'Icon'); let busName = keyfile.get_string(group, 'BusName'); let objectPath = keyfile.get_string(group, 'ObjectPath'); - title = keyfile.get_locale_string(group, 'Title', null); - let icon = new Gio.ThemedIcon({ name: iconName }); + let appInfo = null; + try { + let desktopId = keyfile.get_string(group, 'DesktopId'); + appInfo = Gio.DesktopAppInfo.new(desktopId); + } catch (e) { + } + + let icon; + if (appInfo) { + icon = appInfo.get_icon(); + title = appInfo.get_name(); + } else { + let iconName = keyfile.get_string(group, 'Icon'); + icon = new Gio.ThemedIcon({ name: iconName }); + title = keyfile.get_locale_string(group, 'Title', null); + } + remoteProvider = new RemoteSearchProvider(title, icon, busName,