[gnome-shell/wip/clutter-deprecation-fixes: 7/7] search: Junk the OpenSearch system



commit 6dea34544f86143ecad7e257f37da447f391816f
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Feb 21 15:25:36 2012 -0500

    search: Junk the OpenSearch system
    
    The original design for the overview had buttons for searching for
    Wikipedia and Google, but in practice this is a bad idea. The buttons
    are the default activations, meaning that using the overview as a
    fluent motion of launching something - "firefxo<Enter>", will launch
    Google/Wikipedia.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=670168

 js/ui/search.js        |   93 -------------------------------------
 js/ui/searchDisplay.js |  118 ++++++++----------------------------------------
 js/ui/viewSelector.js  |    3 +-
 3 files changed, 20 insertions(+), 194 deletions(-)
---
diff --git a/js/ui/search.js b/js/ui/search.js
index ed0ea48..69758d5 100644
--- a/js/ui/search.js
+++ b/js/ui/search.js
@@ -250,99 +250,6 @@ const SearchProvider = new Lang.Class({
 });
 Signals.addSignalMethods(SearchProvider.prototype);
 
-const OpenSearchSystem = new Lang.Class({
-    Name: 'OpenSearchSystem',
-
-    _init: function() {
-        this._providers = [];
-        global.settings.connect('changed::' + DISABLED_OPEN_SEARCH_PROVIDERS_KEY, Lang.bind(this, this._refresh));
-        this._refresh();
-    },
-
-    getProviders: function() {
-        let res = [];
-        for (let i = 0; i < this._providers.length; i++)
-            res.push({ id: i, name: this._providers[i].name });
-
-        return res;
-    },
-
-    setSearchTerms: function(terms) {
-        this._terms = terms;
-    },
-
-    _checkSupportedProviderLanguage: function(provider) {
-        if (provider.url.search(/{language}/) == -1)
-            return true;
-
-        let langs = GLib.get_language_names();
-
-        langs.push('en');
-        let lang = null;
-        for (let i = 0; i < langs.length; i++) {
-            for (let k = 0; k < provider.langs.length; k++) {
-                if (langs[i] == provider.langs[k])
-                    lang = langs[i];
-            }
-            if (lang)
-                break;
-        }
-        provider.lang = lang;
-        return lang != null;
-    },
-
-    activateResult: function(id, params) {
-        let searchTerms = this._terms.join(' ');
-
-        let url = this._providers[id].url.replace('{searchTerms}', encodeURIComponent(searchTerms));
-        if (url.match('{language}'))
-            url = url.replace('{language}', this._providers[id].lang);
-
-        try {
-            Gio.app_info_launch_default_for_uri(url, global.create_app_launch_context());
-        } catch (e) {
-            // TODO: remove this after glib will be removed from moduleset
-            // In the default jhbuild, gio is in our prefix but gvfs is not
-            Util.spawn(['gvfs-open', url])
-        }
-
-        Main.overview.hide();
-    },
-
-    _addProvider: function(fileName) {
-        let path = global.datadir + '/open-search-providers/' + fileName;
-        let source = Shell.get_file_contents_utf8_sync(path);
-        let [success, name, url, langs, icon_uri] = Shell.parse_search_provider(source);
-        let provider ={ name: name,
-                        url: url,
-                        id: this._providers.length,
-                        icon_uri: icon_uri,
-                        langs: langs };
-        if (this._checkSupportedProviderLanguage(provider)) {
-            this._providers.push(provider);
-            this.emit('changed');
-        }
-    },
-
-    _refresh: function() {
-        this._providers = [];
-        let names = global.settings.get_strv(DISABLED_OPEN_SEARCH_PROVIDERS_KEY);
-        let file = Gio.file_new_for_path(global.datadir + '/open-search-providers');
-        FileUtils.listDirAsync(file, Lang.bind(this, function(files) {
-            for (let i = 0; i < files.length; i++) {
-                let enabled = true;
-                let name = files[i].get_name();
-                for (let k = 0; k < names.length; k++)
-                    if (names[k] == name)
-                        enabled = false;
-                if (enabled)
-                    this._addProvider(name);
-            }
-        }));
-    }
-});
-Signals.addSignalMethods(OpenSearchSystem.prototype);
-
 const SearchSystem = new Lang.Class({
     Name: 'SearchSystem',
 
diff --git a/js/ui/searchDisplay.js b/js/ui/searchDisplay.js
index 984a55a..4320ac8 100644
--- a/js/ui/searchDisplay.js
+++ b/js/ui/searchDisplay.js
@@ -195,11 +195,10 @@ const GridSearchResults = new Lang.Class({
 const SearchResults = new Lang.Class({
     Name: 'SearchResults',
 
-    _init: function(searchSystem, openSearchSystem) {
+    _init: function(searchSystem) {
         this._searchSystem = searchSystem;
         this._searchSystem.connect('search-updated', Lang.bind(this, this._updateCurrentResults));
         this._searchSystem.connect('search-completed', Lang.bind(this, this._updateResults));
-        this._openSearchSystem = openSearchSystem;
 
         this.actor = new St.BoxLayout({ name: 'searchResults',
                                         vertical: true });
@@ -240,49 +239,6 @@ const SearchResults = new Lang.Class({
         }
         this._searchProvidersBox = new St.BoxLayout({ style_class: 'search-providers-box' });
         this.actor.add(this._searchProvidersBox);
-
-        this._openSearchProviders = [];
-        this._openSearchSystem.connect('changed', Lang.bind(this, this._updateOpenSearchProviderButtons));
-        this._updateOpenSearchProviderButtons();
-    },
-
-    _updateOpenSearchProviderButtons: function() {
-        this._selectedOpenSearchButton = -1;
-        for (let i = 0; i < this._openSearchProviders.length; i++)
-            this._openSearchProviders[i].actor.destroy();
-        this._openSearchProviders = this._openSearchSystem.getProviders();
-        for (let i = 0; i < this._openSearchProviders.length; i++)
-            this._createOpenSearchProviderButton(this._openSearchProviders[i]);
-    },
-
-    _updateOpenSearchButtonState: function() {
-         for (let i = 0; i < this._openSearchProviders.length; i++) {
-             if (i == this._selectedOpenSearchButton)
-                 this._openSearchProviders[i].actor.add_style_pseudo_class('selected');
-             else
-                 this._openSearchProviders[i].actor.remove_style_pseudo_class('selected');
-         }
-    },
-
-    _createOpenSearchProviderButton: function(provider) {
-        let button = new St.Button({ style_class: 'dash-search-button',
-                                     reactive: true,
-                                     x_fill: true,
-                                     y_align: St.Align.MIDDLE });
-        let bin = new St.Bin({ x_fill: false,
-                               x_align:St.Align.MIDDLE });
-        button.connect('clicked', Lang.bind(this, function() {
-            this._openSearchSystem.activateResult(provider.id);
-        }));
-        let title = new St.Label({ text: provider.name,
-                                   style_class: 'dash-search-button-label' });
-
-        button.label_actor = title;
-        bin.set_child(title);
-        button.set_child(bin);
-        provider.actor = button;
-
-        this._searchProvidersBox.add(button);
     },
 
     createProviderMeta: function(provider) {
@@ -340,8 +296,6 @@ const SearchResults = new Lang.Class({
         this._searchSystem.reset();
         this._statusText.hide();
         this._clearDisplay();
-        this._selectedOpenSearchButton = -1;
-        this._updateOpenSearchButtonState();
     },
 
     startingSearch: function() {
@@ -359,9 +313,6 @@ const SearchResults = new Lang.Class({
     },
 
     _maybeSetInitialSelection: function() {
-        if (this._selectedOpenSearchButton > -1 || this._selectedProvider > -1)
-            return;
-
         for (let i = 0; i < this._providerMeta.length; i++) {
             let meta = this._providerMeta[i];
             if (meta.hasPendingResults)
@@ -417,14 +368,10 @@ const SearchResults = new Lang.Class({
             this._statusText.set_text(_("No matching results."));
             this._statusText.show();
         } else {
-            this._selectedOpenSearchButton = -1;
-            this._updateOpenSearchButtonState();
-            this._selectedProvider = -1;
             this._statusText.hide();
         }
 
         let terms = searchSystem.getTerms();
-        this._openSearchSystem.setSearchTerms(terms);
 
         // To avoid CSS transitions causing flickering
         // of the selection when the first search result
@@ -460,26 +407,17 @@ const SearchResults = new Lang.Class({
     },
 
     selectUp: function(recursing) {
-        if (this._selectedOpenSearchButton == -1) {
-            for (let i = this._selectedProvider; i >= 0; i--) {
-                let meta = this._providerMeta[i];
-                if (!meta.actor.visible)
-                    continue;
-                let success = this._modifyActorSelection(meta.resultDisplay, true);
-                if (success) {
-                    this._selectedProvider = i;
-                    return;
-                }
+        for (let i = this._selectedProvider; i >= 0; i--) {
+            let meta = this._providerMeta[i];
+            if (!meta.actor.visible)
+                continue;
+            let success = this._modifyActorSelection(meta.resultDisplay, true);
+            if (success) {
+                this._selectedProvider = i;
+                return;
             }
         }
 
-        if (this._selectedOpenSearchButton == -1)
-            this._selectedOpenSearchButton = this._openSearchProviders.length;
-        this._selectedOpenSearchButton--;
-        this._updateOpenSearchButtonState();
-        if (this._selectedOpenSearchButton >= 0)
-            return;
-
         if (this._providerMeta.length > 0 && !recursing) {
             this._selectedProvider = this._providerMeta.length - 1;
             this.selectUp(true);
@@ -488,29 +426,18 @@ const SearchResults = new Lang.Class({
 
     selectDown: function(recursing) {
         let current = this._selectedProvider;
-        if (this._selectedOpenSearchButton == -1) {
-            if (current == -1)
-                current = 0;
-            for (let i = current; i < this._providerMeta.length; i++) {
-                let meta = this._providerMeta[i];
-                if (!meta.actor.visible)
-                    continue;
-                 let success = this._modifyActorSelection(meta.resultDisplay, false);
-                 if (success) {
-                    this._selectedProvider = i;
-                    return;
-                 }
+        if (current == -1)
+            current = 0;
+        for (let i = current; i < this._providerMeta.length; i++) {
+            let meta = this._providerMeta[i];
+            if (!meta.actor.visible)
+                continue;
+            let success = this._modifyActorSelection(meta.resultDisplay, false);
+            if (success) {
+                this._selectedProvider = i;
+                return;
             }
         }
-        this._selectedOpenSearchButton++;
-
-        if (this._selectedOpenSearchButton < this._openSearchProviders.length) {
-            this._updateOpenSearchButtonState();
-            return;
-        }
-
-        this._selectedOpenSearchButton = -1;
-        this._updateOpenSearchButtonState();
 
         if (this._providerMeta.length > 0 && !recursing) {
             this._selectedProvider = 0;
@@ -519,13 +446,6 @@ const SearchResults = new Lang.Class({
     },
 
     activateSelected: function() {
-        if (this._selectedOpenSearchButton != -1) {
-            let provider = this._openSearchProviders[this._selectedOpenSearchButton];
-            this._openSearchSystem.activateResult(provider.id);
-            Main.overview.hide();
-            return;
-        }
-
         let current = this._selectedProvider;
         if (current < 0)
             return;
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index 4ba9c94..786b37b 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -103,7 +103,6 @@ const SearchTab = new Lang.Class({
         this._searchTimeoutId = 0;
 
         this._searchSystem = new Search.SearchSystem();
-        this._openSearchSystem = new Search.OpenSearchSystem();
 
         this._entry = new St.Entry({ name: 'searchEntry',
                                      /* Translators: this is the text displayed
@@ -127,7 +126,7 @@ const SearchTab = new Lang.Class({
 
         this._iconClickedId = 0;
 
-        this._searchResults = new SearchDisplay.SearchResults(this._searchSystem, this._openSearchSystem);
+        this._searchResults = new SearchDisplay.SearchResults(this._searchSystem);
         this.parent(this._entry, this._searchResults.actor, _("Search"), 'edit-find');
 
         this._text.connect('text-changed', Lang.bind(this, this._onTextChanged));



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