From 52084a21e1ae31a778a094267c3b3d839e3830f3 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sat, 18 Apr 2009 23:26:54 +0200 Subject: [PATCH] Add a preference Search engines in location completion It seems that deletion of completion actions can fail, which means that the actions remain until the next restart. It is not clear how to fix this. --- midori/midori-browser.c | 21 +++++++++++++++++++-- midori/midori-locationaction.c | 5 +++-- midori/midori-preferences.c | 2 ++ midori/midori-websettings.c | 24 ++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index f329c896..d37eb49d 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -4569,6 +4569,15 @@ midori_browser_settings_notify (MidoriWebSettings* web_settings, browser->show_statusbar = g_value_get_boolean (&value); else if (name == g_intern_string ("progress-in-location")) browser->progress_in_location = g_value_get_boolean (&value); + else if (name == g_intern_string ("search-engines-in-completion")) + { + 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")) { katze_assign (browser->location_entry_search, g_value_dup_string (&value)); @@ -4727,8 +4736,16 @@ midori_browser_set_property (GObject* object, case PROP_SEARCH_ENGINES: /* FIXME: Disconnect handlers */ katze_object_assign (browser->search_engines, g_value_dup_object (value)); - midori_location_action_set_search_engines (MIDORI_LOCATION_ACTION ( - _action_by_name (browser, "Location")), browser->search_engines); + if (browser->settings) + { + 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 */ diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c index 030f83d9..5036ba64 100644 --- a/midori/midori-locationaction.c +++ b/midori/midori-locationaction.c @@ -1246,9 +1246,10 @@ midori_location_action_set_search_engines (MidoriLocationAction* location_action completion = gtk_entry_get_completion (GTK_ENTRY (child)); i = 0; + /* FIXME: Apparently deleting doesn't always work, but why? */ if (location_action->search_engines) - while ((item = katze_array_get_nth_item (location_action->search_engines, i))) - gtk_entry_completion_delete_action (completion, i++); + while ((item = katze_array_get_nth_item (location_action->search_engines, i++))) + gtk_entry_completion_delete_action (completion, i); midori_location_action_add_actions (completion, search_engines); } diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c index 3c492e1a..0ca3ea3d 100644 --- a/midori/midori-preferences.c +++ b/midori/midori-preferences.c @@ -553,6 +553,8 @@ midori_preferences_set_settings (MidoriPreferences* preferences, FILLED_ADD (button, 1, 2, 0, 1); #endif button = katze_property_proxy (settings, "progress-in-location", NULL); + FILLED_ADD (button, 0, 1, 1, 2); + button = katze_property_proxy (settings, "search-engines-in-completion", NULL); FILLED_ADD (button, 1, 2, 1, 2); FRAME_NEW (_("Browsing")); TABLE_NEW (5, 2); diff --git a/midori/midori-websettings.c b/midori/midori-websettings.c index 40e42fbc..29cf757c 100644 --- a/midori/midori-websettings.c +++ b/midori/midori-websettings.c @@ -41,6 +41,7 @@ struct _MidoriWebSettings MidoriToolbarStyle toolbar_style; gboolean progress_in_location; + gboolean search_engines_in_completion; gchar* toolbar_items; gboolean compact_sidepanel; gboolean right_align_sidepanel; @@ -110,6 +111,7 @@ enum PROP_TOOLBAR_STYLE, PROP_PROGRESS_IN_LOCATION, + PROP_SEARCH_ENGINES_IN_COMPLETION, PROP_TOOLBAR_ITEMS, PROP_COMPACT_SIDEPANEL, PROP_RIGHT_ALIGN_SIDEPANEL, @@ -481,6 +483,22 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class) TRUE, flags)); + /** + * MidoriWebSettings:search-engines-in-completion: + * + * Whether to show search engines in the location completion. + * + * Since: 0.1.3 + */ + g_object_class_install_property (gobject_class, + PROP_SEARCH_ENGINES_IN_COMPLETION, + g_param_spec_boolean ( + "search-engines-in-completion", + _("Search engines in location completion"), + _("Whether to show search engines in the location completion"), + TRUE, + flags)); + g_object_class_install_property (gobject_class, PROP_TOOLBAR_ITEMS, g_param_spec_string ( @@ -1036,6 +1054,9 @@ midori_web_settings_set_property (GObject* object, case PROP_PROGRESS_IN_LOCATION: web_settings->progress_in_location = g_value_get_boolean (value); break; + case PROP_SEARCH_ENGINES_IN_COMPLETION: + web_settings->search_engines_in_completion = g_value_get_boolean (value); + break; case PROP_TOOLBAR_ITEMS: katze_assign (web_settings->toolbar_items, g_value_dup_string (value)); break; @@ -1232,6 +1253,9 @@ midori_web_settings_get_property (GObject* object, case PROP_PROGRESS_IN_LOCATION: g_value_set_boolean (value, web_settings->progress_in_location); break; + case PROP_SEARCH_ENGINES_IN_COMPLETION: + g_value_set_boolean (value, web_settings->search_engines_in_completion); + break; case PROP_TOOLBAR_ITEMS: g_value_set_string (value, web_settings->toolbar_items); break;