view-selector: filter out disabled search providers
If the added search provider has an appId in the list of the disabled search providers settings, ignore it. https://bugzilla.gnome.org/show_bug.cgi?id=687491
This commit is contained in:
parent
80e7f5832b
commit
9791d15f39
@ -10,6 +10,8 @@ const Util = imports.misc.util;
|
|||||||
const FileUtils = imports.misc.fileUtils;
|
const FileUtils = imports.misc.fileUtils;
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
|
|
||||||
|
const SEARCH_PROVIDERS_SCHEMA = 'org.gnome.desktop.search-providers';
|
||||||
|
|
||||||
// Not currently referenced by the search API, but
|
// Not currently referenced by the search API, but
|
||||||
// this enumeration can be useful for provider
|
// this enumeration can be useful for provider
|
||||||
// implementations.
|
// implementations.
|
||||||
|
@ -94,6 +94,9 @@ const ViewSelector = new Lang.Class({
|
|||||||
this._searchPage = this._addPage(this._searchResults.actor, this._entry,
|
this._searchPage = this._addPage(this._searchResults.actor, this._entry,
|
||||||
_("Search"), 'edit-find-symbolic');
|
_("Search"), 'edit-find-symbolic');
|
||||||
|
|
||||||
|
this._searchSettings = new Gio.Settings({ schema: Search.SEARCH_PROVIDERS_SCHEMA });
|
||||||
|
this._searchSettings.connect('changed::disabled', Lang.bind(this, this._reloadRemoteProviders));
|
||||||
|
|
||||||
// Default search providers
|
// Default search providers
|
||||||
// Wanda comes obviously first
|
// Wanda comes obviously first
|
||||||
this.addSearchProvider(new Wanda.WandaSearchProvider());
|
this.addSearchProvider(new Wanda.WandaSearchProvider());
|
||||||
@ -435,7 +438,28 @@ const ViewSelector = new Lang.Class({
|
|||||||
this._showPage(this._searchPage);
|
this._showPage(this._searchPage);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_shouldUseSearchProvider: function(provider) {
|
||||||
|
if (!provider.isRemoteProvider)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
let appId = provider.appInfo.get_id();
|
||||||
|
let disable = this._searchSettings.get_strv('disabled');
|
||||||
|
return disable.indexOf(appId) == -1;
|
||||||
|
},
|
||||||
|
|
||||||
|
_reloadRemoteProviders: function() {
|
||||||
|
// removeSearchProvider() modifies the provider list we iterate on,
|
||||||
|
// so make a copy first
|
||||||
|
let remoteProviders = this._searchSystem.getRemoteProviders().slice(0);
|
||||||
|
|
||||||
|
remoteProviders.forEach(Lang.bind(this, this.removeSearchProvider));
|
||||||
|
RemoteSearch.loadRemoteSearchProviders(Lang.bind(this, this.addSearchProvider));
|
||||||
|
},
|
||||||
|
|
||||||
addSearchProvider: function(provider) {
|
addSearchProvider: function(provider) {
|
||||||
|
if (!this._shouldUseSearchProvider(provider))
|
||||||
|
return;
|
||||||
|
|
||||||
this._searchSystem.registerProvider(provider);
|
this._searchSystem.registerProvider(provider);
|
||||||
this._searchResults.createProviderMeta(provider);
|
this._searchResults.createProviderMeta(provider);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user