From 926177785dbf526c15323dcc3ee35a4bc363ee37 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Fri, 1 Aug 2014 13:35:31 +0200 Subject: [PATCH] search: add support for default disabled search providers Search providers that should be disabled by default come with a DefaultDisabled=true key in their keyfile, and are enabled with the "enabled" whitelist, not with the "disabled" blacklist. https://bugzilla.gnome.org/show_bug.cgi?id=734110 --- js/ui/remoteSearch.js | 17 +++++++++++++++-- js/ui/search.js | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/js/ui/remoteSearch.js b/js/ui/remoteSearch.js index 8781de893..9ab413e6f 100644 --- a/js/ui/remoteSearch.js +++ b/js/ui/remoteSearch.js @@ -110,6 +110,13 @@ function loadRemoteSearchProviders(callback) { else remoteProvider = new RemoteSearchProvider(appInfo, busName, objectPath); + remoteProvider.defaultEnabled = true; + try { + remoteProvider.defaultEnabled = !keyfile.get_boolean(group, 'DefaultDisabled'); + } catch(e) { + // ignore error + } + objectPaths[objectPath] = remoteProvider; loadedProviders.push(remoteProvider); } catch(e) { @@ -132,8 +139,14 @@ function loadRemoteSearchProviders(callback) { loadedProviders = loadedProviders.filter(function(provider) { let appId = provider.appInfo.get_id(); - let disabled = searchSettings.get_strv('disabled'); - return disabled.indexOf(appId) == -1; + + if (provider.defaultEnabled) { + let disabled = searchSettings.get_strv('disabled'); + return disabled.indexOf(appId) == -1; + } else { + let enabled = searchSettings.get_strv('enabled'); + return enabled.indexOf(appId) != -1; + } }); loadedProviders.sort(function(providerA, providerB) { diff --git a/js/ui/search.js b/js/ui/search.js index dc2729a4a..1d8ce7389 100644 --- a/js/ui/search.js +++ b/js/ui/search.js @@ -32,6 +32,7 @@ const SearchSystem = new Lang.Class({ this._registerProvider(new AppDisplay.AppSearchProvider()); this._searchSettings = new Gio.Settings({ schema_id: SEARCH_PROVIDERS_SCHEMA }); + this._searchSettings.connect('changed::enabled', Lang.bind(this, this._reloadRemoteProviders)); this._searchSettings.connect('changed::disabled', Lang.bind(this, this._reloadRemoteProviders)); this._searchSettings.connect('changed::disable-external', Lang.bind(this, this._reloadRemoteProviders)); this._searchSettings.connect('changed::sort-order', Lang.bind(this, this._reloadRemoteProviders));