gtk4/auto/
stack_page.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{Accessible, Widget, ffi};
6use glib::{
7    prelude::*,
8    signal::{SignalHandlerId, connect_raw},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    /// An auxiliary class used by [`Stack`][crate::Stack].
15    ///
16    /// ## Properties
17    ///
18    ///
19    /// #### `child`
20    ///  The child that this page is for.
21    ///
22    /// Readable | Writeable | Construct Only
23    ///
24    ///
25    /// #### `icon-name`
26    ///  The icon name of the child page.
27    ///
28    /// Readable | Writeable
29    ///
30    ///
31    /// #### `name`
32    ///  The name of the child page.
33    ///
34    /// Readable | Writeable
35    ///
36    ///
37    /// #### `needs-attention`
38    ///  Whether the page requires the user attention.
39    ///
40    /// This is used by the [`StackSwitcher`][crate::StackSwitcher] to change the
41    /// appearance of the corresponding button when a page needs
42    /// attention and it is not the current one.
43    ///
44    /// Readable | Writeable
45    ///
46    ///
47    /// #### `title`
48    ///  The title of the child page.
49    ///
50    /// Readable | Writeable
51    ///
52    ///
53    /// #### `use-underline`
54    ///  If set, an underline in the title indicates a mnemonic.
55    ///
56    /// Readable | Writeable
57    ///
58    ///
59    /// #### `visible`
60    ///  Whether this page is visible.
61    ///
62    /// Readable | Writeable
63    /// <details><summary><h4>Accessible</h4></summary>
64    ///
65    ///
66    /// #### `accessible-role`
67    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
68    ///
69    /// The accessible role cannot be changed once set.
70    ///
71    /// Readable | Writeable
72    /// </details>
73    ///
74    /// # Implements
75    ///
76    /// [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
77    #[doc(alias = "GtkStackPage")]
78    pub struct StackPage(Object<ffi::GtkStackPage>) @implements Accessible;
79
80    match fn {
81        type_ => || ffi::gtk_stack_page_get_type(),
82    }
83}
84
85impl StackPage {
86    /// Returns the stack child to which @self belongs.
87    ///
88    /// # Returns
89    ///
90    /// the child to which @self belongs
91    #[doc(alias = "gtk_stack_page_get_child")]
92    #[doc(alias = "get_child")]
93    pub fn child(&self) -> Widget {
94        unsafe { from_glib_none(ffi::gtk_stack_page_get_child(self.to_glib_none().0)) }
95    }
96
97    /// Returns the icon name of the page.
98    ///
99    /// # Returns
100    ///
101    /// The value of the [`icon-name`][struct@crate::StackPage#icon-name] property
102    #[doc(alias = "gtk_stack_page_get_icon_name")]
103    #[doc(alias = "get_icon_name")]
104    #[doc(alias = "icon-name")]
105    pub fn icon_name(&self) -> Option<glib::GString> {
106        unsafe { from_glib_none(ffi::gtk_stack_page_get_icon_name(self.to_glib_none().0)) }
107    }
108
109    /// Returns the name of the page.
110    ///
111    /// # Returns
112    ///
113    /// The value of the [`name`][struct@crate::StackPage#name] property
114    #[doc(alias = "gtk_stack_page_get_name")]
115    #[doc(alias = "get_name")]
116    pub fn name(&self) -> Option<glib::GString> {
117        unsafe { from_glib_none(ffi::gtk_stack_page_get_name(self.to_glib_none().0)) }
118    }
119
120    /// Returns whether the page is marked as “needs attention”.
121    ///
122    /// # Returns
123    ///
124    /// The value of the [`needs-attention`][struct@crate::StackPage#needs-attention]
125    ///   property.
126    #[doc(alias = "gtk_stack_page_get_needs_attention")]
127    #[doc(alias = "get_needs_attention")]
128    #[doc(alias = "needs-attention")]
129    pub fn needs_attention(&self) -> bool {
130        unsafe {
131            from_glib(ffi::gtk_stack_page_get_needs_attention(
132                self.to_glib_none().0,
133            ))
134        }
135    }
136
137    /// Gets the page title.
138    ///
139    /// # Returns
140    ///
141    /// The value of the [`title`][struct@crate::StackPage#title] property
142    #[doc(alias = "gtk_stack_page_get_title")]
143    #[doc(alias = "get_title")]
144    pub fn title(&self) -> Option<glib::GString> {
145        unsafe { from_glib_none(ffi::gtk_stack_page_get_title(self.to_glib_none().0)) }
146    }
147
148    /// Gets whether underlines in the page title indicate mnemonics.
149    ///
150    /// # Returns
151    ///
152    /// The value of the [`use-underline`][struct@crate::StackPage#use-underline] property
153    #[doc(alias = "gtk_stack_page_get_use_underline")]
154    #[doc(alias = "get_use_underline")]
155    #[doc(alias = "use-underline")]
156    pub fn uses_underline(&self) -> bool {
157        unsafe { from_glib(ffi::gtk_stack_page_get_use_underline(self.to_glib_none().0)) }
158    }
159
160    /// Returns whether @page is visible in its [`Stack`][crate::Stack].
161    ///
162    /// This is independent from the [`visible`][struct@crate::Widget#visible]
163    /// property of its widget.
164    ///
165    /// # Returns
166    ///
167    /// [`true`] if @page is visible
168    #[doc(alias = "gtk_stack_page_get_visible")]
169    #[doc(alias = "get_visible")]
170    #[doc(alias = "visible")]
171    pub fn is_visible(&self) -> bool {
172        unsafe { from_glib(ffi::gtk_stack_page_get_visible(self.to_glib_none().0)) }
173    }
174
175    /// Sets the icon name of the page.
176    /// ## `setting`
177    /// the new value to set
178    #[doc(alias = "gtk_stack_page_set_icon_name")]
179    #[doc(alias = "icon-name")]
180    pub fn set_icon_name(&self, setting: &str) {
181        unsafe {
182            ffi::gtk_stack_page_set_icon_name(self.to_glib_none().0, setting.to_glib_none().0);
183        }
184    }
185
186    /// Sets the name of the page.
187    /// ## `setting`
188    /// the new value to set
189    #[doc(alias = "gtk_stack_page_set_name")]
190    #[doc(alias = "name")]
191    pub fn set_name(&self, setting: &str) {
192        unsafe {
193            ffi::gtk_stack_page_set_name(self.to_glib_none().0, setting.to_glib_none().0);
194        }
195    }
196
197    /// Sets whether the page is marked as “needs attention”.
198    /// ## `setting`
199    /// the new value to set
200    #[doc(alias = "gtk_stack_page_set_needs_attention")]
201    #[doc(alias = "needs-attention")]
202    pub fn set_needs_attention(&self, setting: bool) {
203        unsafe {
204            ffi::gtk_stack_page_set_needs_attention(self.to_glib_none().0, setting.into_glib());
205        }
206    }
207
208    /// Sets the page title.
209    /// ## `setting`
210    /// the new value to set
211    #[doc(alias = "gtk_stack_page_set_title")]
212    #[doc(alias = "title")]
213    pub fn set_title(&self, setting: &str) {
214        unsafe {
215            ffi::gtk_stack_page_set_title(self.to_glib_none().0, setting.to_glib_none().0);
216        }
217    }
218
219    /// Sets whether underlines in the page title indicate mnemonics.
220    /// ## `setting`
221    /// the new value to set
222    #[doc(alias = "gtk_stack_page_set_use_underline")]
223    #[doc(alias = "use-underline")]
224    pub fn set_use_underline(&self, setting: bool) {
225        unsafe {
226            ffi::gtk_stack_page_set_use_underline(self.to_glib_none().0, setting.into_glib());
227        }
228    }
229
230    /// Sets whether @page is visible in its [`Stack`][crate::Stack].
231    /// ## `visible`
232    /// The new property value
233    #[doc(alias = "gtk_stack_page_set_visible")]
234    #[doc(alias = "visible")]
235    pub fn set_visible(&self, visible: bool) {
236        unsafe {
237            ffi::gtk_stack_page_set_visible(self.to_glib_none().0, visible.into_glib());
238        }
239    }
240
241    #[doc(alias = "icon-name")]
242    pub fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
243        unsafe extern "C" fn notify_icon_name_trampoline<F: Fn(&StackPage) + 'static>(
244            this: *mut ffi::GtkStackPage,
245            _param_spec: glib::ffi::gpointer,
246            f: glib::ffi::gpointer,
247        ) {
248            unsafe {
249                let f: &F = &*(f as *const F);
250                f(&from_glib_borrow(this))
251            }
252        }
253        unsafe {
254            let f: Box_<F> = Box_::new(f);
255            connect_raw(
256                self.as_ptr() as *mut _,
257                c"notify::icon-name".as_ptr() as *const _,
258                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
259                    notify_icon_name_trampoline::<F> as *const (),
260                )),
261                Box_::into_raw(f),
262            )
263        }
264    }
265
266    #[doc(alias = "name")]
267    pub fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
268        unsafe extern "C" fn notify_name_trampoline<F: Fn(&StackPage) + 'static>(
269            this: *mut ffi::GtkStackPage,
270            _param_spec: glib::ffi::gpointer,
271            f: glib::ffi::gpointer,
272        ) {
273            unsafe {
274                let f: &F = &*(f as *const F);
275                f(&from_glib_borrow(this))
276            }
277        }
278        unsafe {
279            let f: Box_<F> = Box_::new(f);
280            connect_raw(
281                self.as_ptr() as *mut _,
282                c"notify::name".as_ptr() as *const _,
283                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
284                    notify_name_trampoline::<F> as *const (),
285                )),
286                Box_::into_raw(f),
287            )
288        }
289    }
290
291    #[doc(alias = "needs-attention")]
292    pub fn connect_needs_attention_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
293        unsafe extern "C" fn notify_needs_attention_trampoline<F: Fn(&StackPage) + 'static>(
294            this: *mut ffi::GtkStackPage,
295            _param_spec: glib::ffi::gpointer,
296            f: glib::ffi::gpointer,
297        ) {
298            unsafe {
299                let f: &F = &*(f as *const F);
300                f(&from_glib_borrow(this))
301            }
302        }
303        unsafe {
304            let f: Box_<F> = Box_::new(f);
305            connect_raw(
306                self.as_ptr() as *mut _,
307                c"notify::needs-attention".as_ptr() as *const _,
308                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
309                    notify_needs_attention_trampoline::<F> as *const (),
310                )),
311                Box_::into_raw(f),
312            )
313        }
314    }
315
316    #[doc(alias = "title")]
317    pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
318        unsafe extern "C" fn notify_title_trampoline<F: Fn(&StackPage) + 'static>(
319            this: *mut ffi::GtkStackPage,
320            _param_spec: glib::ffi::gpointer,
321            f: glib::ffi::gpointer,
322        ) {
323            unsafe {
324                let f: &F = &*(f as *const F);
325                f(&from_glib_borrow(this))
326            }
327        }
328        unsafe {
329            let f: Box_<F> = Box_::new(f);
330            connect_raw(
331                self.as_ptr() as *mut _,
332                c"notify::title".as_ptr() as *const _,
333                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
334                    notify_title_trampoline::<F> as *const (),
335                )),
336                Box_::into_raw(f),
337            )
338        }
339    }
340
341    #[doc(alias = "use-underline")]
342    pub fn connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
343        unsafe extern "C" fn notify_use_underline_trampoline<F: Fn(&StackPage) + 'static>(
344            this: *mut ffi::GtkStackPage,
345            _param_spec: glib::ffi::gpointer,
346            f: glib::ffi::gpointer,
347        ) {
348            unsafe {
349                let f: &F = &*(f as *const F);
350                f(&from_glib_borrow(this))
351            }
352        }
353        unsafe {
354            let f: Box_<F> = Box_::new(f);
355            connect_raw(
356                self.as_ptr() as *mut _,
357                c"notify::use-underline".as_ptr() as *const _,
358                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
359                    notify_use_underline_trampoline::<F> as *const (),
360                )),
361                Box_::into_raw(f),
362            )
363        }
364    }
365
366    #[doc(alias = "visible")]
367    pub fn connect_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
368        unsafe extern "C" fn notify_visible_trampoline<F: Fn(&StackPage) + 'static>(
369            this: *mut ffi::GtkStackPage,
370            _param_spec: glib::ffi::gpointer,
371            f: glib::ffi::gpointer,
372        ) {
373            unsafe {
374                let f: &F = &*(f as *const F);
375                f(&from_glib_borrow(this))
376            }
377        }
378        unsafe {
379            let f: Box_<F> = Box_::new(f);
380            connect_raw(
381                self.as_ptr() as *mut _,
382                c"notify::visible".as_ptr() as *const _,
383                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
384                    notify_visible_trampoline::<F> as *const (),
385                )),
386                Box_::into_raw(f),
387            )
388        }
389    }
390}