Fill in address if clicked on completion suggestion

This commit is contained in:
Christian Dywan 2010-01-20 07:42:40 +01:00
parent 8f37e3802e
commit cabc3f0764

View file

@ -302,6 +302,37 @@ midori_location_action_popup_position (GtkWidget* popup,
widget->allocation.width, 1);
}
static gboolean
midori_location_action_treeview_button_press_cb (GtkWidget* treeview,
GdkEventButton* event,
MidoriLocationAction* action)
{
GtkTreePath* path;
if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (treeview),
event->x, event->y, &path, NULL, NULL, NULL))
{
GtkTreeIter iter;
gchar* uri;
gtk_tree_model_get_iter (action->completion_model, &iter, path);
gtk_tree_path_free (path);
gtk_widget_hide (action->popup);
gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (
GTK_TREE_VIEW (treeview)));
action->completion_timeout = 0;
gtk_tree_model_get (action->completion_model, &iter, URI_COL, &uri, -1);
gtk_entry_set_text (GTK_ENTRY (action->entry), uri);
g_free (uri);
return TRUE;
}
return FALSE;
}
static gboolean
midori_location_action_popup_timeout_cb (gpointer data)
{
@ -345,7 +376,9 @@ midori_location_action_popup_timeout_cb (gpointer data)
treeview = gtk_tree_view_new_with_model (model);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
gtk_container_add (GTK_CONTAINER (scrolled), treeview);
/* FIXME: Handle button presses and hovering rows */
/* FIXME: Handle hovering rows */
g_signal_connect (treeview, "button-press-event",
G_CALLBACK (midori_location_action_treeview_button_press_cb), action);
action->treeview = treeview;
column = gtk_tree_view_column_new ();