Skip to main content

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