From 312a55327aeb23e160714249fe646ed36b6878e1 Mon Sep 17 00:00:00 2001 From: Sophie Herold Date: Mon, 23 Jan 2023 17:35:21 +0100 Subject: [PATCH] swipeable: Fix return type and remove default impl --- libadwaita/src/subclass/swipeable.rs | 103 ++------------------------- 1 file changed, 5 insertions(+), 98 deletions(-) diff --git a/libadwaita/src/subclass/swipeable.rs b/libadwaita/src/subclass/swipeable.rs index 0d7f26f..bbbefc7 100644 --- a/libadwaita/src/subclass/swipeable.rs +++ b/libadwaita/src/subclass/swipeable.rs @@ -4,21 +4,13 @@ use glib::Cast; use gtk::subclass::prelude::*; pub trait SwipeableImpl: WidgetImpl { - fn cancel_progress(&self) -> f64 { - self.parent_cancel_progress() - } + fn cancel_progress(&self) -> f64; - fn distance(&self) -> f64 { - self.parent_distance() - } + fn distance(&self) -> f64; - fn progress(&self) -> f64 { - self.parent_progress() - } + fn progress(&self) -> f64; - fn snap_points(&self) -> &[f64] { - self.parent_snap_points() - } + fn snap_points(&self) -> Vec; fn swipe_area( &self, @@ -30,10 +22,6 @@ pub trait SwipeableImpl: WidgetImpl { } pub trait SwipeableImplExt: ObjectSubclass { - fn parent_cancel_progress(&self) -> f64; - fn parent_distance(&self) -> f64; - fn parent_progress(&self) -> f64; - fn parent_snap_points(&self) -> &[f64]; fn parent_swipe_area( &self, navigation_direction: NavigationDirection, @@ -42,87 +30,6 @@ pub trait SwipeableImplExt: ObjectSubclass { } impl SwipeableImplExt for T { - fn parent_cancel_progress(&self) -> f64 { - unsafe { - let type_data = Self::type_data(); - let parent_iface = type_data.as_ref().parent_interface::() - as *const ffi::AdwSwipeableInterface; - - let func = (*parent_iface) - .get_cancel_progress - .expect("no parent \"get_cancel_progress\" implementation"); - - func( - self.instance() - .unsafe_cast_ref::() - .to_glib_none() - .0, - ) - } - } - - fn parent_distance(&self) -> f64 { - unsafe { - let type_data = Self::type_data(); - let parent_iface = type_data.as_ref().parent_interface::() - as *const ffi::AdwSwipeableInterface; - - let func = (*parent_iface) - .get_distance - .expect("no parent \"get_distance\" implementation"); - - func( - self.instance() - .unsafe_cast_ref::() - .to_glib_none() - .0, - ) - } - } - - fn parent_progress(&self) -> f64 { - unsafe { - let type_data = Self::type_data(); - let parent_iface = type_data.as_ref().parent_interface::() - as *const ffi::AdwSwipeableInterface; - - let func = (*parent_iface) - .get_progress - .expect("no parent \"get_progress\" implementation"); - - func( - self.instance() - .unsafe_cast_ref::() - .to_glib_none() - .0, - ) - } - } - - fn parent_snap_points(&self) -> &[f64] { - unsafe { - let type_data = Self::type_data(); - let parent_iface = type_data.as_ref().parent_interface::() - as *const ffi::AdwSwipeableInterface; - - let func = (*parent_iface) - .get_snap_points - .expect("no parent \"get_snap_points\" implementation"); - - let mut n_points = std::mem::MaybeUninit::uninit(); - - let points = func( - self.instance() - .unsafe_cast_ref::() - .to_glib_none() - .0, - n_points.as_mut_ptr(), - ); - - std::slice::from_raw_parts(points, n_points.assume_init() as usize) - } - } - fn parent_swipe_area( &self, navigation_direction: NavigationDirection, @@ -202,7 +109,7 @@ unsafe extern "C" fn swipeable_get_snap_points( let points = imp.snap_points(); n_pointsptr.write(points.len() as libc::c_int); - ToGlibContainerFromSlice::to_glib_full_from_slice(points) + ToGlibContainerFromSlice::to_glib_full_from_slice(points.as_slice()) } unsafe extern "C" fn swipeable_get_swipe_area( -- GitLab