Pass action to cell renderer callback rather than the entry

The entry pointer is only meaningful if completion was triggered
by typing or editing in an entry.
We shouldn't render a key in results if the arrow button opened the
completion popup.
We need to check the key in the callback to avoid accidentally
working with an entry of a different window.
This commit is contained in:
Christian Dywan 2010-02-11 23:55:36 +01:00
parent f733f453d2
commit f19412bc70

View file

@ -417,7 +417,7 @@ midori_location_action_popup_timeout_cb (gpointer data)
NULL);
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (column), renderer,
midori_location_entry_render_text_cb,
action->entry, NULL);
action, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
action->popup = popup;
@ -517,6 +517,7 @@ midori_location_action_popdown_completion (MidoriLocationAction* location_action
if (G_LIKELY (location_action->popup))
{
gtk_widget_hide (location_action->popup);
katze_assign (location_action->key, NULL);
gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (
GTK_TREE_VIEW (location_action->treeview)));
}
@ -1013,13 +1014,13 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout,
GtkTreeIter* iter,
gpointer data)
{
MidoriLocationAction* action = data;
gchar* uri;
gchar* title;
GdkColor* background;
gchar* desc;
gchar* desc_uri;
gchar* desc_title;
GtkWidget* entry;
const gchar* str;
gchar* key;
gchar* start;
@ -1028,16 +1029,9 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout,
gchar** parts;
size_t len;
entry = data;
gtk_tree_model_get (model, iter, URI_COL, &uri, TITLE_COL, &title,
BACKGROUND_COL, &background, -1);
desc = desc_uri = desc_title = key = NULL;
str = gtk_entry_get_text (GTK_ENTRY (entry));
if (!str)
return;
if (background != NULL) /* A search engine action */
{
g_object_set (renderer, "text", title,
@ -1047,6 +1041,12 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout,
return;
}
desc = desc_uri = desc_title = key = NULL;
if (action->key)
str = action->key;
else
str = "";
key = g_utf8_strdown (str, -1);
len = strlen (key);
@ -1274,7 +1274,7 @@ midori_location_action_connect_proxy (GtkAction* action,
g_object_set_data (G_OBJECT (renderer), "location-action", action);
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (entry), renderer, TRUE);
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (entry),
renderer, midori_location_entry_render_text_cb, child, NULL);
renderer, midori_location_entry_render_text_cb, action, NULL);
gtk_combo_box_set_active (GTK_COMBO_BOX (entry), -1);
if (location_action->history)