[gnome-shell] search: add support for default disabled search providers



commit 926177785dbf526c15323dcc3ee35a4bc363ee37
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Fri Aug 1 13:35:31 2014 +0200

    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 8781de8..9ab413e 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 dc2729a..1d8ce73 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));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]