Handy.Leaflet

g Atk.ImplementorIface Atk.ImplementorIface Gtk.Widget Gtk.Widget Atk.ImplementorIface->Gtk.Widget GObject.GInterface GObject.GInterface GObject.GInterface->Atk.ImplementorIface Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.Orientable Gtk.Orientable GObject.GInterface->Gtk.Orientable Handy.Swipeable Handy.Swipeable GObject.GInterface->Handy.Swipeable GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Buildable->Gtk.Widget Gtk.Container Gtk.Container Handy.Leaflet Handy.Leaflet Gtk.Container->Handy.Leaflet Gtk.Orientable->Handy.Leaflet Gtk.Widget->Gtk.Container Handy.Swipeable->Handy.Leaflet

Subclasses:

None

Methods

Inherited:

Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10), Gtk.Orientable (2), Handy.Swipeable (8)

Structs:

Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)

class

new ()

get_adjacent_child (direction)

get_can_swipe_back ()

get_can_swipe_forward ()

get_child_by_name (name)

get_child_transition_duration ()

get_child_transition_running ()

get_folded ()

get_homogeneous (folded, orientation)

get_interpolate_size ()

get_mode_transition_duration ()

get_transition_type ()

get_visible_child ()

get_visible_child_name ()

insert_child_after (child, sibling)

navigate (direction)

prepend (child)

reorder_child_after (child, sibling)

set_can_swipe_back (can_swipe_back)

set_can_swipe_forward (can_swipe_forward)

set_child_transition_duration (duration)

set_homogeneous (folded, orientation, homogeneous)

set_interpolate_size (interpolate_size)

set_mode_transition_duration (duration)

set_transition_type (transition)

set_visible_child (visible_child)

set_visible_child_name (name)

Virtual Methods

Inherited:

Gtk.Container (10), Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10), Handy.Swipeable (7)

Properties

Inherited:

Gtk.Container (3), Gtk.Widget (39), Gtk.Orientable (1)

Name

Type

Flags

Short Description

can-swipe-back

bool

r/w/en

Whether or not swipe gesture can be used to switch to the previous child

can-swipe-forward

bool

r/w/en

Whether or not swipe gesture can be used to switch to the next child

child-transition-duration

int

r/w/en

The child transition animation duration, in milliseconds

child-transition-running

bool

r

Whether or not the child transition is currently running

folded

bool

r/en

Whether the widget is folded

hhomogeneous-folded

bool

r/w/en

Horizontally homogeneous sizing when the leaflet is folded

hhomogeneous-unfolded

bool

r/w/en

Horizontally homogeneous sizing when the leaflet is unfolded

interpolate-size

bool

r/w/en

Whether or not the size should smoothly change when changing between differently sized children

mode-transition-duration

int

r/w/en

The mode transition animation duration, in milliseconds

transition-type

Handy.LeafletTransitionType

r/w/en

The type of animation used to transition between modes and children

vhomogeneous-folded

bool

r/w/en

Vertically homogeneous sizing when the leaflet is folded

vhomogeneous-unfolded

bool

r/w/en

Vertically homogeneous sizing when the leaflet is unfolded

visible-child

Gtk.Widget

r/w/en

The widget currently visible when the leaflet is folded

visible-child-name

str

r/w/en

The name of the widget currently visible when the children are stacked

Child Properties

Name

Type

Default

Flags

Short Description

name

str

None

r/w

The name of the child page

navigatable

bool

True

r/w

Whether the child can be navigated to

Style Properties

Inherited:

Gtk.Widget (17)

Signals

Inherited:

Gtk.Container (4), Gtk.Widget (69), GObject.Object (1), Handy.Swipeable (1)

Fields

Inherited:

Gtk.Container (4), Gtk.Widget (69), GObject.Object (1), Handy.Swipeable (1)

Name

Type

Access

Description

parent_instance

Gtk.Container

r

Class Details

class Handy.Leaflet(**kwargs)
Bases:

Gtk.Container, Gtk.Orientable, Handy.Swipeable

Abstract:

No

Structure:

Handy.LeafletClass

An adaptive container acting like a box or a stack.

The HdyLeaflet 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.

The “over” and “under” transitions can draw their shadow on top of the window’s transparent areas, like the rounded corners. This is a side-effect of allowing shadows to be drawn on top of OpenGL areas. It can be mitigated by using [class`Window`] or [class`ApplicationWindow`] as they will crop anything drawn beyond the rounded corners.

The child property navigatable can be set on HdyLeaflet children to determine whether they can be navigated to when folded. If FALSE, the child will be ignored by [method`Leaflet`.get_adjacent_child], [method`Leaflet`.navigate], and swipe gestures. This can be used used to prevent switching to widgets like separators.

CSS nodes

HdyLeaflet 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 didn’t compute its fold yet.

New in version 1.0.

classmethod new()
Returns:

the newly created HdyLeaflet

Return type:

Gtk.Widget

Creates a new HdyLeaflet.

New in version 1.0.

get_adjacent_child(direction)
Parameters:

direction (Handy.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 widget [method`Leaflet`.navigate] will navigate to.

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

New in version 1.0.

get_can_swipe_back()
Returns:

TRUE if back swipe is enabled

Return type:

bool

Gets whether swipe gestures switch to the previous navigatable child.

New in version 1.0.

get_can_swipe_forward()
Returns:

TRUE if forward swipe is enabled

Return type:

bool

Gets whether swipe gestures switch to the next navigatable child.

New in version 1.0.

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 the name given as the argument.

Returns NULL if there is no child with this name.

New in version 1.0.

get_child_transition_duration()
Returns:

the child transition duration, in milliseconds

Return type:

int

Gets the amount of time that transitions between children will take.

New in version 1.0.

get_child_transition_running()
Returns:

whether a transition is currently running

Return type:

bool

Returns whether self is currently in a transition from one page to another.

New in version 1.0.

get_folded()
Returns:

whether self is folded

Return type:

bool

Gets whether self is folded.

New in version 1.0.

get_homogeneous(folded, orientation)
Parameters:
Returns:

whether self is homogeneous for the given fold and orientation

Return type:

bool

Gets whether self is homogeneous for the given fold and orientation.

New in version 1.0.

get_interpolate_size()
Returns:

TRUE if child sizes are interpolated

Return type:

bool

Gets whether to interpolate between the sizes of children on page switches.

New in version 1.0.

get_mode_transition_duration()
Returns:

the mode transition duration, in milliseconds

Return type:

int

Gets the amount of time that transitions between modes in self will take.

New in version 1.0.

get_transition_type()
Returns:

the current transition type of self

Return type:

Handy.LeafletTransitionType

Gets the animation type that will be used for transitions between modes and children.

New in version 1.0.

get_visible_child()
Returns:

the visible child widget

Return type:

Gtk.Widget

Gets the visible child widget.

New in version 1.0.

get_visible_child_name()
Returns:

the name of the visible child

Return type:

str

Gets the name of the currently visible child widget.

New in version 1.0.

insert_child_after(child, sibling)
Parameters:

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

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

New in version 1.2.

navigate(direction)
Parameters:

direction (Handy.NavigationDirection) – the direction

Returns:

whether the visible child was changed

Return type:

bool

Navigates to the previous or next navigatable child.

The switch is similar to performing a swipe gesture to go in direction.

New in version 1.0.

prepend(child)
Parameters:

child (Gtk.Widget) – the widget to prepend

Inserts child at the first position in self.

New in version 1.2.

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, move child to the first position.

New in version 1.2.

set_can_swipe_back(can_swipe_back)
Parameters:

can_swipe_back (bool) – the new value

Sets whether swipe gestures switch to the previous navigatable child.

New in version 1.0.

set_can_swipe_forward(can_swipe_forward)
Parameters:

can_swipe_forward (bool) – the new value

Sets whether swipe gestures switch to the next navigatable child.

New in version 1.0.

set_child_transition_duration(duration)
Parameters:

duration (int) – the new duration, in milliseconds

Sets the duration that transitions between children in self will take.

New in version 1.0.

set_homogeneous(folded, orientation, homogeneous)
Parameters:
  • folded (bool) – the fold

  • orientation (Gtk.Orientation) – the orientation

  • homogeneous (bool) – TRUE to make self homogeneous

Sets whether to be homogeneous for the given fold and orientation.

If it is homogeneous, the [class`Leaflet`] will request the same width or height for all its children depending on the orientation. If it isn’t and it is folded, the leaflet may change width or height when a different child becomes visible.

New in version 1.0.

set_interpolate_size(interpolate_size)
Parameters:

interpolate_size (bool) – the new value

Sets whether self will interpolate its size when changing the visible child.

If the [property`Leaflet`:py:data::interpolate-size<Handy.Leaflet.props.interpolate_size>] property is set to TRUE, self will interpolate its size between the current one and the one it’ll take after changing the visible child, according to the set transition duration.

New in version 1.0.

set_mode_transition_duration(duration)
Parameters:

duration (int) – the new duration, in milliseconds

Sets the duration that transitions between modes in self will take.

New in version 1.0.

set_transition_type(transition)
Parameters:

transition (Handy.LeafletTransitionType) – the new transition type

Sets the animation type that will be 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.

New in version 1.0.

set_visible_child(visible_child)
Parameters:

visible_child (Gtk.Widget) – the new child

Sets the currently visible widget when the leaflet is folded.

New in version 1.0.

set_visible_child_name(name)
Parameters:

name (str) – the name of a child

Makes the child with the name name visible.

See [method`Leaflet`.set_visible_child] for more details.

New in version 1.0.

Property Details

Handy.Leaflet.props.can_swipe_back
Name:

can-swipe-back

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether swipe gestures allow switching to the previous navigatable child.

New in version 1.0.

Handy.Leaflet.props.can_swipe_forward
Name:

can-swipe-forward

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether swipe gestures allow switching to the next navigatable child.

New in version 1.0.

Handy.Leaflet.props.child_transition_duration
Name:

child-transition-duration

Type:

int

Default Value:

200

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The child transition animation duration, in milliseconds.

New in version 1.0.

Handy.Leaflet.props.child_transition_running
Name:

child-transition-running

Type:

bool

Default Value:

False

Flags:

READABLE

Whether a child transition is currently running.

New in version 1.0.

Handy.Leaflet.props.folded
Name:

folded

Type:

bool

Default Value:

False

Flags:

READABLE, EXPLICIT_NOTIFY

Whether the leaflet is folded.

The leaflet will be folded if the size allocated to it is smaller than the sum of the natural size of its children, it will be unfolded otherwise.

New in version 1.0.

Handy.Leaflet.props.hhomogeneous_folded
Name:

hhomogeneous-folded

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether to allocate the same width for all children when folded.

New in version 1.0.

Handy.Leaflet.props.hhomogeneous_unfolded
Name:

hhomogeneous-unfolded

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether to allocate the same width for all children when unfolded.

New in version 1.0.

Handy.Leaflet.props.interpolate_size
Name:

interpolate-size

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether the size should smoothly change when changing between children.

New in version 1.0.

Handy.Leaflet.props.mode_transition_duration
Name:

mode-transition-duration

Type:

int

Default Value:

250

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The mode transition animation duration, in milliseconds.

New in version 1.0.

Handy.Leaflet.props.transition_type
Name:

transition-type

Type:

Handy.LeafletTransitionType

Default Value:

Handy.LeafletTransitionType.OVER

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The animation type 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.

New in version 1.0.

Handy.Leaflet.props.vhomogeneous_folded
Name:

vhomogeneous-folded

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether to allocates the same height for all children when folded.

New in version 1.0.

Handy.Leaflet.props.vhomogeneous_unfolded
Name:

vhomogeneous-unfolded

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether to allocate the same height for all children when unfolded.

New in version 1.0.

Handy.Leaflet.props.visible_child
Name:

visible-child

Type:

Gtk.Widget

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The widget currently visible when the leaflet is folded.

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

New in version 1.0.

Handy.Leaflet.props.visible_child_name
Name:

visible-child-name

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

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

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

New in version 1.0.