Adw.ClampLayout

g Adw.ClampLayout Adw.ClampLayout GObject.GInterface GObject.GInterface Gtk.Orientable Gtk.Orientable GObject.GInterface->Gtk.Orientable GObject.Object GObject.Object Gtk.LayoutManager Gtk.LayoutManager GObject.Object->Gtk.LayoutManager Gtk.LayoutManager->Adw.ClampLayout Gtk.Orientable->Adw.ClampLayout

Subclasses:

None

Methods

Inherited:

Gtk.LayoutManager (6), GObject.Object (37), Gtk.Orientable (2)

Structs:

GObject.ObjectClass (5)

class

new ()

get_maximum_size ()

get_tightening_threshold ()

get_unit ()

set_maximum_size (maximum_size)

set_tightening_threshold (tightening_threshold)

set_unit (unit)

Virtual Methods

Inherited:

Gtk.LayoutManager (6), GObject.Object (7)

Properties

Inherited:

Gtk.Orientable (1)

Name

Type

Flags

Short Description

maximum-size

int

r/w/en

tightening-threshold

int

r/w/en

unit

Adw.LengthUnit

r/w/en

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Adw.ClampLayout(**kwargs)
Bases:

Gtk.LayoutManager, Gtk.Orientable

Abstract:

No

Structure:

Adw.ClampLayoutClass

A layout manager constraining its children to a given size.

<picture> <source srcset=”clamp-wide-dark.png” media=”(prefers-color-scheme: dark)”> <img src=”clamp-wide.png” alt=”clamp-wide”> </picture> <picture> <source srcset=”clamp-narrow-dark.png” media=”(prefers-color-scheme: dark)”> <img src=”clamp-narrow.png” alt=”clamp-narrow”> </picture>

AdwClampLayout constraints the size of the widgets it contains to a given maximum size. It will constrain the width if it is horizontal, or the height if it is vertical. The expansion of the children from their minimum to their maximum size is eased out for a smooth transition.

If a child requires more than the requested maximum size, it will be allocated the minimum size it can fit in instead.

AdwClampLayout can scale with the text scale factor, use the [property`ClampLayout`:py:data::unit<Adw.ClampLayout.props.unit>] property to enable that behavior.

classmethod new()
Returns:

the newly created AdwClampLayout

Return type:

Gtk.LayoutManager

Creates a new AdwClampLayout.

get_maximum_size()
Returns:

the maximum size to allocate to the children

Return type:

int

Gets the maximum size allocated to the children.

get_tightening_threshold()
Returns:

the size above which the children are clamped

Return type:

int

Gets the size above which the children are clamped.

get_unit()
Returns:

the length unit

Return type:

Adw.LengthUnit

Gets the length unit for maximum size and tightening threshold.

New in version 1.4.

set_maximum_size(maximum_size)
Parameters:

maximum_size (int) – the maximum size

Sets the maximum size allocated to the children.

It is the width if the layout is horizontal, or the height if it is vertical.

set_tightening_threshold(tightening_threshold)
Parameters:

tightening_threshold (int) – the tightening threshold

Sets the size above which the children are clamped.

Starting from this size, the layout will tighten its grip on the children, slowly allocating less and less of the available size up to the maximum allocated size. Below that threshold and below the maximum size, the children will be allocated all the available size.

If the threshold is greater than the maximum size to allocate to the children, they will be allocated the whole size up to the maximum. If the threshold is lower than the minimum size to allocate to the children, that size will be used as the tightening threshold.

Effectively, tightening the grip on a child before it reaches its maximum size makes transitions to and from the maximum size smoother when resizing.

set_unit(unit)
Parameters:

unit (Adw.LengthUnit) – the length unit

Sets the length unit for maximum size and tightening threshold.

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

New in version 1.4.

Property Details

Adw.ClampLayout.props.maximum_size
Name:

maximum-size

Type:

int

Default Value:

600

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The maximum size to allocate to the children.

It is the width if the layout is horizontal, or the height if it is vertical.

Adw.ClampLayout.props.tightening_threshold
Name:

tightening-threshold

Type:

int

Default Value:

400

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The size above which the children are clamped.

Starting from this size, the layout will tighten its grip on the children, slowly allocating less and less of the available size up to the maximum allocated size. Below that threshold and below the maximum size, the children will be allocated all the available size.

If the threshold is greater than the maximum size to allocate to the children, they will be allocated the whole size up to the maximum. If the threshold is lower than the minimum size to allocate to the children, that size will be used as the tightening threshold.

Effectively, tightening the grip on a child before it reaches its maximum size makes transitions to and from the maximum size smoother when resizing.

Adw.ClampLayout.props.unit
Name:

unit

Type:

Adw.LengthUnit

Default Value:

Adw.LengthUnit.SP

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The length unit for maximum size and tightening threshold.

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

New in version 1.4.