Skip to main content

libadwaita/auto/
preferences_group.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;
7use glib::{
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "AdwPreferencesGroup")]
16    pub struct PreferencesGroup(Object<ffi::AdwPreferencesGroup, ffi::AdwPreferencesGroupClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
17
18    match fn {
19        type_ => || ffi::adw_preferences_group_get_type(),
20    }
21}
22
23impl PreferencesGroup {
24    pub const NONE: Option<&'static PreferencesGroup> = None;
25
26    #[doc(alias = "adw_preferences_group_new")]
27    pub fn new() -> PreferencesGroup {
28        assert_initialized_main_thread!();
29        unsafe { gtk::Widget::from_glib_none(ffi::adw_preferences_group_new()).unsafe_cast() }
30    }
31
32    // rustdoc-stripper-ignore-next
33    /// Creates a new builder-pattern struct instance to construct [`PreferencesGroup`] objects.
34    ///
35    /// This method returns an instance of [`PreferencesGroupBuilder`](crate::builders::PreferencesGroupBuilder) which can be used to create [`PreferencesGroup`] objects.
36    pub fn builder() -> PreferencesGroupBuilder {
37        PreferencesGroupBuilder::new()
38    }
39}
40
41impl Default for PreferencesGroup {
42    fn default() -> Self {
43        Self::new()
44    }
45}
46
47// rustdoc-stripper-ignore-next
48/// A [builder-pattern] type to construct [`PreferencesGroup`] objects.
49///
50/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
51#[must_use = "The builder must be built to be used"]
52pub struct PreferencesGroupBuilder {
53    builder: glib::object::ObjectBuilder<'static, PreferencesGroup>,
54}
55
56impl PreferencesGroupBuilder {
57    fn new() -> Self {
58        Self {
59            builder: glib::object::Object::builder(),
60        }
61    }
62
63    pub fn description(self, description: impl Into<glib::GString>) -> Self {
64        Self {
65            builder: self.builder.property("description", description.into()),
66        }
67    }
68
69    #[cfg(feature = "v1_1")]
70    #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
71    pub fn header_suffix(self, header_suffix: &impl IsA<gtk::Widget>) -> Self {
72        Self {
73            builder: self
74                .builder
75                .property("header-suffix", header_suffix.clone().upcast()),
76        }
77    }
78
79    #[cfg(feature = "v1_6")]
80    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
81    pub fn separate_rows(self, separate_rows: bool) -> Self {
82        Self {
83            builder: self.builder.property("separate-rows", separate_rows),
84        }
85    }
86
87    pub fn title(self, title: impl Into<glib::GString>) -> Self {
88        Self {
89            builder: self.builder.property("title", title.into()),
90        }
91    }
92
93    pub fn can_focus(self, can_focus: bool) -> Self {
94        Self {
95            builder: self.builder.property("can-focus", can_focus),
96        }
97    }
98
99    pub fn can_target(self, can_target: bool) -> Self {
100        Self {
101            builder: self.builder.property("can-target", can_target),
102        }
103    }
104
105    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
106        Self {
107            builder: self.builder.property("css-classes", css_classes.into()),
108        }
109    }
110
111    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
112        Self {
113            builder: self.builder.property("css-name", css_name.into()),
114        }
115    }
116
117    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
118        Self {
119            builder: self.builder.property("cursor", cursor.clone()),
120        }
121    }
122
123    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
124        Self {
125            builder: self.builder.property("focus-on-click", focus_on_click),
126        }
127    }
128
129    pub fn focusable(self, focusable: bool) -> Self {
130        Self {
131            builder: self.builder.property("focusable", focusable),
132        }
133    }
134
135    pub fn halign(self, halign: gtk::Align) -> Self {
136        Self {
137            builder: self.builder.property("halign", halign),
138        }
139    }
140
141    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
142        Self {
143            builder: self.builder.property("has-tooltip", has_tooltip),
144        }
145    }
146
147    pub fn height_request(self, height_request: i32) -> Self {
148        Self {
149            builder: self.builder.property("height-request", height_request),
150        }
151    }
152
153    pub fn hexpand(self, hexpand: bool) -> Self {
154        Self {
155            builder: self.builder.property("hexpand", hexpand),
156        }
157    }
158
159    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
160        Self {
161            builder: self.builder.property("hexpand-set", hexpand_set),
162        }
163    }
164
165    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
166        Self {
167            builder: self
168                .builder
169                .property("layout-manager", layout_manager.clone().upcast()),
170        }
171    }
172
173    #[cfg(feature = "gtk_v4_18")]
174    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
175    pub fn limit_events(self, limit_events: bool) -> Self {
176        Self {
177            builder: self.builder.property("limit-events", limit_events),
178        }
179    }
180
181    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
182        Self {
183            builder: self.builder.property("margin-bottom", margin_bottom),
184        }
185    }
186
187    pub fn margin_end(self, margin_end: i32) -> Self {
188        Self {
189            builder: self.builder.property("margin-end", margin_end),
190        }
191    }
192
193    pub fn margin_start(self, margin_start: i32) -> Self {
194        Self {
195            builder: self.builder.property("margin-start", margin_start),
196        }
197    }
198
199    pub fn margin_top(self, margin_top: i32) -> Self {
200        Self {
201            builder: self.builder.property("margin-top", margin_top),
202        }
203    }
204
205    pub fn name(self, name: impl Into<glib::GString>) -> Self {
206        Self {
207            builder: self.builder.property("name", name.into()),
208        }
209    }
210
211    pub fn opacity(self, opacity: f64) -> Self {
212        Self {
213            builder: self.builder.property("opacity", opacity),
214        }
215    }
216
217    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
218        Self {
219            builder: self.builder.property("overflow", overflow),
220        }
221    }
222
223    pub fn receives_default(self, receives_default: bool) -> Self {
224        Self {
225            builder: self.builder.property("receives-default", receives_default),
226        }
227    }
228
229    pub fn sensitive(self, sensitive: bool) -> Self {
230        Self {
231            builder: self.builder.property("sensitive", sensitive),
232        }
233    }
234
235    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
236        Self {
237            builder: self
238                .builder
239                .property("tooltip-markup", tooltip_markup.into()),
240        }
241    }
242
243    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
244        Self {
245            builder: self.builder.property("tooltip-text", tooltip_text.into()),
246        }
247    }
248
249    pub fn valign(self, valign: gtk::Align) -> Self {
250        Self {
251            builder: self.builder.property("valign", valign),
252        }
253    }
254
255    pub fn vexpand(self, vexpand: bool) -> Self {
256        Self {
257            builder: self.builder.property("vexpand", vexpand),
258        }
259    }
260
261    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
262        Self {
263            builder: self.builder.property("vexpand-set", vexpand_set),
264        }
265    }
266
267    pub fn visible(self, visible: bool) -> Self {
268        Self {
269            builder: self.builder.property("visible", visible),
270        }
271    }
272
273    pub fn width_request(self, width_request: i32) -> Self {
274        Self {
275            builder: self.builder.property("width-request", width_request),
276        }
277    }
278
279    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
280        Self {
281            builder: self.builder.property("accessible-role", accessible_role),
282        }
283    }
284
285    // rustdoc-stripper-ignore-next
286    /// Build the [`PreferencesGroup`].
287    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
288    pub fn build(self) -> PreferencesGroup {
289        assert_initialized_main_thread!();
290        self.builder.build()
291    }
292}
293
294pub trait PreferencesGroupExt: IsA<PreferencesGroup> + 'static {
295    #[doc(alias = "adw_preferences_group_add")]
296    fn add(&self, child: &impl IsA<gtk::Widget>) {
297        unsafe {
298            ffi::adw_preferences_group_add(
299                self.as_ref().to_glib_none().0,
300                child.as_ref().to_glib_none().0,
301            );
302        }
303    }
304
305    #[cfg(feature = "v1_8")]
306    #[cfg_attr(docsrs, doc(cfg(feature = "v1_8")))]
307    #[doc(alias = "adw_preferences_group_bind_model")]
308    fn bind_model<P: Fn(&glib::Object) -> gtk::Widget + 'static>(
309        &self,
310        model: Option<&impl IsA<gio::ListModel>>,
311        create_row_func: P,
312    ) {
313        let create_row_func_data: Box_<P> = Box_::new(create_row_func);
314        unsafe extern "C" fn create_row_func_func<P: Fn(&glib::Object) -> gtk::Widget + 'static>(
315            item: *mut glib::gobject_ffi::GObject,
316            user_data: glib::ffi::gpointer,
317        ) -> *mut gtk::ffi::GtkWidget {
318            unsafe {
319                let item = from_glib_borrow(item);
320                let callback = &*(user_data as *mut P);
321                (*callback)(&item).to_glib_full()
322            }
323        }
324        let create_row_func = Some(create_row_func_func::<P> as _);
325        unsafe extern "C" fn user_data_free_func_func<
326            P: Fn(&glib::Object) -> gtk::Widget + 'static,
327        >(
328            data: glib::ffi::gpointer,
329        ) {
330            unsafe {
331                let _callback = Box_::from_raw(data as *mut P);
332            }
333        }
334        let destroy_call4 = Some(user_data_free_func_func::<P> as _);
335        let super_callback0: Box_<P> = create_row_func_data;
336        unsafe {
337            ffi::adw_preferences_group_bind_model(
338                self.as_ref().to_glib_none().0,
339                model.map(|p| p.as_ref()).to_glib_none().0,
340                create_row_func,
341                Box_::into_raw(super_callback0) as *mut _,
342                destroy_call4,
343            );
344        }
345    }
346
347    #[doc(alias = "adw_preferences_group_get_description")]
348    #[doc(alias = "get_description")]
349    fn description(&self) -> Option<glib::GString> {
350        unsafe {
351            from_glib_none(ffi::adw_preferences_group_get_description(
352                self.as_ref().to_glib_none().0,
353            ))
354        }
355    }
356
357    #[cfg(feature = "v1_1")]
358    #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
359    #[doc(alias = "adw_preferences_group_get_header_suffix")]
360    #[doc(alias = "get_header_suffix")]
361    #[doc(alias = "header-suffix")]
362    fn header_suffix(&self) -> Option<gtk::Widget> {
363        unsafe {
364            from_glib_none(ffi::adw_preferences_group_get_header_suffix(
365                self.as_ref().to_glib_none().0,
366            ))
367        }
368    }
369
370    #[cfg(feature = "v1_8")]
371    #[cfg_attr(docsrs, doc(cfg(feature = "v1_8")))]
372    #[doc(alias = "adw_preferences_group_get_row")]
373    #[doc(alias = "get_row")]
374    fn row(&self, index: u32) -> Option<gtk::Widget> {
375        unsafe {
376            from_glib_none(ffi::adw_preferences_group_get_row(
377                self.as_ref().to_glib_none().0,
378                index,
379            ))
380        }
381    }
382
383    #[cfg(feature = "v1_6")]
384    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
385    #[doc(alias = "adw_preferences_group_get_separate_rows")]
386    #[doc(alias = "get_separate_rows")]
387    #[doc(alias = "separate-rows")]
388    fn is_separate_rows(&self) -> bool {
389        unsafe {
390            from_glib(ffi::adw_preferences_group_get_separate_rows(
391                self.as_ref().to_glib_none().0,
392            ))
393        }
394    }
395
396    #[doc(alias = "adw_preferences_group_get_title")]
397    #[doc(alias = "get_title")]
398    fn title(&self) -> glib::GString {
399        unsafe {
400            from_glib_none(ffi::adw_preferences_group_get_title(
401                self.as_ref().to_glib_none().0,
402            ))
403        }
404    }
405
406    #[doc(alias = "adw_preferences_group_remove")]
407    fn remove(&self, child: &impl IsA<gtk::Widget>) {
408        unsafe {
409            ffi::adw_preferences_group_remove(
410                self.as_ref().to_glib_none().0,
411                child.as_ref().to_glib_none().0,
412            );
413        }
414    }
415
416    #[doc(alias = "adw_preferences_group_set_description")]
417    #[doc(alias = "description")]
418    fn set_description(&self, description: Option<&str>) {
419        unsafe {
420            ffi::adw_preferences_group_set_description(
421                self.as_ref().to_glib_none().0,
422                description.to_glib_none().0,
423            );
424        }
425    }
426
427    #[cfg(feature = "v1_1")]
428    #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
429    #[doc(alias = "adw_preferences_group_set_header_suffix")]
430    #[doc(alias = "header-suffix")]
431    fn set_header_suffix(&self, suffix: Option<&impl IsA<gtk::Widget>>) {
432        unsafe {
433            ffi::adw_preferences_group_set_header_suffix(
434                self.as_ref().to_glib_none().0,
435                suffix.map(|p| p.as_ref()).to_glib_none().0,
436            );
437        }
438    }
439
440    #[cfg(feature = "v1_6")]
441    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
442    #[doc(alias = "adw_preferences_group_set_separate_rows")]
443    #[doc(alias = "separate-rows")]
444    fn set_separate_rows(&self, separate_rows: bool) {
445        unsafe {
446            ffi::adw_preferences_group_set_separate_rows(
447                self.as_ref().to_glib_none().0,
448                separate_rows.into_glib(),
449            );
450        }
451    }
452
453    #[doc(alias = "adw_preferences_group_set_title")]
454    #[doc(alias = "title")]
455    fn set_title(&self, title: &str) {
456        unsafe {
457            ffi::adw_preferences_group_set_title(
458                self.as_ref().to_glib_none().0,
459                title.to_glib_none().0,
460            );
461        }
462    }
463
464    #[doc(alias = "description")]
465    fn connect_description_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
466        unsafe extern "C" fn notify_description_trampoline<
467            P: IsA<PreferencesGroup>,
468            F: Fn(&P) + 'static,
469        >(
470            this: *mut ffi::AdwPreferencesGroup,
471            _param_spec: glib::ffi::gpointer,
472            f: glib::ffi::gpointer,
473        ) {
474            unsafe {
475                let f: &F = &*(f as *const F);
476                f(PreferencesGroup::from_glib_borrow(this).unsafe_cast_ref())
477            }
478        }
479        unsafe {
480            let f: Box_<F> = Box_::new(f);
481            connect_raw(
482                self.as_ptr() as *mut _,
483                c"notify::description".as_ptr(),
484                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
485                    notify_description_trampoline::<Self, F> as *const (),
486                )),
487                Box_::into_raw(f),
488            )
489        }
490    }
491
492    #[cfg(feature = "v1_1")]
493    #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
494    #[doc(alias = "header-suffix")]
495    fn connect_header_suffix_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
496        unsafe extern "C" fn notify_header_suffix_trampoline<
497            P: IsA<PreferencesGroup>,
498            F: Fn(&P) + 'static,
499        >(
500            this: *mut ffi::AdwPreferencesGroup,
501            _param_spec: glib::ffi::gpointer,
502            f: glib::ffi::gpointer,
503        ) {
504            unsafe {
505                let f: &F = &*(f as *const F);
506                f(PreferencesGroup::from_glib_borrow(this).unsafe_cast_ref())
507            }
508        }
509        unsafe {
510            let f: Box_<F> = Box_::new(f);
511            connect_raw(
512                self.as_ptr() as *mut _,
513                c"notify::header-suffix".as_ptr(),
514                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
515                    notify_header_suffix_trampoline::<Self, F> as *const (),
516                )),
517                Box_::into_raw(f),
518            )
519        }
520    }
521
522    #[cfg(feature = "v1_6")]
523    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
524    #[doc(alias = "separate-rows")]
525    fn connect_separate_rows_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
526        unsafe extern "C" fn notify_separate_rows_trampoline<
527            P: IsA<PreferencesGroup>,
528            F: Fn(&P) + 'static,
529        >(
530            this: *mut ffi::AdwPreferencesGroup,
531            _param_spec: glib::ffi::gpointer,
532            f: glib::ffi::gpointer,
533        ) {
534            unsafe {
535                let f: &F = &*(f as *const F);
536                f(PreferencesGroup::from_glib_borrow(this).unsafe_cast_ref())
537            }
538        }
539        unsafe {
540            let f: Box_<F> = Box_::new(f);
541            connect_raw(
542                self.as_ptr() as *mut _,
543                c"notify::separate-rows".as_ptr(),
544                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
545                    notify_separate_rows_trampoline::<Self, F> as *const (),
546                )),
547                Box_::into_raw(f),
548            )
549        }
550    }
551
552    #[doc(alias = "title")]
553    fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
554        unsafe extern "C" fn notify_title_trampoline<
555            P: IsA<PreferencesGroup>,
556            F: Fn(&P) + 'static,
557        >(
558            this: *mut ffi::AdwPreferencesGroup,
559            _param_spec: glib::ffi::gpointer,
560            f: glib::ffi::gpointer,
561        ) {
562            unsafe {
563                let f: &F = &*(f as *const F);
564                f(PreferencesGroup::from_glib_borrow(this).unsafe_cast_ref())
565            }
566        }
567        unsafe {
568            let f: Box_<F> = Box_::new(f);
569            connect_raw(
570                self.as_ptr() as *mut _,
571                c"notify::title".as_ptr(),
572                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
573                    notify_title_trampoline::<Self, F> as *const (),
574                )),
575                Box_::into_raw(f),
576            )
577        }
578    }
579}
580
581impl<O: IsA<PreferencesGroup>> PreferencesGroupExt for O {}