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::{ffi, Accessible, Widget};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    /// [`StackPage`][crate::StackPage] is 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            let f: &F = &*(f as *const F);
249            f(&from_glib_borrow(this))
250        }
251        unsafe {
252            let f: Box_<F> = Box_::new(f);
253            connect_raw(
254                self.as_ptr() as *mut _,
255                b"notify::icon-name\0".as_ptr() as *const _,
256                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
257                    notify_icon_name_trampoline::<F> as *const (),
258                )),
259                Box_::into_raw(f),
260            )
261        }
262    }
263
264    #[doc(alias = "name")]
265    pub fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
266        unsafe extern "C" fn notify_name_trampoline<F: Fn(&StackPage) + 'static>(
267            this: *mut ffi::GtkStackPage,
268            _param_spec: glib::ffi::gpointer,
269            f: glib::ffi::gpointer,
270        ) {
271            let f: &F = &*(f as *const F);
272            f(&from_glib_borrow(this))
273        }
274        unsafe {
275            let f: Box_<F> = Box_::new(f);
276            connect_raw(
277                self.as_ptr() as *mut _,
278                b"notify::name\0".as_ptr() as *const _,
279                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
280                    notify_name_trampoline::<F> as *const (),
281                )),
282                Box_::into_raw(f),
283            )
284        }
285    }
286
287    #[doc(alias = "needs-attention")]
288    pub fn connect_needs_attention_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
289        unsafe extern "C" fn notify_needs_attention_trampoline<F: Fn(&StackPage) + 'static>(
290            this: *mut ffi::GtkStackPage,
291            _param_spec: glib::ffi::gpointer,
292            f: glib::ffi::gpointer,
293        ) {
294            let f: &F = &*(f as *const F);
295            f(&from_glib_borrow(this))
296        }
297        unsafe {
298            let f: Box_<F> = Box_::new(f);
299            connect_raw(
300                self.as_ptr() as *mut _,
301                b"notify::needs-attention\0".as_ptr() as *const _,
302                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
303                    notify_needs_attention_trampoline::<F> as *const (),
304                )),
305                Box_::into_raw(f),
306            )
307        }
308    }
309
310    #[doc(alias = "title")]
311    pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
312        unsafe extern "C" fn notify_title_trampoline<F: Fn(&StackPage) + 'static>(
313            this: *mut ffi::GtkStackPage,
314            _param_spec: glib::ffi::gpointer,
315            f: glib::ffi::gpointer,
316        ) {
317            let f: &F = &*(f as *const F);
318            f(&from_glib_borrow(this))
319        }
320        unsafe {
321            let f: Box_<F> = Box_::new(f);
322            connect_raw(
323                self.as_ptr() as *mut _,
324                b"notify::title\0".as_ptr() as *const _,
325                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
326                    notify_title_trampoline::<F> as *const (),
327                )),
328                Box_::into_raw(f),
329            )
330        }
331    }
332
333    #[doc(alias = "use-underline")]
334    pub fn connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
335        unsafe extern "C" fn notify_use_underline_trampoline<F: Fn(&StackPage) + 'static>(
336            this: *mut ffi::GtkStackPage,
337            _param_spec: glib::ffi::gpointer,
338            f: glib::ffi::gpointer,
339        ) {
340            let f: &F = &*(f as *const F);
341            f(&from_glib_borrow(this))
342        }
343        unsafe {
344            let f: Box_<F> = Box_::new(f);
345            connect_raw(
346                self.as_ptr() as *mut _,
347                b"notify::use-underline\0".as_ptr() as *const _,
348                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
349                    notify_use_underline_trampoline::<F> as *const (),
350                )),
351                Box_::into_raw(f),
352            )
353        }
354    }
355
356    #[doc(alias = "visible")]
357    pub fn connect_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
358        unsafe extern "C" fn notify_visible_trampoline<F: Fn(&StackPage) + 'static>(
359            this: *mut ffi::GtkStackPage,
360            _param_spec: glib::ffi::gpointer,
361            f: glib::ffi::gpointer,
362        ) {
363            let f: &F = &*(f as *const F);
364            f(&from_glib_borrow(this))
365        }
366        unsafe {
367            let f: Box_<F> = Box_::new(f);
368            connect_raw(
369                self.as_ptr() as *mut _,
370                b"notify::visible\0".as_ptr() as *const _,
371                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
372                    notify_visible_trampoline::<F> as *const (),
373                )),
374                Box_::into_raw(f),
375            )
376        }
377    }
378}