]> spindle.queued.net Git - midori/commitdiff
Fill in address if clicked on completion suggestion
authorChristian Dywan <christian@twotoasts.de>
Wed, 20 Jan 2010 06:42:40 +0000 (07:42 +0100)
committerChristian Dywan <christian@twotoasts.de>
Wed, 20 Jan 2010 06:48:34 +0000 (07:48 +0100)
midori/midori-locationaction.c

index babce963e89a17926fbb2e2770c981844641c075..4e9d489f81c99c411da33c11e7ec5f3592071499 100644 (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 ();