libappstream/auto/
category.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::{ffi, Component};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "AsCategory")]
16    pub struct Category(Object<ffi::AsCategory, ffi::AsCategoryClass>);
17
18    match fn {
19        type_ => || ffi::as_category_get_type(),
20    }
21}
22
23impl Category {
24    pub const NONE: Option<&'static Category> = None;
25
26    #[doc(alias = "as_category_new")]
27    pub fn new() -> Category {
28        assert_initialized_main_thread!();
29        unsafe { from_glib_full(ffi::as_category_new()) }
30    }
31}
32
33impl Default for Category {
34    fn default() -> Self {
35        Self::new()
36    }
37}
38
39pub trait CategoryExt: IsA<Category> + 'static {
40    #[doc(alias = "as_category_add_child")]
41    fn add_child(&self, subcat: &impl IsA<Category>) {
42        unsafe {
43            ffi::as_category_add_child(
44                self.as_ref().to_glib_none().0,
45                subcat.as_ref().to_glib_none().0,
46            );
47        }
48    }
49
50    #[doc(alias = "as_category_add_component")]
51    fn add_component(&self, cpt: &impl IsA<Component>) {
52        unsafe {
53            ffi::as_category_add_component(
54                self.as_ref().to_glib_none().0,
55                cpt.as_ref().to_glib_none().0,
56            );
57        }
58    }
59
60    #[doc(alias = "as_category_add_desktop_group")]
61    fn add_desktop_group(&self, group_name: &str) {
62        unsafe {
63            ffi::as_category_add_desktop_group(
64                self.as_ref().to_glib_none().0,
65                group_name.to_glib_none().0,
66            );
67        }
68    }
69
70    #[doc(alias = "as_category_get_children")]
71    #[doc(alias = "get_children")]
72    fn children(&self) -> Vec<Category> {
73        unsafe {
74            FromGlibPtrContainer::from_glib_none(ffi::as_category_get_children(
75                self.as_ref().to_glib_none().0,
76            ))
77        }
78    }
79
80    #[doc(alias = "as_category_get_components")]
81    #[doc(alias = "get_components")]
82    fn components(&self) -> Vec<Component> {
83        unsafe {
84            FromGlibPtrContainer::from_glib_none(ffi::as_category_get_components(
85                self.as_ref().to_glib_none().0,
86            ))
87        }
88    }
89
90    #[doc(alias = "as_category_get_desktop_groups")]
91    #[doc(alias = "get_desktop_groups")]
92    fn desktop_groups(&self) -> Vec<glib::GString> {
93        unsafe {
94            FromGlibPtrContainer::from_glib_none(ffi::as_category_get_desktop_groups(
95                self.as_ref().to_glib_none().0,
96            ))
97        }
98    }
99
100    #[doc(alias = "as_category_get_icon")]
101    #[doc(alias = "get_icon")]
102    fn icon(&self) -> Option<glib::GString> {
103        unsafe { from_glib_none(ffi::as_category_get_icon(self.as_ref().to_glib_none().0)) }
104    }
105
106    #[doc(alias = "as_category_get_id")]
107    #[doc(alias = "get_id")]
108    fn id(&self) -> Option<glib::GString> {
109        unsafe { from_glib_none(ffi::as_category_get_id(self.as_ref().to_glib_none().0)) }
110    }
111
112    #[doc(alias = "as_category_get_name")]
113    #[doc(alias = "get_name")]
114    fn name(&self) -> Option<glib::GString> {
115        unsafe { from_glib_none(ffi::as_category_get_name(self.as_ref().to_glib_none().0)) }
116    }
117
118    #[doc(alias = "as_category_get_summary")]
119    #[doc(alias = "get_summary")]
120    fn summary(&self) -> Option<glib::GString> {
121        unsafe { from_glib_none(ffi::as_category_get_summary(self.as_ref().to_glib_none().0)) }
122    }
123
124    #[doc(alias = "as_category_has_children")]
125    fn has_children(&self) -> bool {
126        unsafe {
127            from_glib(ffi::as_category_has_children(
128                self.as_ref().to_glib_none().0,
129            ))
130        }
131    }
132
133    #[doc(alias = "as_category_has_component")]
134    fn has_component(&self, cpt: &impl IsA<Component>) -> bool {
135        unsafe {
136            from_glib(ffi::as_category_has_component(
137                self.as_ref().to_glib_none().0,
138                cpt.as_ref().to_glib_none().0,
139            ))
140        }
141    }
142
143    #[doc(alias = "as_category_remove_child")]
144    fn remove_child(&self, subcat: &impl IsA<Category>) {
145        unsafe {
146            ffi::as_category_remove_child(
147                self.as_ref().to_glib_none().0,
148                subcat.as_ref().to_glib_none().0,
149            );
150        }
151    }
152
153    #[doc(alias = "as_category_set_icon")]
154    #[doc(alias = "icon")]
155    fn set_icon(&self, value: &str) {
156        unsafe {
157            ffi::as_category_set_icon(self.as_ref().to_glib_none().0, value.to_glib_none().0);
158        }
159    }
160
161    #[doc(alias = "as_category_set_id")]
162    #[doc(alias = "id")]
163    fn set_id(&self, id: &str) {
164        unsafe {
165            ffi::as_category_set_id(self.as_ref().to_glib_none().0, id.to_glib_none().0);
166        }
167    }
168
169    #[doc(alias = "as_category_set_name")]
170    #[doc(alias = "name")]
171    fn set_name(&self, value: &str) {
172        unsafe {
173            ffi::as_category_set_name(self.as_ref().to_glib_none().0, value.to_glib_none().0);
174        }
175    }
176
177    #[doc(alias = "as_category_set_summary")]
178    fn set_summary(&self, value: &str) {
179        unsafe {
180            ffi::as_category_set_summary(self.as_ref().to_glib_none().0, value.to_glib_none().0);
181        }
182    }
183
184    #[doc(alias = "children")]
185    fn connect_children_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
186        unsafe extern "C" fn notify_children_trampoline<P: IsA<Category>, F: Fn(&P) + 'static>(
187            this: *mut ffi::AsCategory,
188            _param_spec: glib::ffi::gpointer,
189            f: glib::ffi::gpointer,
190        ) {
191            let f: &F = &*(f as *const F);
192            f(Category::from_glib_borrow(this).unsafe_cast_ref())
193        }
194        unsafe {
195            let f: Box_<F> = Box_::new(f);
196            connect_raw(
197                self.as_ptr() as *mut _,
198                c"notify::children".as_ptr() as *const _,
199                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
200                    notify_children_trampoline::<Self, F> as *const (),
201                )),
202                Box_::into_raw(f),
203            )
204        }
205    }
206
207    #[doc(alias = "icon")]
208    fn connect_icon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
209        unsafe extern "C" fn notify_icon_trampoline<P: IsA<Category>, F: Fn(&P) + 'static>(
210            this: *mut ffi::AsCategory,
211            _param_spec: glib::ffi::gpointer,
212            f: glib::ffi::gpointer,
213        ) {
214            let f: &F = &*(f as *const F);
215            f(Category::from_glib_borrow(this).unsafe_cast_ref())
216        }
217        unsafe {
218            let f: Box_<F> = Box_::new(f);
219            connect_raw(
220                self.as_ptr() as *mut _,
221                c"notify::icon".as_ptr() as *const _,
222                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
223                    notify_icon_trampoline::<Self, F> as *const (),
224                )),
225                Box_::into_raw(f),
226            )
227        }
228    }
229
230    #[doc(alias = "id")]
231    fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
232        unsafe extern "C" fn notify_id_trampoline<P: IsA<Category>, F: Fn(&P) + 'static>(
233            this: *mut ffi::AsCategory,
234            _param_spec: glib::ffi::gpointer,
235            f: glib::ffi::gpointer,
236        ) {
237            let f: &F = &*(f as *const F);
238            f(Category::from_glib_borrow(this).unsafe_cast_ref())
239        }
240        unsafe {
241            let f: Box_<F> = Box_::new(f);
242            connect_raw(
243                self.as_ptr() as *mut _,
244                c"notify::id".as_ptr() as *const _,
245                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
246                    notify_id_trampoline::<Self, F> as *const (),
247                )),
248                Box_::into_raw(f),
249            )
250        }
251    }
252
253    #[doc(alias = "name")]
254    fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
255        unsafe extern "C" fn notify_name_trampoline<P: IsA<Category>, F: Fn(&P) + 'static>(
256            this: *mut ffi::AsCategory,
257            _param_spec: glib::ffi::gpointer,
258            f: glib::ffi::gpointer,
259        ) {
260            let f: &F = &*(f as *const F);
261            f(Category::from_glib_borrow(this).unsafe_cast_ref())
262        }
263        unsafe {
264            let f: Box_<F> = Box_::new(f);
265            connect_raw(
266                self.as_ptr() as *mut _,
267                c"notify::name".as_ptr() as *const _,
268                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
269                    notify_name_trampoline::<Self, F> as *const (),
270                )),
271                Box_::into_raw(f),
272            )
273        }
274    }
275
276    #[doc(alias = "summary")]
277    fn connect_summary_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
278        unsafe extern "C" fn notify_summary_trampoline<P: IsA<Category>, F: Fn(&P) + 'static>(
279            this: *mut ffi::AsCategory,
280            _param_spec: glib::ffi::gpointer,
281            f: glib::ffi::gpointer,
282        ) {
283            let f: &F = &*(f as *const F);
284            f(Category::from_glib_borrow(this).unsafe_cast_ref())
285        }
286        unsafe {
287            let f: Box_<F> = Box_::new(f);
288            connect_raw(
289                self.as_ptr() as *mut _,
290                c"notify::summary".as_ptr() as *const _,
291                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
292                    notify_summary_trampoline::<Self, F> as *const (),
293                )),
294                Box_::into_raw(f),
295            )
296        }
297    }
298}
299
300impl<O: IsA<Category>> CategoryExt for O {}