libadwaita/auto/
leaflet.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#![allow(deprecated)]
6
7use crate::{
8    ffi, FoldThresholdPolicy, LeafletPage, LeafletTransitionType, NavigationDirection,
9    SpringParams, Swipeable,
10};
11use glib::{
12    prelude::*,
13    signal::{connect_raw, SignalHandlerId},
14    translate::*,
15};
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19    #[doc(alias = "AdwLeaflet")]
20    pub struct Leaflet(Object<ffi::AdwLeaflet, ffi::AdwLeafletClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, Swipeable, gtk::Orientable;
21
22    match fn {
23        type_ => || ffi::adw_leaflet_get_type(),
24    }
25}
26
27impl Leaflet {
28    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
29    #[allow(deprecated)]
30    #[doc(alias = "adw_leaflet_new")]
31    pub fn new() -> Leaflet {
32        assert_initialized_main_thread!();
33        unsafe { gtk::Widget::from_glib_none(ffi::adw_leaflet_new()).unsafe_cast() }
34    }
35
36    // rustdoc-stripper-ignore-next
37    /// Creates a new builder-pattern struct instance to construct [`Leaflet`] objects.
38    ///
39    /// This method returns an instance of [`LeafletBuilder`](crate::builders::LeafletBuilder) which can be used to create [`Leaflet`] objects.
40    pub fn builder() -> LeafletBuilder {
41        LeafletBuilder::new()
42    }
43
44    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
45    #[allow(deprecated)]
46    #[doc(alias = "adw_leaflet_append")]
47    pub fn append(&self, child: &impl IsA<gtk::Widget>) -> LeafletPage {
48        unsafe {
49            from_glib_none(ffi::adw_leaflet_append(
50                self.to_glib_none().0,
51                child.as_ref().to_glib_none().0,
52            ))
53        }
54    }
55
56    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
57    #[allow(deprecated)]
58    #[doc(alias = "adw_leaflet_get_adjacent_child")]
59    #[doc(alias = "get_adjacent_child")]
60    pub fn adjacent_child(&self, direction: NavigationDirection) -> Option<gtk::Widget> {
61        unsafe {
62            from_glib_none(ffi::adw_leaflet_get_adjacent_child(
63                self.to_glib_none().0,
64                direction.into_glib(),
65            ))
66        }
67    }
68
69    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
70    #[allow(deprecated)]
71    #[doc(alias = "adw_leaflet_get_can_navigate_back")]
72    #[doc(alias = "get_can_navigate_back")]
73    #[doc(alias = "can-navigate-back")]
74    pub fn can_navigate_back(&self) -> bool {
75        unsafe {
76            from_glib(ffi::adw_leaflet_get_can_navigate_back(
77                self.to_glib_none().0,
78            ))
79        }
80    }
81
82    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
83    #[allow(deprecated)]
84    #[doc(alias = "adw_leaflet_get_can_navigate_forward")]
85    #[doc(alias = "get_can_navigate_forward")]
86    #[doc(alias = "can-navigate-forward")]
87    pub fn can_navigate_forward(&self) -> bool {
88        unsafe {
89            from_glib(ffi::adw_leaflet_get_can_navigate_forward(
90                self.to_glib_none().0,
91            ))
92        }
93    }
94
95    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
96    #[allow(deprecated)]
97    #[doc(alias = "adw_leaflet_get_can_unfold")]
98    #[doc(alias = "get_can_unfold")]
99    #[doc(alias = "can-unfold")]
100    pub fn can_unfold(&self) -> bool {
101        unsafe { from_glib(ffi::adw_leaflet_get_can_unfold(self.to_glib_none().0)) }
102    }
103
104    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
105    #[allow(deprecated)]
106    #[doc(alias = "adw_leaflet_get_child_by_name")]
107    #[doc(alias = "get_child_by_name")]
108    pub fn child_by_name(&self, name: &str) -> Option<gtk::Widget> {
109        unsafe {
110            from_glib_none(ffi::adw_leaflet_get_child_by_name(
111                self.to_glib_none().0,
112                name.to_glib_none().0,
113            ))
114        }
115    }
116
117    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
118    #[allow(deprecated)]
119    #[doc(alias = "adw_leaflet_get_child_transition_params")]
120    #[doc(alias = "get_child_transition_params")]
121    #[doc(alias = "child-transition-params")]
122    pub fn child_transition_params(&self) -> SpringParams {
123        unsafe {
124            from_glib_full(ffi::adw_leaflet_get_child_transition_params(
125                self.to_glib_none().0,
126            ))
127        }
128    }
129
130    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
131    #[allow(deprecated)]
132    #[doc(alias = "adw_leaflet_get_child_transition_running")]
133    #[doc(alias = "get_child_transition_running")]
134    #[doc(alias = "child-transition-running")]
135    pub fn is_child_transition_running(&self) -> bool {
136        unsafe {
137            from_glib(ffi::adw_leaflet_get_child_transition_running(
138                self.to_glib_none().0,
139            ))
140        }
141    }
142
143    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
144    #[allow(deprecated)]
145    #[doc(alias = "adw_leaflet_get_fold_threshold_policy")]
146    #[doc(alias = "get_fold_threshold_policy")]
147    #[doc(alias = "fold-threshold-policy")]
148    pub fn fold_threshold_policy(&self) -> FoldThresholdPolicy {
149        unsafe {
150            from_glib(ffi::adw_leaflet_get_fold_threshold_policy(
151                self.to_glib_none().0,
152            ))
153        }
154    }
155
156    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
157    #[allow(deprecated)]
158    #[doc(alias = "adw_leaflet_get_folded")]
159    #[doc(alias = "get_folded")]
160    #[doc(alias = "folded")]
161    pub fn is_folded(&self) -> bool {
162        unsafe { from_glib(ffi::adw_leaflet_get_folded(self.to_glib_none().0)) }
163    }
164
165    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
166    #[allow(deprecated)]
167    #[doc(alias = "adw_leaflet_get_homogeneous")]
168    #[doc(alias = "get_homogeneous")]
169    #[doc(alias = "homogeneous")]
170    pub fn is_homogeneous(&self) -> bool {
171        unsafe { from_glib(ffi::adw_leaflet_get_homogeneous(self.to_glib_none().0)) }
172    }
173
174    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
175    #[allow(deprecated)]
176    #[doc(alias = "adw_leaflet_get_mode_transition_duration")]
177    #[doc(alias = "get_mode_transition_duration")]
178    #[doc(alias = "mode-transition-duration")]
179    pub fn mode_transition_duration(&self) -> u32 {
180        unsafe { ffi::adw_leaflet_get_mode_transition_duration(self.to_glib_none().0) }
181    }
182
183    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
184    #[allow(deprecated)]
185    #[doc(alias = "adw_leaflet_get_page")]
186    #[doc(alias = "get_page")]
187    pub fn page(&self, child: &impl IsA<gtk::Widget>) -> LeafletPage {
188        unsafe {
189            from_glib_none(ffi::adw_leaflet_get_page(
190                self.to_glib_none().0,
191                child.as_ref().to_glib_none().0,
192            ))
193        }
194    }
195
196    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
197    #[allow(deprecated)]
198    #[doc(alias = "adw_leaflet_get_pages")]
199    #[doc(alias = "get_pages")]
200    pub fn pages(&self) -> gtk::SelectionModel {
201        unsafe { from_glib_full(ffi::adw_leaflet_get_pages(self.to_glib_none().0)) }
202    }
203
204    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
205    #[allow(deprecated)]
206    #[doc(alias = "adw_leaflet_get_transition_type")]
207    #[doc(alias = "get_transition_type")]
208    #[doc(alias = "transition-type")]
209    pub fn transition_type(&self) -> LeafletTransitionType {
210        unsafe { from_glib(ffi::adw_leaflet_get_transition_type(self.to_glib_none().0)) }
211    }
212
213    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
214    #[allow(deprecated)]
215    #[doc(alias = "adw_leaflet_get_visible_child")]
216    #[doc(alias = "get_visible_child")]
217    #[doc(alias = "visible-child")]
218    pub fn visible_child(&self) -> Option<gtk::Widget> {
219        unsafe { from_glib_none(ffi::adw_leaflet_get_visible_child(self.to_glib_none().0)) }
220    }
221
222    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
223    #[allow(deprecated)]
224    #[doc(alias = "adw_leaflet_get_visible_child_name")]
225    #[doc(alias = "get_visible_child_name")]
226    #[doc(alias = "visible-child-name")]
227    pub fn visible_child_name(&self) -> Option<glib::GString> {
228        unsafe {
229            from_glib_none(ffi::adw_leaflet_get_visible_child_name(
230                self.to_glib_none().0,
231            ))
232        }
233    }
234
235    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
236    #[allow(deprecated)]
237    #[doc(alias = "adw_leaflet_insert_child_after")]
238    pub fn insert_child_after(
239        &self,
240        child: &impl IsA<gtk::Widget>,
241        sibling: Option<&impl IsA<gtk::Widget>>,
242    ) -> LeafletPage {
243        unsafe {
244            from_glib_none(ffi::adw_leaflet_insert_child_after(
245                self.to_glib_none().0,
246                child.as_ref().to_glib_none().0,
247                sibling.map(|p| p.as_ref()).to_glib_none().0,
248            ))
249        }
250    }
251
252    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
253    #[allow(deprecated)]
254    #[doc(alias = "adw_leaflet_navigate")]
255    pub fn navigate(&self, direction: NavigationDirection) -> bool {
256        unsafe {
257            from_glib(ffi::adw_leaflet_navigate(
258                self.to_glib_none().0,
259                direction.into_glib(),
260            ))
261        }
262    }
263
264    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
265    #[allow(deprecated)]
266    #[doc(alias = "adw_leaflet_prepend")]
267    pub fn prepend(&self, child: &impl IsA<gtk::Widget>) -> LeafletPage {
268        unsafe {
269            from_glib_none(ffi::adw_leaflet_prepend(
270                self.to_glib_none().0,
271                child.as_ref().to_glib_none().0,
272            ))
273        }
274    }
275
276    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
277    #[allow(deprecated)]
278    #[doc(alias = "adw_leaflet_remove")]
279    pub fn remove(&self, child: &impl IsA<gtk::Widget>) {
280        unsafe {
281            ffi::adw_leaflet_remove(self.to_glib_none().0, child.as_ref().to_glib_none().0);
282        }
283    }
284
285    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
286    #[allow(deprecated)]
287    #[doc(alias = "adw_leaflet_reorder_child_after")]
288    pub fn reorder_child_after(
289        &self,
290        child: &impl IsA<gtk::Widget>,
291        sibling: Option<&impl IsA<gtk::Widget>>,
292    ) {
293        unsafe {
294            ffi::adw_leaflet_reorder_child_after(
295                self.to_glib_none().0,
296                child.as_ref().to_glib_none().0,
297                sibling.map(|p| p.as_ref()).to_glib_none().0,
298            );
299        }
300    }
301
302    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
303    #[allow(deprecated)]
304    #[doc(alias = "adw_leaflet_set_can_navigate_back")]
305    #[doc(alias = "can-navigate-back")]
306    pub fn set_can_navigate_back(&self, can_navigate_back: bool) {
307        unsafe {
308            ffi::adw_leaflet_set_can_navigate_back(
309                self.to_glib_none().0,
310                can_navigate_back.into_glib(),
311            );
312        }
313    }
314
315    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
316    #[allow(deprecated)]
317    #[doc(alias = "adw_leaflet_set_can_navigate_forward")]
318    #[doc(alias = "can-navigate-forward")]
319    pub fn set_can_navigate_forward(&self, can_navigate_forward: bool) {
320        unsafe {
321            ffi::adw_leaflet_set_can_navigate_forward(
322                self.to_glib_none().0,
323                can_navigate_forward.into_glib(),
324            );
325        }
326    }
327
328    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
329    #[allow(deprecated)]
330    #[doc(alias = "adw_leaflet_set_can_unfold")]
331    #[doc(alias = "can-unfold")]
332    pub fn set_can_unfold(&self, can_unfold: bool) {
333        unsafe {
334            ffi::adw_leaflet_set_can_unfold(self.to_glib_none().0, can_unfold.into_glib());
335        }
336    }
337
338    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
339    #[allow(deprecated)]
340    #[doc(alias = "adw_leaflet_set_child_transition_params")]
341    #[doc(alias = "child-transition-params")]
342    pub fn set_child_transition_params(&self, params: &SpringParams) {
343        unsafe {
344            ffi::adw_leaflet_set_child_transition_params(
345                self.to_glib_none().0,
346                params.to_glib_none().0,
347            );
348        }
349    }
350
351    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
352    #[allow(deprecated)]
353    #[doc(alias = "adw_leaflet_set_fold_threshold_policy")]
354    #[doc(alias = "fold-threshold-policy")]
355    pub fn set_fold_threshold_policy(&self, policy: FoldThresholdPolicy) {
356        unsafe {
357            ffi::adw_leaflet_set_fold_threshold_policy(self.to_glib_none().0, policy.into_glib());
358        }
359    }
360
361    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
362    #[allow(deprecated)]
363    #[doc(alias = "adw_leaflet_set_homogeneous")]
364    #[doc(alias = "homogeneous")]
365    pub fn set_homogeneous(&self, homogeneous: bool) {
366        unsafe {
367            ffi::adw_leaflet_set_homogeneous(self.to_glib_none().0, homogeneous.into_glib());
368        }
369    }
370
371    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
372    #[allow(deprecated)]
373    #[doc(alias = "adw_leaflet_set_mode_transition_duration")]
374    #[doc(alias = "mode-transition-duration")]
375    pub fn set_mode_transition_duration(&self, duration: u32) {
376        unsafe {
377            ffi::adw_leaflet_set_mode_transition_duration(self.to_glib_none().0, duration);
378        }
379    }
380
381    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
382    #[allow(deprecated)]
383    #[doc(alias = "adw_leaflet_set_transition_type")]
384    #[doc(alias = "transition-type")]
385    pub fn set_transition_type(&self, transition: LeafletTransitionType) {
386        unsafe {
387            ffi::adw_leaflet_set_transition_type(self.to_glib_none().0, transition.into_glib());
388        }
389    }
390
391    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
392    #[allow(deprecated)]
393    #[doc(alias = "adw_leaflet_set_visible_child")]
394    #[doc(alias = "visible-child")]
395    pub fn set_visible_child(&self, visible_child: &impl IsA<gtk::Widget>) {
396        unsafe {
397            ffi::adw_leaflet_set_visible_child(
398                self.to_glib_none().0,
399                visible_child.as_ref().to_glib_none().0,
400            );
401        }
402    }
403
404    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
405    #[allow(deprecated)]
406    #[doc(alias = "adw_leaflet_set_visible_child_name")]
407    #[doc(alias = "visible-child-name")]
408    pub fn set_visible_child_name(&self, name: &str) {
409        unsafe {
410            ffi::adw_leaflet_set_visible_child_name(self.to_glib_none().0, name.to_glib_none().0);
411        }
412    }
413
414    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
415    #[doc(alias = "can-navigate-back")]
416    pub fn connect_can_navigate_back_notify<F: Fn(&Self) + 'static>(
417        &self,
418        f: F,
419    ) -> SignalHandlerId {
420        unsafe extern "C" fn notify_can_navigate_back_trampoline<F: Fn(&Leaflet) + 'static>(
421            this: *mut ffi::AdwLeaflet,
422            _param_spec: glib::ffi::gpointer,
423            f: glib::ffi::gpointer,
424        ) {
425            let f: &F = &*(f as *const F);
426            f(&from_glib_borrow(this))
427        }
428        unsafe {
429            let f: Box_<F> = Box_::new(f);
430            connect_raw(
431                self.as_ptr() as *mut _,
432                c"notify::can-navigate-back".as_ptr() as *const _,
433                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
434                    notify_can_navigate_back_trampoline::<F> as *const (),
435                )),
436                Box_::into_raw(f),
437            )
438        }
439    }
440
441    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
442    #[doc(alias = "can-navigate-forward")]
443    pub fn connect_can_navigate_forward_notify<F: Fn(&Self) + 'static>(
444        &self,
445        f: F,
446    ) -> SignalHandlerId {
447        unsafe extern "C" fn notify_can_navigate_forward_trampoline<F: Fn(&Leaflet) + 'static>(
448            this: *mut ffi::AdwLeaflet,
449            _param_spec: glib::ffi::gpointer,
450            f: glib::ffi::gpointer,
451        ) {
452            let f: &F = &*(f as *const F);
453            f(&from_glib_borrow(this))
454        }
455        unsafe {
456            let f: Box_<F> = Box_::new(f);
457            connect_raw(
458                self.as_ptr() as *mut _,
459                c"notify::can-navigate-forward".as_ptr() as *const _,
460                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
461                    notify_can_navigate_forward_trampoline::<F> as *const (),
462                )),
463                Box_::into_raw(f),
464            )
465        }
466    }
467
468    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
469    #[doc(alias = "can-unfold")]
470    pub fn connect_can_unfold_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
471        unsafe extern "C" fn notify_can_unfold_trampoline<F: Fn(&Leaflet) + 'static>(
472            this: *mut ffi::AdwLeaflet,
473            _param_spec: glib::ffi::gpointer,
474            f: glib::ffi::gpointer,
475        ) {
476            let f: &F = &*(f as *const F);
477            f(&from_glib_borrow(this))
478        }
479        unsafe {
480            let f: Box_<F> = Box_::new(f);
481            connect_raw(
482                self.as_ptr() as *mut _,
483                c"notify::can-unfold".as_ptr() as *const _,
484                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
485                    notify_can_unfold_trampoline::<F> as *const (),
486                )),
487                Box_::into_raw(f),
488            )
489        }
490    }
491
492    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
493    #[doc(alias = "child-transition-params")]
494    pub fn connect_child_transition_params_notify<F: Fn(&Self) + 'static>(
495        &self,
496        f: F,
497    ) -> SignalHandlerId {
498        unsafe extern "C" fn notify_child_transition_params_trampoline<
499            F: Fn(&Leaflet) + 'static,
500        >(
501            this: *mut ffi::AdwLeaflet,
502            _param_spec: glib::ffi::gpointer,
503            f: glib::ffi::gpointer,
504        ) {
505            let f: &F = &*(f as *const F);
506            f(&from_glib_borrow(this))
507        }
508        unsafe {
509            let f: Box_<F> = Box_::new(f);
510            connect_raw(
511                self.as_ptr() as *mut _,
512                c"notify::child-transition-params".as_ptr() as *const _,
513                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
514                    notify_child_transition_params_trampoline::<F> as *const (),
515                )),
516                Box_::into_raw(f),
517            )
518        }
519    }
520
521    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
522    #[doc(alias = "child-transition-running")]
523    pub fn connect_child_transition_running_notify<F: Fn(&Self) + 'static>(
524        &self,
525        f: F,
526    ) -> SignalHandlerId {
527        unsafe extern "C" fn notify_child_transition_running_trampoline<
528            F: Fn(&Leaflet) + 'static,
529        >(
530            this: *mut ffi::AdwLeaflet,
531            _param_spec: glib::ffi::gpointer,
532            f: glib::ffi::gpointer,
533        ) {
534            let f: &F = &*(f as *const F);
535            f(&from_glib_borrow(this))
536        }
537        unsafe {
538            let f: Box_<F> = Box_::new(f);
539            connect_raw(
540                self.as_ptr() as *mut _,
541                c"notify::child-transition-running".as_ptr() as *const _,
542                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
543                    notify_child_transition_running_trampoline::<F> as *const (),
544                )),
545                Box_::into_raw(f),
546            )
547        }
548    }
549
550    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
551    #[doc(alias = "fold-threshold-policy")]
552    pub fn connect_fold_threshold_policy_notify<F: Fn(&Self) + 'static>(
553        &self,
554        f: F,
555    ) -> SignalHandlerId {
556        unsafe extern "C" fn notify_fold_threshold_policy_trampoline<F: Fn(&Leaflet) + 'static>(
557            this: *mut ffi::AdwLeaflet,
558            _param_spec: glib::ffi::gpointer,
559            f: glib::ffi::gpointer,
560        ) {
561            let f: &F = &*(f as *const F);
562            f(&from_glib_borrow(this))
563        }
564        unsafe {
565            let f: Box_<F> = Box_::new(f);
566            connect_raw(
567                self.as_ptr() as *mut _,
568                c"notify::fold-threshold-policy".as_ptr() as *const _,
569                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
570                    notify_fold_threshold_policy_trampoline::<F> as *const (),
571                )),
572                Box_::into_raw(f),
573            )
574        }
575    }
576
577    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
578    #[doc(alias = "folded")]
579    pub fn connect_folded_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
580        unsafe extern "C" fn notify_folded_trampoline<F: Fn(&Leaflet) + 'static>(
581            this: *mut ffi::AdwLeaflet,
582            _param_spec: glib::ffi::gpointer,
583            f: glib::ffi::gpointer,
584        ) {
585            let f: &F = &*(f as *const F);
586            f(&from_glib_borrow(this))
587        }
588        unsafe {
589            let f: Box_<F> = Box_::new(f);
590            connect_raw(
591                self.as_ptr() as *mut _,
592                c"notify::folded".as_ptr() as *const _,
593                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
594                    notify_folded_trampoline::<F> as *const (),
595                )),
596                Box_::into_raw(f),
597            )
598        }
599    }
600
601    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
602    #[doc(alias = "homogeneous")]
603    pub fn connect_homogeneous_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
604        unsafe extern "C" fn notify_homogeneous_trampoline<F: Fn(&Leaflet) + 'static>(
605            this: *mut ffi::AdwLeaflet,
606            _param_spec: glib::ffi::gpointer,
607            f: glib::ffi::gpointer,
608        ) {
609            let f: &F = &*(f as *const F);
610            f(&from_glib_borrow(this))
611        }
612        unsafe {
613            let f: Box_<F> = Box_::new(f);
614            connect_raw(
615                self.as_ptr() as *mut _,
616                c"notify::homogeneous".as_ptr() as *const _,
617                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
618                    notify_homogeneous_trampoline::<F> as *const (),
619                )),
620                Box_::into_raw(f),
621            )
622        }
623    }
624
625    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
626    #[doc(alias = "mode-transition-duration")]
627    pub fn connect_mode_transition_duration_notify<F: Fn(&Self) + 'static>(
628        &self,
629        f: F,
630    ) -> SignalHandlerId {
631        unsafe extern "C" fn notify_mode_transition_duration_trampoline<
632            F: Fn(&Leaflet) + 'static,
633        >(
634            this: *mut ffi::AdwLeaflet,
635            _param_spec: glib::ffi::gpointer,
636            f: glib::ffi::gpointer,
637        ) {
638            let f: &F = &*(f as *const F);
639            f(&from_glib_borrow(this))
640        }
641        unsafe {
642            let f: Box_<F> = Box_::new(f);
643            connect_raw(
644                self.as_ptr() as *mut _,
645                c"notify::mode-transition-duration".as_ptr() as *const _,
646                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
647                    notify_mode_transition_duration_trampoline::<F> as *const (),
648                )),
649                Box_::into_raw(f),
650            )
651        }
652    }
653
654    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
655    #[doc(alias = "pages")]
656    pub fn connect_pages_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
657        unsafe extern "C" fn notify_pages_trampoline<F: Fn(&Leaflet) + 'static>(
658            this: *mut ffi::AdwLeaflet,
659            _param_spec: glib::ffi::gpointer,
660            f: glib::ffi::gpointer,
661        ) {
662            let f: &F = &*(f as *const F);
663            f(&from_glib_borrow(this))
664        }
665        unsafe {
666            let f: Box_<F> = Box_::new(f);
667            connect_raw(
668                self.as_ptr() as *mut _,
669                c"notify::pages".as_ptr() as *const _,
670                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
671                    notify_pages_trampoline::<F> as *const (),
672                )),
673                Box_::into_raw(f),
674            )
675        }
676    }
677
678    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
679    #[doc(alias = "transition-type")]
680    pub fn connect_transition_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
681        unsafe extern "C" fn notify_transition_type_trampoline<F: Fn(&Leaflet) + 'static>(
682            this: *mut ffi::AdwLeaflet,
683            _param_spec: glib::ffi::gpointer,
684            f: glib::ffi::gpointer,
685        ) {
686            let f: &F = &*(f as *const F);
687            f(&from_glib_borrow(this))
688        }
689        unsafe {
690            let f: Box_<F> = Box_::new(f);
691            connect_raw(
692                self.as_ptr() as *mut _,
693                c"notify::transition-type".as_ptr() as *const _,
694                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
695                    notify_transition_type_trampoline::<F> as *const (),
696                )),
697                Box_::into_raw(f),
698            )
699        }
700    }
701
702    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
703    #[doc(alias = "visible-child")]
704    pub fn connect_visible_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
705        unsafe extern "C" fn notify_visible_child_trampoline<F: Fn(&Leaflet) + 'static>(
706            this: *mut ffi::AdwLeaflet,
707            _param_spec: glib::ffi::gpointer,
708            f: glib::ffi::gpointer,
709        ) {
710            let f: &F = &*(f as *const F);
711            f(&from_glib_borrow(this))
712        }
713        unsafe {
714            let f: Box_<F> = Box_::new(f);
715            connect_raw(
716                self.as_ptr() as *mut _,
717                c"notify::visible-child".as_ptr() as *const _,
718                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
719                    notify_visible_child_trampoline::<F> as *const (),
720                )),
721                Box_::into_raw(f),
722            )
723        }
724    }
725
726    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
727    #[doc(alias = "visible-child-name")]
728    pub fn connect_visible_child_name_notify<F: Fn(&Self) + 'static>(
729        &self,
730        f: F,
731    ) -> SignalHandlerId {
732        unsafe extern "C" fn notify_visible_child_name_trampoline<F: Fn(&Leaflet) + 'static>(
733            this: *mut ffi::AdwLeaflet,
734            _param_spec: glib::ffi::gpointer,
735            f: glib::ffi::gpointer,
736        ) {
737            let f: &F = &*(f as *const F);
738            f(&from_glib_borrow(this))
739        }
740        unsafe {
741            let f: Box_<F> = Box_::new(f);
742            connect_raw(
743                self.as_ptr() as *mut _,
744                c"notify::visible-child-name".as_ptr() as *const _,
745                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
746                    notify_visible_child_name_trampoline::<F> as *const (),
747                )),
748                Box_::into_raw(f),
749            )
750        }
751    }
752}
753
754impl Default for Leaflet {
755    fn default() -> Self {
756        Self::new()
757    }
758}
759
760// rustdoc-stripper-ignore-next
761/// A [builder-pattern] type to construct [`Leaflet`] objects.
762///
763/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
764#[must_use = "The builder must be built to be used"]
765pub struct LeafletBuilder {
766    builder: glib::object::ObjectBuilder<'static, Leaflet>,
767}
768
769impl LeafletBuilder {
770    fn new() -> Self {
771        Self {
772            builder: glib::object::Object::builder(),
773        }
774    }
775
776    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
777    pub fn can_navigate_back(self, can_navigate_back: bool) -> Self {
778        Self {
779            builder: self
780                .builder
781                .property("can-navigate-back", can_navigate_back),
782        }
783    }
784
785    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
786    pub fn can_navigate_forward(self, can_navigate_forward: bool) -> Self {
787        Self {
788            builder: self
789                .builder
790                .property("can-navigate-forward", can_navigate_forward),
791        }
792    }
793
794    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
795    pub fn can_unfold(self, can_unfold: bool) -> Self {
796        Self {
797            builder: self.builder.property("can-unfold", can_unfold),
798        }
799    }
800
801    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
802    pub fn child_transition_params(self, child_transition_params: &SpringParams) -> Self {
803        Self {
804            builder: self
805                .builder
806                .property("child-transition-params", child_transition_params.clone()),
807        }
808    }
809
810    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
811    pub fn fold_threshold_policy(self, fold_threshold_policy: FoldThresholdPolicy) -> Self {
812        Self {
813            builder: self
814                .builder
815                .property("fold-threshold-policy", fold_threshold_policy),
816        }
817    }
818
819    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
820    pub fn homogeneous(self, homogeneous: bool) -> Self {
821        Self {
822            builder: self.builder.property("homogeneous", homogeneous),
823        }
824    }
825
826    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
827    pub fn mode_transition_duration(self, mode_transition_duration: u32) -> Self {
828        Self {
829            builder: self
830                .builder
831                .property("mode-transition-duration", mode_transition_duration),
832        }
833    }
834
835    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
836    pub fn transition_type(self, transition_type: LeafletTransitionType) -> Self {
837        Self {
838            builder: self.builder.property("transition-type", transition_type),
839        }
840    }
841
842    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
843    pub fn visible_child(self, visible_child: &impl IsA<gtk::Widget>) -> Self {
844        Self {
845            builder: self
846                .builder
847                .property("visible-child", visible_child.clone().upcast()),
848        }
849    }
850
851    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
852    pub fn visible_child_name(self, visible_child_name: impl Into<glib::GString>) -> Self {
853        Self {
854            builder: self
855                .builder
856                .property("visible-child-name", visible_child_name.into()),
857        }
858    }
859
860    pub fn can_focus(self, can_focus: bool) -> Self {
861        Self {
862            builder: self.builder.property("can-focus", can_focus),
863        }
864    }
865
866    pub fn can_target(self, can_target: bool) -> Self {
867        Self {
868            builder: self.builder.property("can-target", can_target),
869        }
870    }
871
872    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
873        Self {
874            builder: self.builder.property("css-classes", css_classes.into()),
875        }
876    }
877
878    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
879        Self {
880            builder: self.builder.property("css-name", css_name.into()),
881        }
882    }
883
884    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
885        Self {
886            builder: self.builder.property("cursor", cursor.clone()),
887        }
888    }
889
890    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
891        Self {
892            builder: self.builder.property("focus-on-click", focus_on_click),
893        }
894    }
895
896    pub fn focusable(self, focusable: bool) -> Self {
897        Self {
898            builder: self.builder.property("focusable", focusable),
899        }
900    }
901
902    pub fn halign(self, halign: gtk::Align) -> Self {
903        Self {
904            builder: self.builder.property("halign", halign),
905        }
906    }
907
908    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
909        Self {
910            builder: self.builder.property("has-tooltip", has_tooltip),
911        }
912    }
913
914    pub fn height_request(self, height_request: i32) -> Self {
915        Self {
916            builder: self.builder.property("height-request", height_request),
917        }
918    }
919
920    pub fn hexpand(self, hexpand: bool) -> Self {
921        Self {
922            builder: self.builder.property("hexpand", hexpand),
923        }
924    }
925
926    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
927        Self {
928            builder: self.builder.property("hexpand-set", hexpand_set),
929        }
930    }
931
932    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
933        Self {
934            builder: self
935                .builder
936                .property("layout-manager", layout_manager.clone().upcast()),
937        }
938    }
939
940    #[cfg(feature = "gtk_v4_18")]
941    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
942    pub fn limit_events(self, limit_events: bool) -> Self {
943        Self {
944            builder: self.builder.property("limit-events", limit_events),
945        }
946    }
947
948    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
949        Self {
950            builder: self.builder.property("margin-bottom", margin_bottom),
951        }
952    }
953
954    pub fn margin_end(self, margin_end: i32) -> Self {
955        Self {
956            builder: self.builder.property("margin-end", margin_end),
957        }
958    }
959
960    pub fn margin_start(self, margin_start: i32) -> Self {
961        Self {
962            builder: self.builder.property("margin-start", margin_start),
963        }
964    }
965
966    pub fn margin_top(self, margin_top: i32) -> Self {
967        Self {
968            builder: self.builder.property("margin-top", margin_top),
969        }
970    }
971
972    pub fn name(self, name: impl Into<glib::GString>) -> Self {
973        Self {
974            builder: self.builder.property("name", name.into()),
975        }
976    }
977
978    pub fn opacity(self, opacity: f64) -> Self {
979        Self {
980            builder: self.builder.property("opacity", opacity),
981        }
982    }
983
984    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
985        Self {
986            builder: self.builder.property("overflow", overflow),
987        }
988    }
989
990    pub fn receives_default(self, receives_default: bool) -> Self {
991        Self {
992            builder: self.builder.property("receives-default", receives_default),
993        }
994    }
995
996    pub fn sensitive(self, sensitive: bool) -> Self {
997        Self {
998            builder: self.builder.property("sensitive", sensitive),
999        }
1000    }
1001
1002    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1003        Self {
1004            builder: self
1005                .builder
1006                .property("tooltip-markup", tooltip_markup.into()),
1007        }
1008    }
1009
1010    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1011        Self {
1012            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1013        }
1014    }
1015
1016    pub fn valign(self, valign: gtk::Align) -> Self {
1017        Self {
1018            builder: self.builder.property("valign", valign),
1019        }
1020    }
1021
1022    pub fn vexpand(self, vexpand: bool) -> Self {
1023        Self {
1024            builder: self.builder.property("vexpand", vexpand),
1025        }
1026    }
1027
1028    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1029        Self {
1030            builder: self.builder.property("vexpand-set", vexpand_set),
1031        }
1032    }
1033
1034    pub fn visible(self, visible: bool) -> Self {
1035        Self {
1036            builder: self.builder.property("visible", visible),
1037        }
1038    }
1039
1040    pub fn width_request(self, width_request: i32) -> Self {
1041        Self {
1042            builder: self.builder.property("width-request", width_request),
1043        }
1044    }
1045
1046    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
1047        Self {
1048            builder: self.builder.property("accessible-role", accessible_role),
1049        }
1050    }
1051
1052    pub fn orientation(self, orientation: gtk::Orientation) -> Self {
1053        Self {
1054            builder: self.builder.property("orientation", orientation),
1055        }
1056    }
1057
1058    // rustdoc-stripper-ignore-next
1059    /// Build the [`Leaflet`].
1060    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1061    pub fn build(self) -> Leaflet {
1062        assert_initialized_main_thread!();
1063        self.builder.build()
1064    }
1065}