Commit 8b6ce7b8 authored by Michael Catanzaro's avatar Michael Catanzaro

search-engine-manager: Add convenience function to get default address

Add ephy_search_engine_manager_get_address_for_default_engine(), a
simpler way to get the address of the default search engine without
having to make separate calls to
ephy_search_engine_manager_get_default_engine() and
ephy_search_engine_manager_get_address().
parent 8d7b39a6
......@@ -270,15 +270,13 @@ ephy_embed_utils_autosearch_address (const char *search_key)
{
char *query_param;
const char *address_search;
char *default_name;
char *effective_address;
EphyEmbedShell *shell;
EphySearchEngineManager *search_engine_manager;
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);
address_search = ephy_search_engine_manager_get_address (search_engine_manager, default_name);
address_search = ephy_search_engine_manager_get_address_for_default_engine (search_engine_manager);
query_param = soup_form_encode ("q", search_key, NULL);
#pragma GCC diagnostic push
......@@ -288,7 +286,6 @@ ephy_embed_utils_autosearch_address (const char *search_key)
effective_address = g_strdup_printf (address_search, query_param + 2);
#pragma GCC diagnostic pop
g_free (query_param);
g_free (default_name);
return effective_address;
}
......
......@@ -148,6 +148,19 @@ ephy_search_engine_manager_get_address (EphySearchEngineManager *manager,
return NULL;
}
const char *
ephy_search_engine_manager_get_address_for_default_engine (EphySearchEngineManager *manager)
{
char *name;
const char *address;
name = ephy_search_engine_manager_get_default_engine (manager);
address = ephy_search_engine_manager_get_address (manager, name);
g_free (name);
return address;
}
const char *
ephy_search_engine_manager_get_bang (EphySearchEngineManager *manager,
const char *name)
......
......@@ -39,6 +39,8 @@ G_DECLARE_FINAL_TYPE (EphySearchEngineManager, ephy_search_engine_manager, EPHY,
EphySearchEngineManager *ephy_search_engine_manager_new (void);
const char *ephy_search_engine_manager_get_address (EphySearchEngineManager *manager,
const char *name);
const char *ephy_search_engine_manager_get_address_for_default_engine
(EphySearchEngineManager *manager);
const char *ephy_search_engine_manager_get_bang (EphySearchEngineManager *manager,
const char *name);
char *ephy_search_engine_manager_get_default_engine (EphySearchEngineManager *manager);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment