[epiphany/gnome-3-36] Only show default search engine in search provider
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/gnome-3-36] Only show default search engine in search provider
- Date: Fri, 29 May 2020 15:10:45 +0000 (UTC)
commit 59ea60938e07b873f431893372778929d7257825
Author: Jan-Michael Brummer <jan brummer tabos org>
Date: Sat May 16 12:58:35 2020 +0000
Only show default search engine in search provider
Fixes: https://gitlab.gnome.org/GNOME/epiphany/-/issues/923
(cherry picked from commit 19d9325d6e3a5d98375864812257c6da1795bf81)
src/ephy-location-controller.c | 2 +-
src/ephy-suggestion-model.c | 48 +++++++++++++++++++++++++-----
src/ephy-suggestion-model.h | 1 +
src/search-provider/ephy-search-provider.c | 1 +
4 files changed, 43 insertions(+), 9 deletions(-)
---
diff --git a/src/ephy-location-controller.c b/src/ephy-location-controller.c
index 62e82582d..fe5e5a036 100644
--- a/src/ephy-location-controller.c
+++ b/src/ephy-location-controller.c
@@ -204,7 +204,7 @@ user_changed_cb (GtkWidget *widget,
model = dzl_suggestion_entry_get_model (entry);
- ephy_suggestion_model_query_async (EPHY_SUGGESTION_MODEL (model), address, NULL, NULL, NULL);
+ ephy_suggestion_model_query_async (EPHY_SUGGESTION_MODEL (model), address, TRUE, NULL, NULL, NULL);
}
static void
diff --git a/src/ephy-suggestion-model.c b/src/ephy-suggestion-model.c
index 0fa51a487..92c4e7652 100644
--- a/src/ephy-suggestion-model.c
+++ b/src/ephy-suggestion-model.c
@@ -500,6 +500,32 @@ add_tabs (EphySuggestionModel *self,
return added;
}
+typedef struct {
+ char *query;
+ gboolean include_search_engines;
+} QueryData;
+
+static QueryData *
+query_data_new (const char *query,
+ gboolean include_search_engines)
+{
+ QueryData *data;
+
+ data = g_malloc0 (sizeof (QueryData));
+ data->query = g_strdup (query);
+ data->include_search_engines = include_search_engines;
+
+ return data;
+}
+
+static void
+query_data_free (QueryData *data)
+{
+ g_assert (data != NULL);
+ g_free (data->query);
+ g_free (data);
+}
+
static void
query_completed_cb (EphyHistoryService *service,
gboolean success,
@@ -508,13 +534,13 @@ query_completed_cb (EphyHistoryService *service,
{
GTask *task = user_data;
EphySuggestionModel *self;
- const gchar *query;
+ QueryData *data;
GList *urls;
guint removed;
guint added = 0;
self = g_task_get_source_object (task);
- query = g_task_get_task_data (task);
+ data = g_task_get_task_data (task);
urls = (GList *)result_data;
g_cancellable_cancel (self->icon_cancellable);
@@ -530,11 +556,13 @@ query_completed_cb (EphyHistoryService *service,
self->items = g_sequence_new (g_object_unref);
self->num_custom_entries = 0;
- if (strlen (query) > 0) {
- added = add_tabs (self, query);
- added += add_bookmarks (self, query);
- added += add_history (self, urls, query);
- added += add_search_engines (self, query);
+ if (strlen (data->query) > 0) {
+ added = add_tabs (self, data->query);
+ added += add_bookmarks (self, data->query);
+ added += add_history (self, urls, data->query);
+
+ if (data->include_search_engines)
+ added += add_search_engines (self, data->query);
}
g_list_model_items_changed (G_LIST_MODEL (self), 0, removed, added);
@@ -546,6 +574,7 @@ query_completed_cb (EphyHistoryService *service,
void
ephy_suggestion_model_query_async (EphySuggestionModel *self,
const gchar *query,
+ gboolean include_search_engines,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -553,6 +582,7 @@ ephy_suggestion_model_query_async (EphySuggestionModel *self,
GTask *task = NULL;
char **strings;
GList *qlist = NULL;
+ QueryData *data;
g_assert (EPHY_IS_SUGGESTION_MODEL (self));
g_assert (query != NULL);
@@ -560,7 +590,9 @@ ephy_suggestion_model_query_async (EphySuggestionModel *self,
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, ephy_suggestion_model_query_async);
- g_task_set_task_data (task, g_strdup (query), g_free);
+
+ data = query_data_new (query, include_search_engines);
+ g_task_set_task_data (task, data, (GDestroyNotify)query_data_free);
/* Split the search string. */
strings = g_strsplit (query, " ", -1);
diff --git a/src/ephy-suggestion-model.h b/src/ephy-suggestion-model.h
index ba1ff06d1..85985c760 100644
--- a/src/ephy-suggestion-model.h
+++ b/src/ephy-suggestion-model.h
@@ -34,6 +34,7 @@ EphySuggestionModel *ephy_suggestion_model_new (EphyHistoryS
EphyBookmarksManager
*bookmarks_manager);
void ephy_suggestion_model_query_async (EphySuggestionModel *self,
const gchar *query,
+ gboolean
include_search_engines,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
diff --git a/src/search-provider/ephy-search-provider.c b/src/search-provider/ephy-search-provider.c
index c794992a4..f34e8974b 100644
--- a/src/search-provider/ephy-search-provider.c
+++ b/src/search-provider/ephy-search-provider.c
@@ -115,6 +115,7 @@ gather_results_async (EphySearchProvider *self,
ephy_suggestion_model_query_async (self->model,
search_string,
+ FALSE,
cancellable,
(GAsyncReadyCallback)on_model_updated,
task);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]