mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 21:21:21 +00:00
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.
This commit is contained in:
parent
0f1c4a303e
commit
29f5cdda10
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user