Re-implement search engines in the completion

This commit is contained in:
Christian Dywan 2010-01-28 22:19:00 +01:00
parent 7065767a61
commit b947e5d662
4 changed files with 51 additions and 9 deletions

View file

@ -6640,7 +6640,12 @@ midori_browser_settings_notify (MidoriWebSettings* web_settings,
g_value_get_string (&value) && *g_value_get_string (&value));
else if (name == g_intern_string ("search-engines-in-completion"))
{
/* Do nothing */
if (g_value_get_boolean (&value))
midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
_action_by_name (browser, "Location")), browser->search_engines);
else
midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
_action_by_name (browser, "Location")), NULL);
}
else if (name == g_intern_string ("location-entry-search"))
{
@ -6854,6 +6859,13 @@ midori_browser_set_property (GObject* object,
/* FIXME: Disconnect handlers */
katze_object_assign (browser->search_engines, g_value_dup_object (value));
if (katze_object_get_boolean (browser->settings,
"search-engines-in-completion"))
midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
_action_by_name (browser, "Location")), browser->search_engines);
else
midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION (
_action_by_name (browser, "Location")), NULL);
midori_search_action_set_search_engines (MIDORI_SEARCH_ACTION (
_action_by_name (browser, "Search")), browser->search_engines);
/* FIXME: Connect to updates */

View file

@ -34,6 +34,7 @@ struct _MidoriLocationAction
gchar* text;
gchar* uri;
KatzeArray* search_engines;
gdouble progress;
gchar* secondary_icon;
@ -373,7 +374,7 @@ midori_location_action_popup_timeout_cb (gpointer data)
}
result = sqlite3_step (statement);
if (result != SQLITE_ROW)
if (result != SQLITE_ROW && !action->search_engines)
{
sqlite3_finalize (statement);
midori_location_action_popdown_completion (action);
@ -432,7 +433,7 @@ midori_location_action_popup_timeout_cb (gpointer data)
gtk_list_store_clear (store);
matches = 0;
do
while (result == SQLITE_ROW)
{
const unsigned char* uri = sqlite3_column_text (statement, 0);
const unsigned char* title = sqlite3_column_text (statement, 1);
@ -445,8 +446,27 @@ midori_location_action_popup_timeout_cb (gpointer data)
matches++;
result = sqlite3_step (statement);
}
while (result == SQLITE_ROW);
/* TODO: Suggest _("Search with %s") or opening hostname as actions */
if (action->search_engines)
{
gint i = 0;
KatzeItem* item;
while ((item = katze_array_get_nth_item (action->search_engines, i)))
{
gchar* uri;
gchar* title;
uri = sokoke_search_uri (katze_item_get_uri (item), action->key);
title = g_strdup_printf (_("Search with %s"), katze_item_get_name (item));
gtk_list_store_insert_with_values (store, NULL, matches,
URI_COL, uri, TITLE_COL, title, YALIGN_COL, 0.25,
FAVICON_COL, NULL, -1);
g_free (uri);
g_free (title);
i++;
}
matches += i;
}
if (!GTK_WIDGET_VISIBLE (action->popup))
{
@ -547,6 +567,7 @@ static void
midori_location_action_init (MidoriLocationAction* location_action)
{
location_action->text = location_action->uri = NULL;
location_action->search_engines = NULL;
location_action->progress = 0.0;
location_action->secondary_icon = NULL;
location_action->default_icon = NULL;
@ -565,6 +586,7 @@ midori_location_action_finalize (GObject* object)
katze_assign (location_action->text, NULL);
katze_assign (location_action->uri, NULL);
katze_assign (location_action->search_engines, NULL);
katze_assign (location_action->key, NULL);
if (location_action->popup)
@ -1455,15 +1477,21 @@ midori_location_action_set_title_for_uri (MidoriLocationAction* location_action,
* @location_action: a #MidoriLocationAction
* @search_engines: a #KatzeArray
*
* This function is obsolete and has no effect.
* Assigns the specified search engines to the location action.
* Search engines will appear as actions in the completion.
*
* Deprecated: 0.2.3
* Since: 0.1.6
**/
void
midori_location_action_set_search_engines (MidoriLocationAction* location_action,
KatzeArray* search_engines)
{
/* Do nothing */
g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action));
if (search_engines)
g_object_ref (search_engines);
katze_object_assign (location_action->search_engines, search_engines);
}
gdouble

View file

@ -435,6 +435,8 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
SPANNED_ADD (button);
button = katze_property_proxy (settings, "progress-in-location", NULL);
INDENTED_ADD (button);
button = katze_property_proxy (settings, "search-engines-in-completion", NULL);
SPANNED_ADD (button);
#endif
FRAME_NEW (_("Browsing"));
label = katze_property_label (settings, "open-new-pages-in");

View file

@ -512,7 +512,7 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
*
* Whether to show search engines in the location completion.
*
* Deprecated: 0.2.3: This setting is obsolete.
* Since: 0.1.6
*/
g_object_class_install_property (gobject_class,
PROP_SEARCH_ENGINES_IN_COMPLETION,