Fix search from location bar

This commit is contained in:
Christian Dywan 2008-06-20 00:06:12 +02:00
parent 3537ef3e8d
commit 3535ed6e48
2 changed files with 8 additions and 7 deletions

View file

@ -1608,7 +1608,9 @@ midori_browser_location_key_press_event_cb (GtkWidget* widget,
g_object_get (browser->settings, "location-entry-search", g_object_get (browser->settings, "location-entry-search",
&location_entry_search, NULL); &location_entry_search, NULL);
gchar* new_uri = sokoke_magic_uri (uri, browser->search_engines); gchar* new_uri = sokoke_magic_uri (uri, browser->search_engines);
if (!new_uri) if (!new_uri && strstr (location_entry_search, "%s"))
new_uri = g_strdup_printf (location_entry_search, uri);
else if (!new_uri)
new_uri = g_strdup (location_entry_search); new_uri = g_strdup (location_entry_search);
g_free (location_entry_search); g_free (location_entry_search);
/* TODO: Use new_uri intermediately when completion is better /* TODO: Use new_uri intermediately when completion is better

View file

@ -28,12 +28,6 @@ gchar*
sokoke_magic_uri (const gchar* uri, sokoke_magic_uri (const gchar* uri,
MidoriWebList* search_engines) MidoriWebList* search_engines)
{ {
g_return_val_if_fail (uri, NULL);
if (search_engines)
{
g_return_val_if_fail (MIDORI_IS_WEB_LIST (search_engines), NULL);
}
gchar* current_dir; gchar* current_dir;
gchar* result; gchar* result;
gchar* search; gchar* search;
@ -41,6 +35,10 @@ sokoke_magic_uri (const gchar* uri,
gchar** parts; gchar** parts;
MidoriWebItem* web_item; MidoriWebItem* web_item;
g_return_val_if_fail (uri, NULL);
if (search_engines)
g_return_val_if_fail (MIDORI_IS_WEB_LIST (search_engines), NULL);
/* Add file:// if we have a local path */ /* Add file:// if we have a local path */
if (g_path_is_absolute (uri)) if (g_path_is_absolute (uri))
return g_strconcat ("file://", uri, NULL); return g_strconcat ("file://", uri, NULL);
@ -73,6 +71,7 @@ sokoke_magic_uri (const gchar* uri,
if (web_item) if (web_item)
search_uri = midori_web_item_get_uri (web_item); search_uri = midori_web_item_get_uri (web_item);
} }
g_free (parts);
if (search_uri) if (search_uri)
search = g_strdup_printf (search_uri, parts[1]); search = g_strdup_printf (search_uri, parts[1]);
return search; return search;