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::AccessibleRange;
8use crate::{
9    ffi, Accessible, AccessibleRole, Adjustment, Align, Buildable, CellEditable, ConstraintTarget,
10    Editable, LayoutManager, Orientable, Orientation, Overflow, ScrollType, SpinButtonUpdatePolicy,
11    SpinType, Widget,
12};
13use glib::{
14    object::ObjectType as _,
15    prelude::*,
16    signal::{connect_raw, SignalHandlerId},
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(any(feature = "v4_10")))]
33glib::wrapper! {
34    #[doc(alias = "GtkSpinButton")]
35    pub struct SpinButton(Object<ffi::GtkSpinButton>) @extends Widget, @implements Accessible, 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            let f: &F = &*(f as *const F);
325            f(&from_glib_borrow(this))
326        }
327        unsafe {
328            let f: Box_<F> = Box_::new(f);
329            connect_raw(
330                self.as_ptr() as *mut _,
331                c"activate".as_ptr() as *const _,
332                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
333                    activate_trampoline::<F> as *const (),
334                )),
335                Box_::into_raw(f),
336            )
337        }
338    }
339
340    #[cfg(feature = "v4_14")]
341    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
342    pub fn emit_activate(&self) {
343        self.emit_by_name::<()>("activate", &[]);
344    }
345
346    #[doc(alias = "change-value")]
347    pub fn connect_change_value<F: Fn(&Self, ScrollType) + 'static>(
348        &self,
349        f: F,
350    ) -> SignalHandlerId {
351        unsafe extern "C" fn change_value_trampoline<F: Fn(&SpinButton, ScrollType) + 'static>(
352            this: *mut ffi::GtkSpinButton,
353            scroll: ffi::GtkScrollType,
354            f: glib::ffi::gpointer,
355        ) {
356            let f: &F = &*(f as *const F);
357            f(&from_glib_borrow(this), from_glib(scroll))
358        }
359        unsafe {
360            let f: Box_<F> = Box_::new(f);
361            connect_raw(
362                self.as_ptr() as *mut _,
363                c"change-value".as_ptr() as *const _,
364                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
365                    change_value_trampoline::<F> as *const (),
366                )),
367                Box_::into_raw(f),
368            )
369        }
370    }
371
372    pub fn emit_change_value(&self, scroll: ScrollType) {
373        self.emit_by_name::<()>("change-value", &[&scroll]);
374    }
375
376    #[doc(alias = "output")]
377    pub fn connect_output<F: Fn(&Self) -> glib::Propagation + 'static>(
378        &self,
379        f: F,
380    ) -> SignalHandlerId {
381        unsafe extern "C" fn output_trampoline<
382            F: Fn(&SpinButton) -> glib::Propagation + 'static,
383        >(
384            this: *mut ffi::GtkSpinButton,
385            f: glib::ffi::gpointer,
386        ) -> glib::ffi::gboolean {
387            let f: &F = &*(f as *const F);
388            f(&from_glib_borrow(this)).into_glib()
389        }
390        unsafe {
391            let f: Box_<F> = Box_::new(f);
392            connect_raw(
393                self.as_ptr() as *mut _,
394                c"output".as_ptr() as *const _,
395                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
396                    output_trampoline::<F> as *const (),
397                )),
398                Box_::into_raw(f),
399            )
400        }
401    }
402
403    #[doc(alias = "value-changed")]
404    pub fn connect_value_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
405        unsafe extern "C" fn value_changed_trampoline<F: Fn(&SpinButton) + 'static>(
406            this: *mut ffi::GtkSpinButton,
407            f: glib::ffi::gpointer,
408        ) {
409            let f: &F = &*(f as *const F);
410            f(&from_glib_borrow(this))
411        }
412        unsafe {
413            let f: Box_<F> = Box_::new(f);
414            connect_raw(
415                self.as_ptr() as *mut _,
416                c"value-changed".as_ptr() as *const _,
417                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
418                    value_changed_trampoline::<F> as *const (),
419                )),
420                Box_::into_raw(f),
421            )
422        }
423    }
424
425    #[doc(alias = "wrapped")]
426    pub fn connect_wrapped<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
427        unsafe extern "C" fn wrapped_trampoline<F: Fn(&SpinButton) + 'static>(
428            this: *mut ffi::GtkSpinButton,
429            f: glib::ffi::gpointer,
430        ) {
431            let f: &F = &*(f as *const F);
432            f(&from_glib_borrow(this))
433        }
434        unsafe {
435            let f: Box_<F> = Box_::new(f);
436            connect_raw(
437                self.as_ptr() as *mut _,
438                c"wrapped".as_ptr() as *const _,
439                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
440                    wrapped_trampoline::<F> as *const (),
441                )),
442                Box_::into_raw(f),
443            )
444        }
445    }
446
447    #[cfg(feature = "v4_14")]
448    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
449    #[doc(alias = "activates-default")]
450    pub fn connect_activates_default_notify<F: Fn(&Self) + 'static>(
451        &self,
452        f: F,
453    ) -> SignalHandlerId {
454        unsafe extern "C" fn notify_activates_default_trampoline<F: Fn(&SpinButton) + 'static>(
455            this: *mut ffi::GtkSpinButton,
456            _param_spec: glib::ffi::gpointer,
457            f: glib::ffi::gpointer,
458        ) {
459            let f: &F = &*(f as *const F);
460            f(&from_glib_borrow(this))
461        }
462        unsafe {
463            let f: Box_<F> = Box_::new(f);
464            connect_raw(
465                self.as_ptr() as *mut _,
466                c"notify::activates-default".as_ptr() as *const _,
467                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
468                    notify_activates_default_trampoline::<F> as *const (),
469                )),
470                Box_::into_raw(f),
471            )
472        }
473    }
474
475    #[doc(alias = "adjustment")]
476    pub fn connect_adjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
477        unsafe extern "C" fn notify_adjustment_trampoline<F: Fn(&SpinButton) + 'static>(
478            this: *mut ffi::GtkSpinButton,
479            _param_spec: glib::ffi::gpointer,
480            f: glib::ffi::gpointer,
481        ) {
482            let f: &F = &*(f as *const F);
483            f(&from_glib_borrow(this))
484        }
485        unsafe {
486            let f: Box_<F> = Box_::new(f);
487            connect_raw(
488                self.as_ptr() as *mut _,
489                c"notify::adjustment".as_ptr() as *const _,
490                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
491                    notify_adjustment_trampoline::<F> as *const (),
492                )),
493                Box_::into_raw(f),
494            )
495        }
496    }
497
498    #[doc(alias = "climb-rate")]
499    pub fn connect_climb_rate_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
500        unsafe extern "C" fn notify_climb_rate_trampoline<F: Fn(&SpinButton) + 'static>(
501            this: *mut ffi::GtkSpinButton,
502            _param_spec: glib::ffi::gpointer,
503            f: glib::ffi::gpointer,
504        ) {
505            let f: &F = &*(f as *const F);
506            f(&from_glib_borrow(this))
507        }
508        unsafe {
509            let f: Box_<F> = Box_::new(f);
510            connect_raw(
511                self.as_ptr() as *mut _,
512                c"notify::climb-rate".as_ptr() as *const _,
513                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
514                    notify_climb_rate_trampoline::<F> as *const (),
515                )),
516                Box_::into_raw(f),
517            )
518        }
519    }
520
521    #[doc(alias = "digits")]
522    pub fn connect_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
523        unsafe extern "C" fn notify_digits_trampoline<F: Fn(&SpinButton) + 'static>(
524            this: *mut ffi::GtkSpinButton,
525            _param_spec: glib::ffi::gpointer,
526            f: glib::ffi::gpointer,
527        ) {
528            let f: &F = &*(f as *const F);
529            f(&from_glib_borrow(this))
530        }
531        unsafe {
532            let f: Box_<F> = Box_::new(f);
533            connect_raw(
534                self.as_ptr() as *mut _,
535                c"notify::digits".as_ptr() as *const _,
536                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
537                    notify_digits_trampoline::<F> as *const (),
538                )),
539                Box_::into_raw(f),
540            )
541        }
542    }
543
544    #[doc(alias = "numeric")]
545    pub fn connect_numeric_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
546        unsafe extern "C" fn notify_numeric_trampoline<F: Fn(&SpinButton) + 'static>(
547            this: *mut ffi::GtkSpinButton,
548            _param_spec: glib::ffi::gpointer,
549            f: glib::ffi::gpointer,
550        ) {
551            let f: &F = &*(f as *const F);
552            f(&from_glib_borrow(this))
553        }
554        unsafe {
555            let f: Box_<F> = Box_::new(f);
556            connect_raw(
557                self.as_ptr() as *mut _,
558                c"notify::numeric".as_ptr() as *const _,
559                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
560                    notify_numeric_trampoline::<F> as *const (),
561                )),
562                Box_::into_raw(f),
563            )
564        }
565    }
566
567    #[doc(alias = "snap-to-ticks")]
568    pub fn connect_snap_to_ticks_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
569        unsafe extern "C" fn notify_snap_to_ticks_trampoline<F: Fn(&SpinButton) + 'static>(
570            this: *mut ffi::GtkSpinButton,
571            _param_spec: glib::ffi::gpointer,
572            f: glib::ffi::gpointer,
573        ) {
574            let f: &F = &*(f as *const F);
575            f(&from_glib_borrow(this))
576        }
577        unsafe {
578            let f: Box_<F> = Box_::new(f);
579            connect_raw(
580                self.as_ptr() as *mut _,
581                c"notify::snap-to-ticks".as_ptr() as *const _,
582                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
583                    notify_snap_to_ticks_trampoline::<F> as *const (),
584                )),
585                Box_::into_raw(f),
586            )
587        }
588    }
589
590    #[doc(alias = "update-policy")]
591    pub fn connect_update_policy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
592        unsafe extern "C" fn notify_update_policy_trampoline<F: Fn(&SpinButton) + 'static>(
593            this: *mut ffi::GtkSpinButton,
594            _param_spec: glib::ffi::gpointer,
595            f: glib::ffi::gpointer,
596        ) {
597            let f: &F = &*(f as *const F);
598            f(&from_glib_borrow(this))
599        }
600        unsafe {
601            let f: Box_<F> = Box_::new(f);
602            connect_raw(
603                self.as_ptr() as *mut _,
604                c"notify::update-policy".as_ptr() as *const _,
605                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
606                    notify_update_policy_trampoline::<F> as *const (),
607                )),
608                Box_::into_raw(f),
609            )
610        }
611    }
612
613    #[doc(alias = "value")]
614    pub fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
615        unsafe extern "C" fn notify_value_trampoline<F: Fn(&SpinButton) + 'static>(
616            this: *mut ffi::GtkSpinButton,
617            _param_spec: glib::ffi::gpointer,
618            f: glib::ffi::gpointer,
619        ) {
620            let f: &F = &*(f as *const F);
621            f(&from_glib_borrow(this))
622        }
623        unsafe {
624            let f: Box_<F> = Box_::new(f);
625            connect_raw(
626                self.as_ptr() as *mut _,
627                c"notify::value".as_ptr() as *const _,
628                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
629                    notify_value_trampoline::<F> as *const (),
630                )),
631                Box_::into_raw(f),
632            )
633        }
634    }
635
636    #[doc(alias = "wrap")]
637    pub fn connect_wrap_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
638        unsafe extern "C" fn notify_wrap_trampoline<F: Fn(&SpinButton) + 'static>(
639            this: *mut ffi::GtkSpinButton,
640            _param_spec: glib::ffi::gpointer,
641            f: glib::ffi::gpointer,
642        ) {
643            let f: &F = &*(f as *const F);
644            f(&from_glib_borrow(this))
645        }
646        unsafe {
647            let f: Box_<F> = Box_::new(f);
648            connect_raw(
649                self.as_ptr() as *mut _,
650                c"notify::wrap".as_ptr() as *const _,
651                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
652                    notify_wrap_trampoline::<F> as *const (),
653                )),
654                Box_::into_raw(f),
655            )
656        }
657    }
658}
659
660impl Default for SpinButton {
661    fn default() -> Self {
662        glib::object::Object::new::<Self>()
663    }
664}
665
666// rustdoc-stripper-ignore-next
667/// A [builder-pattern] type to construct [`SpinButton`] objects.
668///
669/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
670#[must_use = "The builder must be built to be used"]
671pub struct SpinButtonBuilder {
672    builder: glib::object::ObjectBuilder<'static, SpinButton>,
673}
674
675impl SpinButtonBuilder {
676    fn new() -> Self {
677        Self {
678            builder: glib::object::Object::builder(),
679        }
680    }
681
682    #[cfg(feature = "v4_14")]
683    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
684    pub fn activates_default(self, activates_default: bool) -> Self {
685        Self {
686            builder: self
687                .builder
688                .property("activates-default", activates_default),
689        }
690    }
691
692    pub fn adjustment(self, adjustment: &impl IsA<Adjustment>) -> Self {
693        Self {
694            builder: self
695                .builder
696                .property("adjustment", adjustment.clone().upcast()),
697        }
698    }
699
700    pub fn climb_rate(self, climb_rate: f64) -> Self {
701        Self {
702            builder: self.builder.property("climb-rate", climb_rate),
703        }
704    }
705
706    pub fn digits(self, digits: u32) -> Self {
707        Self {
708            builder: self.builder.property("digits", digits),
709        }
710    }
711
712    pub fn numeric(self, numeric: bool) -> Self {
713        Self {
714            builder: self.builder.property("numeric", numeric),
715        }
716    }
717
718    pub fn snap_to_ticks(self, snap_to_ticks: bool) -> Self {
719        Self {
720            builder: self.builder.property("snap-to-ticks", snap_to_ticks),
721        }
722    }
723
724    pub fn update_policy(self, update_policy: SpinButtonUpdatePolicy) -> Self {
725        Self {
726            builder: self.builder.property("update-policy", update_policy),
727        }
728    }
729
730    pub fn value(self, value: f64) -> Self {
731        Self {
732            builder: self.builder.property("value", value),
733        }
734    }
735
736    pub fn wrap(self, wrap: bool) -> Self {
737        Self {
738            builder: self.builder.property("wrap", wrap),
739        }
740    }
741
742    pub fn can_focus(self, can_focus: bool) -> Self {
743        Self {
744            builder: self.builder.property("can-focus", can_focus),
745        }
746    }
747
748    pub fn can_target(self, can_target: bool) -> Self {
749        Self {
750            builder: self.builder.property("can-target", can_target),
751        }
752    }
753
754    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
755        Self {
756            builder: self.builder.property("css-classes", css_classes.into()),
757        }
758    }
759
760    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
761        Self {
762            builder: self.builder.property("css-name", css_name.into()),
763        }
764    }
765
766    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
767        Self {
768            builder: self.builder.property("cursor", cursor.clone()),
769        }
770    }
771
772    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
773        Self {
774            builder: self.builder.property("focus-on-click", focus_on_click),
775        }
776    }
777
778    pub fn focusable(self, focusable: bool) -> Self {
779        Self {
780            builder: self.builder.property("focusable", focusable),
781        }
782    }
783
784    pub fn halign(self, halign: Align) -> Self {
785        Self {
786            builder: self.builder.property("halign", halign),
787        }
788    }
789
790    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
791        Self {
792            builder: self.builder.property("has-tooltip", has_tooltip),
793        }
794    }
795
796    pub fn height_request(self, height_request: i32) -> Self {
797        Self {
798            builder: self.builder.property("height-request", height_request),
799        }
800    }
801
802    pub fn hexpand(self, hexpand: bool) -> Self {
803        Self {
804            builder: self.builder.property("hexpand", hexpand),
805        }
806    }
807
808    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
809        Self {
810            builder: self.builder.property("hexpand-set", hexpand_set),
811        }
812    }
813
814    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
815        Self {
816            builder: self
817                .builder
818                .property("layout-manager", layout_manager.clone().upcast()),
819        }
820    }
821
822    #[cfg(feature = "v4_18")]
823    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
824    pub fn limit_events(self, limit_events: bool) -> Self {
825        Self {
826            builder: self.builder.property("limit-events", limit_events),
827        }
828    }
829
830    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
831        Self {
832            builder: self.builder.property("margin-bottom", margin_bottom),
833        }
834    }
835
836    pub fn margin_end(self, margin_end: i32) -> Self {
837        Self {
838            builder: self.builder.property("margin-end", margin_end),
839        }
840    }
841
842    pub fn margin_start(self, margin_start: i32) -> Self {
843        Self {
844            builder: self.builder.property("margin-start", margin_start),
845        }
846    }
847
848    pub fn margin_top(self, margin_top: i32) -> Self {
849        Self {
850            builder: self.builder.property("margin-top", margin_top),
851        }
852    }
853
854    pub fn name(self, name: impl Into<glib::GString>) -> Self {
855        Self {
856            builder: self.builder.property("name", name.into()),
857        }
858    }
859
860    pub fn opacity(self, opacity: f64) -> Self {
861        Self {
862            builder: self.builder.property("opacity", opacity),
863        }
864    }
865
866    pub fn overflow(self, overflow: Overflow) -> Self {
867        Self {
868            builder: self.builder.property("overflow", overflow),
869        }
870    }
871
872    pub fn receives_default(self, receives_default: bool) -> Self {
873        Self {
874            builder: self.builder.property("receives-default", receives_default),
875        }
876    }
877
878    pub fn sensitive(self, sensitive: bool) -> Self {
879        Self {
880            builder: self.builder.property("sensitive", sensitive),
881        }
882    }
883
884    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
885        Self {
886            builder: self
887                .builder
888                .property("tooltip-markup", tooltip_markup.into()),
889        }
890    }
891
892    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
893        Self {
894            builder: self.builder.property("tooltip-text", tooltip_text.into()),
895        }
896    }
897
898    pub fn valign(self, valign: Align) -> Self {
899        Self {
900            builder: self.builder.property("valign", valign),
901        }
902    }
903
904    pub fn vexpand(self, vexpand: bool) -> Self {
905        Self {
906            builder: self.builder.property("vexpand", vexpand),
907        }
908    }
909
910    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
911        Self {
912            builder: self.builder.property("vexpand-set", vexpand_set),
913        }
914    }
915
916    pub fn visible(self, visible: bool) -> Self {
917        Self {
918            builder: self.builder.property("visible", visible),
919        }
920    }
921
922    pub fn width_request(self, width_request: i32) -> Self {
923        Self {
924            builder: self.builder.property("width-request", width_request),
925        }
926    }
927
928    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
929        Self {
930            builder: self.builder.property("accessible-role", accessible_role),
931        }
932    }
933
934    pub fn editing_canceled(self, editing_canceled: bool) -> Self {
935        Self {
936            builder: self.builder.property("editing-canceled", editing_canceled),
937        }
938    }
939
940    pub fn editable(self, editable: bool) -> Self {
941        Self {
942            builder: self.builder.property("editable", editable),
943        }
944    }
945
946    pub fn enable_undo(self, enable_undo: bool) -> Self {
947        Self {
948            builder: self.builder.property("enable-undo", enable_undo),
949        }
950    }
951
952    pub fn max_width_chars(self, max_width_chars: i32) -> Self {
953        Self {
954            builder: self.builder.property("max-width-chars", max_width_chars),
955        }
956    }
957
958    pub fn text(self, text: impl Into<glib::GString>) -> Self {
959        Self {
960            builder: self.builder.property("text", text.into()),
961        }
962    }
963
964    pub fn width_chars(self, width_chars: i32) -> Self {
965        Self {
966            builder: self.builder.property("width-chars", width_chars),
967        }
968    }
969
970    pub fn xalign(self, xalign: f32) -> Self {
971        Self {
972            builder: self.builder.property("xalign", xalign),
973        }
974    }
975
976    pub fn orientation(self, orientation: Orientation) -> Self {
977        Self {
978            builder: self.builder.property("orientation", orientation),
979        }
980    }
981
982    // rustdoc-stripper-ignore-next
983    /// Build the [`SpinButton`].
984    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
985    pub fn build(self) -> SpinButton {
986        assert_initialized_main_thread!();
987        self.builder.build()
988    }
989}