[go: up one dir, main page]

gtk4/auto/
filter.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, FilterChange, FilterMatch};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GtkFilter")]
16    pub struct Filter(Object<ffi::GtkFilter, ffi::GtkFilterClass>);
17
18    match fn {
19        type_ => || ffi::gtk_filter_get_type(),
20    }
21}
22
23impl Filter {
24    pub const NONE: Option<&'static Filter> = None;
25}
26
27pub trait FilterExt: IsA<Filter> + 'static {
28    #[doc(alias = "gtk_filter_changed")]
29    fn changed(&self, change: FilterChange) {
30        unsafe {
31            ffi::gtk_filter_changed(self.as_ref().to_glib_none().0, change.into_glib());
32        }
33    }
34
35    #[doc(alias = "gtk_filter_get_strictness")]
36    #[doc(alias = "get_strictness")]
37    fn strictness(&self) -> FilterMatch {
38        unsafe {
39            from_glib(ffi::gtk_filter_get_strictness(
40                self.as_ref().to_glib_none().0,
41            ))
42        }
43    }
44
45    #[doc(alias = "gtk_filter_match")]
46    #[doc(alias = "match")]
47    fn match_(&self, item: &impl IsA<glib::Object>) -> bool {
48        unsafe {
49            from_glib(ffi::gtk_filter_match(
50                self.as_ref().to_glib_none().0,
51                item.as_ref().to_glib_none().0,
52            ))
53        }
54    }
55
56    #[doc(alias = "changed")]
57    fn connect_changed<F: Fn(&Self, FilterChange) + 'static>(&self, f: F) -> SignalHandlerId {
58        unsafe extern "C" fn changed_trampoline<
59            P: IsA<Filter>,
60            F: Fn(&P, FilterChange) + 'static,
61        >(
62            this: *mut ffi::GtkFilter,
63            change: ffi::GtkFilterChange,
64            f: glib::ffi::gpointer,
65        ) {
66            let f: &F = &*(f as *const F);
67            f(
68                Filter::from_glib_borrow(this).unsafe_cast_ref(),
69                from_glib(change),
70            )
71        }
72        unsafe {
73            let f: Box_<F> = Box_::new(f);
74            connect_raw(
75                self.as_ptr() as *mut _,
76                c"changed".as_ptr() as *const _,
77                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
78                    changed_trampoline::<Self, F> as *const (),
79                )),
80                Box_::into_raw(f),
81            )
82        }
83    }
84}
85
86impl<O: IsA<Filter>> FilterExt for O {}