From 3044a6b5178187bf987277c0dffaeb54b20c668c Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Fri, 28 Dec 2012 18:03:13 +0100 Subject: [PATCH] Remove builtin settings search provider It is now provided as a remote provider by gnome-control-center. https://bugzilla.gnome.org/show_bug.cgi?id=690824 --- js/ui/appDisplay.js | 38 ---------------------- js/ui/remoteSearch.js | 4 +++ js/ui/viewSelector.js | 1 - src/shell-app-system.c | 71 ------------------------------------------ src/shell-app-system.h | 3 -- 5 files changed, 4 insertions(+), 113 deletions(-) diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 244964522..c3cd38260 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -366,44 +366,6 @@ const AppSearchProvider = new Lang.Class({ } }); -const SettingsSearchProvider = new Lang.Class({ - Name: 'SettingsSearchProvider', - - _init: function() { - this.appInfo = Gio.DesktopAppInfo.new('gnome-control-center.desktop'); - this._appSys = Shell.AppSystem.get_default(); - }, - - getResultMetas: function(prefs, callback) { - let metas = []; - for (let i = 0; i < prefs.length; i++) { - let pref = prefs[i]; - metas.push({ 'id': pref, - 'name': pref.get_name(), - 'createIcon': function() { return null; } - }); - } - callback(metas); - }, - - getInitialResultSet: function(terms) { - this.searchSystem.pushResults(this, this._appSys.search_settings(terms)); - }, - - getSubsearchResultSet: function(previousResults, terms) { - this.searchSystem.pushResults(this, this._appSys.search_settings(terms)); - }, - - activateResult: function(pref) { - pref.activate(); - }, - - launchSearch: function(terms) { - // FIXME: this should be a remote search provider - this.appInfo.launch([], global.create_app_launch_context()); - } -}); - const AppIcon = new Lang.Class({ Name: 'AppIcon', Extends: IconGrid.BaseIcon, diff --git a/js/ui/remoteSearch.js b/js/ui/remoteSearch.js index 96bf81bfe..64af9e9c0 100644 --- a/js/ui/remoteSearch.js +++ b/js/ui/remoteSearch.js @@ -123,6 +123,10 @@ function loadRemoteSearchProvider(file, info, data) { function remoteProvidersLoaded(loadState) { let searchSettings = new Gio.Settings({ schema: Search.SEARCH_PROVIDERS_SCHEMA }); let sortOrder = searchSettings.get_strv('sort-order'); + + // Special case gnome-control-center to be always active and always first + sortOrder.unshift('gnome-control-center.desktop'); + let numSorted = sortOrder.length; loadState.loadedProviders.sort( diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js index 48b3e3b70..85f4a6c3e 100644 --- a/js/ui/viewSelector.js +++ b/js/ui/viewSelector.js @@ -114,7 +114,6 @@ const ViewSelector = new Lang.Class({ // Wanda comes obviously first this.addSearchProvider(new Wanda.WandaSearchProvider()); this.addSearchProvider(new AppDisplay.AppSearchProvider()); - this.addSearchProvider(new AppDisplay.SettingsSearchProvider()); // Load remote search providers provided by applications RemoteSearch.loadRemoteSearchProviders(Lang.bind(this, this.addSearchProvider)); diff --git a/src/shell-app-system.c b/src/shell-app-system.c index 66f94f808..847e9a403 100644 --- a/src/shell-app-system.c +++ b/src/shell-app-system.c @@ -45,14 +45,10 @@ struct _ShellAppSystemPrivate { GHashTable *id_to_app; GSList *known_vendor_prefixes; - - GMenuTree *settings_tree; - GHashTable *setting_id_to_app; }; static void shell_app_system_finalize (GObject *object); static void on_apps_tree_changed_cb (GMenuTree *tree, gpointer user_data); -static void on_settings_tree_changed_cb (GMenuTree *tree, gpointer user_data); G_DEFINE_TYPE(ShellAppSystem, shell_app_system, G_TYPE_OBJECT); @@ -97,20 +93,12 @@ shell_app_system_init (ShellAppSystem *self) /* All the objects in this hash table are owned by id_to_app */ priv->visible_id_to_app = g_hash_table_new (g_str_hash, g_str_equal); - priv->setting_id_to_app = g_hash_table_new_full (g_str_hash, g_str_equal, - NULL, - (GDestroyNotify)g_object_unref); - /* We want to track NoDisplay apps, so we add INCLUDE_NODISPLAY. We'll * filter NoDisplay apps out when showing them to the user. */ priv->apps_tree = gmenu_tree_new ("applications.menu", GMENU_TREE_FLAGS_INCLUDE_NODISPLAY); g_signal_connect (priv->apps_tree, "changed", G_CALLBACK (on_apps_tree_changed_cb), self); - priv->settings_tree = gmenu_tree_new ("gnomecc.menu", 0); - g_signal_connect (priv->settings_tree, "changed", G_CALLBACK (on_settings_tree_changed_cb), self); - on_apps_tree_changed_cb (priv->apps_tree, self); - on_settings_tree_changed_cb (priv->settings_tree, self); } static void @@ -120,12 +108,10 @@ shell_app_system_finalize (GObject *object) ShellAppSystemPrivate *priv = self->priv; g_object_unref (priv->apps_tree); - g_object_unref (priv->settings_tree); g_hash_table_destroy (priv->running_apps); g_hash_table_destroy (priv->id_to_app); g_hash_table_destroy (priv->visible_id_to_app); - g_hash_table_destroy (priv->setting_id_to_app); g_slist_free_full (priv->known_vendor_prefixes, g_free); priv->known_vendor_prefixes = NULL; @@ -404,48 +390,6 @@ on_apps_tree_changed_cb (GMenuTree *tree, g_signal_emit (self, signals[INSTALLED_CHANGED], 0); } -static void -on_settings_tree_changed_cb (GMenuTree *tree, - gpointer user_data) -{ - ShellAppSystem *self = SHELL_APP_SYSTEM (user_data); - GError *error = NULL; - GHashTable *new_settings; - GHashTableIter iter; - gpointer key, value; - - g_assert (tree == self->priv->settings_tree); - - g_hash_table_remove_all (self->priv->setting_id_to_app); - if (!gmenu_tree_load_sync (self->priv->settings_tree, &error)) - { - if (error) - { - g_warning ("Failed to load apps: %s", error->message); - g_error_free (error); - } - else - { - g_warning ("Failed to load apps"); - } - return; - } - - new_settings = get_flattened_entries_from_tree (tree); - - g_hash_table_iter_init (&iter, new_settings); - while (g_hash_table_iter_next (&iter, &key, &value)) - { - const char *id = key; - GMenuTreeEntry *entry = value; - ShellApp *app; - - app = _shell_app_new (entry); - g_hash_table_replace (self->priv->setting_id_to_app, (char*)id, app); - } - g_hash_table_destroy (new_settings); -} - /** * shell_app_system_get_tree: * @@ -798,18 +742,3 @@ shell_app_system_subsearch (ShellAppSystem *system, return sort_and_concat_results (system, prefix_results, substring_results); } -/** - * shell_app_system_search_settings: - * @system: A #ShellAppSystem - * @terms: (element-type utf8): List of terms, logical AND - * - * Search through settings for the given search terms. - * - * Returns: (transfer container) (element-type ShellApp): List of setting applications - */ -GSList * -shell_app_system_search_settings (ShellAppSystem *self, - GSList *terms) -{ - return search_tree (self, terms, self->priv->setting_id_to_app); -} diff --git a/src/shell-app-system.h b/src/shell-app-system.h index 78d37bd0c..243a6c028 100644 --- a/src/shell-app-system.h +++ b/src/shell-app-system.h @@ -60,7 +60,4 @@ GSList *shell_app_system_subsearch (ShellAppSystem *sys GSList *previous_results, GSList *terms); -GSList *shell_app_system_search_settings (ShellAppSystem *system, - GSList *terms); - #endif /* __SHELL_APP_SYSTEM_H__ */