Remove 'Search engines in completion' functionality

The feature doesn't work well with more than two engines.
This commit is contained in:
Christian Dywan 2010-01-17 10:23:35 +01:00
parent c335bb19c7
commit 7f26cc7384
4 changed files with 5 additions and 102 deletions

View file

@ -6616,12 +6616,7 @@ midori_browser_settings_notify (MidoriWebSettings* web_settings,
g_value_get_string (&value) && *g_value_get_string (&value)); g_value_get_string (&value) && *g_value_get_string (&value));
else if (name == g_intern_string ("search-engines-in-completion")) else if (name == g_intern_string ("search-engines-in-completion"))
{ {
if (g_value_get_boolean (&value)) /* Do nothing */
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")) else if (name == g_intern_string ("location-entry-search"))
{ {
@ -6835,13 +6830,6 @@ midori_browser_set_property (GObject* object,
/* FIXME: Disconnect handlers */ /* FIXME: Disconnect handlers */
katze_object_assign (browser->search_engines, g_value_dup_object (value)); 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 ( midori_search_action_set_search_engines (MIDORI_SEARCH_ACTION (
_action_by_name (browser, "Search")), browser->search_engines); _action_by_name (browser, "Search")), browser->search_engines);
/* FIXME: Connect to updates */ /* FIXME: Connect to updates */

View file

@ -29,7 +29,6 @@ struct _MidoriLocationAction
gchar* text; gchar* text;
gchar* uri; gchar* uri;
KatzeArray* search_engines;
gdouble progress; gdouble progress;
gchar* secondary_icon; gchar* secondary_icon;
@ -361,7 +360,6 @@ static void
midori_location_action_init (MidoriLocationAction* location_action) midori_location_action_init (MidoriLocationAction* location_action)
{ {
location_action->text = location_action->uri = NULL; location_action->text = location_action->uri = NULL;
location_action->search_engines = NULL;
location_action->progress = 0.0; location_action->progress = 0.0;
location_action->secondary_icon = NULL; location_action->secondary_icon = NULL;
location_action->default_icon = NULL; location_action->default_icon = NULL;
@ -384,7 +382,6 @@ midori_location_action_finalize (GObject* object)
katze_assign (location_action->text, NULL); katze_assign (location_action->text, NULL);
katze_assign (location_action->uri, NULL); katze_assign (location_action->uri, NULL);
katze_assign (location_action->search_engines, NULL);
katze_object_assign (location_action->model, NULL); katze_object_assign (location_action->model, NULL);
katze_object_assign (location_action->filter_model, NULL); katze_object_assign (location_action->filter_model, NULL);
@ -979,48 +976,6 @@ midori_location_entry_match_selected_cb (GtkEntryCompletion* completion,
return FALSE; return FALSE;
} }
static void
midori_location_entry_action_activated_cb (GtkEntryCompletion* completion,
gint action,
MidoriLocationAction* location_action)
{
if (location_action->search_engines)
{
KatzeItem* item = katze_array_get_nth_item (
location_action->search_engines, action);
GtkWidget* entry = gtk_entry_completion_get_entry (completion);
const gchar* keywords = gtk_entry_get_text (GTK_ENTRY (entry));
const gchar* uri = katze_item_get_uri (item);
gchar* search;
if (!item)
return;
search = sokoke_search_uri (uri, keywords);
midori_location_action_set_text (location_action, search);
g_signal_emit (location_action, signals[SUBMIT_URI], 0, search, FALSE);
g_free (search);
}
}
static void
midori_location_action_add_actions (GtkEntryCompletion* completion,
KatzeArray* search_engines)
{
guint i;
KatzeItem* item;
if (!search_engines)
return;
i = 0;
while ((item = katze_array_get_nth_item (search_engines, i)))
{
gchar* text = g_strdup_printf (_("Search with %s"),
katze_item_get_name (item));
gtk_entry_completion_insert_action_text (completion, i++, text);
g_free (text);
}
}
static void static void
midori_location_action_completion_init (MidoriLocationAction* location_action, midori_location_action_completion_init (MidoriLocationAction* location_action,
GtkEntry* entry) GtkEntry* entry)
@ -1067,11 +1022,6 @@ midori_location_action_completion_init (MidoriLocationAction* location_action,
g_signal_connect (completion, "match-selected", g_signal_connect (completion, "match-selected",
G_CALLBACK (midori_location_entry_match_selected_cb), location_action); G_CALLBACK (midori_location_entry_match_selected_cb), location_action);
midori_location_action_add_actions (completion,
location_action->search_engines);
g_signal_connect (completion, "action-activated",
G_CALLBACK (midori_location_entry_action_activated_cb), location_action);
} }
static void static void
@ -1471,48 +1421,15 @@ midori_location_action_set_title_for_uri (MidoriLocationAction* location_action,
* @location_action: a #MidoriLocationAction * @location_action: a #MidoriLocationAction
* @search_engines: a #KatzeArray * @search_engines: a #KatzeArray
* *
* Assigns the specified search engines to the location action. * This function is obsolete and has no effect.
* Search engines will appear as actions in the completion.
* *
* Since: 0.1.6 * Deprecated: 0.2.3
**/ **/
void void
midori_location_action_set_search_engines (MidoriLocationAction* location_action, midori_location_action_set_search_engines (MidoriLocationAction* location_action,
KatzeArray* search_engines) KatzeArray* search_engines)
{ {
GSList* proxies; /* Do nothing */
GtkWidget* entry;
GtkWidget* child;
GtkEntryCompletion* completion;
g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action));
if (search_engines)
g_object_ref (search_engines);
proxies = gtk_action_get_proxies (GTK_ACTION (location_action));
for (; proxies != NULL; proxies = g_slist_next (proxies))
if (GTK_IS_TOOL_ITEM (proxies->data))
{
KatzeItem* item;
guint i;
entry = midori_location_action_entry_for_proxy (proxies->data);
child = gtk_bin_get_child (GTK_BIN (entry));
midori_location_action_completion_init (location_action, GTK_ENTRY (child));
completion = gtk_entry_get_completion (GTK_ENTRY (child));
i = 0;
if (location_action->search_engines)
while ((item = katze_array_get_nth_item (location_action->search_engines, i++)))
gtk_entry_completion_delete_action (completion, 0);
midori_location_action_add_actions (completion, search_engines);
}
katze_object_assign (location_action->search_engines, search_engines);
/* FIXME: Take care of adding and removing search engines as needed */
} }
gdouble gdouble

View file

@ -435,8 +435,6 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
SPANNED_ADD (button); SPANNED_ADD (button);
button = katze_property_proxy (settings, "progress-in-location", NULL); button = katze_property_proxy (settings, "progress-in-location", NULL);
INDENTED_ADD (button); INDENTED_ADD (button);
button = katze_property_proxy (settings, "search-engines-in-completion", NULL);
SPANNED_ADD (button);
#endif #endif
FRAME_NEW (_("Browsing")); FRAME_NEW (_("Browsing"));
label = katze_property_label (settings, "open-new-pages-in"); 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. * Whether to show search engines in the location completion.
* *
* Since: 0.1.6 * Deprecated: 0.2.3: This setting is obsolete.
*/ */
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_SEARCH_ENGINES_IN_COMPLETION, PROP_SEARCH_ENGINES_IN_COMPLETION,