From 9d03f7d62215379670853248f53be4ae1ec1d120 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Wed, 17 Apr 2002 21:55:23 +0000 Subject: [PATCH] Add a small test case. 2002-04-17 Anders Carlsson * tests/testtreeedit.c (button_press_event): Add a small test case. --- ChangeLog | 5 +++++ ChangeLog.pre-2-10 | 5 +++++ ChangeLog.pre-2-2 | 5 +++++ ChangeLog.pre-2-4 | 5 +++++ ChangeLog.pre-2-6 | 5 +++++ ChangeLog.pre-2-8 | 5 +++++ tests/testtreeedit.c | 15 +++++++++++++++ 7 files changed, 45 insertions(+) diff --git a/ChangeLog b/ChangeLog index a0c1e9994b..80579d8017 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-04-17 Anders Carlsson + + * tests/testtreeedit.c (button_press_event): Add a small + test case. + Wed Apr 17 00:21:36 2002 Kristian Rietveld * gtk/gtktreestore.c (gtk_tree_store_insert_before): fix docs diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index a0c1e9994b..80579d8017 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +2002-04-17 Anders Carlsson + + * tests/testtreeedit.c (button_press_event): Add a small + test case. + Wed Apr 17 00:21:36 2002 Kristian Rietveld * gtk/gtktreestore.c (gtk_tree_store_insert_before): fix docs diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index a0c1e9994b..80579d8017 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,8 @@ +2002-04-17 Anders Carlsson + + * tests/testtreeedit.c (button_press_event): Add a small + test case. + Wed Apr 17 00:21:36 2002 Kristian Rietveld * gtk/gtktreestore.c (gtk_tree_store_insert_before): fix docs diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index a0c1e9994b..80579d8017 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,8 @@ +2002-04-17 Anders Carlsson + + * tests/testtreeedit.c (button_press_event): Add a small + test case. + Wed Apr 17 00:21:36 2002 Kristian Rietveld * gtk/gtktreestore.c (gtk_tree_store_insert_before): fix docs diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index a0c1e9994b..80579d8017 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,8 @@ +2002-04-17 Anders Carlsson + + * tests/testtreeedit.c (button_press_event): Add a small + test case. + Wed Apr 17 00:21:36 2002 Kristian Rietveld * gtk/gtktreestore.c (gtk_tree_store_insert_before): fix docs diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index a0c1e9994b..80579d8017 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,8 @@ +2002-04-17 Anders Carlsson + + * tests/testtreeedit.c (button_press_event): Add a small + test case. + Wed Apr 17 00:21:36 2002 Kristian Rietveld * gtk/gtktreestore.c (gtk_tree_store_insert_before): fix docs diff --git a/tests/testtreeedit.c b/tests/testtreeedit.c index f91c0b2b8b..9163fd2c9b 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);