1.80 <AdwWrapBox>

Class: <AdwWrapBox>

It derives from <GtkWidget>.

A box-like widget that can wrap into multiple lines.

<AdwWrapBox> is similar to <GtkBox>, but can wrap lines when the widgets cannot fit otherwise. Unlike <GtkFlowBox>, the children aren’t arranged into a grid and behave more like words in a wrapping label.

Like <GtkBox>, <AdwWrapBox> is orientable and has spacing:

  • WrapBox:child-spacing between children in the same line;
  • WrapBox:line-spacing between lines.

::: note Unlike <GtkBox>, <AdwWrapBox> cannot follow the CSS border-spacing property.

Use the WrapBox:natural-line-length property to determine the layout’s natural size, e.g. when using it in a <GtkPopover>.

Normally, a horizontal <AdwWrapBox> wraps left to right and top to bottom for left-to-right languages. Both of these directions can be reversed, using the WrapBox:pack-direction and WrapBox:wrap-reverse properties. Additionally, the alignment of each line can be controlled with the WrapBox:align property.

Lines can be justified using the WrapBox:justify property, filling the entire line by either increasing child size or spacing depending on the value. Set WrapBox:justify-last-line to justify the last line as well.

By default, <AdwWrapBox> wraps as soon as the previous line cannot fit any more children without shrinking them past their natural size. Set WrapBox:wrap-policy to Adw.WrapPolicy.minimum to only wrap once all the children in the previous line have been shrunk to their minimum size.

To make each line take the same amount of space, set WrapBox:line-homogeneous to TRUE.

Spacing and natural line length can scale with the text scale factor, use the WrapBox:child-spacing-unit, WrapBox:line-spacing-unit and/or WrapBox:natural-line-length-unit properties to enable that behavior.

See WrapLayout.

CSS nodes

<AdwWrapBox> uses a single CSS node with name wrap-box.

Accessibility

<AdwWrapBox> uses the Gtk.AccessibleRole.group role.

Properties

Property: wrap-box:align self

The alignment of the children within each line.

0 means the children are placed at the start of the line, 1 means they are placed at the end of the line. 0.5 means they are placed in the middle of the line.

Alignment is only used when WrapBox:justify is set to Adw.JustifyMode.none, or on the last line when the WrapBox:justify-last-line is FALSE.

Its value is a real number.

Set it with (set! (wrap-box:align self) value).

Property: wrap-box:child-spacing self

The spacing between widgets on the same line.

See WrapBox:child-spacing-unit.

Its value is a 32-bit integer.

Set it with (set! (wrap-box:child-spacing self) value).

Property: wrap-box:child-spacing-unit self

The length unit for child spacing.

Allows the spacing to vary depending on the text scale factor.

See WrapBox:child-spacing.

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

Set it with (set! (wrap-box:child-spacing-unit self) value).

Property: wrap-box:justify self

Determines whether and how each complete line should be stretched to fill the entire widget.

If set to Adw.JustifyMode.fill, each widget in the line will be stretched, keeping consistent spacing, so that the line fills the entire widget.

If set to Adw.JustifyMode.spread, the spacing between widgets will be increased, keeping widget sizes intact. The first and last widget will be aligned with the beginning and end of the line. If the line only contains a single widget, it will be stretched regardless.

If set to Adw.JustifyMode.none, the line will not be stretched and the children will be placed together within the line, according to WrapBox:align.

By default this doesn’t affect the last line, as it will be incomplete. Use WrapBox:justify-last-line to justify it as well.

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

Set it with (set! (wrap-box:justify self) value).

Property: wrap-box:justify-last-line self

Whether the last line should be stretched to fill the entire widget.

See WrapBox:justify.

Its value is a boolean.

Set it with (set! (wrap-box:justify-last-line self) value).

Property: wrap-box:line-homogeneous self

Whether all lines should take the same amount of space.

Its value is a boolean.

Set it with (set! (wrap-box:line-homogeneous self) value).

Property: wrap-box:line-spacing self

The spacing between lines.

See WrapBox:line-spacing-unit.

Its value is a 32-bit integer.

Set it with (set! (wrap-box:line-spacing self) value).

Property: wrap-box:line-spacing-unit self

The length unit for line spacing.

Allows the spacing to vary depending on the text scale factor.

See WrapBox:line-spacing.

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

Set it with (set! (wrap-box:line-spacing-unit self) value).

Property: wrap-box:natural-line-length self

Determines the natural size for each line.

It should be used to limit the line lengths, for example when used in popovers.

See WrapBox:natural-line-length-unit.

Its value is a 32-bit integer.

Set it with (set! (wrap-box:natural-line-length self) value).

Property: wrap-box:natural-line-length-unit self

The length unit for natural line length.

Allows the length to vary depending on the text scale factor.

See WrapBox:natural-line-length.

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

Set it with (set! (wrap-box:natural-line-length-unit self) value).

Property: wrap-box:pack-direction self

The direction children are packed in each line.

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

Set it with (set! (wrap-box:pack-direction self) value).

Property: wrap-box:wrap-policy self

The policy for line wrapping.

  • If set to Adw.WrapPolicy.natural, the box will wrap to the next line as soon as the previous line cannot fit any more children without shrinking them past their natural size.

If set to Adw.WrapPolicy.minimum, the box will try to fit as many children into each line as possible, shrinking them down to their minimum size before wrapping to the next line.

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

Set it with (set! (wrap-box:wrap-policy self) value).

Property: wrap-box:wrap-reverse self

Whether wrap direction should be reversed.

By default, lines wrap downwards in a horizontal box, and towards the end in a vertical box. If set to TRUE, they wrap upwards or towards the start respectively.

Its value is a boolean.

Set it with (set! (wrap-box:wrap-reverse self) value).

Procedures

Method: wrap-box:append self child
Method: append self child

Adds child as the last child to self.

self

Passed: a <AdwWrapBox>.

a wrap box

child

Passed: a <GtkWidget>.

the widget to append

Method: wrap-box:get-align self ⇒ %return
Method: get-align self ⇒ %return

Gets the alignment of the children within each line.

self

Passed: a <AdwWrapBox>.

a wrap box

%return

Returned: a real number.

the child alignment

Method: wrap-box:get-child-spacing self ⇒ %return
Method: get-child-spacing self ⇒ %return

Gets spacing between widgets on the same line.

self

Passed: a <AdwWrapBox>.

a wrap box

%return

Returned: a 32-bit integer.

spacing between widgets on the same line

Method: wrap-box:get-child-spacing-unit self ⇒ %return
Method: get-child-spacing-unit self ⇒ %return

Gets the length unit for child spacing.

self

Passed: a <AdwWrapBox>.

a wrap box

%return

Returned: a <AdwLengthUnit>.

the length unit

Method: wrap-box:get-justify self ⇒ %return
Method: get-justify self ⇒ %return

Gets whether and how each complete line is stretched to fill the entire widget.

self

Passed: a <AdwWrapBox>.

a wrap box

%return

Returned: a <AdwJustifyMode>.

the justify mode

Method: wrap-box:get-justify-last-line? self ⇒ %return
Method: get-justify-last-line? self ⇒ %return

Gets whether the last line should be stretched to fill the entire widget.

self

Passed: a <AdwWrapBox>.

a wrap box

%return

Returned: a boolean.

whether the last line is justified

Method: wrap-box:get-line-homogeneous? self ⇒ %return
Method: get-line-homogeneous? self ⇒ %return

Gets whether all lines should take the same amount of space.

self

Passed: a <AdwWrapBox>.

a wrap box

%return

Returned: a boolean.

whether lines should be homogeneous

Method: wrap-box:get-line-spacing self ⇒ %return
Method: get-line-spacing self ⇒ %return

Gets the spacing between lines.

See WrapBox:line-spacing-unit.

self

Passed: a <AdwWrapBox>.

a wrap box

%return

Returned: a 32-bit integer.

the line spacing

Method: wrap-box:get-line-spacing-unit self ⇒ %return
Method: get-line-spacing-unit self ⇒ %return

Gets the length unit for line spacing.

self

Passed: a <AdwWrapBox>.

a wrap box

%return

Returned: a <AdwLengthUnit>.

the length unit

Method: wrap-box:get-natural-line-length self ⇒ %return
Method: get-natural-line-length self ⇒ %return

Gets the natural size for each line.

self

Passed: a <AdwWrapBox>.

a wrap box

%return

Returned: a 32-bit integer.

the natural length

Method: wrap-box:get-natural-line-length-unit self ⇒ %return
Method: get-natural-line-length-unit self ⇒ %return

Gets the length unit for line spacing.

self

Passed: a <AdwWrapBox>.

a wrap box

%return

Returned: a <AdwLengthUnit>.

the length unit

Method: wrap-box:get-pack-direction self ⇒ %return
Method: get-pack-direction self ⇒ %return

Gets the direction children are packed in each line.

self

Passed: a <AdwWrapBox>.

a wrap box

%return

Returned: a <AdwPackDirection>.

the line direction

Method: wrap-box:get-wrap-policy self ⇒ %return
Method: get-wrap-policy self ⇒ %return

Gets the policy for line wrapping.

self

Passed: a <AdwWrapBox>.

a wrap box

%return

Returned: a <AdwWrapPolicy>.

the wrap policy

Method: wrap-box:get-wrap-reverse? self ⇒ %return
Method: get-wrap-reverse? self ⇒ %return

Gets whether wrap direction is reversed.

self

Passed: a <AdwWrapBox>.

a wrap box

%return

Returned: a boolean.

whether wrap direction is reversed

Method: wrap-box:insert-child-after self child [sibling]
Method: insert-child-after self child [sibling]

Inserts child in the position after sibling in the list of self children.

If sibling is NULL, inserts child at the first position.

self

Passed: a <AdwWrapBox>.

a wrap box

child

Passed: a <GtkWidget>.

the widget to insert

sibling

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

the sibling after which to insert child

Procedure: wrap-box:new ⇒ %return

Creates a new <AdwWrapBox>.

%return

Returned: a <GtkWidget>.

the newly created <AdwWrapBox>

Method: wrap-box:prepend self child
Method: prepend self child

Adds child as the first child to self.

self

Passed: a <AdwWrapBox>.

a wrap box

child

Passed: a <GtkWidget>.

the widget to prepend

Method: wrap-box:remove self child
Method: remove self child

Removes a child widget from self.

The child must have been added before with wrap-box:append, wrap-box:prepend, or wrap-box:insert-child-after.

self

Passed: a <AdwWrapBox>.

a wrap box

child

Passed: a <GtkWidget>.

the child to remove

Method: wrap-box:remove-all self
Method: remove-all self

Removes all children from self.

self

Passed: a <AdwWrapBox>.

a wrap box

Method: wrap-box:reorder-child-after self child [sibling]
Method: reorder-child-after self child [sibling]

Moves child to the position after sibling in the list of self children.

If sibling is NULL, moves child to the first position.

self

Passed: a <AdwWrapBox>.

a wrap box

child

Passed: a <GtkWidget>.

the widget to move, must be a child of self

sibling

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

the sibling to move child after

Method: wrap-box:set-align self align
Method: set-align self align

Sets the alignment of the children within each line.

0 means the children are placed at the start of the line, 1 means they are placed at the end of the line. 0.5 means they are placed in the middle of the line.

Alignment is only used when WrapBox:justify is set to Adw.JustifyMode.none, or on the last line when the WrapBox:justify-last-line is FALSE.

self

Passed: a <AdwWrapBox>.

a wrap box

align

Passed: a real number.

the child alignment

Method: wrap-box:set-child-spacing self child-spacing
Method: set-child-spacing self child-spacing

Sets the spacing between widgets on the same line.

See WrapBox:child-spacing-unit.

self

Passed: a <AdwWrapBox>.

a wrap box

child-spacing

Passed: a 32-bit integer.

the child spacing

Method: wrap-box:set-child-spacing-unit self unit
Method: set-child-spacing-unit self unit

Sets the length unit for child spacing.

Allows the spacing to vary depending on the text scale factor.

See WrapBox:child-spacing.

self

Passed: a <AdwWrapBox>.

a wrap box

unit

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

the length unit

Method: wrap-box:set-justify self justify
Method: set-justify self justify

Determines whether and how each complete line should be stretched to fill the entire widget.

If set to Adw.JustifyMode.fill, each widget in the line will be stretched, keeping consistent spacing, so that the line fills the entire widget.

If set to Adw.JustifyMode.spread, the spacing between widgets will be increased, keeping widget sizes intact. The first and last widget will be aligned with the beginning and end of the line. If the line only contains a single widget, it will be stretched regardless.

If set to Adw.JustifyMode.none, the line will not be stretched and the children will be placed together within the line, according to WrapBox:align.

By default this doesn’t affect the last line, as it will be incomplete. Use WrapBox:justify-last-line to justify it as well.

self

Passed: a <AdwWrapBox>.

a wrap box

justify

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

the justify mode

Method: wrap-box:set-justify-last-line self justify-last-line
Method: set-justify-last-line self justify-last-line

Sets whether the last line should be stretched to fill the entire widget.

See WrapBox:justify.

self

Passed: a <AdwWrapBox>.

a wrap box

justify-last-line

Passed: a boolean.

whether to justify the last line

Method: wrap-box:set-line-homogeneous self homogeneous
Method: set-line-homogeneous self homogeneous

Sets whether all lines should take the same amount of space.

self

Passed: a <AdwWrapBox>.

a wrap box

homogeneous

Passed: a boolean.

whether lines should be homogeneous

Method: wrap-box:set-line-spacing self line-spacing
Method: set-line-spacing self line-spacing

Sets the spacing between lines.

self

Passed: a <AdwWrapBox>.

a wrap box

line-spacing

Passed: a 32-bit integer.

the line spacing

Method: wrap-box:set-line-spacing-unit self unit
Method: set-line-spacing-unit self unit

Sets the length unit for line spacing.

Allows the spacing to vary depending on the text scale factor.

See WrapBox:line-spacing.

self

Passed: a <AdwWrapBox>.

a wrap box

unit

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

the length unit

Method: wrap-box:set-natural-line-length self natural-line-length
Method: set-natural-line-length self natural-line-length

Sets the natural size for each line.

It should be used to limit the line lengths, for example when used in popovers.

See WrapBox:natural-line-length-unit.

self

Passed: a <AdwWrapBox>.

a wrap box

natural-line-length

Passed: a 32-bit integer.

the natural length

Method: wrap-box:set-natural-line-length-unit self unit
Method: set-natural-line-length-unit self unit

Sets the length unit for natural line length.

Allows the length to vary depending on the text scale factor.

See WrapBox:natural-line-length.

self

Passed: a <AdwWrapBox>.

a wrap box

unit

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

the length unit

Method: wrap-box:set-pack-direction self pack-direction
Method: set-pack-direction self pack-direction

Sets the direction children are packed in each line.

self

Passed: a <AdwWrapBox>.

a wrap box

pack-direction

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

the new line direction

Method: wrap-box:set-wrap-policy self wrap-policy
Method: set-wrap-policy self wrap-policy

Sets the policy for line wrapping.

If set to Adw.WrapPolicy.natural, the box will wrap to the next line as soon as the previous line cannot fit any more children without shrinking them past their natural size.

If set to Adw.WrapPolicy.minimum, the box will try to fit as many children into each line as possible, shrinking them down to their minimum\ size before wrapping to the next line.

self

Passed: a <AdwWrapBox>.

a wrap box

wrap-policy

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

the new wrap policy

Method: wrap-box:set-wrap-reverse self wrap-reverse
Method: set-wrap-reverse self wrap-reverse

Sets whether wrap direction should be reversed.

By default, lines wrap downwards in a horizontal box, and towards the end in a vertical box. If set to TRUE, they wrap upwards or towards the start respectively.

self

Passed: a <AdwWrapBox>.

a wrap box

wrap-reverse

Passed: a boolean.

whether to reverse wrap direction