Skip to main content

gtk4/auto/
spin_button.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, AccessibleRange};
8use crate::{
9    AccessibleRole, Adjustment, Align, Buildable, CellEditable, ConstraintTarget, Editable,
10    LayoutManager, Orientable, Orientation, Overflow, ScrollType, SpinButtonUpdatePolicy, SpinType,
11    Widget, ffi,
12};
13use glib::{
14    object::ObjectType as _,
15    prelude::*,
16    signal::{SignalHandlerId, connect_raw},
17    translate::*,
18};
19use std::boxed::Box as Box_;
20
21#[cfg(feature = "v4_10")]
22#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
23glib::wrapper! {
24    #[doc(alias = "GtkSpinButton")]
25    pub struct SpinButton(Object<ffi::GtkSpinButton>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, AccessibleRange, CellEditable, Editable, Orientable;
26
27    match fn {
28        type_ => || ffi::gtk_spin_button_get_type(),
29    }
30}
31
32#[cfg(not(feature = "v4_10"))]
33glib::wrapper! {
34    #[doc(alias = "GtkSpinButton")]
35    pub struct SpinButton(Object<ffi::GtkSpinButton>) @extends Widget, @implements Buildable, ConstraintTarget, CellEditable, Editable, Orientable;
36
37    match fn {
38        type_ => || ffi::gtk_spin_button_get_type(),
39    }
40}
41
42impl SpinButton {
43    #[doc(alias = "gtk_spin_button_new")]
44    pub fn new(
45        adjustment: Option<&impl IsA<Adjustment>>,
46        climb_rate: f64,
47        digits: u32,
48    ) -> SpinButton {
49        assert_initialized_main_thread!();
50        unsafe {
51            Widget::from_glib_none(ffi::gtk_spin_button_new(
52                adjustment.map(|p| p.as_ref()).to_glib_none().0,
53                climb_rate,
54                digits,
55            ))
56            .unsafe_cast()
57        }
58    }
59
60    #[doc(alias = "gtk_spin_button_new_with_range")]
61    #[doc(alias = "new_with_range")]
62    pub fn with_range(min: f64, max: f64, step: f64) -> SpinButton {
63        assert_initialized_main_thread!();
64        unsafe {
65            Widget::from_glib_none(ffi::gtk_spin_button_new_with_range(min, max, step))
66                .unsafe_cast()
67        }
68    }
69
70    // rustdoc-stripper-ignore-next
71    /// Creates a new builder-pattern struct instance to construct [`SpinButton`] objects.
72    ///
73    /// This method returns an instance of [`SpinButtonBuilder`](crate::builders::SpinButtonBuilder) which can be used to create [`SpinButton`] objects.
74    pub fn builder() -> SpinButtonBuilder {
75        SpinButtonBuilder::new()
76    }
77
78    #[doc(alias = "gtk_spin_button_configure")]
79    pub fn configure(
80        &self,
81        adjustment: Option<&impl IsA<Adjustment>>,
82        climb_rate: f64,
83        digits: u32,
84    ) {
85        unsafe {
86            ffi::gtk_spin_button_configure(
87                self.to_glib_none().0,
88                adjustment.map(|p| p.as_ref()).to_glib_none().0,
89                climb_rate,
90                digits,
91            );
92        }
93    }
94
95    #[cfg(feature = "v4_14")]
96    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
97    #[doc(alias = "gtk_spin_button_get_activates_default")]
98    #[doc(alias = "get_activates_default")]
99    #[doc(alias = "activates-default")]
100    pub fn activates_default(&self) -> bool {
101        unsafe {
102            from_glib(ffi::gtk_spin_button_get_activates_default(
103                self.to_glib_none().0,
104            ))
105        }
106    }
107
108    #[doc(alias = "gtk_spin_button_get_adjustment")]
109    #[doc(alias = "get_adjustment")]
110    pub fn adjustment(&self) -> Adjustment {
111        unsafe { from_glib_none(ffi::gtk_spin_button_get_adjustment(self.to_glib_none().0)) }
112    }
113
114    #[doc(alias = "gtk_spin_button_get_climb_rate")]
115    #[doc(alias = "get_climb_rate")]
116    #[doc(alias = "climb-rate")]
117    pub fn climb_rate(&self) -> f64 {
118        unsafe { ffi::gtk_spin_button_get_climb_rate(self.to_glib_none().0) }
119    }
120
121    #[doc(alias = "gtk_spin_button_get_digits")]
122    #[doc(alias = "get_digits")]
123    pub fn digits(&self) -> u32 {
124        unsafe { ffi::gtk_spin_button_get_digits(self.to_glib_none().0) }
125    }
126
127    #[doc(alias = "gtk_spin_button_get_increments")]
128    #[doc(alias = "get_increments")]
129    pub fn increments(&self) -> (f64, f64) {
130        unsafe {
131            let mut step = std::mem::MaybeUninit::uninit();
132            let mut page = std::mem::MaybeUninit::uninit();
133            ffi::gtk_spin_button_get_increments(
134                self.to_glib_none().0,
135                step.as_mut_ptr(),
136                page.as_mut_ptr(),
137            );
138            (step.assume_init(), page.assume_init())
139        }
140    }
141
142    #[doc(alias = "gtk_spin_button_get_numeric")]
143    #[doc(alias = "get_numeric")]
144    #[doc(alias = "numeric")]
145    pub fn is_numeric(&self) -> bool {
146        unsafe { from_glib(ffi::gtk_spin_button_get_numeric(self.to_glib_none().0)) }
147    }
148
149    #[doc(alias = "gtk_spin_button_get_range")]
150    #[doc(alias = "get_range")]
151    pub fn range(&self) -> (f64, f64) {
152        unsafe {
153            let mut min = std::mem::MaybeUninit::uninit();
154            let mut max = std::mem::MaybeUninit::uninit();
155            ffi::gtk_spin_button_get_range(
156                self.to_glib_none().0,
157                min.as_mut_ptr(),
158                max.as_mut_ptr(),
159            );
160            (min.assume_init(), max.assume_init())
161        }
162    }
163
164    #[doc(alias = "gtk_spin_button_get_snap_to_ticks")]
165    #[doc(alias = "get_snap_to_ticks")]
166    #[doc(alias = "snap-to-ticks")]
167    pub fn snaps_to_ticks(&self) -> bool {
168        unsafe {
169            from_glib(ffi::gtk_spin_button_get_snap_to_ticks(
170                self.to_glib_none().0,
171            ))
172        }
173    }
174
175    #[doc(alias = "gtk_spin_button_get_update_policy")]
176    #[doc(alias = "get_update_policy")]
177    #[doc(alias = "update-policy")]
178    pub fn update_policy(&self) -> SpinButtonUpdatePolicy {
179        unsafe {
180            from_glib(ffi::gtk_spin_button_get_update_policy(
181                self.to_glib_none().0,
182            ))
183        }
184    }
185
186    #[doc(alias = "gtk_spin_button_get_value")]
187    #[doc(alias = "get_value")]
188    pub fn value(&self) -> f64 {
189        unsafe { ffi::gtk_spin_button_get_value(self.to_glib_none().0) }
190    }
191
192    #[doc(alias = "gtk_spin_button_get_value_as_int")]
193    #[doc(alias = "get_value_as_int")]
194    pub fn value_as_int(&self) -> i32 {
195        unsafe { ffi::gtk_spin_button_get_value_as_int(self.to_glib_none().0) }
196    }
197
198    #[doc(alias = "gtk_spin_button_get_wrap")]
199    #[doc(alias = "get_wrap")]
200    #[doc(alias = "wrap")]
201    pub fn wraps(&self) -> bool {
202        unsafe { from_glib(ffi::gtk_spin_button_get_wrap(self.to_glib_none().0)) }
203    }
204
205    #[cfg(feature = "v4_14")]
206    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
207    #[doc(alias = "gtk_spin_button_set_activates_default")]
208    #[doc(alias = "activates-default")]
209    pub fn set_activates_default(&self, activates_default: bool) {
210        unsafe {
211            ffi::gtk_spin_button_set_activates_default(
212                self.to_glib_none().0,
213                activates_default.into_glib(),
214            );
215        }
216    }
217
218    #[doc(alias = "gtk_spin_button_set_adjustment")]
219    #[doc(alias = "adjustment")]
220    pub fn set_adjustment(&self, adjustment: &impl IsA<Adjustment>) {
221        unsafe {
222            ffi::gtk_spin_button_set_adjustment(
223                self.to_glib_none().0,
224                adjustment.as_ref().to_glib_none().0,
225            );
226        }
227    }
228
229    #[doc(alias = "gtk_spin_button_set_climb_rate")]
230    #[doc(alias = "climb-rate")]
231    pub fn set_climb_rate(&self, climb_rate: f64) {
232        unsafe {
233            ffi::gtk_spin_button_set_climb_rate(self.to_glib_none().0, climb_rate);
234        }
235    }
236
237    #[doc(alias = "gtk_spin_button_set_digits")]
238    #[doc(alias = "digits")]
239    pub fn set_digits(&self, digits: u32) {
240        unsafe {
241            ffi::gtk_spin_button_set_digits(self.to_glib_none().0, digits);
242        }
243    }
244
245    #[doc(alias = "gtk_spin_button_set_increments")]
246    pub fn set_increments(&self, step: f64, page: f64) {
247        unsafe {
248            ffi::gtk_spin_button_set_increments(self.to_glib_none().0, step, page);
249        }
250    }
251
252    #[doc(alias = "gtk_spin_button_set_numeric")]
253    #[doc(alias = "numeric")]
254    pub fn set_numeric(&self, numeric: bool) {
255        unsafe {
256            ffi::gtk_spin_button_set_numeric(self.to_glib_none().0, numeric.into_glib());
257        }
258    }
259
260    #[doc(alias = "gtk_spin_button_set_range")]
261    pub fn set_range(&self, min: f64, max: f64) {
262        unsafe {
263            ffi::gtk_spin_button_set_range(self.to_glib_none().0, min, max);
264        }
265    }
266
267    #[doc(alias = "gtk_spin_button_set_snap_to_ticks")]
268    #[doc(alias = "snap-to-ticks")]
269    pub fn set_snap_to_ticks(&self, snap_to_ticks: bool) {
270        unsafe {
271            ffi::gtk_spin_button_set_snap_to_ticks(
272                self.to_glib_none().0,
273                snap_to_ticks.into_glib(),
274            );
275        }
276    }
277
278    #[doc(alias = "gtk_spin_button_set_update_policy")]
279    #[doc(alias = "update-policy")]
280    pub fn set_update_policy(&self, policy: SpinButtonUpdatePolicy) {
281        unsafe {
282            ffi::gtk_spin_button_set_update_policy(self.to_glib_none().0, policy.into_glib());
283        }
284    }
285
286    #[doc(alias = "gtk_spin_button_set_value")]
287    #[doc(alias = "value")]
288    pub fn set_value(&self, value: f64) {
289        unsafe {
290            ffi::gtk_spin_button_set_value(self.to_glib_none().0, value);
291        }
292    }
293
294    #[doc(alias = "gtk_spin_button_set_wrap")]
295    #[doc(alias = "wrap")]
296    pub fn set_wrap(&self, wrap: bool) {
297        unsafe {
298            ffi::gtk_spin_button_set_wrap(self.to_glib_none().0, wrap.into_glib());
299        }
300    }
301
302    #[doc(alias = "gtk_spin_button_spin")]
303    pub fn spin(&self, direction: SpinType, increment: f64) {
304        unsafe {
305            ffi::gtk_spin_button_spin(self.to_glib_none().0, direction.into_glib(), increment);
306        }
307    }
308
309    #[doc(alias = "gtk_spin_button_update")]
310    pub fn update(&self) {
311        unsafe {
312            ffi::gtk_spin_button_update(self.to_glib_none().0);
313        }
314    }
315
316    #[cfg(feature = "v4_14")]
317    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
318    #[doc(alias = "activate")]
319    pub fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
320        unsafe extern "C" fn activate_trampoline<F: Fn(&SpinButton) + 'static>(
321            this: *mut ffi::GtkSpinButton,
322            f: glib::ffi::gpointer,
323        ) {
324            unsafe {
325                let f: &F = &*(f as *const F);
326                f(&from_glib_borrow(this))
327            }
328        }
329        unsafe {
330            let f: Box_<F> = Box_::new(f);
331            connect_raw(
332                self.as_ptr() as *mut _,
333                c"activate".as_ptr(),
334                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
335                    activate_trampoline::<F> as *const (),
336                )),
337                Box_::into_raw(f),
338            )
339        }
340    }
341
342    #[cfg(feature = "v4_14")]
343    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
344    pub fn emit_activate(&self) {
345        self.emit_by_name::<()>("activate", &[]);
346    }
347
348    #[doc(alias = "change-value")]
349    pub fn connect_change_value<F: Fn(&Self, ScrollType) + 'static>(
350        &self,
351        f: F,
352    ) -> SignalHandlerId {
353        unsafe extern "C" fn change_value_trampoline<F: Fn(&SpinButton, ScrollType) + 'static>(
354            this: *mut ffi::GtkSpinButton,
355            scroll: ffi::GtkScrollType,
356            f: glib::ffi::gpointer,
357        ) {
358            unsafe {
359                let f: &F = &*(f as *const F);
360                f(&from_glib_borrow(this), from_glib(scroll))
361            }
362        }
363        unsafe {
364            let f: Box_<F> = Box_::new(f);
365            connect_raw(
366                self.as_ptr() as *mut _,
367                c"change-value".as_ptr(),
368                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
369                    change_value_trampoline::<F> as *const (),
370                )),
371                Box_::into_raw(f),
372            )
373        }
374    }
375
376    pub fn emit_change_value(&self, scroll: ScrollType) {
377        self.emit_by_name::<()>("change-value", &[&scroll]);
378    }
379
380    #[doc(alias = "output")]
381    pub fn connect_output<F: Fn(&Self) -> glib::Propagation + 'static>(
382        &self,
383        f: F,
384    ) -> SignalHandlerId {
385        unsafe extern "C" fn output_trampoline<
386            F: Fn(&SpinButton) -> glib::Propagation + 'static,
387        >(
388            this: *mut ffi::GtkSpinButton,
389            f: glib::ffi::gpointer,
390        ) -> glib::ffi::gboolean {
391            unsafe {
392                let f: &F = &*(f as *const F);
393                f(&from_glib_borrow(this)).into_glib()
394            }
395        }
396        unsafe {
397            let f: Box_<F> = Box_::new(f);
398            connect_raw(
399                self.as_ptr() as *mut _,
400                c"output".as_ptr(),
401                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
402                    output_trampoline::<F> as *const (),
403                )),
404                Box_::into_raw(f),
405            )
406        }
407    }
408
409    #[doc(alias = "value-changed")]
410    pub fn connect_value_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
411        unsafe extern "C" fn value_changed_trampoline<F: Fn(&SpinButton) + 'static>(
412            this: *mut ffi::GtkSpinButton,
413            f: glib::ffi::gpointer,
414        ) {
415            unsafe {
416                let f: &F = &*(f as *const F);
417                f(&from_glib_borrow(this))
418            }
419        }
420        unsafe {
421            let f: Box_<F> = Box_::new(f);
422            connect_raw(
423                self.as_ptr() as *mut _,
424                c"value-changed".as_ptr(),
425                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
426                    value_changed_trampoline::<F> as *const (),
427                )),
428                Box_::into_raw(f),
429            )
430        }
431    }
432
433    #[doc(alias = "wrapped")]
434    pub fn connect_wrapped<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
435        unsafe extern "C" fn wrapped_trampoline<F: Fn(&SpinButton) + 'static>(
436            this: *mut ffi::GtkSpinButton,
437            f: glib::ffi::gpointer,
438        ) {
439            unsafe {
440                let f: &F = &*(f as *const F);
441                f(&from_glib_borrow(this))
442            }
443        }
444        unsafe {
445            let f: Box_<F> = Box_::new(f);
446            connect_raw(
447                self.as_ptr() as *mut _,
448                c"wrapped".as_ptr(),
449                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
450                    wrapped_trampoline::<F> as *const (),
451                )),
452                Box_::into_raw(f),
453            )
454        }
455    }
456
457    #[cfg(feature = "v4_14")]
458    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
459    #[doc(alias = "activates-default")]
460    pub fn connect_activates_default_notify<F: Fn(&Self) + 'static>(
461        &self,
462        f: F,
463    ) -> SignalHandlerId {
464        unsafe extern "C" fn notify_activates_default_trampoline<F: Fn(&SpinButton) + 'static>(
465            this: *mut ffi::GtkSpinButton,
466            _param_spec: glib::ffi::gpointer,
467            f: glib::ffi::gpointer,
468        ) {
469            unsafe {
470                let f: &F = &*(f as *const F);
471                f(&from_glib_borrow(this))
472            }
473        }
474        unsafe {
475            let f: Box_<F> = Box_::new(f);
476            connect_raw(
477                self.as_ptr() as *mut _,
478                c"notify::activates-default".as_ptr(),
479                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
480                    notify_activates_default_trampoline::<F> as *const (),
481                )),
482                Box_::into_raw(f),
483            )
484        }
485    }
486
487    #[doc(alias = "adjustment")]
488    pub fn connect_adjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
489        unsafe extern "C" fn notify_adjustment_trampoline<F: Fn(&SpinButton) + 'static>(
490            this: *mut ffi::GtkSpinButton,
491            _param_spec: glib::ffi::gpointer,
492            f: glib::ffi::gpointer,
493        ) {
494            unsafe {
495                let f: &F = &*(f as *const F);
496                f(&from_glib_borrow(this))
497            }
498        }
499        unsafe {
500            let f: Box_<F> = Box_::new(f);
501            connect_raw(
502                self.as_ptr() as *mut _,
503                c"notify::adjustment".as_ptr(),
504                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
505                    notify_adjustment_trampoline::<F> as *const (),
506                )),
507                Box_::into_raw(f),
508            )
509        }
510    }
511
512    #[doc(alias = "climb-rate")]
513    pub fn connect_climb_rate_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
514        unsafe extern "C" fn notify_climb_rate_trampoline<F: Fn(&SpinButton) + 'static>(
515            this: *mut ffi::GtkSpinButton,
516            _param_spec: glib::ffi::gpointer,
517            f: glib::ffi::gpointer,
518        ) {
519            unsafe {
520                let f: &F = &*(f as *const F);
521                f(&from_glib_borrow(this))
522            }
523        }
524        unsafe {
525            let f: Box_<F> = Box_::new(f);
526            connect_raw(
527                self.as_ptr() as *mut _,
528                c"notify::climb-rate".as_ptr(),
529                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
530                    notify_climb_rate_trampoline::<F> as *const (),
531                )),
532                Box_::into_raw(f),
533            )
534        }
535    }
536
537    #[doc(alias = "digits")]
538    pub fn connect_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
539        unsafe extern "C" fn notify_digits_trampoline<F: Fn(&SpinButton) + 'static>(
540            this: *mut ffi::GtkSpinButton,
541            _param_spec: glib::ffi::gpointer,
542            f: glib::ffi::gpointer,
543        ) {
544            unsafe {
545                let f: &F = &*(f as *const F);
546                f(&from_glib_borrow(this))
547            }
548        }
549        unsafe {
550            let f: Box_<F> = Box_::new(f);
551            connect_raw(
552                self.as_ptr() as *mut _,
553                c"notify::digits".as_ptr(),
554                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
555                    notify_digits_trampoline::<F> as *const (),
556                )),
557                Box_::into_raw(f),
558            )
559        }
560    }
561
562    #[doc(alias = "numeric")]
563    pub fn connect_numeric_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
564        unsafe extern "C" fn notify_numeric_trampoline<F: Fn(&SpinButton) + 'static>(
565            this: *mut ffi::GtkSpinButton,
566            _param_spec: glib::ffi::gpointer,
567            f: glib::ffi::gpointer,
568        ) {
569            unsafe {
570                let f: &F = &*(f as *const F);
571                f(&from_glib_borrow(this))
572            }
573        }
574        unsafe {
575            let f: Box_<F> = Box_::new(f);
576            connect_raw(
577                self.as_ptr() as *mut _,
578                c"notify::numeric".as_ptr(),
579                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
580                    notify_numeric_trampoline::<F> as *const (),
581                )),
582                Box_::into_raw(f),
583            )
584        }
585    }
586
587    #[doc(alias = "snap-to-ticks")]
588    pub fn connect_snap_to_ticks_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
589        unsafe extern "C" fn notify_snap_to_ticks_trampoline<F: Fn(&SpinButton) + 'static>(
590            this: *mut ffi::GtkSpinButton,
591            _param_spec: glib::ffi::gpointer,
592            f: glib::ffi::gpointer,
593        ) {
594            unsafe {
595                let f: &F = &*(f as *const F);
596                f(&from_glib_borrow(this))
597            }
598        }
599        unsafe {
600            let f: Box_<F> = Box_::new(f);
601            connect_raw(
602                self.as_ptr() as *mut _,
603                c"notify::snap-to-ticks".as_ptr(),
604                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
605                    notify_snap_to_ticks_trampoline::<F> as *const (),
606                )),
607                Box_::into_raw(f),
608            )
609        }
610    }
611
612    #[doc(alias = "update-policy")]
613    pub fn connect_update_policy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
614        unsafe extern "C" fn notify_update_policy_trampoline<F: Fn(&SpinButton) + 'static>(
615            this: *mut ffi::GtkSpinButton,
616            _param_spec: glib::ffi::gpointer,
617            f: glib::ffi::gpointer,
618        ) {
619            unsafe {
620                let f: &F = &*(f as *const F);
621                f(&from_glib_borrow(this))
622            }
623        }
624        unsafe {
625            let f: Box_<F> = Box_::new(f);
626            connect_raw(
627                self.as_ptr() as *mut _,
628                c"notify::update-policy".as_ptr(),
629                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
630                    notify_update_policy_trampoline::<F> as *const (),
631                )),
632                Box_::into_raw(f),
633            )
634        }
635    }
636
637    #[doc(alias = "value")]
638    pub fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
639        unsafe extern "C" fn notify_value_trampoline<F: Fn(&SpinButton) + 'static>(
640            this: *mut ffi::GtkSpinButton,
641            _param_spec: glib::ffi::gpointer,
642            f: glib::ffi::gpointer,
643        ) {
644            unsafe {
645                let f: &F = &*(f as *const F);
646                f(&from_glib_borrow(this))
647            }
648        }
649        unsafe {
650            let f: Box_<F> = Box_::new(f);
651            connect_raw(
652                self.as_ptr() as *mut _,
653                c"notify::value".as_ptr(),
654                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
655                    notify_value_trampoline::<F> as *const (),
656                )),
657                Box_::into_raw(f),
658            )
659        }
660    }
661
662    #[doc(alias = "wrap")]
663    pub fn connect_wrap_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
664        unsafe extern "C" fn notify_wrap_trampoline<F: Fn(&SpinButton) + 'static>(
665            this: *mut ffi::GtkSpinButton,
666            _param_spec: glib::ffi::gpointer,
667            f: glib::ffi::gpointer,
668        ) {
669            unsafe {
670                let f: &F = &*(f as *const F);
671                f(&from_glib_borrow(this))
672            }
673        }
674        unsafe {
675            let f: Box_<F> = Box_::new(f);
676            connect_raw(
677                self.as_ptr() as *mut _,
678                c"notify::wrap".as_ptr(),
679                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
680                    notify_wrap_trampoline::<F> as *const (),
681                )),
682                Box_::into_raw(f),
683            )
684        }
685    }
686}
687
688impl Default for SpinButton {
689    fn default() -> Self {
690        glib::object::Object::new::<Self>()
691    }
692}
693
694// rustdoc-stripper-ignore-next
695/// A [builder-pattern] type to construct [`SpinButton`] objects.
696///
697/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
698#[must_use = "The builder must be built to be used"]
699pub struct SpinButtonBuilder {
700    builder: glib::object::ObjectBuilder<'static, SpinButton>,
701}
702
703impl SpinButtonBuilder {
704    fn new() -> Self {
705        Self {
706            builder: glib::object::Object::builder(),
707        }
708    }
709
710    #[cfg(feature = "v4_14")]
711    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
712    pub fn activates_default(self, activates_default: bool) -> Self {
713        Self {
714            builder: self
715                .builder
716                .property("activates-default", activates_default),
717        }
718    }
719
720    pub fn adjustment(self, adjustment: &impl IsA<Adjustment>) -> Self {
721        Self {
722            builder: self
723                .builder
724                .property("adjustment", adjustment.clone().upcast()),
725        }
726    }
727
728    pub fn climb_rate(self, climb_rate: f64) -> Self {
729        Self {
730            builder: self.builder.property("climb-rate", climb_rate),
731        }
732    }
733
734    pub fn digits(self, digits: u32) -> Self {
735        Self {
736            builder: self.builder.property("digits", digits),
737        }
738    }
739
740    pub fn numeric(self, numeric: bool) -> Self {
741        Self {
742            builder: self.builder.property("numeric", numeric),
743        }
744    }
745
746    pub fn snap_to_ticks(self, snap_to_ticks: bool) -> Self {
747        Self {
748            builder: self.builder.property("snap-to-ticks", snap_to_ticks),
749        }
750    }
751
752    pub fn update_policy(self, update_policy: SpinButtonUpdatePolicy) -> Self {
753        Self {
754            builder: self.builder.property("update-policy", update_policy),
755        }
756    }
757
758    pub fn value(self, value: f64) -> Self {
759        Self {
760            builder: self.builder.property("value", value),
761        }
762    }
763
764    pub fn wrap(self, wrap: bool) -> Self {
765        Self {
766            builder: self.builder.property("wrap", wrap),
767        }
768    }
769
770    pub fn can_focus(self, can_focus: bool) -> Self {
771        Self {
772            builder: self.builder.property("can-focus", can_focus),
773        }
774    }
775
776    pub fn can_target(self, can_target: bool) -> Self {
777        Self {
778            builder: self.builder.property("can-target", can_target),
779        }
780    }
781
782    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
783        Self {
784            builder: self.builder.property("css-classes", css_classes.into()),
785        }
786    }
787
788    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
789        Self {
790            builder: self.builder.property("css-name", css_name.into()),
791        }
792    }
793
794    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
795        Self {
796            builder: self.builder.property("cursor", cursor.clone()),
797        }
798    }
799
800    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
801        Self {
802            builder: self.builder.property("focus-on-click", focus_on_click),
803        }
804    }
805
806    pub fn focusable(self, focusable: bool) -> Self {
807        Self {
808            builder: self.builder.property("focusable", focusable),
809        }
810    }
811
812    pub fn halign(self, halign: Align) -> Self {
813        Self {
814            builder: self.builder.property("halign", halign),
815        }
816    }
817
818    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
819        Self {
820            builder: self.builder.property("has-tooltip", has_tooltip),
821        }
822    }
823
824    pub fn height_request(self, height_request: i32) -> Self {
825        Self {
826            builder: self.builder.property("height-request", height_request),
827        }
828    }
829
830    pub fn hexpand(self, hexpand: bool) -> Self {
831        Self {
832            builder: self.builder.property("hexpand", hexpand),
833        }
834    }
835
836    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
837        Self {
838            builder: self.builder.property("hexpand-set", hexpand_set),
839        }
840    }
841
842    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
843        Self {
844            builder: self
845                .builder
846                .property("layout-manager", layout_manager.clone().upcast()),
847        }
848    }
849
850    #[cfg(feature = "v4_18")]
851    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
852    pub fn limit_events(self, limit_events: bool) -> Self {
853        Self {
854            builder: self.builder.property("limit-events", limit_events),
855        }
856    }
857
858    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
859        Self {
860            builder: self.builder.property("margin-bottom", margin_bottom),
861        }
862    }
863
864    pub fn margin_end(self, margin_end: i32) -> Self {
865        Self {
866            builder: self.builder.property("margin-end", margin_end),
867        }
868    }
869
870    pub fn margin_start(self, margin_start: i32) -> Self {
871        Self {
872            builder: self.builder.property("margin-start", margin_start),
873        }
874    }
875
876    pub fn margin_top(self, margin_top: i32) -> Self {
877        Self {
878            builder: self.builder.property("margin-top", margin_top),
879        }
880    }
881
882    pub fn name(self, name: impl Into<glib::GString>) -> Self {
883        Self {
884            builder: self.builder.property("name", name.into()),
885        }
886    }
887
888    pub fn opacity(self, opacity: f64) -> Self {
889        Self {
890            builder: self.builder.property("opacity", opacity),
891        }
892    }
893
894    pub fn overflow(self, overflow: Overflow) -> Self {
895        Self {
896            builder: self.builder.property("overflow", overflow),
897        }
898    }
899
900    pub fn receives_default(self, receives_default: bool) -> Self {
901        Self {
902            builder: self.builder.property("receives-default", receives_default),
903        }
904    }
905
906    pub fn sensitive(self, sensitive: bool) -> Self {
907        Self {
908            builder: self.builder.property("sensitive", sensitive),
909        }
910    }
911
912    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
913        Self {
914            builder: self
915                .builder
916                .property("tooltip-markup", tooltip_markup.into()),
917        }
918    }
919
920    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
921        Self {
922            builder: self.builder.property("tooltip-text", tooltip_text.into()),
923        }
924    }
925
926    pub fn valign(self, valign: Align) -> Self {
927        Self {
928            builder: self.builder.property("valign", valign),
929        }
930    }
931
932    pub fn vexpand(self, vexpand: bool) -> Self {
933        Self {
934            builder: self.builder.property("vexpand", vexpand),
935        }
936    }
937
938    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
939        Self {
940            builder: self.builder.property("vexpand-set", vexpand_set),
941        }
942    }
943
944    pub fn visible(self, visible: bool) -> Self {
945        Self {
946            builder: self.builder.property("visible", visible),
947        }
948    }
949
950    pub fn width_request(self, width_request: i32) -> Self {
951        Self {
952            builder: self.builder.property("width-request", width_request),
953        }
954    }
955
956    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
957        Self {
958            builder: self.builder.property("accessible-role", accessible_role),
959        }
960    }
961
962    pub fn editing_canceled(self, editing_canceled: bool) -> Self {
963        Self {
964            builder: self.builder.property("editing-canceled", editing_canceled),
965        }
966    }
967
968    pub fn editable(self, editable: bool) -> Self {
969        Self {
970            builder: self.builder.property("editable", editable),
971        }
972    }
973
974    pub fn enable_undo(self, enable_undo: bool) -> Self {
975        Self {
976            builder: self.builder.property("enable-undo", enable_undo),
977        }
978    }
979
980    pub fn max_width_chars(self, max_width_chars: i32) -> Self {
981        Self {
982            builder: self.builder.property("max-width-chars", max_width_chars),
983        }
984    }
985
986    pub fn text(self, text: impl Into<glib::GString>) -> Self {
987        Self {
988            builder: self.builder.property("text", text.into()),
989        }
990    }
991
992    pub fn width_chars(self, width_chars: i32) -> Self {
993        Self {
994            builder: self.builder.property("width-chars", width_chars),
995        }
996    }
997
998    pub fn xalign(self, xalign: f32) -> Self {
999        Self {
1000            builder: self.builder.property("xalign", xalign),
1001        }
1002    }
1003
1004    pub fn orientation(self, orientation: Orientation) -> Self {
1005        Self {
1006            builder: self.builder.property("orientation", orientation),
1007        }
1008    }
1009
1010    // rustdoc-stripper-ignore-next
1011    /// Build the [`SpinButton`].
1012    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1013    pub fn build(self) -> SpinButton {
1014        assert_initialized_main_thread!();
1015        self.builder.build()
1016    }
1017}