[go: up one dir, main page]

gtk4/auto/
list_header.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, Widget};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    #[doc(alias = "GtkListHeader")]
15    pub struct ListHeader(Object<ffi::GtkListHeader, ffi::GtkListHeaderClass>);
16
17    match fn {
18        type_ => || ffi::gtk_list_header_get_type(),
19    }
20}
21
22impl ListHeader {
23    #[doc(alias = "gtk_list_header_get_child")]
24    #[doc(alias = "get_child")]
25    pub fn child(&self) -> Option<Widget> {
26        unsafe { from_glib_none(ffi::gtk_list_header_get_child(self.to_glib_none().0)) }
27    }
28
29    #[doc(alias = "gtk_list_header_get_end")]
30    #[doc(alias = "get_end")]
31    pub fn end(&self) -> u32 {
32        unsafe { ffi::gtk_list_header_get_end(self.to_glib_none().0) }
33    }
34
35    #[doc(alias = "gtk_list_header_get_item")]
36    #[doc(alias = "get_item")]
37    pub fn item(&self) -> Option<glib::Object> {
38        unsafe { from_glib_none(ffi::gtk_list_header_get_item(self.to_glib_none().0)) }
39    }
40
41    #[doc(alias = "gtk_list_header_get_n_items")]
42    #[doc(alias = "get_n_items")]
43    #[doc(alias = "n-items")]
44    pub fn n_items(&self) -> u32 {
45        unsafe { ffi::gtk_list_header_get_n_items(self.to_glib_none().0) }
46    }
47
48    #[doc(alias = "gtk_list_header_get_start")]
49    #[doc(alias = "get_start")]
50    pub fn start(&self) -> u32 {
51        unsafe { ffi::gtk_list_header_get_start(self.to_glib_none().0) }
52    }
53
54    #[doc(alias = "gtk_list_header_set_child")]
55    #[doc(alias = "child")]
56    pub fn set_child(&self, child: Option<&impl IsA<Widget>>) {
57        unsafe {
58            ffi::gtk_list_header_set_child(
59                self.to_glib_none().0,
60                child.map(|p| p.as_ref()).to_glib_none().0,
61            );
62        }
63    }
64
65    #[cfg(feature = "v4_12")]
66    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
67    #[doc(alias = "child")]
68    pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
69        unsafe extern "C" fn notify_child_trampoline<F: Fn(&ListHeader) + 'static>(
70            this: *mut ffi::GtkListHeader,
71            _param_spec: glib::ffi::gpointer,
72            f: glib::ffi::gpointer,
73        ) {
74            let f: &F = &*(f as *const F);
75            f(&from_glib_borrow(this))
76        }
77        unsafe {
78            let f: Box_<F> = Box_::new(f);
79            connect_raw(
80                self.as_ptr() as *mut _,
81                c"notify::child".as_ptr() as *const _,
82                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
83                    notify_child_trampoline::<F> as *const (),
84                )),
85                Box_::into_raw(f),
86            )
87        }
88    }
89
90    #[cfg(feature = "v4_12")]
91    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
92    #[doc(alias = "end")]
93    pub fn connect_end_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
94        unsafe extern "C" fn notify_end_trampoline<F: Fn(&ListHeader) + 'static>(
95            this: *mut ffi::GtkListHeader,
96            _param_spec: glib::ffi::gpointer,
97            f: glib::ffi::gpointer,
98        ) {
99            let f: &F = &*(f as *const F);
100            f(&from_glib_borrow(this))
101        }
102        unsafe {
103            let f: Box_<F> = Box_::new(f);
104            connect_raw(
105                self.as_ptr() as *mut _,
106                c"notify::end".as_ptr() as *const _,
107                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
108                    notify_end_trampoline::<F> as *const (),
109                )),
110                Box_::into_raw(f),
111            )
112        }
113    }
114
115    #[cfg(feature = "v4_12")]
116    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
117    #[doc(alias = "item")]
118    pub fn connect_item_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
119        unsafe extern "C" fn notify_item_trampoline<F: Fn(&ListHeader) + 'static>(
120            this: *mut ffi::GtkListHeader,
121            _param_spec: glib::ffi::gpointer,
122            f: glib::ffi::gpointer,
123        ) {
124            let f: &F = &*(f as *const F);
125            f(&from_glib_borrow(this))
126        }
127        unsafe {
128            let f: Box_<F> = Box_::new(f);
129            connect_raw(
130                self.as_ptr() as *mut _,
131                c"notify::item".as_ptr() as *const _,
132                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
133                    notify_item_trampoline::<F> as *const (),
134                )),
135                Box_::into_raw(f),
136            )
137        }
138    }
139
140    #[cfg(feature = "v4_12")]
141    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
142    #[doc(alias = "n-items")]
143    pub fn connect_n_items_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
144        unsafe extern "C" fn notify_n_items_trampoline<F: Fn(&ListHeader) + 'static>(
145            this: *mut ffi::GtkListHeader,
146            _param_spec: glib::ffi::gpointer,
147            f: glib::ffi::gpointer,
148        ) {
149            let f: &F = &*(f as *const F);
150            f(&from_glib_borrow(this))
151        }
152        unsafe {
153            let f: Box_<F> = Box_::new(f);
154            connect_raw(
155                self.as_ptr() as *mut _,
156                c"notify::n-items".as_ptr() as *const _,
157                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
158                    notify_n_items_trampoline::<F> as *const (),
159                )),
160                Box_::into_raw(f),
161            )
162        }
163    }
164
165    #[cfg(feature = "v4_12")]
166    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
167    #[doc(alias = "start")]
168    pub fn connect_start_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
169        unsafe extern "C" fn notify_start_trampoline<F: Fn(&ListHeader) + 'static>(
170            this: *mut ffi::GtkListHeader,
171            _param_spec: glib::ffi::gpointer,
172            f: glib::ffi::gpointer,
173        ) {
174            let f: &F = &*(f as *const F);
175            f(&from_glib_borrow(this))
176        }
177        unsafe {
178            let f: Box_<F> = Box_::new(f);
179            connect_raw(
180                self.as_ptr() as *mut _,
181                c"notify::start".as_ptr() as *const _,
182                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
183                    notify_start_trampoline::<F> as *const (),
184                )),
185                Box_::into_raw(f),
186            )
187        }
188    }
189}