summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Michael Brummer <jan.brummer@tabos.org>2020-05-16 14:58:35 +0200
committerJan-Michael Brummer <jan.brummer@tabos.org>2020-05-16 19:00:30 +0200
commit19d9325d6e3a5d98375864812257c6da1795bf81 (patch)
tree1c475e0e326c755e8be81f75bca4255f154589cf
parenta9c76a0841689f2e755919a351f55117055662ec (diff)
downloadepiphany-19d9325d6e3a5d98375864812257c6da1795bf81.tar.gz
Only show default search engine in search provider
Fixes: https://gitlab.gnome.org/GNOME/epiphany/-/issues/923
-rw-r--r--src/ephy-location-controller.c2
-rw-r--r--src/ephy-suggestion-model.c48
-rw-r--r--src/ephy-suggestion-model.h1
-rw-r--r--src/search-provider/ephy-search-provider.c1
4 files changed, 43 insertions, 9 deletions
diff --git a/src/ephy-location-controller.c b/src/ephy-location-controller.c
index 96bfe906c..01175c445 100644
--- a/src/ephy-location-controller.c
+++ b/src/ephy-location-controller.c
@@ -223,7 +223,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 23118c9b6..106b39c8b 100644
--- a/src/ephy-suggestion-model.c
+++ b/src/ephy-suggestion-model.c
@@ -502,6 +502,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,
@@ -510,13 +536,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);
@@ -532,11 +558,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);
@@ -548,6 +576,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)
@@ -555,6 +584,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);
@@ -562,7 +592,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 a82aa2552..fdbb37ef5 100644
--- a/src/search-provider/ephy-search-provider.c
+++ b/src/search-provider/ephy-search-provider.c
@@ -116,6 +116,7 @@ gather_results_async (EphySearchProvider *self,
ephy_suggestion_model_query_async (self->model,
search_string,
+ FALSE,
cancellable,
(GAsyncReadyCallback)on_model_updated,
task);