gio/auto/
list_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 gio_sys;
6#[cfg(any(feature = "v2_44", feature = "dox"))]
7use glib;
8#[cfg(any(feature = "v2_44", feature = "dox"))]
9use glib::object::Cast;
10use glib::object::IsA;
11#[cfg(any(feature = "v2_44", feature = "dox"))]
12use glib::signal::connect_raw;
13#[cfg(any(feature = "v2_44", feature = "dox"))]
14use glib::signal::SignalHandlerId;
15use glib::translate::*;
16#[cfg(any(feature = "v2_44", feature = "dox"))]
17use glib_sys;
18#[cfg(any(feature = "v2_44", feature = "dox"))]
19use libc;
20#[cfg(any(feature = "v2_44", feature = "dox"))]
21use std::boxed::Box as Box_;
22use std::fmt;
23#[cfg(any(feature = "v2_44", feature = "dox"))]
24use std::mem::transmute;
25
26glib_wrapper! {
27    pub struct ListModel(Interface<gio_sys::GListModel>);
28
29    match fn {
30        get_type => || gio_sys::g_list_model_get_type(),
31    }
32}
33
34pub const NONE_LIST_MODEL: Option<&ListModel> = None;
35
36pub trait ListModelExt: 'static {
37    //#[cfg(any(feature = "v2_44", feature = "dox"))]
38    //fn get_item(&self, position: u32) -> /*Unimplemented*/Option<Fundamental: Pointer>;
39
40    #[cfg(any(feature = "v2_44", feature = "dox"))]
41    fn get_item_type(&self) -> glib::types::Type;
42
43    #[cfg(any(feature = "v2_44", feature = "dox"))]
44    fn get_n_items(&self) -> u32;
45
46    #[cfg(any(feature = "v2_44", feature = "dox"))]
47    fn get_object(&self, position: u32) -> Option<glib::Object>;
48
49    #[cfg(any(feature = "v2_44", feature = "dox"))]
50    fn items_changed(&self, position: u32, removed: u32, added: u32);
51
52    #[cfg(any(feature = "v2_44", feature = "dox"))]
53    fn connect_items_changed<F: Fn(&Self, u32, u32, u32) + 'static>(&self, f: F)
54        -> SignalHandlerId;
55}
56
57impl<O: IsA<ListModel>> ListModelExt for O {
58    //#[cfg(any(feature = "v2_44", feature = "dox"))]
59    //fn get_item(&self, position: u32) -> /*Unimplemented*/Option<Fundamental: Pointer> {
60    //    unsafe { TODO: call gio_sys:g_list_model_get_item() }
61    //}
62
63    #[cfg(any(feature = "v2_44", feature = "dox"))]
64    fn get_item_type(&self) -> glib::types::Type {
65        unsafe {
66            from_glib(gio_sys::g_list_model_get_item_type(
67                self.as_ref().to_glib_none().0,
68            ))
69        }
70    }
71
72    #[cfg(any(feature = "v2_44", feature = "dox"))]
73    fn get_n_items(&self) -> u32 {
74        unsafe { gio_sys::g_list_model_get_n_items(self.as_ref().to_glib_none().0) }
75    }
76
77    #[cfg(any(feature = "v2_44", feature = "dox"))]
78    fn get_object(&self, position: u32) -> Option<glib::Object> {
79        unsafe {
80            from_glib_full(gio_sys::g_list_model_get_object(
81                self.as_ref().to_glib_none().0,
82                position,
83            ))
84        }
85    }
86
87    #[cfg(any(feature = "v2_44", feature = "dox"))]
88    fn items_changed(&self, position: u32, removed: u32, added: u32) {
89        unsafe {
90            gio_sys::g_list_model_items_changed(
91                self.as_ref().to_glib_none().0,
92                position,
93                removed,
94                added,
95            );
96        }
97    }
98
99    #[cfg(any(feature = "v2_44", feature = "dox"))]
100    fn connect_items_changed<F: Fn(&Self, u32, u32, u32) + 'static>(
101        &self,
102        f: F,
103    ) -> SignalHandlerId {
104        unsafe extern "C" fn items_changed_trampoline<P, F: Fn(&P, u32, u32, u32) + 'static>(
105            this: *mut gio_sys::GListModel,
106            position: libc::c_uint,
107            removed: libc::c_uint,
108            added: libc::c_uint,
109            f: glib_sys::gpointer,
110        ) where
111            P: IsA<ListModel>,
112        {
113            let f: &F = &*(f as *const F);
114            f(
115                &ListModel::from_glib_borrow(this).unsafe_cast(),
116                position,
117                removed,
118                added,
119            )
120        }
121        unsafe {
122            let f: Box_<F> = Box_::new(f);
123            connect_raw(
124                self.as_ptr() as *mut _,
125                b"items-changed\0".as_ptr() as *const _,
126                Some(transmute(items_changed_trampoline::<Self, F> as usize)),
127                Box_::into_raw(f),
128            )
129        }
130    }
131}
132
133impl fmt::Display for ListModel {
134    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
135        write!(f, "ListModel")
136    }
137}