Add a test for gtk_flow_box_bind_model

This commit is contained in:
Matthias Clasen 2015-08-16 18:20:12 -04:00
parent a777186785
commit 3d7647991a

View File

@ -167,23 +167,12 @@ remove_some (GtkButton *button, GListStore *store)
int
main (int argc, char *argv[])
{
GtkWidget *window, *grid, *sw, *list, *button;
GtkWidget *window, *grid, *sw, *box, *button;
GListStore *store;
gint i;
gtk_init (NULL, NULL);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
grid = gtk_grid_new ();
gtk_container_add (GTK_CONTAINER (window), grid);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_widget_set_hexpand (sw, TRUE);
gtk_widget_set_vexpand (sw, TRUE);
gtk_grid_attach (GTK_GRID (grid), sw, 0, 0, 1, 1);
store = g_list_store_new (my_object_get_type ());
for (i = 0; i < 100; i++)
{
@ -200,9 +189,32 @@ main (int argc, char *argv[])
g_object_unref (obj);
}
list = gtk_list_box_new ();
gtk_list_box_bind_model (GTK_LIST_BOX (list), G_LIST_MODEL (store), create_widget, NULL, NULL);
gtk_container_add (GTK_CONTAINER (sw), list);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
grid = gtk_grid_new ();
gtk_container_add (GTK_CONTAINER (window), grid);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_widget_set_hexpand (sw, TRUE);
gtk_widget_set_vexpand (sw, TRUE);
gtk_grid_attach (GTK_GRID (grid), sw, 0, 0, 1, 1);
box = gtk_list_box_new ();
gtk_list_box_bind_model (GTK_LIST_BOX (box), G_LIST_MODEL (store), create_widget, NULL, NULL);
gtk_container_add (GTK_CONTAINER (sw), box);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_widget_set_hexpand (sw, TRUE);
gtk_widget_set_vexpand (sw, TRUE);
gtk_grid_attach (GTK_GRID (grid), sw, 1, 0, 1, 1);
box = gtk_flow_box_new ();
gtk_flow_box_bind_model (GTK_FLOW_BOX (box), G_LIST_MODEL (store), create_widget, NULL, NULL);
gtk_container_add (GTK_CONTAINER (sw), box);
button = gtk_button_new_with_label ("Add some");
g_signal_connect (button, "clicked", G_CALLBACK (add_some), store);