GTK4 Implementing Adw.Swipeable fails when calling "do_get_snap_points()"
When trying to implement a swipeable widget with Adw.Swipeable, the widget will silently fail when do_get_snap_points
is called.
Below is a example of a simple Adw.Swipeable, based on the implementations in the libadwaita library:
class ExampleWidget(Gtk.Widget, Adw.Swipeable):
__gtype_name__ = "ExampleWidget"
def __init__(self):
super().__init__()
GObject.GObject.__init__(self)
self.tracker = Adw.SwipeTracker.new(self)
self.tracker.set_orientation(Gtk.Orientation.VERTICAL)
self.tracker.connect("update-swipe", self.set_animation_progress)
self.progress = 0
def do_switch_child(self, index, duration) -> None:
pass # Omitted because widget specific
def do_get_swipe_tracker(self) -> Adw.SwipeTracker:
return self.tracker
def do_get_distance(self) -> float:
return float(self.get_allocated_height())
def do_get_snap_points(self):
return [float(0), float(1)]
def do_get_progress(self):
return float(self.progress)
def do_get_cancel_progress(self):
return 0.5
When the Swipetracker starts calling the vfuncs implemented here when I swipe on a touchscreen (or enable mouse dragging in the tracker and click+drag), the tracker calls:
do_get_distance
do_get_distance
do_get_progress
do_get_distance
do_get_snap_points
then the application crashes.
If it's helpful, I can create a minimal implementation for a widget to build in builder demonstrating this.
Edited by GeoLang