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
This commit is contained in:
Giovanni Campagna 2014-08-01 13:35:31 +02:00
parent 7d80647170
commit 926177785d
2 changed files with 16 additions and 2 deletions

View File

@ -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) {

View File

@ -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));