mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 05:01:09 +00:00
tests: Convert testexpand from GtkTable to GtkGrid
This commit is contained in:
parent
4866b04dce
commit
d4d4f7f7e7
@ -123,36 +123,32 @@ create_box_window (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
create_table_window (void)
|
create_grid_window (void)
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
GtkWidget *table;
|
GtkWidget *grid;
|
||||||
GtkWidget *toggle;
|
GtkWidget *toggle;
|
||||||
GtkWidget *alignment;
|
GtkWidget *alignment;
|
||||||
GtkWidget *colorbox;
|
GtkWidget *colorbox;
|
||||||
GdkRGBA red, blue;
|
GdkRGBA red, blue;
|
||||||
|
|
||||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||||
gtk_window_set_title (GTK_WINDOW (window), "Table");
|
gtk_window_set_title (GTK_WINDOW (window), "Grid");
|
||||||
|
|
||||||
table = gtk_table_new (4, 3, FALSE);
|
grid = gtk_grid_new ();
|
||||||
|
|
||||||
gtk_table_attach (GTK_TABLE (table),
|
gtk_grid_attach (GTK_GRID (grid),
|
||||||
gtk_label_new ("Top"),
|
gtk_label_new ("Top"),
|
||||||
1, 2, 0, 1,
|
1, 0, 1, 1);
|
||||||
GTK_FILL, GTK_FILL, 0, 0);
|
gtk_grid_attach (GTK_GRID (grid),
|
||||||
gtk_table_attach (GTK_TABLE (table),
|
gtk_label_new ("Bottom"),
|
||||||
gtk_label_new ("Bottom"),
|
1, 3, 1, 1);
|
||||||
1, 2, 3, 4,
|
gtk_grid_attach (GTK_GRID (grid),
|
||||||
GTK_FILL, GTK_FILL, 0, 0);
|
gtk_label_new ("Left"),
|
||||||
gtk_table_attach (GTK_TABLE (table),
|
0, 1, 1, 2);
|
||||||
gtk_label_new ("Left"),
|
gtk_grid_attach (GTK_GRID (grid),
|
||||||
0, 1, 1, 3,
|
gtk_label_new ("Right"),
|
||||||
GTK_FILL, GTK_FILL, 0, 0);
|
2, 1, 1, 2);
|
||||||
gtk_table_attach (GTK_TABLE (table),
|
|
||||||
gtk_label_new ("Right"),
|
|
||||||
2, 3, 1, 3,
|
|
||||||
GTK_FILL, GTK_FILL, 0, 0);
|
|
||||||
|
|
||||||
gdk_rgba_parse (&red, "red");
|
gdk_rgba_parse (&red, "red");
|
||||||
gdk_rgba_parse (&blue, "blue");
|
gdk_rgba_parse (&blue, "blue");
|
||||||
@ -169,10 +165,9 @@ create_table_window (void)
|
|||||||
G_CALLBACK (on_toggle_hexpand), NULL);
|
G_CALLBACK (on_toggle_hexpand), NULL);
|
||||||
gtk_container_add (GTK_CONTAINER (alignment), toggle);
|
gtk_container_add (GTK_CONTAINER (alignment), toggle);
|
||||||
|
|
||||||
gtk_table_attach (GTK_TABLE (table),
|
gtk_grid_attach (GTK_GRID (grid),
|
||||||
colorbox,
|
colorbox,
|
||||||
1, 2, 1, 2,
|
1, 1, 1, 1);
|
||||||
GTK_FILL, GTK_FILL, 0, 0);
|
|
||||||
|
|
||||||
colorbox = gtk_event_box_new ();
|
colorbox = gtk_event_box_new ();
|
||||||
gtk_widget_override_background_color (colorbox, 0, &blue);
|
gtk_widget_override_background_color (colorbox, 0, &blue);
|
||||||
@ -186,12 +181,11 @@ create_table_window (void)
|
|||||||
G_CALLBACK (on_toggle_vexpand), NULL);
|
G_CALLBACK (on_toggle_vexpand), NULL);
|
||||||
gtk_container_add (GTK_CONTAINER (alignment), toggle);
|
gtk_container_add (GTK_CONTAINER (alignment), toggle);
|
||||||
|
|
||||||
gtk_table_attach (GTK_TABLE (table),
|
gtk_grid_attach (GTK_GRID (grid),
|
||||||
colorbox,
|
colorbox,
|
||||||
1, 2, 2, 3,
|
1, 2, 1, 1);
|
||||||
GTK_FILL, GTK_FILL, 0, 0);
|
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (window), table);
|
gtk_container_add (GTK_CONTAINER (window), grid);
|
||||||
gtk_widget_show_all (window);
|
gtk_widget_show_all (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +198,7 @@ main (int argc, char *argv[])
|
|||||||
gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
|
gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
|
||||||
|
|
||||||
create_box_window ();
|
create_box_window ();
|
||||||
create_table_window ();
|
create_grid_window ();
|
||||||
|
|
||||||
gtk_main ();
|
gtk_main ();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user