Handy.Swipeable

g GObject.GInterface GObject.GInterface Handy.Swipeable Handy.Swipeable GObject.GInterface->Handy.Swipeable

Implementations:

Handy.Carousel, Handy.Deck, Handy.Flap, Handy.Leaflet

Methods

emit_child_switched (index, duration)

get_cancel_progress ()

get_distance ()

get_progress ()

get_snap_points ()

get_swipe_area (navigation_direction, is_drag)

get_swipe_tracker ()

switch_child (index, duration)

Virtual Methods

do_get_cancel_progress ()

do_get_distance ()

do_get_progress ()

do_get_snap_points ()

do_get_swipe_area (navigation_direction, is_drag)

do_get_swipe_tracker ()

do_switch_child (index, duration)

Properties

None

Signals

Name

Short Description

child-switched

Emitted when the widget’s visible child is changed.

Fields

None

Class Details

class Handy.Swipeable
Bases:

GObject.GInterface

Structure:

Handy.SwipeableInterface

An interface for swipeable widgets.

The HdySwipeable interface is implemented by all swipeable widgets. They can be synced using [class`SwipeGroup`].

See [class`SwipeTracker`] for details about implementing it.

New in version 1.0.

emit_child_switched(index, duration)
Parameters:
  • index (int) – the index of the child to switch to

  • duration (int) – animation duration, in milliseconds

Emits [signal`Swipeable`:py:func:::child-switched<Handy.Swipeable.signals.child_switched>] signal.

This should be called when the widget switches visible child widget.

duration can be 0 if the child is switched without animation.

New in version 1.0.

get_cancel_progress()
Returns:

the cancel progress, unitless

Return type:

float

Gets the progress self will snap back to after the gesture is canceled.

New in version 1.0.

get_distance()
Returns:

the swipe distance in pixels

Return type:

float

Gets the swipe distance of self.

This corresponds to how many pixels 1 unit represents.

New in version 1.0.

get_progress()
Returns:

the current progress, unitless

Return type:

float

Gets the current progress of self.

New in version 1.0.

get_snap_points()
Returns:

the snap points

Return type:

[float]

Gets the snap points of self.

Each snap point represents a progress value that is considered acceptable to end the swipe on.

New in version 1.0.

get_swipe_area(navigation_direction, is_drag)
Parameters:
  • navigation_direction (Handy.NavigationDirection) – the direction of the swipe

  • is_drag (bool) – whether the swipe is caused by a dragging gesture

Returns:

a pointer to a rectangle to store the swipe area

Return type:

rect: Gdk.Rectangle

Gets the area self can start a swipe from for the given direction and gesture type.

This can be used to restrict swipes to only be possible from a certain area, for example, to only allow edge swipes, or to have a draggable element and ignore swipes elsewhere.

Swipe area is only considered for direct swipes (as in, not initiated by [class`SwipeGroup`]).

If not implemented, the default implementation returns the allocation of self, allowing swipes from anywhere.

New in version 1.0.

get_swipe_tracker()
Returns:

the swipe tracker

Return type:

Handy.SwipeTracker

Gets the [class`SwipeTracker`] used by this swipeable widget.

New in version 1.0.

switch_child(index, duration)
Parameters:
  • index (int) – the index of the child to switch to

  • duration (int) – animation duration, in milliseconds

Switches to child with index index.

See [signal`Swipeable`:py:func:::child-switched<Handy.Swipeable.signals.child_switched>].

New in version 1.0.

do_get_cancel_progress() virtual
Returns:

the cancel progress, unitless

Return type:

float

Gets the progress self will snap back to after the gesture is canceled.

New in version 1.0.

do_get_distance() virtual
Returns:

the swipe distance in pixels

Return type:

float

Gets the swipe distance of self.

This corresponds to how many pixels 1 unit represents.

New in version 1.0.

do_get_progress() virtual
Returns:

the current progress, unitless

Return type:

float

Gets the current progress of self.

New in version 1.0.

do_get_snap_points() virtual
Returns:

the snap points

Return type:

[float]

Gets the snap points of self.

Each snap point represents a progress value that is considered acceptable to end the swipe on.

New in version 1.0.

do_get_swipe_area(navigation_direction, is_drag) virtual
Parameters:
  • navigation_direction (Handy.NavigationDirection) – the direction of the swipe

  • is_drag (bool) – whether the swipe is caused by a dragging gesture

Returns:

a pointer to a rectangle to store the swipe area

Return type:

rect: Gdk.Rectangle

Gets the area self can start a swipe from for the given direction and gesture type.

This can be used to restrict swipes to only be possible from a certain area, for example, to only allow edge swipes, or to have a draggable element and ignore swipes elsewhere.

Swipe area is only considered for direct swipes (as in, not initiated by [class`SwipeGroup`]).

If not implemented, the default implementation returns the allocation of self, allowing swipes from anywhere.

New in version 1.0.

do_get_swipe_tracker() virtual
Returns:

the swipe tracker

Return type:

Handy.SwipeTracker

Gets the [class`SwipeTracker`] used by this swipeable widget.

New in version 1.0.

do_switch_child(index, duration) virtual
Parameters:
  • index (int) – the index of the child to switch to

  • duration (int) – animation duration, in milliseconds

Switches to child with index index.

See [signal`Swipeable`:py:func:::child-switched<Handy.Swipeable.signals.child_switched>].

New in version 1.0.

Signal Details

Handy.Swipeable.signals.child_switched(swipeable, index, duration)
Signal Name:

child-switched

Flags:

RUN_FIRST

Parameters:
  • swipeable (Handy.Swipeable) – The object which received the signal

  • index (int) – the index of the child to switch to

  • duration (int) – animation duration, in milliseconds

Emitted when the widget’s visible child is changed.

duration can be 0 if the child is switched without animation.

This is used by [class`SwipeGroup`], applications should not connect to it.

New in version 1.0.