GtkBox versus GtkGrid: spacing: GTK+ 3 Reference Manual

## GtkBox versus GtkGrid: spacing

With GtkBox, you have to specify the “spacing” when you construct it. This property specifies the space that separates the children from each other. Additionally, you can specify extra space to put around each child individually, using the GtkBox padding child property.

GtkGrid is very similar when it comes to spacing between the children, except that it has two separate properties, “row-spacing” and “column-spacing”, for the space to leave between rows and columns. Note that row-spacing is the space between rows, not inside a row. So, if you doing a horizontal layout, you need to set “column-spacing”.

GtkGrid doesn't have any custom child properties to specify per-child padding; instead you can use the “margin” property. You can also set different padding on each side with the “margin-left”, “margin-right”, “margin-top” and “margin-bottom” properties.

Example 55. Spacing in boxes

             box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
             gtk_box_pack_start (GTK_BOX (box), child, FALSE, FALSE, 12);

This can be done with GtkGrid as follows:

             grid = gtk_grid_new ();
             gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
             g_object_set (child, "margin", 12, NULL);
             gtk_grid_attach (GTK_GRID (box), child, 0, 0, 1, 1);