[gnome-shell] view-selector: filter out disabled search providers
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] view-selector: filter out disabled search providers
- Date: Mon, 19 Nov 2012 17:02:46 +0000 (UTC)
commit 9791d15f3918a549914cc470d8e58c94bc260e66
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu Nov 1 10:33:40 2012 -0400
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
js/ui/search.js | 2 ++
js/ui/viewSelector.js | 24 ++++++++++++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/search.js b/js/ui/search.js
index bc50cb0..2e746d8 100644
--- a/js/ui/search.js
+++ b/js/ui/search.js
@@ -10,6 +10,8 @@ const Util = imports.misc.util;
const FileUtils = imports.misc.fileUtils;
const Main = imports.ui.main;
+const SEARCH_PROVIDERS_SCHEMA = 'org.gnome.desktop.search-providers';
+
// Not currently referenced by the search API, but
// this enumeration can be useful for provider
// implementations.
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index 4d096ba..d2edfcb 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -94,6 +94,9 @@ const ViewSelector = new Lang.Class({
this._searchPage = this._addPage(this._searchResults.actor, this._entry,
_("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
// Wanda comes obviously first
this.addSearchProvider(new Wanda.WandaSearchProvider());
@@ -435,7 +438,28 @@ const ViewSelector = new Lang.Class({
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) {
+ if (!this._shouldUseSearchProvider(provider))
+ return;
+
this._searchSystem.registerProvider(provider);
this._searchResults.createProviderMeta(provider);
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]