[epiphany] ephy-embed-utils: add ephy_embed_utils_autosearch_address()
- From: Claudio Saavedra <csaavedra src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] ephy-embed-utils: add ephy_embed_utils_autosearch_address()
- Date: Tue, 9 Jun 2015 12:15:16 +0000 (UTC)
commit b92a519ab577c1eb22f6f24dfc5c57da43746048
Author: Claudio Saavedra <csaavedra igalia com>
Date: Thu Jun 4 15:47:35 2015 +0300
ephy-embed-utils: add ephy_embed_utils_autosearch_address()
Factor the code to handle a search key from
ephy_embed_utils_normalize_or_autosearch_address() to a new method to
be able to reuse it later.
https://bugzilla.gnome.org/show_bug.cgi?id=663545
embed/ephy-embed-utils.c | 17 ++++++++++++-----
embed/ephy-embed-utils.h | 1 +
2 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
index a43cee9..6f2eb77 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -229,14 +229,11 @@ ephy_embed_utils_normalize_address (const char *address)
}
char *
-ephy_embed_utils_normalize_or_autosearch_address (const char *address)
+ephy_embed_utils_autosearch_address (const char *search_key)
{
char *query_param, *url_search;
char *effective_address;
- if (ephy_embed_utils_address_is_valid (address))
- return ephy_embed_utils_normalize_address (address);
-
url_search = g_settings_get_string (EPHY_SETTINGS_MAIN,
EPHY_PREFS_KEYWORD_SEARCH_URL);
if (url_search == NULL || url_search[0] == '\0') {
@@ -244,13 +241,23 @@ ephy_embed_utils_normalize_or_autosearch_address (const char *address)
url_search = g_strdup (_("https://duckduckgo.com/?q=%s&t=epiphany"));
}
- query_param = soup_form_encode ("q", address, NULL);
+ query_param = soup_form_encode ("q", search_key, NULL);
/* + 2 here is getting rid of 'q=' */
effective_address = g_strdup_printf (url_search, query_param + 2);
g_free (query_param);
g_free (url_search);
return effective_address;
+
+}
+
+char *
+ephy_embed_utils_normalize_or_autosearch_address (const char *address)
+{
+ if (ephy_embed_utils_address_is_valid (address))
+ return ephy_embed_utils_normalize_address (address);
+ else
+ return ephy_embed_utils_autosearch_address (address);
}
gboolean
diff --git a/embed/ephy-embed-utils.h b/embed/ephy-embed-utils.h
index a857dd7..ec89fd9 100644
--- a/embed/ephy-embed-utils.h
+++ b/embed/ephy-embed-utils.h
@@ -43,6 +43,7 @@ gboolean ephy_embed_utils_address_has_web_scheme (const char *add
gboolean ephy_embed_utils_address_is_existing_absolute_filename (const char *address);
gboolean ephy_embed_utils_address_is_valid (const char *address);
char* ephy_embed_utils_normalize_address (const char *address);
+char * ephy_embed_utils_autosearch_address (const char *search_key);
char * ephy_embed_utils_normalize_or_autosearch_address (const char *address);
gboolean ephy_embed_utils_url_is_empty (const char *location);
gboolean ephy_embed_utils_is_no_show_address (const char *address);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]