Skip to content

Commit

Permalink
CustomSorter: Implement unset_sort_func
Browse files Browse the repository at this point in the history
Fixes: gtk-rs#22
  • Loading branch information
A6GibKm committed Jan 1, 2021
1 parent b394563 commit 8b25957
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions gtk4/src/custom_sorter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::CustomSorter;
use crate::Ordering;
use glib::object::IsA;
use glib::translate::*;
use std::ptr;

impl CustomSorter {
#[doc(alias = "gtk_custom_sorter_new")]
Expand All @@ -26,6 +27,8 @@ pub trait CustomSorterExtManual: 'static {
fn set_sort_func<F>(&self, sort_func: F)
where
F: Fn(&glib::Object, &glib::Object) -> Ordering + 'static;

fn unset_sort_func(&self);
}

unsafe extern "C" fn destroy_closure<F: Fn(&glib::Object, &glib::Object) -> Ordering + 'static>(
Expand Down Expand Up @@ -62,4 +65,15 @@ impl<O: IsA<CustomSorter>> CustomSorterExtManual for O {
)
}
}

fn unset_sort_func(&self) {
unsafe {
ffi::gtk_custom_sorter_set_sort_func(
self.as_ref().to_glib_none().0,
None,
ptr::null_mut(),
None,
)
}
}
}

0 comments on commit 8b25957

Please sign in to comment.