Adw.Squeezer

g Adw.Squeezer Adw.Squeezer GObject.GInterface GObject.GInterface Gtk.Accessible Gtk.Accessible GObject.GInterface->Gtk.Accessible Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.ConstraintTarget Gtk.ConstraintTarget GObject.GInterface->Gtk.ConstraintTarget Gtk.Orientable Gtk.Orientable GObject.GInterface->Gtk.Orientable GObject.InitiallyUnowned GObject.InitiallyUnowned Gtk.Widget Gtk.Widget GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Accessible->Gtk.Widget Gtk.Buildable->Gtk.Widget Gtk.ConstraintTarget->Gtk.Widget Gtk.Orientable->Adw.Squeezer Gtk.Widget->Adw.Squeezer

Subclasses:

None

Methods

Inherited:

Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1), Gtk.Orientable (2)

Structs:

Gtk.WidgetClass (18), GObject.ObjectClass (5)

class

new ()

add (child)

get_allow_none ()

get_homogeneous ()

get_interpolate_size ()

get_page (child)

get_pages ()

get_switch_threshold_policy ()

get_transition_duration ()

get_transition_running ()

get_transition_type ()

get_visible_child ()

get_xalign ()

get_yalign ()

remove (child)

set_allow_none (allow_none)

set_homogeneous (homogeneous)

set_interpolate_size (interpolate_size)

set_switch_threshold_policy (policy)

set_transition_duration (duration)

set_transition_type (transition)

set_xalign (xalign)

set_yalign (yalign)

Virtual Methods

Inherited:

Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9)

Properties

Inherited:

Gtk.Widget (34), Gtk.Accessible (1), Gtk.Orientable (1)

Name

Type

Flags

Short Description

allow-none

bool

d/r/w/en

deprecated

homogeneous

bool

d/r/w/en

deprecated

interpolate-size

bool

d/r/w/en

deprecated

pages

Gtk.SelectionModel

d/r

deprecated

switch-threshold-policy

Adw.FoldThresholdPolicy

d/r/w/en

deprecated

transition-duration

int

d/r/w/en

deprecated

transition-running

bool

d/r

deprecated

transition-type

Adw.SqueezerTransitionType

d/r/w/en

deprecated

visible-child

Gtk.Widget

d/r

deprecated

xalign

float

d/r/w/en

deprecated

yalign

float

d/r/w/en

deprecated

Signals

Inherited:

Gtk.Widget (13), GObject.Object (1)

Fields

Inherited:

Gtk.Widget (13), GObject.Object (1)

Class Details

class Adw.Squeezer(**kwargs)
Bases:

Gtk.Widget, Gtk.Orientable

Abstract:

No

Structure:

Adw.SqueezerClass

A best fit container.

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

The AdwSqueezer widget is a container which only shows the first of its children that fits in the available size. It is convenient to offer different widgets to represent the same data with different levels of detail, making the widget seem to squeeze itself to fit in the available space.

Transitions between children can be animated as fades. This can be controlled with [property`Squeezer`:py:data::transition-type<Adw.Squeezer.props.transition_type>].

CSS nodes

AdwSqueezer has a single CSS node with name squeezer.

Deprecated since version 1.4: See the migration guide

classmethod new()
Returns:

the newly created AdwSqueezer

Return type:

Gtk.Widget

Creates a new AdwSqueezer.

Deprecated since version 1.4: See the migration guide

add(child)
Parameters:

child (Gtk.Widget) – the widget to add

Returns:

the [class`SqueezerPage`] for child

Return type:

Adw.SqueezerPage

Adds a child to self.

Deprecated since version 1.4: See the migration guide

get_allow_none()
Returns:

whether self allows squeezing beyond the last child

Return type:

bool

Gets whether to allow squeezing beyond the last child’s minimum size.

Deprecated since version 1.4: See the migration guide

get_homogeneous()
Returns:

whether self is homogeneous

Return type:

bool

Gets whether all children have the same size for the opposite orientation.

Deprecated since version 1.4: See the migration guide

get_interpolate_size()
Returns:

whether the size is interpolated

Return type:

bool

Gets whether self interpolates its size when changing the visible child.

Deprecated since version 1.4: See the migration guide

get_page(child)
Parameters:

child (Gtk.Widget) – a child of self

Returns:

the page object for child

Return type:

Adw.SqueezerPage

Returns the [class`SqueezerPage`] object for child.

Deprecated since version 1.4: See the migration guide

get_pages()
Returns:

a GtkSelectionModel for the squeezer’s children

Return type:

Gtk.SelectionModel

Returns a [iface`Gio`.ListModel] that contains the pages of self.

This can be used to keep an up-to-date view. The model also implements [iface`Gtk`.SelectionModel] and can be used to track the visible page.

Deprecated since version 1.4: See the migration guide

get_switch_threshold_policy()
Returns:

the fold threshold policy

Return type:

Adw.FoldThresholdPolicy

Gets the switch threshold policy for self.

Deprecated since version 1.4: See the migration guide

get_transition_duration()
Returns:

the transition duration, in milliseconds

Return type:

int

Gets the transition animation duration for self.

Deprecated since version 1.4: See the migration guide

get_transition_running()
Returns:

whether a transition is currently running

Return type:

bool

Gets whether a transition is currently running for self.

If a transition is impossible, the property value will be set to TRUE and then immediately to FALSE, so it’s possible to rely on its notifications to know that a transition has happened.

Deprecated since version 1.4: See the migration guide

get_transition_type()
Returns:

the current transition type of self

Return type:

Adw.SqueezerTransitionType

Gets the type of animation used for transitions between children in self.

Deprecated since version 1.4: See the migration guide

get_visible_child()
Returns:

the visible child

Return type:

Gtk.Widget or None

Gets the currently visible child of self.

Deprecated since version 1.4: See the migration guide

get_xalign()
Returns:

the alignment value

Return type:

float

Gets the horizontal alignment, from 0 (start) to 1 (end).

Deprecated since version 1.4: See the migration guide

get_yalign()
Returns:

the alignment value

Return type:

float

Gets the vertical alignment, from 0 (top) to 1 (bottom).

Deprecated since version 1.4: See the migration guide

remove(child)
Parameters:

child (Gtk.Widget) – the child to remove

Removes a child widget from self.

Deprecated since version 1.4: See the migration guide

set_allow_none(allow_none)
Parameters:

allow_none (bool) – whether self allows squeezing beyond the last child

Sets whether to allow squeezing beyond the last child’s minimum size.

If set to TRUE, the squeezer can shrink to the point where no child can be shown. This is functionally equivalent to appending a widget with 0×0 minimum size.

Deprecated since version 1.4: See the migration guide

set_homogeneous(homogeneous)
Parameters:

homogeneous (bool) – whether self is homogeneous

Sets whether all children have the same size for the opposite orientation.

For example, if a squeezer is horizontal and is homogeneous, it will request the same height for all its children. If it isn’t, the squeezer may change size when a different child becomes visible.

Deprecated since version 1.4: See the migration guide

set_interpolate_size(interpolate_size)
Parameters:

interpolate_size (bool) – whether to interpolate the size

Sets whether self interpolates its size when changing the visible child.

If TRUE, the squeezer will interpolate its size between the one of the previous visible child and the one of the new visible child, according to the set transition duration and the orientation, e.g. if the squeezer is horizontal, it will interpolate the its height.

Deprecated since version 1.4: See the migration guide

set_switch_threshold_policy(policy)
Parameters:

policy (Adw.FoldThresholdPolicy) – the policy to use

Sets the switch threshold policy for self.

Determines when the squeezer will switch children.

If set to ADW_FOLD_THRESHOLD_POLICY_MINIMUM, it will only switch when the visible child cannot fit anymore. With ADW_FOLD_THRESHOLD_POLICY_NATURAL, it will switch as soon as the visible child doesn’t get their natural size.

This can be useful if you have a long ellipsizing label and want to let it ellipsize instead of immediately switching.

Deprecated since version 1.4: See the migration guide

set_transition_duration(duration)
Parameters:

duration (int) – the new duration, in milliseconds

Sets the transition animation duration for self.

Deprecated since version 1.4: See the migration guide

set_transition_type(transition)
Parameters:

transition (Adw.SqueezerTransitionType) – the new transition type

Sets the type of animation used for transitions between children in self.

Deprecated since version 1.4: See the migration guide

set_xalign(xalign)
Parameters:

xalign (float) – the new alignment value

Sets the horizontal alignment, from 0 (start) to 1 (end).

This affects the children allocation during transitions, when they exceed the size of the squeezer.

For example, 0.5 means the child will be centered, 0 means it will keep the start side aligned and overflow the end side, and 1 means the opposite.

Deprecated since version 1.4: See the migration guide

set_yalign(yalign)
Parameters:

yalign (float) – the new alignment value

Sets the vertical alignment, from 0 (top) to 1 (bottom).

This affects the children allocation during transitions, when they exceed the size of the squeezer.

For example, 0.5 means the child will be centered, 0 means it will keep the top side aligned and overflow the bottom side, and 1 means the opposite.

Deprecated since version 1.4: See the migration guide

Property Details

Adw.Squeezer.props.allow_none
Name:

allow-none

Type:

bool

Default Value:

False

Flags:

DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether to allow squeezing beyond the last child’s minimum size.

If set to TRUE, the squeezer can shrink to the point where no child can be shown. This is functionally equivalent to appending a widget with 0×0 minimum size.

Deprecated since version 1.4: See the migration guide

Adw.Squeezer.props.homogeneous
Name:

homogeneous

Type:

bool

Default Value:

False

Flags:

DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether all children have the same size for the opposite orientation.

For example, if a squeezer is horizontal and is homogeneous, it will request the same height for all its children. If it isn’t, the squeezer may change size when a different child becomes visible.

Deprecated since version 1.4: See the migration guide

Adw.Squeezer.props.interpolate_size
Name:

interpolate-size

Type:

bool

Default Value:

False

Flags:

DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether the squeezer interpolates its size when changing the visible child.

If TRUE, the squeezer will interpolate its size between the one of the previous visible child and the one of the new visible child, according to the set transition duration and the orientation, e.g. if the squeezer is horizontal, it will interpolate the its height.

Deprecated since version 1.4: See the migration guide

Adw.Squeezer.props.pages
Name:

pages

Type:

Gtk.SelectionModel

Default Value:

None

Flags:

DEPRECATED, READABLE

A selection model with the squeezer’s pages.

This can be used to keep an up-to-date view. The model also implements [iface`Gtk`.SelectionModel] and can be used to track the visible page.

Deprecated since version 1.4: See the migration guide

Adw.Squeezer.props.switch_threshold_policy
Name:

switch-threshold-policy

Type:

Adw.FoldThresholdPolicy

Default Value:

Adw.FoldThresholdPolicy.NATURAL

Flags:

DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

The switch threshold policy.

Determines when the squeezer will switch children.

If set to ADW_FOLD_THRESHOLD_POLICY_MINIMUM, it will only switch when the visible child cannot fit anymore. With ADW_FOLD_THRESHOLD_POLICY_NATURAL, it will switch as soon as the visible child doesn’t get their natural size.

This can be useful if you have a long ellipsizing label and want to let it ellipsize instead of immediately switching.

Deprecated since version 1.4: See the migration guide

Adw.Squeezer.props.transition_duration
Name:

transition-duration

Type:

int

Default Value:

200

Flags:

DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

The transition animation duration, in milliseconds.

Deprecated since version 1.4: See the migration guide

Adw.Squeezer.props.transition_running
Name:

transition-running

Type:

bool

Default Value:

False

Flags:

DEPRECATED, READABLE

Whether a transition is currently running.

If a transition is impossible, the property value will be set to TRUE and then immediately to FALSE, so it’s possible to rely on its notifications to know that a transition has happened.

Deprecated since version 1.4: See the migration guide

Adw.Squeezer.props.transition_type
Name:

transition-type

Type:

Adw.SqueezerTransitionType

Default Value:

Adw.SqueezerTransitionType.NONE

Flags:

DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

The type of animation used for transitions between children.

Deprecated since version 1.4: See the migration guide

Adw.Squeezer.props.visible_child
Name:

visible-child

Type:

Gtk.Widget

Default Value:

None

Flags:

DEPRECATED, READABLE

The currently visible child.

Deprecated since version 1.4: See the migration guide

Adw.Squeezer.props.xalign
Name:

xalign

Type:

float

Default Value:

0.5

Flags:

DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

The horizontal alignment, from 0 (start) to 1 (end).

This affects the children allocation during transitions, when they exceed the size of the squeezer.

For example, 0.5 means the child will be centered, 0 means it will keep the start side aligned and overflow the end side, and 1 means the opposite.

Deprecated since version 1.4: See the migration guide

Adw.Squeezer.props.yalign
Name:

yalign

Type:

float

Default Value:

0.5

Flags:

DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

The vertical alignment, from 0 (top) to 1 (bottom).

This affects the children allocation during transitions, when they exceed the size of the squeezer.

For example, 0.5 means the child will be centered, 0 means it will keep the top side aligned and overflow the bottom side, and 1 means the opposite.

Deprecated since version 1.4: See the migration guide