1.25 <GtkCenterBox>

Class: <GtkCenterBox>

It derives from <GtkWidget>.

Arranges three children in a row, keeping the middle child centered as well as possible.

To add children to <GtkCenterBox>, use center-box:set-start-widget, center-box:set-center-widget and 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”,

The first child of the <GtkCenterBox> will be allocated depending on the text direction, i.e. in left-to-right layouts it will be allocated on the left and in right-to-left layouts on the right.

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

Accessibility

Until GTK 4.10, <GtkCenterBox> used the Gtk.AccessibleRole.group role.

Starting from GTK 4.12, <GtkCenterBox> uses the Gtk.AccessibleRole.generic role.

Properties

Property: center-box:baseline-position self

The position of the baseline aligned widget if extra space is available.

Its value is a <GtkBaselinePosition> (or, to set it, one of its symbols).

Set it with (set! (center-box:baseline-position self) value).

Property: center-box:center-widget self

The widget that is placed at the center position.

Its value is a <GtkWidget>, or #f.

Set it with (set! (center-box:center-widget self) value).

Property: center-box:end-widget self

The widget that is placed at the end position.

In vertical orientation, the end position is at the bottom. In horizontal orientation, the end position is at the trailing edge with respect to the text direction.

Its value is a <GtkWidget>, or #f.

Set it with (set! (center-box:end-widget self) value).

Property: center-box:shrink-center-last self

Whether to shrink the center widget after other children.

By default, when there’s no space to give all three children their natural widths, the start and end widgets start shrinking and the center child keeps natural width until they reach minimum width.

If false, start and end widgets keep natural width and the center widget starts shrinking instead.

Its value is a boolean.

Set it with (set! (center-box:shrink-center-last self) value).

Property: center-box:start-widget self

The widget that is placed at the start position.

In vertical orientation, the start position is at the top. In horizontal orientation, the start position is at the leading edge with respect to the text direction.

Its value is a <GtkWidget>, or #f.

Set it with (set! (center-box:start-widget self) value).

Procedures

Method: center-box:get-baseline-position self ⇒ %return
Method: get-baseline-position self ⇒ %return

Gets the baseline position of the center box.

See center-box:set-baseline-position.

self

Passed: a <GtkCenterBox>.

a center box

%return

Returned: a <GtkBaselinePosition>.

the baseline position

Method: center-box:get-center-widget self ⇒ %return
Method: get-center-widget self ⇒ %return

Gets the center widget.

self

Passed: a <GtkCenterBox>.

a center box

%return

Returned: a <GtkWidget>, or #f.

the center widget

Method: center-box:get-end-widget self ⇒ %return
Method: get-end-widget self ⇒ %return

Gets the end widget.

self

Passed: a <GtkCenterBox>.

a center box

%return

Returned: a <GtkWidget>, or #f.

the end widget

Method: center-box:get-shrink-center-last? self ⇒ %return
Method: get-shrink-center-last? self ⇒ %return

Gets whether the center widget shrinks after other children.

self

Passed: a <GtkCenterBox>.

a center box

%return

Returned: a boolean.

whether to shrink the center widget after others

Method: center-box:get-start-widget self ⇒ %return
Method: get-start-widget self ⇒ %return

Gets the start widget.

self

Passed: a <GtkCenterBox>.

a center box

%return

Returned: a <GtkWidget>, or #f.

the start widget

Procedure: center-box:new ⇒ %return

Creates a new <GtkCenterBox>.

%return

Returned: a <GtkWidget>.

the new <GtkCenterBox>

Method: center-box:set-baseline-position self position
Method: set-baseline-position self 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 with respect to the extra space available.

self

Passed: a <GtkCenterBox>.

a center box

position

Passed: a <GtkBaselinePosition>, or one of its symbols.

the baseline position

Method: center-box:set-center-widget self [child]
Method: set-center-widget self [child]

Sets the center widget.

To remove the existing center widget, pass NULL.

self

Passed: a <GtkCenterBox>.

a center box

child

Passed, or left out: a <GtkWidget>, or #f.

the new center widget

Method: center-box:set-end-widget self [child]
Method: set-end-widget self [child]

Sets the end widget.

To remove the existing end widget, pass NULL.

self

Passed: a <GtkCenterBox>.

a center box

child

Passed, or left out: a <GtkWidget>, or #f.

the new end widget

Method: center-box:set-shrink-center-last self shrink-center-last
Method: set-shrink-center-last self shrink-center-last

Sets whether to shrink the center widget after other children.

By default, when there’s no space to give all three children their natural widths, the start and end widgets start shrinking and the center child keeps natural width until they reach minimum width.

If shrink-center-last is false, start and end widgets keep natural width and the center widget starts shrinking instead.

self

Passed: a <GtkCenterBox>.

a cener box

shrink-center-last

Passed: a boolean.

whether to shrink the center widget after others

Method: center-box:set-start-widget self [child]
Method: set-start-widget self [child]

Sets the start widget.

To remove the existing start widget, pass NULL.

self

Passed: a <GtkCenterBox>.

a center box

child

Passed, or left out: a <GtkWidget>, or #f.

the new start widget