libadwaita/auto/
clamp_layout.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;
7#[cfg(feature = "v1_4")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
9use crate::LengthUnit;
10use glib::{
11    prelude::*,
12    signal::{connect_raw, SignalHandlerId},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18    #[doc(alias = "AdwClampLayout")]
19    pub struct ClampLayout(Object<ffi::AdwClampLayout, ffi::AdwClampLayoutClass>) @extends gtk::LayoutManager, @implements gtk::Orientable;
20
21    match fn {
22        type_ => || ffi::adw_clamp_layout_get_type(),
23    }
24}
25
26impl ClampLayout {
27    #[doc(alias = "adw_clamp_layout_new")]
28    pub fn new() -> ClampLayout {
29        assert_initialized_main_thread!();
30        unsafe { gtk::LayoutManager::from_glib_full(ffi::adw_clamp_layout_new()).unsafe_cast() }
31    }
32
33    // rustdoc-stripper-ignore-next
34    /// Creates a new builder-pattern struct instance to construct [`ClampLayout`] objects.
35    ///
36    /// This method returns an instance of [`ClampLayoutBuilder`](crate::builders::ClampLayoutBuilder) which can be used to create [`ClampLayout`] objects.
37    pub fn builder() -> ClampLayoutBuilder {
38        ClampLayoutBuilder::new()
39    }
40
41    #[doc(alias = "adw_clamp_layout_get_maximum_size")]
42    #[doc(alias = "get_maximum_size")]
43    #[doc(alias = "maximum-size")]
44    pub fn maximum_size(&self) -> i32 {
45        unsafe { ffi::adw_clamp_layout_get_maximum_size(self.to_glib_none().0) }
46    }
47
48    #[doc(alias = "adw_clamp_layout_get_tightening_threshold")]
49    #[doc(alias = "get_tightening_threshold")]
50    #[doc(alias = "tightening-threshold")]
51    pub fn tightening_threshold(&self) -> i32 {
52        unsafe { ffi::adw_clamp_layout_get_tightening_threshold(self.to_glib_none().0) }
53    }
54
55    #[cfg(feature = "v1_4")]
56    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
57    #[doc(alias = "adw_clamp_layout_get_unit")]
58    #[doc(alias = "get_unit")]
59    pub fn unit(&self) -> LengthUnit {
60        unsafe { from_glib(ffi::adw_clamp_layout_get_unit(self.to_glib_none().0)) }
61    }
62
63    #[doc(alias = "adw_clamp_layout_set_maximum_size")]
64    #[doc(alias = "maximum-size")]
65    pub fn set_maximum_size(&self, maximum_size: i32) {
66        unsafe {
67            ffi::adw_clamp_layout_set_maximum_size(self.to_glib_none().0, maximum_size);
68        }
69    }
70
71    #[doc(alias = "adw_clamp_layout_set_tightening_threshold")]
72    #[doc(alias = "tightening-threshold")]
73    pub fn set_tightening_threshold(&self, tightening_threshold: i32) {
74        unsafe {
75            ffi::adw_clamp_layout_set_tightening_threshold(
76                self.to_glib_none().0,
77                tightening_threshold,
78            );
79        }
80    }
81
82    #[cfg(feature = "v1_4")]
83    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
84    #[doc(alias = "adw_clamp_layout_set_unit")]
85    #[doc(alias = "unit")]
86    pub fn set_unit(&self, unit: LengthUnit) {
87        unsafe {
88            ffi::adw_clamp_layout_set_unit(self.to_glib_none().0, unit.into_glib());
89        }
90    }
91
92    #[doc(alias = "maximum-size")]
93    pub fn connect_maximum_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
94        unsafe extern "C" fn notify_maximum_size_trampoline<F: Fn(&ClampLayout) + 'static>(
95            this: *mut ffi::AdwClampLayout,
96            _param_spec: glib::ffi::gpointer,
97            f: glib::ffi::gpointer,
98        ) {
99            let f: &F = &*(f as *const F);
100            f(&from_glib_borrow(this))
101        }
102        unsafe {
103            let f: Box_<F> = Box_::new(f);
104            connect_raw(
105                self.as_ptr() as *mut _,
106                c"notify::maximum-size".as_ptr() as *const _,
107                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
108                    notify_maximum_size_trampoline::<F> as *const (),
109                )),
110                Box_::into_raw(f),
111            )
112        }
113    }
114
115    #[doc(alias = "tightening-threshold")]
116    pub fn connect_tightening_threshold_notify<F: Fn(&Self) + 'static>(
117        &self,
118        f: F,
119    ) -> SignalHandlerId {
120        unsafe extern "C" fn notify_tightening_threshold_trampoline<
121            F: Fn(&ClampLayout) + 'static,
122        >(
123            this: *mut ffi::AdwClampLayout,
124            _param_spec: glib::ffi::gpointer,
125            f: glib::ffi::gpointer,
126        ) {
127            let f: &F = &*(f as *const F);
128            f(&from_glib_borrow(this))
129        }
130        unsafe {
131            let f: Box_<F> = Box_::new(f);
132            connect_raw(
133                self.as_ptr() as *mut _,
134                c"notify::tightening-threshold".as_ptr() as *const _,
135                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
136                    notify_tightening_threshold_trampoline::<F> as *const (),
137                )),
138                Box_::into_raw(f),
139            )
140        }
141    }
142
143    #[cfg(feature = "v1_4")]
144    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
145    #[doc(alias = "unit")]
146    pub fn connect_unit_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
147        unsafe extern "C" fn notify_unit_trampoline<F: Fn(&ClampLayout) + 'static>(
148            this: *mut ffi::AdwClampLayout,
149            _param_spec: glib::ffi::gpointer,
150            f: glib::ffi::gpointer,
151        ) {
152            let f: &F = &*(f as *const F);
153            f(&from_glib_borrow(this))
154        }
155        unsafe {
156            let f: Box_<F> = Box_::new(f);
157            connect_raw(
158                self.as_ptr() as *mut _,
159                c"notify::unit".as_ptr() as *const _,
160                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
161                    notify_unit_trampoline::<F> as *const (),
162                )),
163                Box_::into_raw(f),
164            )
165        }
166    }
167}
168
169impl Default for ClampLayout {
170    fn default() -> Self {
171        Self::new()
172    }
173}
174
175// rustdoc-stripper-ignore-next
176/// A [builder-pattern] type to construct [`ClampLayout`] objects.
177///
178/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
179#[must_use = "The builder must be built to be used"]
180pub struct ClampLayoutBuilder {
181    builder: glib::object::ObjectBuilder<'static, ClampLayout>,
182}
183
184impl ClampLayoutBuilder {
185    fn new() -> Self {
186        Self {
187            builder: glib::object::Object::builder(),
188        }
189    }
190
191    pub fn maximum_size(self, maximum_size: i32) -> Self {
192        Self {
193            builder: self.builder.property("maximum-size", maximum_size),
194        }
195    }
196
197    pub fn tightening_threshold(self, tightening_threshold: i32) -> Self {
198        Self {
199            builder: self
200                .builder
201                .property("tightening-threshold", tightening_threshold),
202        }
203    }
204
205    #[cfg(feature = "v1_4")]
206    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
207    pub fn unit(self, unit: LengthUnit) -> Self {
208        Self {
209            builder: self.builder.property("unit", unit),
210        }
211    }
212
213    pub fn orientation(self, orientation: gtk::Orientation) -> Self {
214        Self {
215            builder: self.builder.property("orientation", orientation),
216        }
217    }
218
219    // rustdoc-stripper-ignore-next
220    /// Build the [`ClampLayout`].
221    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
222    pub fn build(self) -> ClampLayout {
223        assert_initialized_main_thread!();
224        self.builder.build()
225    }
226}