Skip to main content

libadwaita/auto/
view_stack_page.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    /// An auxiliary class used by [`ViewStack`][crate::ViewStack].
16    ///
17    /// ## Properties
18    ///
19    ///
20    /// #### `badge-number`
21    ///  The badge number for this page.
22    ///
23    /// [`ViewSwitcher`][crate::ViewSwitcher] can display it as a badge next to the page icon. It is
24    /// commonly used to display a number of unread items within the page.
25    ///
26    /// It can be used together with [property@ViewStack{age}:needs-attention].
27    ///
28    /// Readable | Writeable
29    ///
30    ///
31    /// #### `child`
32    ///  The stack child to which the page belongs.
33    ///
34    /// Readable | Writeable | Construct Only
35    ///
36    ///
37    /// #### `icon-name`
38    ///  The icon name of the child page.
39    ///
40    /// Readable | Writeable
41    ///
42    ///
43    /// #### `name`
44    ///  The name of the child page.
45    ///
46    /// Readable | Writeable
47    ///
48    ///
49    /// #### `needs-attention`
50    ///  Whether the page requires the user attention.
51    ///
52    /// [`ViewSwitcher`][crate::ViewSwitcher] will display it as a dot next to the page icon.
53    ///
54    /// Readable | Writeable
55    ///
56    ///
57    /// #### `section-title`
58    ///  Section title for this page.
59    ///
60    /// Does nothing unless [`starts-section`][struct@crate::ViewStackPage#starts-section] is set.
61    ///
62    /// Readable | Writeable
63    ///
64    ///
65    /// #### `starts-section`
66    ///  Whether this page starts a section.
67    ///
68    /// If set to `TRUE`, [`pages`][struct@crate::ViewStack#pages] will have a section starting
69    /// from this page.
70    ///
71    /// If [`section-title`][struct@crate::ViewStackPage#section-title] is set, it should be used as a
72    /// title for the section.
73    ///
74    /// Readable | Writeable
75    ///
76    ///
77    /// #### `title`
78    ///  The title of the child page.
79    ///
80    /// Readable | Writeable
81    ///
82    ///
83    /// #### `use-underline`
84    ///  Whether an embedded underline in the title indicates a mnemonic.
85    ///
86    /// Readable | Writeable
87    ///
88    ///
89    /// #### `visible`
90    ///  Whether this page is visible.
91    ///
92    /// This is independent from the [`visible`][struct@crate::gtk::Widget#visible] property of
93    /// [`child`][struct@crate::ViewStackPage#child].
94    ///
95    /// Readable | Writeable
96    /// <details><summary><h4>Accessible</h4></summary>
97    ///
98    ///
99    /// #### `accessible-role`
100    ///  The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
101    ///
102    /// The accessible role cannot be changed once set.
103    ///
104    /// Readable | Writeable
105    /// </details>
106    ///
107    /// # Implements
108    ///
109    /// [`trait@glib::ObjectExt`], [`trait@gtk::prelude::AccessibleExt`]
110    #[doc(alias = "AdwViewStackPage")]
111    pub struct ViewStackPage(Object<ffi::AdwViewStackPage, ffi::AdwViewStackPageClass>) @implements gtk::Accessible;
112
113    match fn {
114        type_ => || ffi::adw_view_stack_page_get_type(),
115    }
116}
117
118impl ViewStackPage {
119    /// Gets the badge number for this page.
120    ///
121    /// # Returns
122    ///
123    /// the badge number for this page
124    #[doc(alias = "adw_view_stack_page_get_badge_number")]
125    #[doc(alias = "get_badge_number")]
126    #[doc(alias = "badge-number")]
127    pub fn badge_number(&self) -> u32 {
128        unsafe { ffi::adw_view_stack_page_get_badge_number(self.to_glib_none().0) }
129    }
130
131    /// Gets the stack child to which @self belongs.
132    ///
133    /// # Returns
134    ///
135    /// the child to which @self belongs
136    #[doc(alias = "adw_view_stack_page_get_child")]
137    #[doc(alias = "get_child")]
138    pub fn child(&self) -> gtk::Widget {
139        unsafe { from_glib_none(ffi::adw_view_stack_page_get_child(self.to_glib_none().0)) }
140    }
141
142    /// Gets the icon name of the page.
143    ///
144    /// # Returns
145    ///
146    /// the icon name of the page
147    #[doc(alias = "adw_view_stack_page_get_icon_name")]
148    #[doc(alias = "get_icon_name")]
149    #[doc(alias = "icon-name")]
150    pub fn icon_name(&self) -> Option<glib::GString> {
151        unsafe {
152            from_glib_none(ffi::adw_view_stack_page_get_icon_name(
153                self.to_glib_none().0,
154            ))
155        }
156    }
157
158    /// Gets the name of the page.
159    ///
160    /// # Returns
161    ///
162    /// the name of the page
163    #[doc(alias = "adw_view_stack_page_get_name")]
164    #[doc(alias = "get_name")]
165    pub fn name(&self) -> Option<glib::GString> {
166        unsafe { from_glib_none(ffi::adw_view_stack_page_get_name(self.to_glib_none().0)) }
167    }
168
169    /// Gets whether the page requires the user attention.
170    ///
171    /// # Returns
172    ///
173    /// whether the page needs attention
174    #[doc(alias = "adw_view_stack_page_get_needs_attention")]
175    #[doc(alias = "get_needs_attention")]
176    #[doc(alias = "needs-attention")]
177    pub fn needs_attention(&self) -> bool {
178        unsafe {
179            from_glib(ffi::adw_view_stack_page_get_needs_attention(
180                self.to_glib_none().0,
181            ))
182        }
183    }
184
185    /// Gets the section title for @self.
186    ///
187    /// # Returns
188    ///
189    /// the section title
190    #[cfg(feature = "v1_9")]
191    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
192    #[doc(alias = "adw_view_stack_page_get_section_title")]
193    #[doc(alias = "get_section_title")]
194    #[doc(alias = "section-title")]
195    pub fn section_title(&self) -> Option<glib::GString> {
196        unsafe {
197            from_glib_none(ffi::adw_view_stack_page_get_section_title(
198                self.to_glib_none().0,
199            ))
200        }
201    }
202
203    /// Gets whether @self starts a section.
204    ///
205    /// # Returns
206    ///
207    /// whether @self starts a section
208    #[cfg(feature = "v1_9")]
209    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
210    #[doc(alias = "adw_view_stack_page_get_starts_section")]
211    #[doc(alias = "get_starts_section")]
212    #[doc(alias = "starts-section")]
213    pub fn is_starts_section(&self) -> bool {
214        unsafe {
215            from_glib(ffi::adw_view_stack_page_get_starts_section(
216                self.to_glib_none().0,
217            ))
218        }
219    }
220
221    /// Gets the page title.
222    ///
223    /// # Returns
224    ///
225    /// the page title
226    #[doc(alias = "adw_view_stack_page_get_title")]
227    #[doc(alias = "get_title")]
228    pub fn title(&self) -> Option<glib::GString> {
229        unsafe { from_glib_none(ffi::adw_view_stack_page_get_title(self.to_glib_none().0)) }
230    }
231
232    /// Gets whether underlines in the page title indicate mnemonics.
233    ///
234    /// # Returns
235    ///
236    /// whether underlines in the page title indicate mnemonics
237    #[doc(alias = "adw_view_stack_page_get_use_underline")]
238    #[doc(alias = "get_use_underline")]
239    #[doc(alias = "use-underline")]
240    pub fn uses_underline(&self) -> bool {
241        unsafe {
242            from_glib(ffi::adw_view_stack_page_get_use_underline(
243                self.to_glib_none().0,
244            ))
245        }
246    }
247
248    /// Gets whether @self is visible in its [`ViewStack`][crate::ViewStack].
249    ///
250    /// This is independent from the [`visible`][struct@crate::gtk::Widget#visible]
251    /// property of its widget.
252    ///
253    /// # Returns
254    ///
255    /// whether @self is visible
256    #[doc(alias = "adw_view_stack_page_get_visible")]
257    #[doc(alias = "get_visible")]
258    #[doc(alias = "visible")]
259    pub fn is_visible(&self) -> bool {
260        unsafe { from_glib(ffi::adw_view_stack_page_get_visible(self.to_glib_none().0)) }
261    }
262
263    /// Sets the badge number for this page.
264    ///
265    /// [`ViewSwitcher`][crate::ViewSwitcher] can display it as a badge next to the page icon. It is
266    /// commonly used to display a number of unread items within the page.
267    ///
268    /// It can be used together with [property@ViewStack{age}:needs-attention].
269    /// ## `badge_number`
270    /// the new value to set
271    #[doc(alias = "adw_view_stack_page_set_badge_number")]
272    #[doc(alias = "badge-number")]
273    pub fn set_badge_number(&self, badge_number: u32) {
274        unsafe {
275            ffi::adw_view_stack_page_set_badge_number(self.to_glib_none().0, badge_number);
276        }
277    }
278
279    /// Sets the icon name of the page.
280    /// ## `icon_name`
281    /// the icon name
282    #[doc(alias = "adw_view_stack_page_set_icon_name")]
283    #[doc(alias = "icon-name")]
284    pub fn set_icon_name(&self, icon_name: Option<&str>) {
285        unsafe {
286            ffi::adw_view_stack_page_set_icon_name(
287                self.to_glib_none().0,
288                icon_name.to_glib_none().0,
289            );
290        }
291    }
292
293    /// Sets the name of the page.
294    /// ## `name`
295    /// the page name
296    #[doc(alias = "adw_view_stack_page_set_name")]
297    #[doc(alias = "name")]
298    pub fn set_name(&self, name: Option<&str>) {
299        unsafe {
300            ffi::adw_view_stack_page_set_name(self.to_glib_none().0, name.to_glib_none().0);
301        }
302    }
303
304    /// Sets whether the page requires the user attention.
305    ///
306    /// [`ViewSwitcher`][crate::ViewSwitcher] will display it as a dot next to the page icon.
307    /// ## `needs_attention`
308    /// the new value to set
309    #[doc(alias = "adw_view_stack_page_set_needs_attention")]
310    #[doc(alias = "needs-attention")]
311    pub fn set_needs_attention(&self, needs_attention: bool) {
312        unsafe {
313            ffi::adw_view_stack_page_set_needs_attention(
314                self.to_glib_none().0,
315                needs_attention.into_glib(),
316            );
317        }
318    }
319
320    /// Sets the section title for @self.
321    ///
322    /// Does nothing unless [`starts-section`][struct@crate::ViewStackPage#starts-section] is set.
323    /// ## `section_title`
324    /// the section title
325    #[cfg(feature = "v1_9")]
326    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
327    #[doc(alias = "adw_view_stack_page_set_section_title")]
328    #[doc(alias = "section-title")]
329    pub fn set_section_title(&self, section_title: Option<&str>) {
330        unsafe {
331            ffi::adw_view_stack_page_set_section_title(
332                self.to_glib_none().0,
333                section_title.to_glib_none().0,
334            );
335        }
336    }
337
338    /// Sets whether @self starts a section.
339    ///
340    /// If set to `TRUE`, [`pages`][struct@crate::ViewStack#pages] will have a section starting
341    /// from this page.
342    ///
343    /// If [`section-title`][struct@crate::ViewStackPage#section-title] is set, it should be used as a
344    /// title for the section.
345    /// ## `starts_section`
346    /// whether @self starts a section
347    #[cfg(feature = "v1_9")]
348    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
349    #[doc(alias = "adw_view_stack_page_set_starts_section")]
350    #[doc(alias = "starts-section")]
351    pub fn set_starts_section(&self, starts_section: bool) {
352        unsafe {
353            ffi::adw_view_stack_page_set_starts_section(
354                self.to_glib_none().0,
355                starts_section.into_glib(),
356            );
357        }
358    }
359
360    /// Sets the page title.
361    /// ## `title`
362    /// the page title
363    #[doc(alias = "adw_view_stack_page_set_title")]
364    #[doc(alias = "title")]
365    pub fn set_title(&self, title: Option<&str>) {
366        unsafe {
367            ffi::adw_view_stack_page_set_title(self.to_glib_none().0, title.to_glib_none().0);
368        }
369    }
370
371    /// Sets whether underlines in the page title indicate mnemonics.
372    /// ## `use_underline`
373    /// the new value to set
374    #[doc(alias = "adw_view_stack_page_set_use_underline")]
375    #[doc(alias = "use-underline")]
376    pub fn set_use_underline(&self, use_underline: bool) {
377        unsafe {
378            ffi::adw_view_stack_page_set_use_underline(
379                self.to_glib_none().0,
380                use_underline.into_glib(),
381            );
382        }
383    }
384
385    /// Sets whether @self is visible in its [`ViewStack`][crate::ViewStack].
386    ///
387    /// This is independent from the [`visible`][struct@crate::gtk::Widget#visible] property of
388    /// [`child`][struct@crate::ViewStackPage#child].
389    /// ## `visible`
390    /// whether @self is visible
391    #[doc(alias = "adw_view_stack_page_set_visible")]
392    #[doc(alias = "visible")]
393    pub fn set_visible(&self, visible: bool) {
394        unsafe {
395            ffi::adw_view_stack_page_set_visible(self.to_glib_none().0, visible.into_glib());
396        }
397    }
398
399    #[doc(alias = "badge-number")]
400    pub fn connect_badge_number_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
401        unsafe extern "C" fn notify_badge_number_trampoline<F: Fn(&ViewStackPage) + 'static>(
402            this: *mut ffi::AdwViewStackPage,
403            _param_spec: glib::ffi::gpointer,
404            f: glib::ffi::gpointer,
405        ) {
406            unsafe {
407                let f: &F = &*(f as *const F);
408                f(&from_glib_borrow(this))
409            }
410        }
411        unsafe {
412            let f: Box_<F> = Box_::new(f);
413            connect_raw(
414                self.as_ptr() as *mut _,
415                c"notify::badge-number".as_ptr() as *const _,
416                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
417                    notify_badge_number_trampoline::<F> as *const (),
418                )),
419                Box_::into_raw(f),
420            )
421        }
422    }
423
424    #[doc(alias = "icon-name")]
425    pub fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
426        unsafe extern "C" fn notify_icon_name_trampoline<F: Fn(&ViewStackPage) + 'static>(
427            this: *mut ffi::AdwViewStackPage,
428            _param_spec: glib::ffi::gpointer,
429            f: glib::ffi::gpointer,
430        ) {
431            unsafe {
432                let f: &F = &*(f as *const F);
433                f(&from_glib_borrow(this))
434            }
435        }
436        unsafe {
437            let f: Box_<F> = Box_::new(f);
438            connect_raw(
439                self.as_ptr() as *mut _,
440                c"notify::icon-name".as_ptr() as *const _,
441                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
442                    notify_icon_name_trampoline::<F> as *const (),
443                )),
444                Box_::into_raw(f),
445            )
446        }
447    }
448
449    #[doc(alias = "name")]
450    pub fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
451        unsafe extern "C" fn notify_name_trampoline<F: Fn(&ViewStackPage) + 'static>(
452            this: *mut ffi::AdwViewStackPage,
453            _param_spec: glib::ffi::gpointer,
454            f: glib::ffi::gpointer,
455        ) {
456            unsafe {
457                let f: &F = &*(f as *const F);
458                f(&from_glib_borrow(this))
459            }
460        }
461        unsafe {
462            let f: Box_<F> = Box_::new(f);
463            connect_raw(
464                self.as_ptr() as *mut _,
465                c"notify::name".as_ptr() as *const _,
466                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
467                    notify_name_trampoline::<F> as *const (),
468                )),
469                Box_::into_raw(f),
470            )
471        }
472    }
473
474    #[doc(alias = "needs-attention")]
475    pub fn connect_needs_attention_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
476        unsafe extern "C" fn notify_needs_attention_trampoline<F: Fn(&ViewStackPage) + 'static>(
477            this: *mut ffi::AdwViewStackPage,
478            _param_spec: glib::ffi::gpointer,
479            f: glib::ffi::gpointer,
480        ) {
481            unsafe {
482                let f: &F = &*(f as *const F);
483                f(&from_glib_borrow(this))
484            }
485        }
486        unsafe {
487            let f: Box_<F> = Box_::new(f);
488            connect_raw(
489                self.as_ptr() as *mut _,
490                c"notify::needs-attention".as_ptr() as *const _,
491                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
492                    notify_needs_attention_trampoline::<F> as *const (),
493                )),
494                Box_::into_raw(f),
495            )
496        }
497    }
498
499    #[cfg(feature = "v1_9")]
500    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
501    #[doc(alias = "section-title")]
502    pub fn connect_section_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
503        unsafe extern "C" fn notify_section_title_trampoline<F: Fn(&ViewStackPage) + 'static>(
504            this: *mut ffi::AdwViewStackPage,
505            _param_spec: glib::ffi::gpointer,
506            f: glib::ffi::gpointer,
507        ) {
508            unsafe {
509                let f: &F = &*(f as *const F);
510                f(&from_glib_borrow(this))
511            }
512        }
513        unsafe {
514            let f: Box_<F> = Box_::new(f);
515            connect_raw(
516                self.as_ptr() as *mut _,
517                c"notify::section-title".as_ptr() as *const _,
518                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
519                    notify_section_title_trampoline::<F> as *const (),
520                )),
521                Box_::into_raw(f),
522            )
523        }
524    }
525
526    #[cfg(feature = "v1_9")]
527    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
528    #[doc(alias = "starts-section")]
529    pub fn connect_starts_section_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
530        unsafe extern "C" fn notify_starts_section_trampoline<F: Fn(&ViewStackPage) + 'static>(
531            this: *mut ffi::AdwViewStackPage,
532            _param_spec: glib::ffi::gpointer,
533            f: glib::ffi::gpointer,
534        ) {
535            unsafe {
536                let f: &F = &*(f as *const F);
537                f(&from_glib_borrow(this))
538            }
539        }
540        unsafe {
541            let f: Box_<F> = Box_::new(f);
542            connect_raw(
543                self.as_ptr() as *mut _,
544                c"notify::starts-section".as_ptr() as *const _,
545                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
546                    notify_starts_section_trampoline::<F> as *const (),
547                )),
548                Box_::into_raw(f),
549            )
550        }
551    }
552
553    #[doc(alias = "title")]
554    pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
555        unsafe extern "C" fn notify_title_trampoline<F: Fn(&ViewStackPage) + 'static>(
556            this: *mut ffi::AdwViewStackPage,
557            _param_spec: glib::ffi::gpointer,
558            f: glib::ffi::gpointer,
559        ) {
560            unsafe {
561                let f: &F = &*(f as *const F);
562                f(&from_glib_borrow(this))
563            }
564        }
565        unsafe {
566            let f: Box_<F> = Box_::new(f);
567            connect_raw(
568                self.as_ptr() as *mut _,
569                c"notify::title".as_ptr() as *const _,
570                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
571                    notify_title_trampoline::<F> as *const (),
572                )),
573                Box_::into_raw(f),
574            )
575        }
576    }
577
578    #[doc(alias = "use-underline")]
579    pub fn connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
580        unsafe extern "C" fn notify_use_underline_trampoline<F: Fn(&ViewStackPage) + 'static>(
581            this: *mut ffi::AdwViewStackPage,
582            _param_spec: glib::ffi::gpointer,
583            f: glib::ffi::gpointer,
584        ) {
585            unsafe {
586                let f: &F = &*(f as *const F);
587                f(&from_glib_borrow(this))
588            }
589        }
590        unsafe {
591            let f: Box_<F> = Box_::new(f);
592            connect_raw(
593                self.as_ptr() as *mut _,
594                c"notify::use-underline".as_ptr() as *const _,
595                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
596                    notify_use_underline_trampoline::<F> as *const (),
597                )),
598                Box_::into_raw(f),
599            )
600        }
601    }
602
603    #[doc(alias = "visible")]
604    pub fn connect_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
605        unsafe extern "C" fn notify_visible_trampoline<F: Fn(&ViewStackPage) + 'static>(
606            this: *mut ffi::AdwViewStackPage,
607            _param_spec: glib::ffi::gpointer,
608            f: glib::ffi::gpointer,
609        ) {
610            unsafe {
611                let f: &F = &*(f as *const F);
612                f(&from_glib_borrow(this))
613            }
614        }
615        unsafe {
616            let f: Box_<F> = Box_::new(f);
617            connect_raw(
618                self.as_ptr() as *mut _,
619                c"notify::visible".as_ptr() as *const _,
620                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
621                    notify_visible_trampoline::<F> as *const (),
622                )),
623                Box_::into_raw(f),
624            )
625        }
626    }
627}