AdwSwipeable

AdwSwipeable — An interface for swipeable widgets.

Functions

Signals

void child-switched Run First

Types and Values

Object Hierarchy

    GInterface
    ╰── AdwSwipeable

Prerequisites

AdwSwipeable requires GtkWidget.

Known Implementations

AdwSwipeable is implemented by AdwCarousel, AdwFlap and AdwLeaflet.

Description

The AdwSwipeable interface is implemented by all swipeable widgets. They can be synced using AdwSwipeGroup.

See AdwSwipeTracker for details about implementing it.

Functions

adw_swipeable_switch_child ()

void
adw_swipeable_switch_child (AdwSwipeable *self,
                            guint index,
                            gint64 duration);

See AdwSwipeable::child-switched.

Parameters

self

a AdwSwipeable

 

index

the index of the child to switch to

 

duration

Animation duration in milliseconds

 

Since: 1.0


adw_swipeable_emit_child_switched ()

void
adw_swipeable_emit_child_switched (AdwSwipeable *self,
                                   guint index,
                                   gint64 duration);

Emits AdwSwipeable::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.

Parameters

self

a AdwSwipeable

 

index

the index of the child to switch to

 

duration

Animation duration in milliseconds

 

Since: 1.0


adw_swipeable_get_swipe_tracker ()

AdwSwipeTracker *
adw_swipeable_get_swipe_tracker (AdwSwipeable *self);

Gets the AdwSwipeTracker used by this swipeable widget.

Parameters

self

a AdwSwipeable

 

Returns

the swipe tracker.

[transfer none]

Since: 1.0


adw_swipeable_get_distance ()

double
adw_swipeable_get_distance (AdwSwipeable *self);

Gets the swipe distance of self . This corresponds to how many pixels 1 unit represents.

Parameters

self

a AdwSwipeable

 

Returns

the swipe distance in pixels

Since: 1.0


adw_swipeable_get_snap_points ()

double *
adw_swipeable_get_snap_points (AdwSwipeable *self,
                               int *n_snap_points);

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

[virtual get_snap_points]

Parameters

self

a AdwSwipeable

 

n_snap_points

location to return the number of the snap points.

[out]

Returns

the snap points of self . The array must be freed with g_free().

[array length=n_snap_points][transfer full]

Since: 1.0


adw_swipeable_get_progress ()

double
adw_swipeable_get_progress (AdwSwipeable *self);

Gets the current progress of self

Parameters

self

a AdwSwipeable

 

Returns

the current progress, unitless

Since: 1.0


adw_swipeable_get_cancel_progress ()

double
adw_swipeable_get_cancel_progress (AdwSwipeable *self);

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

Parameters

self

a AdwSwipeable

 

Returns

the cancel progress, unitless

Since: 1.0


adw_swipeable_get_swipe_area ()

void
adw_swipeable_get_swipe_area (AdwSwipeable *self,
                              AdwNavigationDirection navigation_direction,
                              gboolean is_drag,
                              GdkRectangle *rect);

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 AdwSwipeGroup).

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

Parameters

self

a AdwSwipeable

 

navigation_direction

the direction of the swipe

 

is_drag

whether the swipe is caused by a dragging gesture

 

rect

a pointer to a GdkRectangle to store the swipe area.

[out]

Since: 1.0

Types and Values

ADW_TYPE_SWIPEABLE

#define ADW_TYPE_SWIPEABLE (adw_swipeable_get_type ())

struct AdwSwipeableInterface

struct AdwSwipeableInterface {
  GTypeInterface parent;

  void (*switch_child) (AdwSwipeable *self,
                        guint         index,
                        gint64        duration);

  AdwSwipeTracker * (*get_swipe_tracker)   (AdwSwipeable *self);
  double            (*get_distance)        (AdwSwipeable *self);
  double *          (*get_snap_points)     (AdwSwipeable *self,
                                            int          *n_snap_points);
  double            (*get_progress)        (AdwSwipeable *self);
  double            (*get_cancel_progress) (AdwSwipeable *self);
  void              (*get_swipe_area)      (AdwSwipeable           *self,
                                            AdwNavigationDirection  navigation_direction,
                                            gboolean                is_drag,
                                            GdkRectangle           *rect);
};

An interface for swipeable widgets.

Members

GTypeInterface parent;

The parent interface.

 

switch_child ()

Switches visible child.

 

get_swipe_tracker ()

Gets the swipe tracker.

 

get_distance ()

Gets the swipe distance.

 

get_snap_points ()

Gets the snap points

 

get_progress ()

Gets the current progress.

 

get_cancel_progress ()

Gets the cancel progress.

 

get_swipe_area ()

Gets the swipeable rectangle.

 

Since: 1.0


AdwSwipeable

typedef struct _AdwSwipeable AdwSwipeable;

Signal Details

The “child-switched” signal

void
user_function (AdwSwipeable *self,
               guint         index,
               gint64        duration,
               gpointer      user_data)

This signal should be emitted when the widget's visible child is changed.

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

This is used by AdwSwipeGroup, applications should not connect to it.

Parameters

self

The AdwSwipeable instance

 

index

the index of the child to switch to

 

duration

Animation duration in milliseconds

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First

Since: 1.0

See Also

AdwCarousel, AdwLeaflet, AdwSwipeGroup