From 29f5cdda100ef24b0e8b7415d78a58649988a05c Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 26 Aug 2015 19:48:29 -0400 Subject: [PATCH] testflowbox: Add an example with buttons This example populates a flow box with buttons, and makes the flow box children unfocusable, with the intention that the focus moves directly between the buttons. Currently, keynav does not work at all in this case. --- tests/testflowbox.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/testflowbox.c b/tests/testflowbox.c index 4efc9b726c..ad181219f5 100644 --- a/tests/testflowbox.c +++ b/tests/testflowbox.c @@ -22,7 +22,8 @@ enum { FOCUS_ITEMS, WRAPPY_ITEMS, STOCK_ITEMS, - IMAGE_ITEMS + IMAGE_ITEMS, + BUTTON_ITEMS }; #define INITIAL_HALIGN GTK_ALIGN_FILL @@ -74,6 +75,7 @@ populate_flowbox_focus (GtkFlowBox *flowbox) { sensitive = TRUE; frame = gtk_frame_new (NULL); + gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_container_add (GTK_CONTAINER (frame), box); @@ -111,6 +113,22 @@ populate_flowbox_focus (GtkFlowBox *flowbox) } } +static void +populate_flowbox_buttons (GtkFlowBox *flowbox) +{ + GtkWidget *widget; + gint i; + + for (i = 0; i < 50; i++) + { + widget = gtk_button_new_with_label ("Button"); + gtk_widget_show (widget); + gtk_container_add (GTK_CONTAINER (flowbox), widget); + widget = gtk_widget_get_parent (widget); + gtk_widget_set_can_focus (widget, FALSE); + } +} + static void populate_flowbox_wrappy (GtkFlowBox *flowbox) { @@ -235,6 +253,8 @@ populate_items (GtkFlowBox *flowbox) populate_flowbox_stock (flowbox); else if (items_type == IMAGE_ITEMS) populate_flowbox_images (flowbox); + else if (items_type == BUTTON_ITEMS) + populate_flowbox_buttons (flowbox); } static void @@ -642,6 +662,7 @@ create_window (void) gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Wrappy"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Stock"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Images"); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Buttons"); gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); gtk_widget_show (widget);