gtk4/auto/
selection_filter_model.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, SelectionModel};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    #[doc(alias = "GtkSelectionFilterModel")]
15    pub struct SelectionFilterModel(Object<ffi::GtkSelectionFilterModel, ffi::GtkSelectionFilterModelClass>) @implements gio::ListModel;
16
17    match fn {
18        type_ => || ffi::gtk_selection_filter_model_get_type(),
19    }
20}
21
22impl SelectionFilterModel {
23    #[doc(alias = "gtk_selection_filter_model_new")]
24    pub fn new(model: Option<&impl IsA<SelectionModel>>) -> SelectionFilterModel {
25        assert_initialized_main_thread!();
26        unsafe {
27            from_glib_full(ffi::gtk_selection_filter_model_new(
28                model.map(|p| p.as_ref()).to_glib_none().0,
29            ))
30        }
31    }
32
33    #[doc(alias = "gtk_selection_filter_model_get_model")]
34    #[doc(alias = "get_model")]
35    pub fn model(&self) -> Option<SelectionModel> {
36        unsafe {
37            from_glib_none(ffi::gtk_selection_filter_model_get_model(
38                self.to_glib_none().0,
39            ))
40        }
41    }
42
43    #[doc(alias = "gtk_selection_filter_model_set_model")]
44    #[doc(alias = "model")]
45    pub fn set_model(&self, model: Option<&impl IsA<SelectionModel>>) {
46        unsafe {
47            ffi::gtk_selection_filter_model_set_model(
48                self.to_glib_none().0,
49                model.map(|p| p.as_ref()).to_glib_none().0,
50            );
51        }
52    }
53
54    #[doc(alias = "model")]
55    pub fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
56        unsafe extern "C" fn notify_model_trampoline<F: Fn(&SelectionFilterModel) + 'static>(
57            this: *mut ffi::GtkSelectionFilterModel,
58            _param_spec: glib::ffi::gpointer,
59            f: glib::ffi::gpointer,
60        ) {
61            let f: &F = &*(f as *const F);
62            f(&from_glib_borrow(this))
63        }
64        unsafe {
65            let f: Box_<F> = Box_::new(f);
66            connect_raw(
67                self.as_ptr() as *mut _,
68                c"notify::model".as_ptr() as *const _,
69                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
70                    notify_model_trampoline::<F> as *const (),
71                )),
72                Box_::into_raw(f),
73            )
74        }
75    }
76}