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:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
d/r/w/en |
|
||
d/r/w/en |
|
||
d/r/w/en |
|
||
d/r/w/en |
|
||
d/r |
|
||
d/r/w/en |
|
||
d/r |
|
||
d/r/w/en |
|
||
d/r/w/en |
|
||
d/r |
|
||
d/r/w/en |
|
||
d/r/w/en |
|
||
d/r/w/en |
|
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Adw.Leaflet(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
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 nameleaflet
. 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:
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:
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
orNone
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
- Returns:
Whether gestures and shortcuts are enabled.
- Return type:
Gets whether gestures and shortcuts for navigating backward are enabled.
Deprecated since version 1.4: See the migration guide
- Returns:
Whether gestures and shortcuts are enabled.
- Return type:
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:
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
orNone
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:
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:
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:
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:
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:
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:
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:
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:
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:
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
orNone
Gets the widget currently visible when the leaflet is folded.
Deprecated since version 1.4: See the migration guide
- get_visible_child_name()¶
-
Gets the name of the currently visible child widget.
Deprecated since version 1.4: See the migration guide
- insert_child_after(child, sibling)¶
- Parameters:
child (
Gtk.Widget
) – the widget to insertsibling (
Gtk.Widget
orNone
) – the sibling after which to insert child
- Returns:
the [class`LeafletPage`] for child
- Return type:
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
- Parameters:
direction (
Adw.NavigationDirection
) – the direction- Returns:
whether the visible child was changed
- Return type:
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:
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 selfsibling (
Gtk.Widget
orNone
) – 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
- 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
- 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. WithADW_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¶
- Name:
can-navigate-back
- Type:
- Default Value:
- Flags:
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
- Name:
can-navigate-forward
- Type:
- Default Value:
- Flags:
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:
- Default Value:
- Flags:
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:
- Default Value:
- Flags:
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:
- Default Value:
- Flags:
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:
- Default Value:
- Flags:
Determines when the leaflet will fold.
If set to
ADW_FOLD_THRESHOLD_POLICY_MINIMUM
, it will only fold when the children cannot fit anymore. WithADW_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:
- Default Value:
- Flags:
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:
- Default Value:
- Flags:
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:
- Default Value:
250
- Flags:
The mode transition animation duration, in milliseconds.
Deprecated since version 1.4: See the migration guide
- Adw.Leaflet.props.pages¶
- Name:
pages
- Type:
- Default Value:
- Flags:
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:
- Default Value:
- Flags:
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:
- Default Value:
- Flags:
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:
- Default Value:
- Flags:
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