summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/Makefile.am6
-rw-r--r--data/org.gnome.epiphany.search.engines.gschema.xml24
-rw-r--r--embed/ephy-embed-shell.c14
-rw-r--r--embed/ephy-embed-shell.h3
-rw-r--r--embed/ephy-embed-utils.c25
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/ephy-search-engine-manager.c215
-rw-r--r--lib/ephy-search-engine-manager.h47
-rw-r--r--src/prefs-dialog.c115
-rw-r--r--src/search-provider/ephy-search-provider.c26
10 files changed, 374 insertions, 103 deletions
diff --git a/data/Makefile.am b/data/Makefile.am
index d6aa63e4e..6d1b85047 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -10,7 +10,9 @@ $(desktop_DATA): $(desktop_in_files)
gsettings_ENUM_NAMESPACE = org.gnome.Epiphany
gsettings_ENUM_FILES = $(top_srcdir)/lib/ephy-prefs.h
-gsettings_SCHEMAS = org.gnome.epiphany.gschema.xml org.gnome.epiphany.host.gschema.xml
+gsettings_SCHEMAS = org.gnome.epiphany.gschema.xml \
+ org.gnome.epiphany.host.gschema.xml \
+ org.gnome.epiphany.search.engines.gschema.xml
@GSETTINGS_RULES@
appstream_in_files = org.gnome.Epiphany.appdata.xml.in
@@ -24,7 +26,7 @@ $(appstream_XML): $(appstream_in_files)
servicedir = $(datadir)/dbus-1/services
service_in_files = org.gnome.EpiphanySearchProvider.service.in
service_DATA = $(service_in_files:.service.in=.service)
-
+
# Rule to make the service file with bindir expanded
$(service_DATA): $(service_in_files) Makefile
$(AM_V_GEN) sed -e "s|\@libexecdir[@]|$(libexecdir)|g" $< > $@
diff --git a/data/org.gnome.epiphany.search.engines.gschema.xml b/data/org.gnome.epiphany.search.engines.gschema.xml
new file mode 100644
index 000000000..0c31c4975
--- /dev/null
+++ b/data/org.gnome.epiphany.search.engines.gschema.xml
@@ -0,0 +1,24 @@
+<schemalist>
+ <schema id="org.gnome.Epiphany.search-engines" gettext-domain="">
+ <key type="s" name="default-search-engine">
+ <default>'DuckDuckGo'</default>
+ <summary>Default search engine.</summary>
+ <description>Name of the search engine selected by default.</description>
+ </key>
+ <key type="as" name="search-engines-names">
+ <default>['DuckDuckGo', 'Google', 'Bing' ]</default>
+ <summary>Default search engines.</summary>
+ <description>List of the names of the default search engines.</description>
+ </key>
+ <key type="as" name="search-engines-urls">
+ <!-- Array of default search engines. Must exactly match the URLs used
+ in the preferences dialog, except this stringes are surrounded by single quotes
+ and use &amp; instead of simply &. If the match is not otherwise exact,
+ there will be a spurious, ugly entry in the preferences combo, so please
+ test this. -->
+ <default l10n="messages">['https://duckduckgo.com/?q=%s&amp;t=epiphany', 'https://google.com/search?q=%s', 'https://www.bing.com/search?q=%s' ]</default>
+ <summary>Default search engines urls.</summary>
+ <description>List of all the urls of the default search engines.</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 101caf900..4556ae9d8 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -70,6 +70,7 @@ typedef struct {
GList *web_extensions;
EphyFiltersManager *filters_manager;
GCancellable *cancellable;
+ EphySearchEngineManager *search_engine_manager;
} EphyEmbedShellPrivate;
enum {
@@ -124,6 +125,7 @@ ephy_embed_shell_dispose (GObject *object)
g_clear_object (&priv->web_context);
g_clear_object (&priv->dbus_server);
g_clear_object (&priv->filters_manager);
+ g_clear_object (&priv->search_engine_manager);
G_OBJECT_CLASS (ephy_embed_shell_parent_class)->dispose (object);
}
@@ -955,6 +957,8 @@ ephy_embed_shell_startup (GApplication *application)
ephy_embed_prefs_set_cookie_accept_policy (cookie_manager, cookie_policy);
g_free (cookie_policy);
+ priv->search_engine_manager = ephy_search_engine_manager_new ();
+
#ifdef HAVE_LIBHTTPSEVERYWHERE
/* We might want to be smarter about this in the future. For now,
* trigger an update of the rulesets once each time Epiphany is started.
@@ -1437,3 +1441,13 @@ ephy_embed_shell_get_hosts_manager (EphyEmbedShell *shell)
priv->hosts_manager = ephy_hosts_manager_new ();
return priv->hosts_manager;
}
+
+EphySearchEngineManager *
+ephy_embed_shell_get_search_engine_manager (EphyEmbedShell *shell)
+{
+ EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
+
+ if (!priv->search_engine_manager)
+ priv->search_engine_manager = ephy_search_engine_manager_new ();
+ return priv->search_engine_manager;
+}
diff --git a/embed/ephy-embed-shell.h b/embed/ephy-embed-shell.h
index e327e7e69..4fc5d05a9 100644
--- a/embed/ephy-embed-shell.h
+++ b/embed/ephy-embed-shell.h
@@ -25,6 +25,7 @@
#include "ephy-downloads-manager.h"
#include "ephy-history-service.h"
#include "ephy-hosts-manager.h"
+#include "ephy-search-engine-manager.h"
G_BEGIN_DECLS
@@ -79,5 +80,5 @@ void ephy_embed_shell_schedule_thumbnail_update (EphyEmbedShell
WebKitUserContentManager *ephy_embed_shell_get_user_content_manager (EphyEmbedShell *shell);
EphyDownloadsManager *ephy_embed_shell_get_downloads_manager (EphyEmbedShell *shell);
EphyHostsManager *ephy_embed_shell_get_hosts_manager (EphyEmbedShell *shell);
-
+EphySearchEngineManager *ephy_embed_shell_get_search_engine_manager (EphyEmbedShell *shell);
G_END_DECLS
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
index 90dcd9572..81bb4b9a1 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -29,10 +29,10 @@
#include "ephy-string.h"
#include "ephy-view-source-handler.h"
-#include <string.h>
+#include <JavaScriptCore/JavaScript.h>
#include <glib/gi18n.h>
#include <libsoup/soup.h>
-#include <JavaScriptCore/JavaScript.h>
+#include <string.h>
static GRegex *non_search_regex;
static GRegex *domain_regex;
@@ -230,15 +230,20 @@ ephy_embed_utils_normalize_address (const char *address)
char *
ephy_embed_utils_autosearch_address (const char *search_key)
{
- char *query_param, *url_search;
+ char *query_param;
+ const char *url_search;
+ char *default_name;
char *effective_address;
+ EphyEmbedShell *shell;
+ EphySearchEngineManager *search_engine_manager;
- url_search = g_settings_get_string (EPHY_SETTINGS_MAIN,
- EPHY_PREFS_KEYWORD_SEARCH_URL);
- if (url_search == NULL || url_search[0] == '\0') {
- g_free (url_search);
- url_search = g_strdup (_("https://duckduckgo.com/?q=%s&amp;t=epiphany"));
- }
+ shell = ephy_embed_shell_get_default ();
+ search_engine_manager = ephy_embed_shell_get_search_engine_manager (shell);
+ default_name = ephy_search_engine_manager_get_default_engine (search_engine_manager);
+ url_search = ephy_search_engine_manager_get_url (search_engine_manager, default_name);
+
+ if (url_search == NULL || url_search[0] == '\0')
+ url_search = _("https://duckduckgo.com/?q=%s&amp;t=epiphany");
query_param = soup_form_encode ("q", search_key, NULL);
#pragma GCC diagnostic push
@@ -248,7 +253,7 @@ ephy_embed_utils_autosearch_address (const char *search_key)
effective_address = g_strdup_printf (url_search, query_param + 2);
#pragma GCC diagnostic pop
g_free (query_param);
- g_free (url_search);
+ g_free (default_name);
return effective_address;
}
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 784dc1ce3..07b99fa8b 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -30,6 +30,8 @@ libephymisc_la_SOURCES = \
ephy-prefs.h \
ephy-profile-utils.c \
ephy-profile-utils.h \
+ ephy-search-engine-manager.c \
+ ephy-search-engine-manager.h \
ephy-security-levels.c \
ephy-security-levels.h \
ephy-settings.c \
diff --git a/lib/ephy-search-engine-manager.c b/lib/ephy-search-engine-manager.c
new file mode 100644
index 000000000..8bb451d16
--- /dev/null
+++ b/lib/ephy-search-engine-manager.c
@@ -0,0 +1,215 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Copyright © 2017 Cedric Le Moigne <cedlemo@gmx.com>
+ *
+ * This file is part of Epiphany.
+ *
+ * Epiphany is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Epiphany is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Epiphany. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "ephy-search-engine-manager.h"
+
+#include "ephy-file-helpers.h"
+#include "ephy-string.h"
+
+#define G_SETTINGS_ENABLE_BACKEND 1
+#include <gio/gsettingsbackend.h>
+
+struct _EphySearchEngineManager
+{
+ GObject parent_instance;
+ GSettingsBackend *backend;
+ GSettings *settings;
+ GHashTable *search_engines;
+};
+
+G_DEFINE_TYPE (EphySearchEngineManager, ephy_search_engine_manager, G_TYPE_OBJECT)
+
+static void
+ephy_search_engine_manager_init (EphySearchEngineManager *manager)
+{
+ char *key_file = NULL;
+ char **search_engine_urls;
+ char **search_engine_names;
+ uint n_engines;
+
+ manager->search_engines = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+ key_file = g_build_filename (ephy_dot_dir (), G_DIR_SEPARATOR_S "search-engines.ini", NULL);
+
+ manager->backend = g_keyfile_settings_backend_new (key_file, "/", "SearchEngines");
+ g_free (key_file);
+
+ manager->settings = g_settings_new_with_backend_and_path ("org.gnome.Epiphany.search-engines",
+ manager->backend,
+ "/org/gnome/epiphany/search-engines/");
+
+ search_engine_names = g_settings_get_strv (manager->settings,
+ "search-engines-names");
+ search_engine_urls = g_settings_get_strv (manager->settings,
+ "search-engines-urls");
+ n_engines = g_strv_length (search_engine_names);
+
+ for (uint i = 0; i < n_engines; ++i) {
+ const char *name = search_engine_names[i];
+ const char *url = search_engine_urls[i];
+ g_hash_table_insert (manager->search_engines,
+ g_strdup (name),
+ g_strdup (url));
+ }
+
+ g_strfreev (search_engine_names);
+ g_strfreev (search_engine_urls);
+}
+
+static void
+ephy_search_engine_manager_dispose (GObject *object)
+{
+ EphySearchEngineManager *manager = EPHY_SEARCH_ENGINE_MANAGER (object);
+
+ g_clear_pointer (&manager->search_engines, g_hash_table_destroy);
+ g_clear_object (&manager->backend);
+ g_clear_object (&manager->settings);
+
+ G_OBJECT_CLASS (ephy_search_engine_manager_parent_class)->dispose (object);
+}
+
+static void
+ephy_search_engine_manager_class_init (EphySearchEngineManagerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = ephy_search_engine_manager_dispose;
+}
+
+EphySearchEngineManager *
+ephy_search_engine_manager_new (void)
+{
+ return EPHY_SEARCH_ENGINE_MANAGER (g_object_new (EPHY_TYPE_SEARCH_ENGINE_MANAGER, NULL));
+}
+
+const char *
+ephy_search_engine_manager_get_url (EphySearchEngineManager *manager,
+ const char *name)
+{
+ if (!manager->search_engines)
+ return NULL;
+
+ return g_hash_table_lookup (manager->search_engines, name);
+}
+
+char *
+ephy_search_engine_manager_get_default_engine (EphySearchEngineManager *manager)
+{
+ if (!manager->settings)
+ return NULL;
+
+ return g_settings_get_string (manager->settings, "default-search-engine");
+}
+
+char **
+ephy_search_engine_manager_get_names (EphySearchEngineManager *manager)
+{
+ if (!manager->settings)
+ return NULL;
+
+ return g_settings_get_strv (manager->settings, "search-engines-names");
+}
+
+GSettings *
+ephy_search_engine_manager_get_settings (EphySearchEngineManager *manager)
+{
+ return g_settings_new_with_backend_and_path ("org.gnome.Epiphany.search-engines",
+ manager->backend,
+ "/org/gnome/epiphany/search-engines/");
+}
+
+static void
+ephy_search_engine_manager_apply_settings (EphySearchEngineManager *manager)
+{
+ GHashTableIter iter;
+ gpointer key, value;
+ int size;
+ int i = 0;
+ char **search_engine_names;
+ char **search_engine_urls;
+
+ if (!manager->search_engines)
+ return;
+
+ size = g_hash_table_size (manager->search_engines);
+
+ search_engine_names = g_malloc(size + 1);
+ search_engine_urls = g_malloc(size + 1);
+
+ g_hash_table_iter_init (&iter, manager->search_engines);
+ while (g_hash_table_iter_next (&iter, &key, &value))
+ {
+ search_engine_names[i] = key;
+ search_engine_urls[i] = value;
+ i++;
+ }
+ search_engine_names[size] = NULL;
+ search_engine_urls[size] = NULL;
+
+ if (!manager->settings)
+ return;
+
+ g_settings_set_strv (manager->settings,
+ "search-engines-names",
+ (const char * const*) search_engine_names);
+ g_settings_set_strv (manager->settings,
+ "search-engines-urls",
+ (const char * const*) search_engine_urls);
+
+ g_strfreev (search_engine_names);
+ g_strfreev (search_engine_urls);
+}
+
+void
+ephy_search_engine_manager_add_engine (EphySearchEngineManager *manager,
+ const char *name,
+ const char *url)
+{
+ if (!manager->search_engines)
+ return;
+
+ g_hash_table_insert (manager->search_engines, g_strdup (name), g_strdup (url));
+ ephy_search_engine_manager_apply_settings (manager);
+}
+
+void
+ephy_search_engine_manager_delete_engine (EphySearchEngineManager *manager,
+ const char *name)
+{
+ if (!manager->search_engines)
+ return;
+
+ g_hash_table_remove (manager->search_engines, name);
+ ephy_search_engine_manager_apply_settings (manager);
+}
+
+void
+ephy_search_engine_manager_modify_engine (EphySearchEngineManager *manager,
+ const char *name,
+ const char *url)
+{
+ if (!manager->search_engines)
+ return;
+
+ g_hash_table_replace (manager->search_engines,
+ g_strdup (name),
+ g_strdup (url));
+ ephy_search_engine_manager_apply_settings (manager);
+}
diff --git a/lib/ephy-search-engine-manager.h b/lib/ephy-search-engine-manager.h
new file mode 100644
index 000000000..701e02e35
--- /dev/null
+++ b/lib/ephy-search-engine-manager.h
@@ -0,0 +1,47 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Copyright © 2017 Cedric Le Moigne <cedlemo@gmx.com>
+ *
+ * This file is part of Epiphany.
+ *
+ * Epiphany is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Epiphany is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Epiphany. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <gio/gio.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_SEARCH_ENGINE_MANAGER (ephy_search_engine_manager_get_type ())
+
+G_DECLARE_FINAL_TYPE (EphySearchEngineManager, ephy_search_engine_manager, EPHY, SEARCH_ENGINE_MANAGER, GObject)
+
+EphySearchEngineManager *ephy_search_engine_manager_new (void);
+const char *ephy_search_engine_manager_get_url (EphySearchEngineManager *manager,
+ const char *name);
+char *ephy_search_engine_manager_get_default_engine (EphySearchEngineManager *manager);
+char **ephy_search_engine_manager_get_names (EphySearchEngineManager *manager);
+GSettings *ephy_search_engine_manager_get_settings (EphySearchEngineManager *manager);
+void ephy_search_engine_manager_add_engine (EphySearchEngineManager *manager,
+ const char *name,
+ const char *url);
+void ephy_search_engine_manager_delete_engine (EphySearchEngineManager *manager,
+ const char *name);
+void ephy_search_engine_manager_modify_engine (EphySearchEngineManager *manager,
+ const char *name,
+ const char *url);
+
+G_END_DECLS
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index d1c16a433..3f9e16b66 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -147,7 +147,6 @@ typedef struct {
enum {
SEARCH_ENGINE_COL_NAME,
- SEARCH_ENGINE_COL_STOCK_URL,
SEARCH_ENGINE_COL_URL,
SEARCH_ENGINE_NUM_COLS
};
@@ -660,7 +659,7 @@ combo_get_mapping (GValue *value,
while (valid) {
char *item_name;
- gtk_tree_model_get (model, &iter, 1, &item_name, -1);
+ gtk_tree_model_get (model, &iter, 0, &item_name, -1);
if (g_strcmp0 (item_name, settings_name) == 0) {
g_value_set_int (value, i);
@@ -693,7 +692,7 @@ combo_set_mapping (const GValue *value,
if (valid) {
char *item_name;
- gtk_tree_model_get (model, &iter, 1, &item_name, -1);
+ gtk_tree_model_get (model, &iter, 0, &item_name, -1);
variant = g_variant_new_string (item_name);
@@ -1341,82 +1340,23 @@ cookies_set_mapping (const GValue *value,
}
static void
-search_engine_combo_add_default_engines (GtkListStore *store)
+search_engine_combo_add_search_engines (GtkListStore *store,
+ EphySearchEngineManager *manager)
{
- guint i;
- const char *default_engines[][3] = { /* Search engine option in the preferences dialog */
- { N_("DuckDuckGo"),
- "https://duckduckgo.com/?q=%s&t=epiphany",
- /* For the preferences dialog. Must exactly match the URL
- * you chose in the gschema, but with & instead of &amp;
- * If the match is not exact, there will be a spurious, ugly
- * entry in the preferences combo, so please test this. */
- N_("https://duckduckgo.com/?q=%s&t=epiphany") },
- /* Search engine option in the preferences dialog */
- { N_("Google"),
- "https://google.com/search?q=%s",
- /* For the preferences dialog. Consider a regional variant, like google.co.uk */
- N_("https://google.com/search?q=%s") },
- /* Search engine option in the preferences dialog */
- { N_("Bing"),
- "https://www.bing.com/search?q=%s",
- /* For the preferences dialog. Consider a regional variant, like uk.bing.com */
- N_("https://www.bing.com/search?q=%s") }
- };
-
- for (i = 0; i < G_N_ELEMENTS (default_engines); ++i) {
+ guint i, n_engines;
+ gchar **engines_names ;
+ engines_names = ephy_search_engine_manager_get_names (manager);
+ n_engines = g_strv_length (engines_names);
+
+ for (i = 0; i < n_engines; i++) {
+ const char *name = engines_names[i];
+ const char *url = ephy_search_engine_manager_get_url (manager, name);
gtk_list_store_insert_with_values (store, NULL, -1,
- SEARCH_ENGINE_COL_NAME,
- _(default_engines[i][0]),
- SEARCH_ENGINE_COL_STOCK_URL,
- default_engines[i][1],
- SEARCH_ENGINE_COL_URL,
- _(default_engines[i][2]),
+ SEARCH_ENGINE_COL_NAME, name,
+ SEARCH_ENGINE_COL_URL, url,
-1);
}
-}
-
-/* Has the user manually set the engine to something not in the combo?
- * If so, add that URL as an extra item in the combo. */
-static void
-search_engine_combo_add_current_engine (GtkListStore *store)
-{
- GtkTreeIter iter;
- char *original_url;
- gboolean in_combo = FALSE;
- gboolean has_next = FALSE;
-
- original_url = g_settings_get_string (EPHY_SETTINGS_MAIN,
- EPHY_PREFS_KEYWORD_SEARCH_URL);
- if (!original_url)
- return;
-
- has_next = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
-
- while (!in_combo && has_next) {
- char *stock_url, *url;
-
- gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
- SEARCH_ENGINE_COL_STOCK_URL, &stock_url,
- SEARCH_ENGINE_COL_URL, &url, -1);
-
- if (strcmp (original_url, stock_url) == 0 ||
- strcmp (original_url, url) == 0)
- in_combo = TRUE;
-
- g_free (stock_url);
- g_free (url);
- has_next = gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter);
- }
-
- if (!in_combo)
- gtk_list_store_insert_with_values (store, NULL, -1,
- SEARCH_ENGINE_COL_NAME, original_url,
- SEARCH_ENGINE_COL_STOCK_URL, original_url,
- SEARCH_ENGINE_COL_URL, original_url,
- -1);
-
- g_free (original_url);
+ g_strfreev (engines_names);
}
static void
@@ -1424,30 +1364,45 @@ create_search_engine_combo (GtkComboBox *combo)
{
GtkCellRenderer *renderer;
GtkListStore *store;
+ char *default_search_engine;
+ GSettings *search_engine_settings;
+ EphyEmbedShell *shell;
+ EphySearchEngineManager *search_engine_manager;
+
+ shell = ephy_embed_shell_get_default ();
+ search_engine_manager = ephy_embed_shell_get_search_engine_manager (shell);
store = GTK_LIST_STORE (gtk_combo_box_get_model (combo));
+ search_engine_combo_add_search_engines (store, search_engine_manager);
- search_engine_combo_add_default_engines (store);
- search_engine_combo_add_current_engine (store);
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), SEARCH_ENGINE_COL_NAME,
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+ SEARCH_ENGINE_COL_NAME,
GTK_SORT_ASCENDING);
gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store));
+ default_search_engine = ephy_search_engine_manager_get_default_engine (search_engine_manager);
+
+ gtk_combo_box_set_id_column (combo, SEARCH_ENGINE_COL_NAME);
+ gtk_combo_box_set_active_id (combo, default_search_engine);
+
renderer = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
"text", SEARCH_ENGINE_COL_NAME,
NULL);
- g_settings_bind_with_mapping (EPHY_SETTINGS_MAIN,
- EPHY_PREFS_KEYWORD_SEARCH_URL,
+ search_engine_settings = ephy_search_engine_manager_get_settings (search_engine_manager);
+
+ g_settings_bind_with_mapping (search_engine_settings,
+ "default-search-engine",
combo, "active",
G_SETTINGS_BIND_DEFAULT,
combo_get_mapping,
combo_set_mapping,
combo,
NULL);
+ g_free (default_search_engine);
}
static gboolean
diff --git a/src/search-provider/ephy-search-provider.c b/src/search-provider/ephy-search-provider.c
index 0926a381e..b91288685 100644
--- a/src/search-provider/ephy-search-provider.c
+++ b/src/search-provider/ephy-search-provider.c
@@ -29,11 +29,11 @@
#include "ephy-profile-utils.h"
#include "ephy-shell.h"
-#include <string.h>
-#include <glib/gi18n.h>
#include <gio/gio.h>
#include <gio/gdesktopappinfo.h>
+#include <glib/gi18n.h>
#include <libsoup/soup.h>
+#include <string.h>
struct _EphySearchProvider {
GApplication parent_instance;
@@ -278,15 +278,21 @@ launch_search (EphySearchProvider *self,
char **terms,
guint timestamp)
{
- char *search_string, *url_search, *query_param, *effective_url;
-
- url_search = g_settings_get_string (self->settings, EPHY_PREFS_KEYWORD_SEARCH_URL);
+ char *search_string;
+ const char *url_search;
+ char *query_param;
+ char *effective_url;
+ char *default_name;
+ EphyEmbedShell *shell;
+ EphySearchEngineManager *search_engine_manager;
- if (url_search == NULL || url_search[0] == '\0') {
- g_free (url_search);
+ shell = ephy_embed_shell_get_default ();
+ search_engine_manager = ephy_embed_shell_get_search_engine_manager (shell);
+ default_name = ephy_search_engine_manager_get_default_engine (search_engine_manager);
+ url_search = ephy_search_engine_manager_get_url (search_engine_manager, default_name);
- url_search = g_strdup (_("https://duckduckgo.com/?q=%s&amp;t=epiphany"));
- }
+ if (url_search == NULL || url_search[0] == '\0')
+ url_search = _("https://duckduckgo.com/?q=%s&amp;t=epiphany");
search_string = g_strjoinv (" ", terms);
query_param = soup_form_encode ("q", search_string, NULL);
@@ -301,9 +307,9 @@ launch_search (EphySearchProvider *self,
launch_uri (effective_url, timestamp);
g_free (query_param);
- g_free (url_search);
g_free (effective_url);
g_free (search_string);
+ g_free (default_name);
}
static gboolean