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:
parent
7d80647170
commit
926177785d
@ -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) {
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user