gtk4/auto/
adjustment.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;
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GtkAdjustment")]
16    pub struct Adjustment(Object<ffi::GtkAdjustment, ffi::GtkAdjustmentClass>);
17
18    match fn {
19        type_ => || ffi::gtk_adjustment_get_type(),
20    }
21}
22
23impl Adjustment {
24    pub const NONE: Option<&'static Adjustment> = None;
25
26    #[doc(alias = "gtk_adjustment_new")]
27    pub fn new(
28        value: f64,
29        lower: f64,
30        upper: f64,
31        step_increment: f64,
32        page_increment: f64,
33        page_size: f64,
34    ) -> Adjustment {
35        assert_initialized_main_thread!();
36        unsafe {
37            from_glib_none(ffi::gtk_adjustment_new(
38                value,
39                lower,
40                upper,
41                step_increment,
42                page_increment,
43                page_size,
44            ))
45        }
46    }
47
48    // rustdoc-stripper-ignore-next
49    /// Creates a new builder-pattern struct instance to construct [`Adjustment`] objects.
50    ///
51    /// This method returns an instance of [`AdjustmentBuilder`](crate::builders::AdjustmentBuilder) which can be used to create [`Adjustment`] objects.
52    pub fn builder() -> AdjustmentBuilder {
53        AdjustmentBuilder::new()
54    }
55}
56
57impl Default for Adjustment {
58    fn default() -> Self {
59        glib::object::Object::new::<Self>()
60    }
61}
62
63// rustdoc-stripper-ignore-next
64/// A [builder-pattern] type to construct [`Adjustment`] objects.
65///
66/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
67#[must_use = "The builder must be built to be used"]
68pub struct AdjustmentBuilder {
69    builder: glib::object::ObjectBuilder<'static, Adjustment>,
70}
71
72impl AdjustmentBuilder {
73    fn new() -> Self {
74        Self {
75            builder: glib::object::Object::builder(),
76        }
77    }
78
79    pub fn lower(self, lower: f64) -> Self {
80        Self {
81            builder: self.builder.property("lower", lower),
82        }
83    }
84
85    pub fn page_increment(self, page_increment: f64) -> Self {
86        Self {
87            builder: self.builder.property("page-increment", page_increment),
88        }
89    }
90
91    pub fn page_size(self, page_size: f64) -> Self {
92        Self {
93            builder: self.builder.property("page-size", page_size),
94        }
95    }
96
97    pub fn step_increment(self, step_increment: f64) -> Self {
98        Self {
99            builder: self.builder.property("step-increment", step_increment),
100        }
101    }
102
103    pub fn upper(self, upper: f64) -> Self {
104        Self {
105            builder: self.builder.property("upper", upper),
106        }
107    }
108
109    pub fn value(self, value: f64) -> Self {
110        Self {
111            builder: self.builder.property("value", value),
112        }
113    }
114
115    // rustdoc-stripper-ignore-next
116    /// Build the [`Adjustment`].
117    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
118    pub fn build(self) -> Adjustment {
119        assert_initialized_main_thread!();
120        self.builder.build()
121    }
122}
123
124pub trait AdjustmentExt: IsA<Adjustment> + 'static {
125    #[doc(alias = "gtk_adjustment_clamp_page")]
126    fn clamp_page(&self, lower: f64, upper: f64) {
127        unsafe {
128            ffi::gtk_adjustment_clamp_page(self.as_ref().to_glib_none().0, lower, upper);
129        }
130    }
131
132    #[doc(alias = "gtk_adjustment_configure")]
133    fn configure(
134        &self,
135        value: f64,
136        lower: f64,
137        upper: f64,
138        step_increment: f64,
139        page_increment: f64,
140        page_size: f64,
141    ) {
142        unsafe {
143            ffi::gtk_adjustment_configure(
144                self.as_ref().to_glib_none().0,
145                value,
146                lower,
147                upper,
148                step_increment,
149                page_increment,
150                page_size,
151            );
152        }
153    }
154
155    #[doc(alias = "gtk_adjustment_get_lower")]
156    #[doc(alias = "get_lower")]
157    fn lower(&self) -> f64 {
158        unsafe { ffi::gtk_adjustment_get_lower(self.as_ref().to_glib_none().0) }
159    }
160
161    #[doc(alias = "gtk_adjustment_get_minimum_increment")]
162    #[doc(alias = "get_minimum_increment")]
163    fn minimum_increment(&self) -> f64 {
164        unsafe { ffi::gtk_adjustment_get_minimum_increment(self.as_ref().to_glib_none().0) }
165    }
166
167    #[doc(alias = "gtk_adjustment_get_page_increment")]
168    #[doc(alias = "get_page_increment")]
169    #[doc(alias = "page-increment")]
170    fn page_increment(&self) -> f64 {
171        unsafe { ffi::gtk_adjustment_get_page_increment(self.as_ref().to_glib_none().0) }
172    }
173
174    #[doc(alias = "gtk_adjustment_get_page_size")]
175    #[doc(alias = "get_page_size")]
176    #[doc(alias = "page-size")]
177    fn page_size(&self) -> f64 {
178        unsafe { ffi::gtk_adjustment_get_page_size(self.as_ref().to_glib_none().0) }
179    }
180
181    #[doc(alias = "gtk_adjustment_get_step_increment")]
182    #[doc(alias = "get_step_increment")]
183    #[doc(alias = "step-increment")]
184    fn step_increment(&self) -> f64 {
185        unsafe { ffi::gtk_adjustment_get_step_increment(self.as_ref().to_glib_none().0) }
186    }
187
188    #[doc(alias = "gtk_adjustment_get_upper")]
189    #[doc(alias = "get_upper")]
190    fn upper(&self) -> f64 {
191        unsafe { ffi::gtk_adjustment_get_upper(self.as_ref().to_glib_none().0) }
192    }
193
194    #[doc(alias = "gtk_adjustment_get_value")]
195    #[doc(alias = "get_value")]
196    fn value(&self) -> f64 {
197        unsafe { ffi::gtk_adjustment_get_value(self.as_ref().to_glib_none().0) }
198    }
199
200    #[doc(alias = "gtk_adjustment_set_lower")]
201    #[doc(alias = "lower")]
202    fn set_lower(&self, lower: f64) {
203        unsafe {
204            ffi::gtk_adjustment_set_lower(self.as_ref().to_glib_none().0, lower);
205        }
206    }
207
208    #[doc(alias = "gtk_adjustment_set_page_increment")]
209    #[doc(alias = "page-increment")]
210    fn set_page_increment(&self, page_increment: f64) {
211        unsafe {
212            ffi::gtk_adjustment_set_page_increment(self.as_ref().to_glib_none().0, page_increment);
213        }
214    }
215
216    #[doc(alias = "gtk_adjustment_set_page_size")]
217    #[doc(alias = "page-size")]
218    fn set_page_size(&self, page_size: f64) {
219        unsafe {
220            ffi::gtk_adjustment_set_page_size(self.as_ref().to_glib_none().0, page_size);
221        }
222    }
223
224    #[doc(alias = "gtk_adjustment_set_step_increment")]
225    #[doc(alias = "step-increment")]
226    fn set_step_increment(&self, step_increment: f64) {
227        unsafe {
228            ffi::gtk_adjustment_set_step_increment(self.as_ref().to_glib_none().0, step_increment);
229        }
230    }
231
232    #[doc(alias = "gtk_adjustment_set_upper")]
233    #[doc(alias = "upper")]
234    fn set_upper(&self, upper: f64) {
235        unsafe {
236            ffi::gtk_adjustment_set_upper(self.as_ref().to_glib_none().0, upper);
237        }
238    }
239
240    #[doc(alias = "gtk_adjustment_set_value")]
241    #[doc(alias = "value")]
242    fn set_value(&self, value: f64) {
243        unsafe {
244            ffi::gtk_adjustment_set_value(self.as_ref().to_glib_none().0, value);
245        }
246    }
247
248    #[doc(alias = "changed")]
249    fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
250        unsafe extern "C" fn changed_trampoline<P: IsA<Adjustment>, F: Fn(&P) + 'static>(
251            this: *mut ffi::GtkAdjustment,
252            f: glib::ffi::gpointer,
253        ) {
254            let f: &F = &*(f as *const F);
255            f(Adjustment::from_glib_borrow(this).unsafe_cast_ref())
256        }
257        unsafe {
258            let f: Box_<F> = Box_::new(f);
259            connect_raw(
260                self.as_ptr() as *mut _,
261                c"changed".as_ptr() as *const _,
262                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
263                    changed_trampoline::<Self, F> as *const (),
264                )),
265                Box_::into_raw(f),
266            )
267        }
268    }
269
270    #[doc(alias = "value-changed")]
271    fn connect_value_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
272        unsafe extern "C" fn value_changed_trampoline<P: IsA<Adjustment>, F: Fn(&P) + 'static>(
273            this: *mut ffi::GtkAdjustment,
274            f: glib::ffi::gpointer,
275        ) {
276            let f: &F = &*(f as *const F);
277            f(Adjustment::from_glib_borrow(this).unsafe_cast_ref())
278        }
279        unsafe {
280            let f: Box_<F> = Box_::new(f);
281            connect_raw(
282                self.as_ptr() as *mut _,
283                c"value-changed".as_ptr() as *const _,
284                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
285                    value_changed_trampoline::<Self, F> as *const (),
286                )),
287                Box_::into_raw(f),
288            )
289        }
290    }
291
292    #[doc(alias = "lower")]
293    fn connect_lower_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
294        unsafe extern "C" fn notify_lower_trampoline<P: IsA<Adjustment>, F: Fn(&P) + 'static>(
295            this: *mut ffi::GtkAdjustment,
296            _param_spec: glib::ffi::gpointer,
297            f: glib::ffi::gpointer,
298        ) {
299            let f: &F = &*(f as *const F);
300            f(Adjustment::from_glib_borrow(this).unsafe_cast_ref())
301        }
302        unsafe {
303            let f: Box_<F> = Box_::new(f);
304            connect_raw(
305                self.as_ptr() as *mut _,
306                c"notify::lower".as_ptr() as *const _,
307                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
308                    notify_lower_trampoline::<Self, F> as *const (),
309                )),
310                Box_::into_raw(f),
311            )
312        }
313    }
314
315    #[doc(alias = "page-increment")]
316    fn connect_page_increment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
317        unsafe extern "C" fn notify_page_increment_trampoline<
318            P: IsA<Adjustment>,
319            F: Fn(&P) + 'static,
320        >(
321            this: *mut ffi::GtkAdjustment,
322            _param_spec: glib::ffi::gpointer,
323            f: glib::ffi::gpointer,
324        ) {
325            let f: &F = &*(f as *const F);
326            f(Adjustment::from_glib_borrow(this).unsafe_cast_ref())
327        }
328        unsafe {
329            let f: Box_<F> = Box_::new(f);
330            connect_raw(
331                self.as_ptr() as *mut _,
332                c"notify::page-increment".as_ptr() as *const _,
333                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
334                    notify_page_increment_trampoline::<Self, F> as *const (),
335                )),
336                Box_::into_raw(f),
337            )
338        }
339    }
340
341    #[doc(alias = "page-size")]
342    fn connect_page_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
343        unsafe extern "C" fn notify_page_size_trampoline<
344            P: IsA<Adjustment>,
345            F: Fn(&P) + 'static,
346        >(
347            this: *mut ffi::GtkAdjustment,
348            _param_spec: glib::ffi::gpointer,
349            f: glib::ffi::gpointer,
350        ) {
351            let f: &F = &*(f as *const F);
352            f(Adjustment::from_glib_borrow(this).unsafe_cast_ref())
353        }
354        unsafe {
355            let f: Box_<F> = Box_::new(f);
356            connect_raw(
357                self.as_ptr() as *mut _,
358                c"notify::page-size".as_ptr() as *const _,
359                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
360                    notify_page_size_trampoline::<Self, F> as *const (),
361                )),
362                Box_::into_raw(f),
363            )
364        }
365    }
366
367    #[doc(alias = "step-increment")]
368    fn connect_step_increment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
369        unsafe extern "C" fn notify_step_increment_trampoline<
370            P: IsA<Adjustment>,
371            F: Fn(&P) + 'static,
372        >(
373            this: *mut ffi::GtkAdjustment,
374            _param_spec: glib::ffi::gpointer,
375            f: glib::ffi::gpointer,
376        ) {
377            let f: &F = &*(f as *const F);
378            f(Adjustment::from_glib_borrow(this).unsafe_cast_ref())
379        }
380        unsafe {
381            let f: Box_<F> = Box_::new(f);
382            connect_raw(
383                self.as_ptr() as *mut _,
384                c"notify::step-increment".as_ptr() as *const _,
385                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
386                    notify_step_increment_trampoline::<Self, F> as *const (),
387                )),
388                Box_::into_raw(f),
389            )
390        }
391    }
392
393    #[doc(alias = "upper")]
394    fn connect_upper_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
395        unsafe extern "C" fn notify_upper_trampoline<P: IsA<Adjustment>, F: Fn(&P) + 'static>(
396            this: *mut ffi::GtkAdjustment,
397            _param_spec: glib::ffi::gpointer,
398            f: glib::ffi::gpointer,
399        ) {
400            let f: &F = &*(f as *const F);
401            f(Adjustment::from_glib_borrow(this).unsafe_cast_ref())
402        }
403        unsafe {
404            let f: Box_<F> = Box_::new(f);
405            connect_raw(
406                self.as_ptr() as *mut _,
407                c"notify::upper".as_ptr() as *const _,
408                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
409                    notify_upper_trampoline::<Self, F> as *const (),
410                )),
411                Box_::into_raw(f),
412            )
413        }
414    }
415
416    #[doc(alias = "value")]
417    fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
418        unsafe extern "C" fn notify_value_trampoline<P: IsA<Adjustment>, F: Fn(&P) + 'static>(
419            this: *mut ffi::GtkAdjustment,
420            _param_spec: glib::ffi::gpointer,
421            f: glib::ffi::gpointer,
422        ) {
423            let f: &F = &*(f as *const F);
424            f(Adjustment::from_glib_borrow(this).unsafe_cast_ref())
425        }
426        unsafe {
427            let f: Box_<F> = Box_::new(f);
428            connect_raw(
429                self.as_ptr() as *mut _,
430                c"notify::value".as_ptr() as *const _,
431                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
432                    notify_value_trampoline::<Self, F> as *const (),
433                )),
434                Box_::into_raw(f),
435            )
436        }
437    }
438}
439
440impl<O: IsA<Adjustment>> AdjustmentExt for O {}