Adw.Leaflet

g Adw.Leaflet Adw.Leaflet Adw.Swipeable Adw.Swipeable Adw.Swipeable->Adw.Leaflet GObject.GInterface GObject.GInterface GObject.GInterface->Adw.Swipeable 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.Leaflet Gtk.Widget->Adw.Leaflet

Subclasses:

None

Methods

Inherited:

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

Structs:

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

class

new ()

append (child)

get_adjacent_child (direction)

get_can_navigate_back ()

get_can_navigate_forward ()

get_can_unfold ()

get_child_by_name (name)

get_child_transition_params ()

get_child_transition_running ()

get_fold_threshold_policy ()

get_folded ()

get_homogeneous ()

get_mode_transition_duration ()

get_page (child)

get_pages ()

get_transition_type ()

get_visible_child ()

get_visible_child_name ()

insert_child_after (child, sibling)

navigate (direction)

prepend (child)

remove (child)

reorder_child_after (child, sibling)

set_can_navigate_back (can_navigate_back)

set_can_navigate_forward (can_navigate_forward)

set_can_unfold (can_unfold)

set_child_transition_params (params)

set_fold_threshold_policy (policy)

set_homogeneous (homogeneous)

set_mode_transition_duration (duration)

set_transition_type (transition)

set_visible_child (visible_child)

set_visible_child_name (name)

Virtual Methods

Inherited:

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

Properties

Inherited:

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

Name

Type

Flags

Short Description

can-navigate-back

bool

d/r/w/en

deprecated

can-navigate-forward

bool

d/r/w/en

deprecated

can-unfold

bool

d/r/w/en

deprecated

child-transition-params

Adw.SpringParams

d/r/w/en

deprecated

child-transition-running

bool

d/r

deprecated

fold-threshold-policy

Adw.FoldThresholdPolicy

d/r/w/en

deprecated

folded

bool

d/r

deprecated

homogeneous

bool

d/r/w/en

deprecated

mode-transition-duration

int

d/r/w/en

deprecated

pages

Gtk.SelectionModel

d/r

deprecated

transition-type

Adw.LeafletTransitionType

d/r/w/en

deprecated

visible-child

Gtk.Widget

d/r/w/en

deprecated

visible-child-name

str

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.Leaflet(**kwargs)
Bases:

Gtk.Widget, Adw.Swipeable, Gtk.Orientable

Abstract:

No

Structure:

Adw.LeafletClass

An adaptive container acting like a box or a stack.

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

The AdwLeaflet widget can display its children like a [class`Gtk`.Box] does or like a [class`Gtk`.Stack] does, adapting to size changes by switching between the two modes.

When there is enough space the children are displayed side by side, otherwise only one is displayed and the leaflet is said to be “folded”. The threshold is dictated by the preferred minimum sizes of the children. When a leaflet is folded, the children can be navigated using swipe gestures.

The “over” and “under” transition types stack the children one on top of the other, while the “slide” transition puts the children side by side. While navigating to a child on the side or below can be performed by swiping the current child away, navigating to an upper child requires dragging it from the edge where it resides. This doesn’t affect non-dragging swipes.

CSS nodes

AdwLeaflet has a single CSS node with name leaflet. The node will get the style classes .folded when it is folded, .unfolded when it’s not, or none if it hasn’t computed its fold yet.

Deprecated since version 1.4: See the migration guide

classmethod new()
Returns:

the new created AdwLeaflet

Return type:

Gtk.Widget

Creates a new AdwLeaflet.

Deprecated since version 1.4: See the migration guide

append(child)
Parameters:

child (Gtk.Widget) – the widget to add

Returns:

the [class`LeafletPage`] for child

Return type:

Adw.LeafletPage

Adds a child to self.

Deprecated since version 1.4: See the migration guide

get_adjacent_child(direction)
Parameters:

direction (Adw.NavigationDirection) – the direction

Returns:

the previous or next child

Return type:

Gtk.Widget or None

Finds the previous or next navigatable child.

This will be the same child [method`Leaflet`.navigate] or swipe gestures will navigate to.

If there’s no child to navigate to, NULL will be returned instead.

See [property`LeafletPage`:py:data::navigatable<Adw.Leaflet.props.navigatable>].

Deprecated since version 1.4: See the migration guide

get_can_navigate_back()
Returns:

Whether gestures and shortcuts are enabled.

Return type:

bool

Gets whether gestures and shortcuts for navigating backward are enabled.

Deprecated since version 1.4: See the migration guide

get_can_navigate_forward()
Returns:

Whether gestures and shortcuts are enabled.

Return type:

bool

Gets whether gestures and shortcuts for navigating forward are enabled.

Deprecated since version 1.4: See the migration guide

get_can_unfold()
Returns:

whether self can unfold

Return type:

bool

Gets whether self can unfold.

Deprecated since version 1.4: See the migration guide

get_child_by_name(name)
Parameters:

name (str) – the name of the child to find

Returns:

the requested child of self

Return type:

Gtk.Widget or None

Finds the child of self with name.

Returns NULL if there is no child with this name.

See [property`LeafletPage`:py:data::name<Adw.Leaflet.props.name>].

Deprecated since version 1.4: See the migration guide

get_child_transition_params()
Returns:

the child transition parameters

Return type:

Adw.SpringParams

Gets the child transition spring parameters for self.

Deprecated since version 1.4: See the migration guide

get_child_transition_running()
Returns:

whether a transition is currently running

Return type:

bool

Gets whether a child transition is currently running for self.

Deprecated since version 1.4: See the migration guide

get_fold_threshold_policy()
Returns:

the fold threshold policy

Return type:

Adw.FoldThresholdPolicy

Gets the fold threshold policy for self.

Deprecated since version 1.4: See the migration guide

get_folded()
Returns:

whether self is folded.

Return type:

bool

Gets whether self is folded.

The leaflet will be folded if the size allocated to it is smaller than the sum of the minimum or natural sizes of the children (see [property`Leaflet`:py:data::fold-threshold-policy<Adw.Leaflet.props.fold_threshold_policy>]), it will be unfolded otherwise.

Deprecated since version 1.4: See the migration guide

get_homogeneous()
Returns:

whether self is homogeneous

Return type:

bool

Gets whether self is homogeneous.

Deprecated since version 1.4: See the migration guide

get_mode_transition_duration()
Returns:

the mode transition duration, in milliseconds.

Return type:

int

Gets the mode transition animation duration for self.

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.LeafletPage

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

Deprecated since version 1.4: See the migration guide

get_pages()
Returns:

a GtkSelectionModel for the leaflet’s children

Return type:

Gtk.SelectionModel

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

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

Deprecated since version 1.4: See the migration guide

get_transition_type()
Returns:

the current transition type of self

Return type:

Adw.LeafletTransitionType

Gets the type of animation used for transitions between modes and children.

Deprecated since version 1.4: See the migration guide

get_visible_child()
Returns:

the visible child

Return type:

Gtk.Widget or None

Gets the widget currently visible when the leaflet is folded.

Deprecated since version 1.4: See the migration guide

get_visible_child_name()
Returns:

the name of the visible child

Return type:

str or None

Gets the name of the currently visible child widget.

Deprecated since version 1.4: See the migration guide

insert_child_after(child, sibling)
Parameters:
Returns:

the [class`LeafletPage`] for child

Return type:

Adw.LeafletPage

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

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

Deprecated since version 1.4: See the migration guide

navigate(direction)
Parameters:

direction (Adw.NavigationDirection) – the direction

Returns:

whether the visible child was changed

Return type:

bool

Navigates to the previous or next child.

The child must have the [property`LeafletPage`:py:data::navigatable<Adw.Leaflet.props.navigatable>] property set to TRUE, otherwise it will be skipped.

This will be the same child as returned by [method`Leaflet`.get_adjacent_child] or navigated to via swipe gestures.

Deprecated since version 1.4: See the migration guide

prepend(child)
Parameters:

child (Gtk.Widget) – the widget to prepend

Returns:

the [class`LeafletPage`] for child

Return type:

Adw.LeafletPage

Inserts child at the first position in self.

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

reorder_child_after(child, sibling)
Parameters:
  • child (Gtk.Widget) – the widget to move, must be a child of self

  • sibling (Gtk.Widget or None) – the sibling to move child after

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

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

Deprecated since version 1.4: See the migration guide

set_can_navigate_back(can_navigate_back)
Parameters:

can_navigate_back (bool) – the new value

Sets whether gestures and shortcuts for navigating backward are enabled.

The supported gestures are:

  • One-finger swipe on touchscreens

  • Horizontal scrolling on touchpads (usually two-finger swipe)

  • Back/forward mouse buttons

The keyboard back/forward keys are also supported, as well as the <kbd>Alt</kbd>+<kbd>←</kbd> shortcut for horizontal orientation, or <kbd>Alt</kbd>+<kbd>↑</kbd> for vertical orientation.

If the orientation is horizontal, for right-to-left locales, gestures and shortcuts are reversed.

Only children that have [property`LeafletPage`:py:data::navigatable<Adw.Leaflet.props.navigatable>] set to TRUE can be navigated to.

Deprecated since version 1.4: See the migration guide

set_can_navigate_forward(can_navigate_forward)
Parameters:

can_navigate_forward (bool) – the new value

Sets whether gestures and shortcuts for navigating forward are enabled.

The supported gestures are:

  • One-finger swipe on touchscreens

  • Horizontal scrolling on touchpads (usually two-finger swipe)

  • Back/forward mouse buttons

The keyboard back/forward keys are also supported, as well as the <kbd>Alt</kbd>+<kbd>→</kbd> shortcut for horizontal orientation, or <kbd>Alt</kbd>+<kbd>↓</kbd> for vertical orientation.

If the orientation is horizontal, for right-to-left locales, gestures and shortcuts are reversed.

Only children that have [property`LeafletPage`:py:data::navigatable<Adw.Leaflet.props.navigatable>] set to TRUE can be navigated to.

Deprecated since version 1.4: See the migration guide

set_can_unfold(can_unfold)
Parameters:

can_unfold (bool) – whether self can unfold

Sets whether self can unfold.

Deprecated since version 1.4: See the migration guide

set_child_transition_params(params)
Parameters:

params (Adw.SpringParams) – the new parameters

Sets the child transition spring parameters for self.

The default value is equivalent to:

``c adw_spring_params_new (1, 0.5, 500) ``

Deprecated since version 1.4: See the migration guide

set_fold_threshold_policy(policy)
Parameters:

policy (Adw.FoldThresholdPolicy) – the policy to use

Sets the fold threshold policy for self.

If set to ADW_FOLD_THRESHOLD_POLICY_MINIMUM, it will only fold when the children cannot fit anymore. With ADW_FOLD_THRESHOLD_POLICY_NATURAL, it will fold as soon as children don’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 folding.

Deprecated since version 1.4: See the migration guide

set_homogeneous(homogeneous)
Parameters:

homogeneous (bool) – whether to make self homogeneous

Sets self to be homogeneous or not.

If set to FALSE, different children can have different size along the opposite orientation.

Deprecated since version 1.4: See the migration guide

set_mode_transition_duration(duration)
Parameters:

duration (int) – the new duration, in milliseconds

Sets the mode transition animation duration for self.

Deprecated since version 1.4: See the migration guide

set_transition_type(transition)
Parameters:

transition (Adw.LeafletTransitionType) – the new transition type

Sets the type of animation used for transitions between modes and children.

The transition type can be changed without problems at runtime, so it is possible to change the animation based on the mode or child that is about to become current.

Deprecated since version 1.4: See the migration guide

set_visible_child(visible_child)
Parameters:

visible_child (Gtk.Widget) – the new child

Sets the widget currently visible when the leaflet is folded.

The transition is determined by [property`Leaflet`:py:data::transition-type<Adw.Leaflet.props.transition_type>] and [property`Leaflet`:py:data::child-transition-params<Adw.Leaflet.props.child_transition_params>]. The transition can be cancelled by the user, in which case visible child will change back to the previously visible child.

Deprecated since version 1.4: See the migration guide

set_visible_child_name(name)
Parameters:

name (str) – the name of a child

Makes the child with the name name visible.

See [property`Leaflet`:py:data::visible-child<Adw.Leaflet.props.visible_child>].

Deprecated since version 1.4: See the migration guide

Property Details

Adw.Leaflet.props.can_navigate_back
Name:

can-navigate-back

Type:

bool

Default Value:

False

Flags:

DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether gestures and shortcuts for navigating backward are enabled.

The supported gestures are:

  • One-finger swipe on touchscreens

  • Horizontal scrolling on touchpads (usually two-finger swipe)

  • Back/forward mouse buttons

The keyboard back/forward keys are also supported, as well as the <kbd>Alt</kbd>+<kbd>←</kbd> shortcut for horizontal orientation, or <kbd>Alt</kbd>+<kbd>↑</kbd> for vertical orientation.

If the orientation is horizontal, for right-to-left locales, gestures and shortcuts are reversed.

Only children that have [property`LeafletPage`:py:data::navigatable<Adw.Leaflet.props.navigatable>] set to TRUE can be navigated to.

Deprecated since version 1.4: See the migration guide

Adw.Leaflet.props.can_navigate_forward
Name:

can-navigate-forward

Type:

bool

Default Value:

False

Flags:

DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether gestures and shortcuts for navigating forward are enabled.

The supported gestures are:

  • One-finger swipe on touchscreens

  • Horizontal scrolling on touchpads (usually two-finger swipe)

  • Back/forward mouse buttons

The keyboard back/forward keys are also supported, as well as the <kbd>Alt</kbd>+<kbd>→</kbd> shortcut for horizontal orientation, or <kbd>Alt</kbd>+<kbd>↓</kbd> for vertical orientation.

If the orientation is horizontal, for right-to-left locales, gestures and shortcuts are reversed.

Only children that have [property`LeafletPage`:py:data::navigatable<Adw.Leaflet.props.navigatable>] set to TRUE can be navigated to.

Deprecated since version 1.4: See the migration guide

Adw.Leaflet.props.can_unfold
Name:

can-unfold

Type:

bool

Default Value:

True

Flags:

DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether or not the leaflet can unfold.

Deprecated since version 1.4: See the migration guide

Adw.Leaflet.props.child_transition_params
Name:

child-transition-params

Type:

Adw.SpringParams

Default Value:

None

Flags:

DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

The child transition spring parameters.

The default value is equivalent to:

``c adw_spring_params_new (1, 0.5, 500) ``

Deprecated since version 1.4: See the migration guide

Adw.Leaflet.props.child_transition_running
Name:

child-transition-running

Type:

bool

Default Value:

False

Flags:

DEPRECATED, READABLE

Whether a child transition is currently running.

Deprecated since version 1.4: See the migration guide

Adw.Leaflet.props.fold_threshold_policy
Name:

fold-threshold-policy

Type:

Adw.FoldThresholdPolicy

Default Value:

Adw.FoldThresholdPolicy.MINIMUM

Flags:

DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

Determines when the leaflet will fold.

If set to ADW_FOLD_THRESHOLD_POLICY_MINIMUM, it will only fold when the children cannot fit anymore. With ADW_FOLD_THRESHOLD_POLICY_NATURAL, it will fold as soon as children don’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 folding.

Deprecated since version 1.4: See the migration guide

Adw.Leaflet.props.folded
Name:

folded

Type:

bool

Default Value:

False

Flags:

DEPRECATED, READABLE

Whether the leaflet is folded.

The leaflet will be folded if the size allocated to it is smaller than the sum of the minimum or natural sizes of the children (see [property`Leaflet`:py:data::fold-threshold-policy<Adw.Leaflet.props.fold_threshold_policy>]), it will be unfolded otherwise.

Deprecated since version 1.4: See the migration guide

Adw.Leaflet.props.homogeneous
Name:

homogeneous

Type:

bool

Default Value:

True

Flags:

DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether the leaflet allocates the same size for all children when folded.

If set to FALSE, different children can have different size along the opposite orientation.

Deprecated since version 1.4: See the migration guide

Adw.Leaflet.props.mode_transition_duration
Name:

mode-transition-duration

Type:

int

Default Value:

250

Flags:

DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

The mode transition animation duration, in milliseconds.

Deprecated since version 1.4: See the migration guide

Adw.Leaflet.props.pages
Name:

pages

Type:

Gtk.SelectionModel

Default Value:

None

Flags:

DEPRECATED, READABLE

A selection model with the leaflet’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 and change the visible page.

Deprecated since version 1.4: See the migration guide

Adw.Leaflet.props.transition_type
Name:

transition-type

Type:

Adw.LeafletTransitionType

Default Value:

Adw.LeafletTransitionType.OVER

Flags:

DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

The type of animation used for transitions between modes and children.

The transition type can be changed without problems at runtime, so it is possible to change the animation based on the mode or child that is about to become current.

Deprecated since version 1.4: See the migration guide

Adw.Leaflet.props.visible_child
Name:

visible-child

Type:

Gtk.Widget

Default Value:

None

Flags:

DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

The widget currently visible when the leaflet is folded.

The transition is determined by [property`Leaflet`:py:data::transition-type<Adw.Leaflet.props.transition_type>] and [property`Leaflet`:py:data::child-transition-params<Adw.Leaflet.props.child_transition_params>]. The transition can be cancelled by the user, in which case visible child will change back to the previously visible child.

Deprecated since version 1.4: See the migration guide

Adw.Leaflet.props.visible_child_name
Name:

visible-child-name

Type:

str

Default Value:

None

Flags:

DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY

The name of the widget currently visible when the leaflet is folded.

See [property`Leaflet`:py:data::visible-child<Adw.Leaflet.props.visible_child>].

Deprecated since version 1.4: See the migration guide