From ef4231b9c0160a597d50f4eea27779452e8af182 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Tue, 21 Feb 2012 15:25:36 -0500 Subject: [PATCH] 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", will launch Google/Wikipedia. https://bugzilla.gnome.org/show_bug.cgi?id=670168 --- data/Makefile.am | 5 - data/open-search-providers/google.xml | 7 -- data/open-search-providers/wikipedia.xml | 44 -------- js/ui/search.js | 95 ---------------- js/ui/searchDisplay.js | 50 +-------- js/ui/viewSelector.js | 3 +- src/shell-util.c | 132 ----------------------- src/shell-util.h | 7 -- 8 files changed, 2 insertions(+), 341 deletions(-) delete mode 100644 data/open-search-providers/google.xml delete mode 100644 data/open-search-providers/wikipedia.xml diff --git a/data/Makefile.am b/data/Makefile.am index a3f581447..f36951629 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -10,11 +10,6 @@ desktop_DATA = gnome-shell.desktop gnome-shell-extension-prefs.desktop @INTLTOOL_DESKTOP_RULE@ -searchprovidersdir = $(pkgdatadir)/open-search-providers -dist_searchproviders_DATA = \ - open-search-providers/google.xml \ - open-search-providers/wikipedia.xml - introspectiondir = $(datadir)/dbus-1/interfaces introspection_DATA = org.gnome.ShellSearchProvider.xml diff --git a/data/open-search-providers/google.xml b/data/open-search-providers/google.xml deleted file mode 100644 index daaa254b7..000000000 --- a/data/open-search-providers/google.xml +++ /dev/null @@ -1,7 +0,0 @@ - -Google -Google Search -UTF-8 -data:image/x-icon;base64,AAABAAEAEBAAAAEAGABoAwAAFgAAACgAAAAQAAAAIAAAAAEAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADs9Pt8xetPtu9FsfFNtu%2BTzvb2%2B%2Fne4dFJeBw0egA%2FfAJAfAA8ewBBegAAAAD%2B%2FPtft98Mp%2BwWsfAVsvEbs%2FQeqvF8xO7%2F%2F%2F63y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z8%2Fv%2FV1PYKDOcAAP0DAf4AAf0AAfYEAOwAAuAAAAD%2F%2FPvi28ymXyChTATRrIb8%2F%2F3v8fk6P8MAAdUCAvoAAP0CAP0AAfYAAO4AAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAQAA - - diff --git a/data/open-search-providers/wikipedia.xml b/data/open-search-providers/wikipedia.xml deleted file mode 100644 index 4c61256a9..000000000 --- a/data/open-search-providers/wikipedia.xml +++ /dev/null @@ -1,44 +0,0 @@ - -Wikipedia -Wikipedia, the free encyclopedia -UTF-8 -data:image/x-icon;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAEAgQAhIOEAMjHyABIR0gA6ejpAGlqaQCpqKkAKCgoAPz9%2FAAZGBkAmJiYANjZ2ABXWFcAent6ALm6uQA8OjwAiIiIiIiIiIiIiI4oiL6IiIiIgzuIV4iIiIhndo53KIiIiB%2FWvXoYiIiIfEZfWBSIiIEGi%2FfoqoiIgzuL84i9iIjpGIoMiEHoiMkos3FojmiLlUipYliEWIF%2BiDe0GoRa7D6GPbjcu1yIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - - -ar -bg -ca -cs -da -de -en -eo -es -fa -fi -fr -he -hu -id -it -ja -ko -lt -nl -no -pl -pt -ro -ru -sk -sl -sr -sv -tr -uk -vi -vo -war -zh - diff --git a/js/ui/search.js b/js/ui/search.js index 447a4395d..22f53d913 100644 --- a/js/ui/search.js +++ b/js/ui/search.js @@ -10,8 +10,6 @@ const Util = imports.misc.util; const FileUtils = imports.misc.fileUtils; const Main = imports.ui.main; -const DISABLED_OPEN_SEARCH_PROVIDERS_KEY = 'disabled-open-search-providers'; - // Not currently referenced by the search API, but // this enumeration can be useful for provider // implementations. @@ -169,99 +167,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 508751eba..f6a383265 100644 --- a/js/ui/searchDisplay.js +++ b/js/ui/searchDisplay.js @@ -173,10 +173,9 @@ 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._updateResults)); - this._openSearchSystem = openSearchSystem; this.actor = new St.BoxLayout({ name: 'searchResults', vertical: true }); @@ -215,55 +214,10 @@ 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(); - this._highlightDefault = false; this._defaultResult = null; }, - _updateOpenSearchProviderButtons: function() { - 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]); - }, - - _createOpenSearchProviderButton: function(provider) { - let button = new St.Button({ style_class: 'dash-search-button', - reactive: true, - can_focus: 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; - - button.setSelected = function(selected) { - if (selected) - button.add_style_pseudo_class('selected'); - else - button.remove_style_pseudo_class('selected'); - }; - button.activate = Lang.bind(this, function() { - this._openSearchSystem.activateResult(provider.id); - }); - button.actor = button; - - this._searchProvidersBox.add(button); - }, - createProviderMeta: function(provider) { let providerBox = new St.BoxLayout({ style_class: 'search-section', vertical: true }); @@ -323,8 +277,6 @@ const SearchResults = new Lang.Class({ doSearch: function (searchString) { this._searchSystem.updateSearch(searchString); - let terms = this._searchSystem.getTerms(); - this._openSearchSystem.setSearchTerms(terms); }, _metaForProvider: function(provider) { diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js index c4a600910..2d112720f 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)); diff --git a/src/shell-util.c b/src/shell-util.c index 7dc87d3a4..8f58d6389 100644 --- a/src/shell-util.c +++ b/src/shell-util.c @@ -14,10 +14,6 @@ #include #endif -#include -#include -#include - #ifdef WITH_SYSTEMD #include #include @@ -646,134 +642,6 @@ shell_get_file_contents_utf8_sync (const char *path, return contents; } -/** - * shell_parse_search_provider: - * @data: description of provider - * @name: (out): location to store a display name - * @url: (out): location to store template of url - * @langs: (out) (transfer full) (element-type utf8): list of supported languages - * @icon_data_uri: (out): location to store uri - * @error: location to store GError - * - * Returns: %TRUE on success - */ -gboolean -shell_parse_search_provider (const char *data, - char **name, - char **url, - GList **langs, - char **icon_data_uri, - GError **error) -{ - xmlDocPtr doc = xmlParseMemory (data, strlen (data)); - xmlNode *root; - - *name = NULL; - *url = NULL; - *icon_data_uri = NULL; - *langs = NULL; - - if (!doc) - { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Malformed xml"); - return FALSE; - } - - root = xmlDocGetRootElement (doc); - if (root && root->name && xmlStrcmp (root->name, (const xmlChar *)"OpenSearchDescription") == 0) - { - xmlNode *child; - for (child = root->children; child; child = child->next) - { - if (!child->name) - continue; - if (xmlStrcmp (child->name, (const xmlChar *)"Language") == 0) - { - xmlChar *val = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); - if (!val) - continue; - *langs = g_list_append (*langs, g_strdup ((char *)val)); - xmlFree (val); - } - if (!*name && xmlStrcmp (child->name, (const xmlChar *)"ShortName") == 0) - { - xmlChar *val = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); - *name = g_strdup ((char *)val); - xmlFree (val); - } - if (!*icon_data_uri && xmlStrcmp (child->name, (const xmlChar *)"Image") == 0) - { - xmlChar *val = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); - if (val) - *icon_data_uri = g_strdup ((char *)val); - xmlFree (val); - } - if (!*url && xmlStrcmp (child->name, (const xmlChar *)"Url") == 0) - { - xmlChar *template; - xmlChar *type; - - type = xmlGetProp(child, (const xmlChar *)"type"); - if (!type) - continue; - - if (xmlStrcmp (type, (const xmlChar *)"text/html") != 0) - { - xmlFree (type); - continue; - } - xmlFree (type); - - template = xmlGetProp(child, (const xmlChar *)"template"); - if (!template) - continue; - *url = g_strdup ((char *)template); - xmlFree (template); - } - } - } - else - { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Invalid OpenSearch document"); - xmlFreeDoc (doc); - return FALSE; - } - xmlFreeDoc (doc); - if (*icon_data_uri && *name && *url) - return TRUE; - - if (*icon_data_uri) - g_free (*icon_data_uri); - else - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - "search provider doesn't have icon"); - - if (*name) - g_free (*name); - else if (error && !*error) - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - "search provider doesn't have ShortName"); - - if (*url) - g_free (*url); - else if (error && !*error) - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - "search provider doesn't have template for url"); - - if (*langs) - { - g_list_foreach (*langs, (GFunc)g_free, NULL); - g_list_free (*langs); - } - - *url = NULL; - *name = NULL; - *icon_data_uri = NULL; - *langs = NULL; - - return FALSE; -} - /** * shell_session_is_active_for_systemd: * diff --git a/src/shell-util.h b/src/shell-util.h index c1b7c4839..b025a03a9 100644 --- a/src/shell-util.h +++ b/src/shell-util.h @@ -33,13 +33,6 @@ gboolean shell_write_string_to_stream (GOutputStream *stream, char *shell_get_file_contents_utf8_sync (const char *path, GError **error); -gboolean shell_parse_search_provider (const char *data, - char **name, - char **url, - GList **langs, - char **icon_data_uri, - GError **error); - gboolean shell_session_is_active_for_systemd (void); gboolean shell_util_wifexited (int status,