summaryrefslogtreecommitdiff
path: root/tests/testtreeedit.c
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@gnu.org>2002-04-17 21:55:23 +0000
committerAnders Carlsson <andersca@src.gnome.org>2002-04-17 21:55:23 +0000
commit9d03f7d62215379670853248f53be4ae1ec1d120 (patch)
tree3f8f1a7c5c7eb816ce5e74de3f491124e1b34311 /tests/testtreeedit.c
parent3140315f1763bec0db3931e9e1d8a84c56315e5f (diff)
downloadgdk-pixbuf-9d03f7d62215379670853248f53be4ae1ec1d120.tar.gz
Add a small test case.
2002-04-17 Anders Carlsson <andersca@gnu.org> * tests/testtreeedit.c (button_press_event): Add a small test case.
Diffstat (limited to 'tests/testtreeedit.c')
-rw-r--r--tests/testtreeedit.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/testtreeedit.c b/tests/testtreeedit.c
index f91c0b2b8..9163fd2c9 100644
--- a/tests/testtreeedit.c
+++ b/tests/testtreeedit.c
@@ -80,6 +80,20 @@ edited (GtkCellRendererText *cell,
gtk_tree_path_free (path);
}
+static gboolean
+button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer callback_data)
+{
+ /* Deselect if people click outside any row. */
+ if (event->window == gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget))
+ && !gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
+ event->x, event->y, NULL, NULL, NULL, NULL)) {
+ gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)));
+ }
+
+ /* Let the default code run in any case; it won't reselect anything. */
+ return FALSE;
+}
+
gint
main (gint argc, gchar **argv)
{
@@ -102,6 +116,7 @@ main (gint argc, gchar **argv)
tree_model = create_model ();
tree_view = gtk_tree_view_new_with_model (tree_model);
+ g_signal_connect (tree_view, "button_press_event", G_CALLBACK (button_press_event), NULL);
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);