diff options
author | Matthias Clasen <mclasen@redhat.com> | 2014-03-29 00:59:05 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-04-06 01:44:38 -0400 |
commit | ccc4fb8512c4582016d6b4f418ccec81c0b57c47 (patch) | |
tree | d1ed23aab8cb191762acc110b055ce386ffd1391 /tests | |
parent | 3fe243d34693f51fb865100a43dca3ac2674af5f (diff) | |
download | gtk+-ccc4fb8512c4582016d6b4f418ccec81c0b57c47.tar.gz |
Improve list selection example
Print out signals, so we see how often they are emitted.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testlist3.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/testlist3.c b/tests/testlist3.c index 3b11055749..9ebd1c1cca 100644 --- a/tests/testlist3.c +++ b/tests/testlist3.c @@ -15,6 +15,27 @@ create_row (const gchar *text) } static void +on_row_activated (GtkListBox *self, + GtkWidget *child) +{ + const char *id; + id = g_object_get_data (G_OBJECT (gtk_bin_get_child (GTK_BIN (child))), "id"); + g_message ("Row activated %p: %s", child, id); +} + +static void +on_selected_children_changed (GtkListBox *self) +{ + g_message ("Selection changed"); +} + +static void +a11y_selection_changed (AtkObject *obj) +{ + g_message ("Accessible selection changed"); +} + +static void selection_mode_changed (GtkComboBox *combo, gpointer data) { GtkListBox *list = data; @@ -44,6 +65,10 @@ main (int argc, char *argv[]) list = gtk_list_box_new (); gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), GTK_SELECTION_NONE); + g_signal_connect (list, "row-activated", G_CALLBACK (on_row_activated), NULL); + g_signal_connect (list, "selected-rows-changed", G_CALLBACK (on_selected_children_changed), NULL); + g_signal_connect (gtk_widget_get_accessible (list), "selection-changed", G_CALLBACK (a11y_selection_changed), NULL); + sw = gtk_scrolled_window_new (NULL, NULL); gtk_widget_set_hexpand (sw, TRUE); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); |