GtkCenterBox: GTK+ 4 Reference Manual

## GtkCenterBox GtkCenterBox — A centering container |

## Functions

GtkWidget * | gtk_center_box_new ()
void | gtk_center_box_set_start_widget ()
void | gtk_center_box_set_center_widget ()
void | gtk_center_box_set_end_widget ()
GtkWidget * | gtk_center_box_get_start_widget ()
GtkWidget * | gtk_center_box_get_center_widget ()
GtkWidget * | gtk_center_box_get_end_widget ()
void | gtk_center_box_set_baseline_position ()
GtkBaselinePosition | gtk_center_box_get_baseline_position ()
#define | GTK_CENTER_BOX()
#define | GTK_CENTER_BOX_CLASS()
#define | GTK_IS_CENTER_BOX()
#define | GTK_IS_CENTER_BOX_CLASS()
#define | GTK_CENTER_BOX_GET_CLASS()

## Types and Values

| GtkCenterBox
#define | GTK_TYPE_CENTER_BOX

## Includes

    #include <gtk/gtk.h>

## Description

The GtkCenterBox widget arranges three children in a horizontal or vertical arrangement, keeping the middle child centered as well as possible.

To add children to GtkCenterBox, use `gtk_center_box_set_start_widget()`, `gtk_center_box_set_center_widget()` and `gtk_center_box_set_end_widget()`.

The sizing and positioning of children can be influenced with the align and expand properties of the children.

### GtkCenterBox as GtkBuildable

The GtkCenterBox implementation of the GtkBuildable interface supports placing children in the 3 positions by specifying “start”, “center” or “end” as the “type” attribute of a <child> element.

### CSS nodes

GtkCenterBox uses a single CSS node with the name “box”,

In horizontal orientation, the nodes of the children are always arranged from left to right. So :first-child will always select the leftmost child, regardless of text direction.

In vertical orientation, the nodes of the children are arranged from top to bottom.

## Functions

### gtk_center_box_new ()

    GtkWidget *
    gtk_center_box_new (void);

Creates a new GtkCenterBox.

#### Returns

the new GtkCenterBox.

Since: 3.92

### gtk_center_box_set_start_widget ()

    void
    gtk_center_box_set_start_widget (GtkCenterBox *self,
                                     GtkWidget *child);

Sets the start widget. To remove the existing start widget, pass `NULL`.

#### Parameters

self | a GtkCenterBox |
child | the new start widget, or `NULL`. | [nullable]

Since: 3.92

### gtk_center_box_set_center_widget ()

    void
    gtk_center_box_set_center_widget (GtkCenterBox *self,
                                      GtkWidget *child);

Sets the center widget. To remove the existing center widget, pas `NULL`.

#### Parameters

self | a GtkCenterBox |
child | the new center widget, or `NULL`. | [nullable]

Since: 3.92

### gtk_center_box_set_end_widget ()

    void
    gtk_center_box_set_end_widget (GtkCenterBox *self,
                                   GtkWidget *child);

Sets the end widget. To remove the existing end widget, pass `NULL`.

#### Parameters

self | a GtkCenterBox |
child | the new end widget, or `NULL`. | [nullable]

Since: 3.92

### gtk_center_box_get_start_widget ()

    GtkWidget *
    gtk_center_box_get_start_widget (GtkCenterBox *self);

Gets the start widget, or `NULL` if there is none.

#### Parameters

self | a GtkCenterBox |

#### Returns

the start widget.

[transfer none][nullable]

Since: 3.92

### gtk_center_box_get_center_widget ()

    GtkWidget *
    gtk_center_box_get_center_widget (GtkCenterBox *self);

Gets the center widget, or `NULL` if there is none.

#### Parameters

self | a GtkCenterBox |

#### Returns

the center widget.

[transfer none][nullable]

Since: 3.92

### gtk_center_box_get_end_widget ()

    GtkWidget *
    gtk_center_box_get_end_widget (GtkCenterBox *self);

Gets the end widget, or `NULL` if there is none.

#### Parameters

self | a GtkCenterBox |

#### Returns

the end widget.

[transfer none][nullable]

Since: 3.92

### gtk_center_box_set_baseline_position ()

    void
    gtk_center_box_set_baseline_position (GtkCenterBox *self,
                                          GtkBaselinePosition position);

Sets the baseline position of a center box.

This affects only horizontal boxes with at least one baseline aligned child. If there is more vertical space available than requested, and the baseline is not allocated by the parent then `position` is used to allocate the baseline wrt. the extra space available.

#### Parameters

self | a GtkCenterBox |
position | a GtkBaselinePosition |

Since: 3.92

### gtk_center_box_get_baseline_position ()

    GtkBaselinePosition
    gtk_center_box_get_baseline_position (GtkCenterBox *self);

Gets the value set by `gtk_center_box_set_baseline_position()`.

#### Parameters

self | a GtkCenterBox |

#### Returns

the baseline position

Since: 3.92

### GTK_CENTER_BOX()

    #define GTK_CENTER_BOX(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CENTER_BOX, GtkCenterBox))

### GTK_CENTER_BOX_CLASS()

    #define GTK_CENTER_BOX_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CENTER_BOX, GtkCenterBoxClass))

### GTK_IS_CENTER_BOX()

    #define GTK_IS_CENTER_BOX(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CENTER_BOX))

### GTK_IS_CENTER_BOX_CLASS()

    #define GTK_IS_CENTER_BOX_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CENTER_BOX))

### GTK_CENTER_BOX_GET_CLASS()

    #define GTK_CENTER_BOX_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CENTER_BOX, GtkCenterBoxClass))

## Types and Values

### GtkCenterBox

    typedef struct _GtkCenterBox GtkCenterBox;

### GTK_TYPE_CENTER_BOX

    #define GTK_TYPE_CENTER_BOX                 (gtk_center_box_get_type ())

## See Also

GtkBox