Skip to main content

libadwaita/auto/
squeezer_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#![allow(deprecated)]
6
7use crate::ffi;
8use glib::{
9    prelude::*,
10    signal::{SignalHandlerId, connect_raw},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    /// See [the migration guide](migrating-to-breakpoints.html#replace-adwsqueezer)
17    /// An auxiliary class used by [`Squeezer`][crate::Squeezer].
18    ///
19    /// ## Properties
20    ///
21    ///
22    /// #### `child`
23    ///  The the squeezer child to which the page belongs.
24    ///
25    /// Readable | Writable | Construct Only
26    ///
27    ///
28    /// #### `enabled`
29    ///  Whether the child is enabled.
30    ///
31    /// If a child is disabled, it will be ignored when looking for the child
32    /// fitting the available size best.
33    ///
34    /// This allows to programmatically and prematurely hide a child even if it
35    /// fits in the available space.
36    ///
37    /// This can be used e.g. to ensure a certain child is hidden below a certain
38    /// window width, or any other constraint you find suitable.
39    ///
40    /// Readable | Writable
41    ///
42    /// # Implements
43    ///
44    /// [`trait@glib::ObjectExt`]
45    #[doc(alias = "AdwSqueezerPage")]
46    pub struct SqueezerPage(Object<ffi::AdwSqueezerPage, ffi::AdwSqueezerPageClass>);
47
48    match fn {
49        type_ => || ffi::adw_squeezer_page_get_type(),
50    }
51}
52
53impl SqueezerPage {
54    /// Returns the squeezer child to which @self belongs.
55    ///
56    /// # Deprecated since 1.4
57    ///
58    /// See [the migration guide](migrating-to-breakpoints.html#replace-adwsqueezer)
59    ///
60    /// # Returns
61    ///
62    /// the child to which @self belongs
63    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
64    #[allow(deprecated)]
65    #[doc(alias = "adw_squeezer_page_get_child")]
66    #[doc(alias = "get_child")]
67    pub fn child(&self) -> gtk::Widget {
68        unsafe { from_glib_none(ffi::adw_squeezer_page_get_child(self.to_glib_none().0)) }
69    }
70
71    /// Gets whether @self is enabled.
72    ///
73    /// # Deprecated since 1.4
74    ///
75    /// See [the migration guide](migrating-to-breakpoints.html#replace-adwsqueezer)
76    ///
77    /// # Returns
78    ///
79    /// whether @self is enabled
80    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
81    #[allow(deprecated)]
82    #[doc(alias = "adw_squeezer_page_get_enabled")]
83    #[doc(alias = "get_enabled")]
84    #[doc(alias = "enabled")]
85    pub fn is_enabled(&self) -> bool {
86        unsafe { from_glib(ffi::adw_squeezer_page_get_enabled(self.to_glib_none().0)) }
87    }
88
89    /// Sets whether @self is enabled.
90    ///
91    /// If a child is disabled, it will be ignored when looking for the child
92    /// fitting the available size best.
93    ///
94    /// This allows to programmatically and prematurely hide a child even if it fits
95    /// in the available space.
96    ///
97    /// This can be used e.g. to ensure a certain child is hidden below a certain
98    /// window width, or any other constraint you find suitable.
99    ///
100    /// # Deprecated since 1.4
101    ///
102    /// See [the migration guide](migrating-to-breakpoints.html#replace-adwsqueezer)
103    /// ## `enabled`
104    /// whether @self is enabled
105    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
106    #[allow(deprecated)]
107    #[doc(alias = "adw_squeezer_page_set_enabled")]
108    #[doc(alias = "enabled")]
109    pub fn set_enabled(&self, enabled: bool) {
110        unsafe {
111            ffi::adw_squeezer_page_set_enabled(self.to_glib_none().0, enabled.into_glib());
112        }
113    }
114
115    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
116    #[doc(alias = "enabled")]
117    pub fn connect_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
118        unsafe extern "C" fn notify_enabled_trampoline<F: Fn(&SqueezerPage) + 'static>(
119            this: *mut ffi::AdwSqueezerPage,
120            _param_spec: glib::ffi::gpointer,
121            f: glib::ffi::gpointer,
122        ) {
123            unsafe {
124                let f: &F = &*(f as *const F);
125                f(&from_glib_borrow(this))
126            }
127        }
128        unsafe {
129            let f: Box_<F> = Box_::new(f);
130            connect_raw(
131                self.as_ptr() as *mut _,
132                c"notify::enabled".as_ptr(),
133                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
134                    notify_enabled_trampoline::<F> as *const (),
135                )),
136                Box_::into_raw(f),
137            )
138        }
139    }
140}