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::AccessibleRange;
8use crate::{
9    Accessible, AccessibleRole, Adjustment, Align, Buildable, CellEditable, ConstraintTarget,
10    Editable, LayoutManager, Orientable, Orientation, Overflow, ScrollType, SpinButtonUpdatePolicy,
11    SpinType, 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    /// Allows to enter or change numeric values.
25    ///
26    /// <picture>
27    ///   <source srcset="spinbutton-dark.png" media="(prefers-color-scheme: dark)">
28    ///   <img alt="An example GtkSpinButton" src="spinbutton.png">
29    /// </picture>
30    ///
31    /// Rather than having to directly type a number into a [`Entry`][crate::Entry],
32    /// [`SpinButton`][crate::SpinButton] allows the user to click on one of two arrows
33    /// to increment or decrement the displayed value. A value can still be
34    /// typed in, with the bonus that it can be checked to ensure it is in a
35    /// given range.
36    ///
37    /// The main properties of a [`SpinButton`][crate::SpinButton] are through an adjustment.
38    /// See the [`Adjustment`][crate::Adjustment] documentation for more details about
39    /// an adjustment's properties.
40    ///
41    /// Note that [`SpinButton`][crate::SpinButton] will by default make its entry large enough
42    /// to accommodate the lower and upper bounds of the adjustment. If this
43    /// is not desired, the automatic sizing can be turned off by explicitly
44    /// setting [`width-chars`][struct@crate::Editable#width-chars] to a value != -1.
45    ///
46    /// ## Using a GtkSpinButton to get an integer
47    ///
48    /// **⚠️ The following code is in c ⚠️**
49    ///
50    /// ```c
51    /// // Provides a function to retrieve an integer value from a GtkSpinButton
52    /// // and creates a spin button to model percentage values.
53    ///
54    /// int
55    /// grab_int_value (GtkSpinButton *button,
56    ///                 gpointer       user_data)
57    /// {
58    ///   return gtk_spin_button_get_value_as_int (button);
59    /// }
60    ///
61    /// void
62    /// create_integer_spin_button (void)
63    /// {
64    ///
65    ///   GtkWidget *window, *button;
66    ///   GtkAdjustment *adjustment;
67    ///
68    ///   adjustment = gtk_adjustment_new (50.0, 0.0, 100.0, 1.0, 5.0, 0.0);
69    ///
70    ///   window = gtk_window_new ();
71    ///
72    ///   // creates the spinbutton, with no decimal places
73    ///   button = gtk_spin_button_new (adjustment, 1.0, 0);
74    ///   gtk_window_set_child (GTK_WINDOW (window), button);
75    ///
76    ///   gtk_window_present (GTK_WINDOW (window));
77    /// }
78    /// ```
79    ///
80    /// ## Using a GtkSpinButton to get a floating point value
81    ///
82    /// **⚠️ The following code is in c ⚠️**
83    ///
84    /// ```c
85    /// // Provides a function to retrieve a floating point value from a
86    /// // GtkSpinButton, and creates a high precision spin button.
87    ///
88    /// float
89    /// grab_float_value (GtkSpinButton *button,
90    ///                   gpointer       user_data)
91    /// {
92    ///   return gtk_spin_button_get_value (button);
93    /// }
94    ///
95    /// void
96    /// create_floating_spin_button (void)
97    /// {
98    ///   GtkWidget *window, *button;
99    ///   GtkAdjustment *adjustment;
100    ///
101    ///   adjustment = gtk_adjustment_new (2.500, 0.0, 5.0, 0.001, 0.1, 0.0);
102    ///
103    ///   window = gtk_window_new ();
104    ///
105    ///   // creates the spinbutton, with three decimal places
106    ///   button = gtk_spin_button_new (adjustment, 0.001, 3);
107    ///   gtk_window_set_child (GTK_WINDOW (window), button);
108    ///
109    ///   gtk_window_present (GTK_WINDOW (window));
110    /// }
111    /// ```
112    ///
113    /// # Shortcuts and Gestures
114    ///
115    /// The following signals have default keybindings:
116    ///
117    /// - [`change-value`][struct@crate::SpinButton#change-value]
118    ///
119    /// # CSS nodes
120    ///
121    /// ```text
122    /// spinbutton.horizontal
123    /// ├── text
124    /// │    ├── undershoot.left
125    /// │    ╰── undershoot.right
126    /// ├── button.down
127    /// ╰── button.up
128    /// ```
129    ///
130    /// ```text
131    /// spinbutton.vertical
132    /// ├── button.up
133    /// ├── text
134    /// │    ├── undershoot.left
135    /// │    ╰── undershoot.right
136    /// ╰── button.down
137    /// ```
138    ///
139    /// [`SpinButton`][crate::SpinButton]s main CSS node has the name spinbutton. It creates subnodes
140    /// for the entry and the two buttons, with these names. The button nodes have
141    /// the style classes .up and .down. The [`Text`][crate::Text] subnodes (if present) are put
142    /// below the text node. The orientation of the spin button is reflected in
143    /// the .vertical or .horizontal style class on the main node.
144    ///
145    /// # Accessibility
146    ///
147    /// [`SpinButton`][crate::SpinButton] uses the [enum@Gtk.AccessibleRole.spin_button] role.
148    ///
149    /// ## Properties
150    ///
151    ///
152    /// #### `activates-default`
153    ///  Whether to activate the default widget when the spin button is activated.
154    ///
155    /// See [`activate`][struct@crate::SpinButton#activate] for what counts as activation.
156    ///
157    /// Readable | Writeable
158    ///
159    ///
160    /// #### `adjustment`
161    ///  The adjustment that holds the value of the spin button.
162    ///
163    /// Readable | Writeable
164    ///
165    ///
166    /// #### `climb-rate`
167    ///  The acceleration rate when you hold down a button or key.
168    ///
169    /// Readable | Writeable
170    ///
171    ///
172    /// #### `digits`
173    ///  The number of decimal places to display.
174    ///
175    /// Readable | Writeable
176    ///
177    ///
178    /// #### `numeric`
179    ///  Whether non-numeric characters should be ignored.
180    ///
181    /// Readable | Writeable
182    ///
183    ///
184    /// #### `snap-to-ticks`
185    ///  Whether erroneous values are automatically changed to the spin buttons
186    /// nearest step increment.
187    ///
188    /// Readable | Writeable
189    ///
190    ///
191    /// #### `update-policy`
192    ///  Whether the spin button should update always, or only when the value
193    /// is acceptable.
194    ///
195    /// Readable | Writeable
196    ///
197    ///
198    /// #### `value`
199    ///  The current value.
200    ///
201    /// Readable | Writeable
202    ///
203    ///
204    /// #### `wrap`
205    ///  Whether a spin button should wrap upon reaching its limits.
206    ///
207    /// Readable | Writeable
208    /// <details><summary><h4>Widget</h4></summary>
209    ///
210    ///
211    /// #### `can-focus`
212    ///  Whether the widget or any of its descendents can accept
213    /// the input focus.
214    ///
215    /// This property is meant to be set by widget implementations,
216    /// typically in their instance init function.
217    ///
218    /// Readable | Writeable
219    ///
220    ///
221    /// #### `can-target`
222    ///  Whether the widget can receive pointer events.
223    ///
224    /// Readable | Writeable
225    ///
226    ///
227    /// #### `css-classes`
228    ///  A list of css classes applied to this widget.
229    ///
230    /// Readable | Writeable
231    ///
232    ///
233    /// #### `css-name`
234    ///  The name of this widget in the CSS tree.
235    ///
236    /// This property is meant to be set by widget implementations,
237    /// typically in their instance init function.
238    ///
239    /// Readable | Writeable | Construct Only
240    ///
241    ///
242    /// #### `cursor`
243    ///  The cursor used by @widget.
244    ///
245    /// Readable | Writeable
246    ///
247    ///
248    /// #### `focus-on-click`
249    ///  Whether the widget should grab focus when it is clicked with the mouse.
250    ///
251    /// This property is only relevant for widgets that can take focus.
252    ///
253    /// Readable | Writeable
254    ///
255    ///
256    /// #### `focusable`
257    ///  Whether this widget itself will accept the input focus.
258    ///
259    /// Readable | Writeable
260    ///
261    ///
262    /// #### `halign`
263    ///  How to distribute horizontal space if widget gets extra space.
264    ///
265    /// Readable | Writeable
266    ///
267    ///
268    /// #### `has-default`
269    ///  Whether the widget is the default widget.
270    ///
271    /// Readable
272    ///
273    ///
274    /// #### `has-focus`
275    ///  Whether the widget has the input focus.
276    ///
277    /// Readable
278    ///
279    ///
280    /// #### `has-tooltip`
281    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
282    /// signal on @widget.
283    ///
284    /// A true value indicates that @widget can have a tooltip, in this case
285    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
286    /// determine whether it will provide a tooltip or not.
287    ///
288    /// Readable | Writeable
289    ///
290    ///
291    /// #### `height-request`
292    ///  Overrides for height request of the widget.
293    ///
294    /// If this is -1, the natural request will be used.
295    ///
296    /// Readable | Writeable
297    ///
298    ///
299    /// #### `hexpand`
300    ///  Whether to expand horizontally.
301    ///
302    /// Readable | Writeable
303    ///
304    ///
305    /// #### `hexpand-set`
306    ///  Whether to use the `hexpand` property.
307    ///
308    /// Readable | Writeable
309    ///
310    ///
311    /// #### `layout-manager`
312    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
313    /// the preferred size of the widget, and allocate its children.
314    ///
315    /// This property is meant to be set by widget implementations,
316    /// typically in their instance init function.
317    ///
318    /// Readable | Writeable
319    ///
320    ///
321    /// #### `limit-events`
322    ///  Makes this widget act like a modal dialog, with respect to
323    /// event delivery.
324    ///
325    /// Global event controllers will not handle events with targets
326    /// inside the widget, unless they are set up to ignore propagation
327    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
328    ///
329    /// Readable | Writeable
330    ///
331    ///
332    /// #### `margin-bottom`
333    ///  Margin on bottom side of widget.
334    ///
335    /// This property adds margin outside of the widget's normal size
336    /// request, the margin will be added in addition to the size from
337    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
338    ///
339    /// Readable | Writeable
340    ///
341    ///
342    /// #### `margin-end`
343    ///  Margin on end of widget, horizontally.
344    ///
345    /// This property supports left-to-right and right-to-left text
346    /// directions.
347    ///
348    /// This property adds margin outside of the widget's normal size
349    /// request, the margin will be added in addition to the size from
350    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
351    ///
352    /// Readable | Writeable
353    ///
354    ///
355    /// #### `margin-start`
356    ///  Margin on start of widget, horizontally.
357    ///
358    /// This property supports left-to-right and right-to-left text
359    /// directions.
360    ///
361    /// This property adds margin outside of the widget's normal size
362    /// request, the margin will be added in addition to the size from
363    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
364    ///
365    /// Readable | Writeable
366    ///
367    ///
368    /// #### `margin-top`
369    ///  Margin on top side of widget.
370    ///
371    /// This property adds margin outside of the widget's normal size
372    /// request, the margin will be added in addition to the size from
373    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
374    ///
375    /// Readable | Writeable
376    ///
377    ///
378    /// #### `name`
379    ///  The name of the widget.
380    ///
381    /// Readable | Writeable
382    ///
383    ///
384    /// #### `opacity`
385    ///  The requested opacity of the widget.
386    ///
387    /// Readable | Writeable
388    ///
389    ///
390    /// #### `overflow`
391    ///  How content outside the widget's content area is treated.
392    ///
393    /// This property is meant to be set by widget implementations,
394    /// typically in their instance init function.
395    ///
396    /// Readable | Writeable
397    ///
398    ///
399    /// #### `parent`
400    ///  The parent widget of this widget.
401    ///
402    /// Readable
403    ///
404    ///
405    /// #### `receives-default`
406    ///  Whether the widget will receive the default action when it is focused.
407    ///
408    /// Readable | Writeable
409    ///
410    ///
411    /// #### `root`
412    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
413    ///
414    /// This will be `NULL` if the widget is not contained in a root widget.
415    ///
416    /// Readable
417    ///
418    ///
419    /// #### `scale-factor`
420    ///  The scale factor of the widget.
421    ///
422    /// Readable
423    ///
424    ///
425    /// #### `sensitive`
426    ///  Whether the widget responds to input.
427    ///
428    /// Readable | Writeable
429    ///
430    ///
431    /// #### `tooltip-markup`
432    ///  Sets the text of tooltip to be the given string, which is marked up
433    /// with Pango markup.
434    ///
435    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
436    ///
437    /// This is a convenience property which will take care of getting the
438    /// tooltip shown if the given string is not `NULL`:
439    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
440    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
441    /// the default signal handler.
442    ///
443    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
444    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
445    ///
446    /// Readable | Writeable
447    ///
448    ///
449    /// #### `tooltip-text`
450    ///  Sets the text of tooltip to be the given string.
451    ///
452    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
453    ///
454    /// This is a convenience property which will take care of getting the
455    /// tooltip shown if the given string is not `NULL`:
456    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
457    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
458    /// the default signal handler.
459    ///
460    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
461    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
462    ///
463    /// Readable | Writeable
464    ///
465    ///
466    /// #### `valign`
467    ///  How to distribute vertical space if widget gets extra space.
468    ///
469    /// Readable | Writeable
470    ///
471    ///
472    /// #### `vexpand`
473    ///  Whether to expand vertically.
474    ///
475    /// Readable | Writeable
476    ///
477    ///
478    /// #### `vexpand-set`
479    ///  Whether to use the `vexpand` property.
480    ///
481    /// Readable | Writeable
482    ///
483    ///
484    /// #### `visible`
485    ///  Whether the widget is visible.
486    ///
487    /// Readable | Writeable
488    ///
489    ///
490    /// #### `width-request`
491    ///  Overrides for width request of the widget.
492    ///
493    /// If this is -1, the natural request will be used.
494    ///
495    /// Readable | Writeable
496    /// </details>
497    /// <details><summary><h4>Accessible</h4></summary>
498    ///
499    ///
500    /// #### `accessible-role`
501    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
502    ///
503    /// The accessible role cannot be changed once set.
504    ///
505    /// Readable | Writeable
506    /// </details>
507    /// <details><summary><h4>CellEditable</h4></summary>
508    ///
509    ///
510    /// #### `editing-canceled`
511    ///  Indicates whether editing on the cell has been canceled.
512    ///
513    /// Readable | Writeable
514    /// </details>
515    /// <details><summary><h4>Editable</h4></summary>
516    ///
517    ///
518    /// #### `complete-text`
519    ///  The contents of the entry, including uncommited content such as the
520    /// preedit.
521    ///
522    /// Readable
523    ///
524    ///
525    /// #### `cursor-position`
526    ///  The current position of the insertion cursor in chars.
527    ///
528    /// Readable
529    ///
530    ///
531    /// #### `editable`
532    ///  Whether the entry contents can be edited.
533    ///
534    /// Readable | Writeable
535    ///
536    ///
537    /// #### `enable-undo`
538    ///  If undo/redo should be enabled for the editable.
539    ///
540    /// Readable | Writeable
541    ///
542    ///
543    /// #### `max-width-chars`
544    ///  The desired maximum width of the entry, in characters.
545    ///
546    /// Readable | Writeable
547    ///
548    ///
549    /// #### `selection-bound`
550    ///  The position of the opposite end of the selection from the cursor in chars.
551    ///
552    /// Readable
553    ///
554    ///
555    /// #### `text`
556    ///  The contents of the entry.
557    ///
558    /// Readable | Writeable
559    ///
560    ///
561    /// #### `width-chars`
562    ///  Number of characters to leave space for in the entry.
563    ///
564    /// Readable | Writeable
565    ///
566    ///
567    /// #### `xalign`
568    ///  The horizontal alignment, from 0 (left) to 1 (right).
569    ///
570    /// Reversed for RTL layouts.
571    ///
572    /// Readable | Writeable
573    /// </details>
574    /// <details><summary><h4>Orientable</h4></summary>
575    ///
576    ///
577    /// #### `orientation`
578    ///  The orientation of the orientable.
579    ///
580    /// Readable | Writeable
581    /// </details>
582    ///
583    /// ## Signals
584    ///
585    ///
586    /// #### `activate`
587    ///  Emitted when the spin button is activated.
588    ///
589    /// The keybindings for this signal are all forms of the <kbd>Enter</kbd> key.
590    ///
591    /// If the <kbd>Enter</kbd> key results in the value being committed to the
592    /// spin button, then activation does not occur until <kbd>Enter</kbd> is
593    /// pressed again.
594    ///
595    /// Action
596    ///
597    ///
598    /// #### `change-value`
599    ///  Emitted when the user initiates a value change.
600    ///
601    /// This is a [keybinding signal](class.SignalAction.html).
602    ///
603    /// Applications should not connect to it, but may emit it with
604    /// g_signal_emit_by_name() if they need to control the cursor
605    /// programmatically.
606    ///
607    /// The default bindings for this signal are Up/Down and PageUp/PageDown.
608    ///
609    /// Action
610    ///
611    ///
612    /// #### `input`
613    ///  Emitted to convert the users input into a double value.
614    ///
615    /// The signal handler is expected to use [`EditableExt::text()`][crate::prelude::EditableExt::text()]
616    /// to retrieve the text of the spinbutton and set @new_value to the
617    /// new value.
618    ///
619    /// The default conversion uses g_strtod().
620    ///
621    ///
622    ///
623    ///
624    /// #### `output`
625    ///  Emitted to tweak the formatting of the value for display.
626    ///
627    /// **⚠️ The following code is in c ⚠️**
628    ///
629    /// ```c
630    /// // show leading zeros
631    /// static gboolean
632    /// on_output (GtkSpinButton *spin,
633    ///            gpointer       data)
634    /// {
635    ///    char *text;
636    ///    int value;
637    ///
638    ///    value = gtk_spin_button_get_value_as_int (spin);
639    ///    text = g_strdup_printf ("%02d", value);
640    ///    gtk_editable_set_text (GTK_EDITABLE (spin), text):
641    ///    g_free (text);
642    ///
643    ///    return TRUE;
644    /// }
645    /// ```
646    ///
647    ///
648    ///
649    ///
650    /// #### `value-changed`
651    ///  Emitted when the value is changed.
652    ///
653    /// Also see the [`output`][struct@crate::SpinButton#output] signal.
654    ///
655    ///
656    ///
657    ///
658    /// #### `wrapped`
659    ///  Emitted right after the spinbutton wraps from its maximum
660    /// to its minimum value or vice-versa.
661    ///
662    ///
663    /// <details><summary><h4>Widget</h4></summary>
664    ///
665    ///
666    /// #### `destroy`
667    ///  Signals that all holders of a reference to the widget should release
668    /// the reference that they hold.
669    ///
670    /// May result in finalization of the widget if all references are released.
671    ///
672    /// This signal is not suitable for saving widget state.
673    ///
674    ///
675    ///
676    ///
677    /// #### `direction-changed`
678    ///  Emitted when the text direction of a widget changes.
679    ///
680    ///
681    ///
682    ///
683    /// #### `hide`
684    ///  Emitted when @widget is hidden.
685    ///
686    ///
687    ///
688    ///
689    /// #### `keynav-failed`
690    ///  Emitted if keyboard navigation fails.
691    ///
692    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
693    ///
694    ///
695    ///
696    ///
697    /// #### `map`
698    ///  Emitted when @widget is going to be mapped.
699    ///
700    /// A widget is mapped when the widget is visible (which is controlled with
701    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
702    /// are also visible.
703    ///
704    /// The `::map` signal can be used to determine whether a widget will be drawn,
705    /// for instance it can resume an animation that was stopped during the
706    /// emission of [`unmap`][struct@crate::Widget#unmap].
707    ///
708    ///
709    ///
710    ///
711    /// #### `mnemonic-activate`
712    ///  Emitted when a widget is activated via a mnemonic.
713    ///
714    /// The default handler for this signal activates @widget if @group_cycling
715    /// is false, or just makes @widget grab focus if @group_cycling is true.
716    ///
717    ///
718    ///
719    ///
720    /// #### `move-focus`
721    ///  Emitted when the focus is moved.
722    ///
723    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
724    ///
725    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
726    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
727    ///
728    /// Action
729    ///
730    ///
731    /// #### `query-tooltip`
732    ///  Emitted when the widget’s tooltip is about to be shown.
733    ///
734    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
735    /// is true and the hover timeout has expired with the cursor hovering
736    /// above @widget; or emitted when @widget got focus in keyboard mode.
737    ///
738    /// Using the given coordinates, the signal handler should determine
739    /// whether a tooltip should be shown for @widget. If this is the case
740    /// true should be returned, false otherwise. Note that if @keyboard_mode
741    /// is true, the values of @x and @y are undefined and should not be used.
742    ///
743    /// The signal handler is free to manipulate @tooltip with the therefore
744    /// destined function calls.
745    ///
746    ///
747    ///
748    ///
749    /// #### `realize`
750    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
751    ///
752    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
753    /// or the widget has been mapped (that is, it is going to be drawn).
754    ///
755    ///
756    ///
757    ///
758    /// #### `show`
759    ///  Emitted when @widget is shown.
760    ///
761    ///
762    ///
763    ///
764    /// #### `state-flags-changed`
765    ///  Emitted when the widget state changes.
766    ///
767    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
768    ///
769    ///
770    ///
771    ///
772    /// #### `unmap`
773    ///  Emitted when @widget is going to be unmapped.
774    ///
775    /// A widget is unmapped when either it or any of its parents up to the
776    /// toplevel widget have been set as hidden.
777    ///
778    /// As `::unmap` indicates that a widget will not be shown any longer,
779    /// it can be used to, for example, stop an animation on the widget.
780    ///
781    ///
782    ///
783    ///
784    /// #### `unrealize`
785    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
786    ///
787    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
788    /// or the widget has been unmapped (that is, it is going to be hidden).
789    ///
790    ///
791    /// </details>
792    /// <details><summary><h4>CellEditable</h4></summary>
793    ///
794    ///
795    /// #### `editing-done`
796    ///  This signal is a sign for the cell renderer to update its
797    /// value from the @cell_editable.
798    ///
799    /// Implementations of [`CellEditable`][crate::CellEditable] are responsible for
800    /// emitting this signal when they are done editing, e.g.
801    /// [`Entry`][crate::Entry] emits this signal when the user presses Enter. Typical things to
802    /// do in a handler for ::editing-done are to capture the edited value,
803    /// disconnect the @cell_editable from signals on the [`CellRenderer`][crate::CellRenderer], etc.
804    ///
805    /// gtk_cell_editable_editing_done() is a convenience method
806    /// for emitting `GtkCellEditable::editing-done`.
807    ///
808    ///
809    ///
810    ///
811    /// #### `remove-widget`
812    ///  This signal is meant to indicate that the cell is finished
813    /// editing, and the @cell_editable widget is being removed and may
814    /// subsequently be destroyed.
815    ///
816    /// Implementations of [`CellEditable`][crate::CellEditable] are responsible for
817    /// emitting this signal when they are done editing. It must
818    /// be emitted after the `GtkCellEditable::editing-done` signal,
819    /// to give the cell renderer a chance to update the cell's value
820    /// before the widget is removed.
821    ///
822    /// gtk_cell_editable_remove_widget() is a convenience method
823    /// for emitting `GtkCellEditable::remove-widget`.
824    ///
825    ///
826    /// </details>
827    /// <details><summary><h4>Editable</h4></summary>
828    ///
829    ///
830    /// #### `changed`
831    ///  Emitted at the end of a single user-visible operation on the
832    /// contents.
833    ///
834    /// E.g., a paste operation that replaces the contents of the
835    /// selection will cause only one signal emission (even though it
836    /// is implemented by first deleting the selection, then inserting
837    /// the new content, and may cause multiple ::notify::text signals
838    /// to be emitted).
839    ///
840    ///
841    ///
842    ///
843    /// #### `delete-text`
844    ///  Emitted when text is deleted from the widget by the user.
845    ///
846    /// The default handler for this signal will normally be responsible for
847    /// deleting the text, so by connecting to this signal and then stopping
848    /// the signal with g_signal_stop_emission(), it is possible to modify the
849    /// range of deleted text, or prevent it from being deleted entirely.
850    ///
851    /// The @start_pos and @end_pos parameters are interpreted as for
852    /// [`EditableExt::delete_text()`][crate::prelude::EditableExt::delete_text()].
853    ///
854    ///
855    ///
856    ///
857    /// #### `insert-text`
858    ///  Emitted when text is inserted into the widget by the user.
859    ///
860    /// The default handler for this signal will normally be responsible
861    /// for inserting the text, so by connecting to this signal and then
862    /// stopping the signal with g_signal_stop_emission(), it is possible
863    /// to modify the inserted text, or prevent it from being inserted entirely.
864    ///
865    ///
866    /// </details>
867    ///
868    /// # Implements
869    ///
870    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`AccessibleRangeExt`][trait@crate::prelude::AccessibleRangeExt], [`CellEditableExt`][trait@crate::prelude::CellEditableExt], [`EditableExt`][trait@crate::prelude::EditableExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual], [`EditableExtManual`][trait@crate::prelude::EditableExtManual]
871    #[doc(alias = "GtkSpinButton")]
872    pub struct SpinButton(Object<ffi::GtkSpinButton>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, AccessibleRange, CellEditable, Editable, Orientable;
873
874    match fn {
875        type_ => || ffi::gtk_spin_button_get_type(),
876    }
877}
878
879#[cfg(not(feature = "v4_10"))]
880glib::wrapper! {
881    #[doc(alias = "GtkSpinButton")]
882    pub struct SpinButton(Object<ffi::GtkSpinButton>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, CellEditable, Editable, Orientable;
883
884    match fn {
885        type_ => || ffi::gtk_spin_button_get_type(),
886    }
887}
888
889impl SpinButton {
890    /// Creates a new [`SpinButton`][crate::SpinButton].
891    /// ## `adjustment`
892    /// the [`Adjustment`][crate::Adjustment] that this spin button should use
893    /// ## `climb_rate`
894    /// specifies by how much the rate of change in the value will
895    ///   accelerate if you continue to hold down an up/down button or arrow key
896    /// ## `digits`
897    /// the number of decimal places to display
898    ///
899    /// # Returns
900    ///
901    /// The new [`SpinButton`][crate::SpinButton]
902    #[doc(alias = "gtk_spin_button_new")]
903    pub fn new(
904        adjustment: Option<&impl IsA<Adjustment>>,
905        climb_rate: f64,
906        digits: u32,
907    ) -> SpinButton {
908        assert_initialized_main_thread!();
909        unsafe {
910            Widget::from_glib_none(ffi::gtk_spin_button_new(
911                adjustment.map(|p| p.as_ref()).to_glib_none().0,
912                climb_rate,
913                digits,
914            ))
915            .unsafe_cast()
916        }
917    }
918
919    /// Creates a new [`SpinButton`][crate::SpinButton] with the given properties.
920    ///
921    /// This is a convenience constructor that allows creation
922    /// of a numeric [`SpinButton`][crate::SpinButton] without manually creating
923    /// an adjustment. The value is initially set to the minimum
924    /// value and a page increment of 10 * @step is the default.
925    /// The precision of the spin button is equivalent to the
926    /// precision of @step.
927    ///
928    /// Note that the way in which the precision is derived works
929    /// best if @step is a power of ten. If the resulting precision
930    /// is not suitable for your needs, use
931    /// [`set_digits()`][Self::set_digits()] to correct it.
932    /// ## `min`
933    /// Minimum allowable value
934    /// ## `max`
935    /// Maximum allowable value
936    /// ## `step`
937    /// Increment added or subtracted by spinning the widget
938    ///
939    /// # Returns
940    ///
941    /// The new [`SpinButton`][crate::SpinButton]
942    #[doc(alias = "gtk_spin_button_new_with_range")]
943    #[doc(alias = "new_with_range")]
944    pub fn with_range(min: f64, max: f64, step: f64) -> SpinButton {
945        assert_initialized_main_thread!();
946        unsafe {
947            Widget::from_glib_none(ffi::gtk_spin_button_new_with_range(min, max, step))
948                .unsafe_cast()
949        }
950    }
951
952    // rustdoc-stripper-ignore-next
953    /// Creates a new builder-pattern struct instance to construct [`SpinButton`] objects.
954    ///
955    /// This method returns an instance of [`SpinButtonBuilder`](crate::builders::SpinButtonBuilder) which can be used to create [`SpinButton`] objects.
956    pub fn builder() -> SpinButtonBuilder {
957        SpinButtonBuilder::new()
958    }
959
960    /// Changes the properties of an existing spin button.
961    ///
962    /// The adjustment, climb rate, and number of decimal places
963    /// are updated accordingly.
964    /// ## `adjustment`
965    /// a [`Adjustment`][crate::Adjustment] to replace the spin button’s
966    ///   existing adjustment, or [`None`] to leave its current adjustment unchanged
967    /// ## `climb_rate`
968    /// the new climb rate
969    /// ## `digits`
970    /// the number of decimal places to display in the spin button
971    #[doc(alias = "gtk_spin_button_configure")]
972    pub fn configure(
973        &self,
974        adjustment: Option<&impl IsA<Adjustment>>,
975        climb_rate: f64,
976        digits: u32,
977    ) {
978        unsafe {
979            ffi::gtk_spin_button_configure(
980                self.to_glib_none().0,
981                adjustment.map(|p| p.as_ref()).to_glib_none().0,
982                climb_rate,
983                digits,
984            );
985        }
986    }
987
988    /// Retrieves the value set by [`set_activates_default()`][Self::set_activates_default()].
989    ///
990    /// # Returns
991    ///
992    /// [`true`] if the spin button will activate the default widget
993    #[cfg(feature = "v4_14")]
994    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
995    #[doc(alias = "gtk_spin_button_get_activates_default")]
996    #[doc(alias = "get_activates_default")]
997    #[doc(alias = "activates-default")]
998    pub fn activates_default(&self) -> bool {
999        unsafe {
1000            from_glib(ffi::gtk_spin_button_get_activates_default(
1001                self.to_glib_none().0,
1002            ))
1003        }
1004    }
1005
1006    /// Get the adjustment associated with a [`SpinButton`][crate::SpinButton].
1007    ///
1008    /// # Returns
1009    ///
1010    /// the [`Adjustment`][crate::Adjustment] of @self
1011    #[doc(alias = "gtk_spin_button_get_adjustment")]
1012    #[doc(alias = "get_adjustment")]
1013    pub fn adjustment(&self) -> Adjustment {
1014        unsafe { from_glib_none(ffi::gtk_spin_button_get_adjustment(self.to_glib_none().0)) }
1015    }
1016
1017    /// Returns the acceleration rate for repeated changes.
1018    ///
1019    /// # Returns
1020    ///
1021    /// the acceleration rate
1022    #[doc(alias = "gtk_spin_button_get_climb_rate")]
1023    #[doc(alias = "get_climb_rate")]
1024    #[doc(alias = "climb-rate")]
1025    pub fn climb_rate(&self) -> f64 {
1026        unsafe { ffi::gtk_spin_button_get_climb_rate(self.to_glib_none().0) }
1027    }
1028
1029    /// Fetches the precision of @self.
1030    ///
1031    /// # Returns
1032    ///
1033    /// the current precision
1034    #[doc(alias = "gtk_spin_button_get_digits")]
1035    #[doc(alias = "get_digits")]
1036    pub fn digits(&self) -> u32 {
1037        unsafe { ffi::gtk_spin_button_get_digits(self.to_glib_none().0) }
1038    }
1039
1040    /// Gets the current step and page the increments
1041    /// used by @self.
1042    ///
1043    /// See [`set_increments()`][Self::set_increments()].
1044    ///
1045    /// # Returns
1046    ///
1047    ///
1048    /// ## `step`
1049    /// location to store step increment
1050    ///
1051    /// ## `page`
1052    /// location to store page increment
1053    #[doc(alias = "gtk_spin_button_get_increments")]
1054    #[doc(alias = "get_increments")]
1055    pub fn increments(&self) -> (f64, f64) {
1056        unsafe {
1057            let mut step = std::mem::MaybeUninit::uninit();
1058            let mut page = std::mem::MaybeUninit::uninit();
1059            ffi::gtk_spin_button_get_increments(
1060                self.to_glib_none().0,
1061                step.as_mut_ptr(),
1062                page.as_mut_ptr(),
1063            );
1064            (step.assume_init(), page.assume_init())
1065        }
1066    }
1067
1068    /// Returns whether non-numeric text can be typed into the spin button.
1069    ///
1070    /// # Returns
1071    ///
1072    /// [`true`] if only numeric text can be entered
1073    #[doc(alias = "gtk_spin_button_get_numeric")]
1074    #[doc(alias = "get_numeric")]
1075    #[doc(alias = "numeric")]
1076    pub fn is_numeric(&self) -> bool {
1077        unsafe { from_glib(ffi::gtk_spin_button_get_numeric(self.to_glib_none().0)) }
1078    }
1079
1080    /// Gets the range allowed for @self.
1081    ///
1082    /// See [`set_range()`][Self::set_range()].
1083    ///
1084    /// # Returns
1085    ///
1086    ///
1087    /// ## `min`
1088    /// location to store minimum allowed value
1089    ///
1090    /// ## `max`
1091    /// location to store maximum allowed value
1092    #[doc(alias = "gtk_spin_button_get_range")]
1093    #[doc(alias = "get_range")]
1094    pub fn range(&self) -> (f64, f64) {
1095        unsafe {
1096            let mut min = std::mem::MaybeUninit::uninit();
1097            let mut max = std::mem::MaybeUninit::uninit();
1098            ffi::gtk_spin_button_get_range(
1099                self.to_glib_none().0,
1100                min.as_mut_ptr(),
1101                max.as_mut_ptr(),
1102            );
1103            (min.assume_init(), max.assume_init())
1104        }
1105    }
1106
1107    /// Returns whether the values are corrected to the nearest step.
1108    ///
1109    /// # Returns
1110    ///
1111    /// [`true`] if values are snapped to the nearest step
1112    #[doc(alias = "gtk_spin_button_get_snap_to_ticks")]
1113    #[doc(alias = "get_snap_to_ticks")]
1114    #[doc(alias = "snap-to-ticks")]
1115    pub fn snaps_to_ticks(&self) -> bool {
1116        unsafe {
1117            from_glib(ffi::gtk_spin_button_get_snap_to_ticks(
1118                self.to_glib_none().0,
1119            ))
1120        }
1121    }
1122
1123    /// Gets the update behavior of a spin button.
1124    ///
1125    /// See [`set_update_policy()`][Self::set_update_policy()].
1126    ///
1127    /// # Returns
1128    ///
1129    /// the current update policy
1130    #[doc(alias = "gtk_spin_button_get_update_policy")]
1131    #[doc(alias = "get_update_policy")]
1132    #[doc(alias = "update-policy")]
1133    pub fn update_policy(&self) -> SpinButtonUpdatePolicy {
1134        unsafe {
1135            from_glib(ffi::gtk_spin_button_get_update_policy(
1136                self.to_glib_none().0,
1137            ))
1138        }
1139    }
1140
1141    /// Get the value in the @self.
1142    ///
1143    /// # Returns
1144    ///
1145    /// the value of @self
1146    #[doc(alias = "gtk_spin_button_get_value")]
1147    #[doc(alias = "get_value")]
1148    pub fn value(&self) -> f64 {
1149        unsafe { ffi::gtk_spin_button_get_value(self.to_glib_none().0) }
1150    }
1151
1152    /// Get the value @self represented as an integer.
1153    ///
1154    /// # Returns
1155    ///
1156    /// the value of @self
1157    #[doc(alias = "gtk_spin_button_get_value_as_int")]
1158    #[doc(alias = "get_value_as_int")]
1159    pub fn value_as_int(&self) -> i32 {
1160        unsafe { ffi::gtk_spin_button_get_value_as_int(self.to_glib_none().0) }
1161    }
1162
1163    /// Returns whether the spin button’s value wraps around to the
1164    /// opposite limit when the upper or lower limit of the range is
1165    /// exceeded.
1166    ///
1167    /// # Returns
1168    ///
1169    /// [`true`] if the spin button wraps around
1170    #[doc(alias = "gtk_spin_button_get_wrap")]
1171    #[doc(alias = "get_wrap")]
1172    #[doc(alias = "wrap")]
1173    pub fn wraps(&self) -> bool {
1174        unsafe { from_glib(ffi::gtk_spin_button_get_wrap(self.to_glib_none().0)) }
1175    }
1176
1177    /// Sets whether activating the spin button will activate the default
1178    /// widget for the window containing the spin button.
1179    ///
1180    /// See [`activate`][struct@crate::SpinButton#activate] for what counts as activation.
1181    /// ## `activates_default`
1182    /// [`true`] to activate window’s default widget on activation
1183    #[cfg(feature = "v4_14")]
1184    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1185    #[doc(alias = "gtk_spin_button_set_activates_default")]
1186    #[doc(alias = "activates-default")]
1187    pub fn set_activates_default(&self, activates_default: bool) {
1188        unsafe {
1189            ffi::gtk_spin_button_set_activates_default(
1190                self.to_glib_none().0,
1191                activates_default.into_glib(),
1192            );
1193        }
1194    }
1195
1196    /// Replaces the [`Adjustment`][crate::Adjustment] associated with @self.
1197    /// ## `adjustment`
1198    /// a [`Adjustment`][crate::Adjustment] to replace the existing adjustment
1199    #[doc(alias = "gtk_spin_button_set_adjustment")]
1200    #[doc(alias = "adjustment")]
1201    pub fn set_adjustment(&self, adjustment: &impl IsA<Adjustment>) {
1202        unsafe {
1203            ffi::gtk_spin_button_set_adjustment(
1204                self.to_glib_none().0,
1205                adjustment.as_ref().to_glib_none().0,
1206            );
1207        }
1208    }
1209
1210    /// Sets the acceleration rate for repeated changes when you
1211    /// hold down a button or key.
1212    /// ## `climb_rate`
1213    /// the rate of acceleration, must be >= 0
1214    #[doc(alias = "gtk_spin_button_set_climb_rate")]
1215    #[doc(alias = "climb-rate")]
1216    pub fn set_climb_rate(&self, climb_rate: f64) {
1217        unsafe {
1218            ffi::gtk_spin_button_set_climb_rate(self.to_glib_none().0, climb_rate);
1219        }
1220    }
1221
1222    /// Set the precision to be displayed by @self.
1223    ///
1224    /// Up to 20 digit precision is allowed.
1225    /// ## `digits`
1226    /// the number of digits after the decimal point to be
1227    ///   displayed for the spin button’s value
1228    #[doc(alias = "gtk_spin_button_set_digits")]
1229    #[doc(alias = "digits")]
1230    pub fn set_digits(&self, digits: u32) {
1231        unsafe {
1232            ffi::gtk_spin_button_set_digits(self.to_glib_none().0, digits);
1233        }
1234    }
1235
1236    /// Sets the step and page increments for spin_button.
1237    ///
1238    /// This affects how quickly the value changes when
1239    /// the spin button’s arrows are activated.
1240    /// ## `step`
1241    /// increment applied for a button 1 press.
1242    /// ## `page`
1243    /// increment applied for a button 2 press.
1244    #[doc(alias = "gtk_spin_button_set_increments")]
1245    pub fn set_increments(&self, step: f64, page: f64) {
1246        unsafe {
1247            ffi::gtk_spin_button_set_increments(self.to_glib_none().0, step, page);
1248        }
1249    }
1250
1251    /// Sets the flag that determines if non-numeric text can be typed
1252    /// into the spin button.
1253    /// ## `numeric`
1254    /// flag indicating if only numeric entry is allowed
1255    #[doc(alias = "gtk_spin_button_set_numeric")]
1256    #[doc(alias = "numeric")]
1257    pub fn set_numeric(&self, numeric: bool) {
1258        unsafe {
1259            ffi::gtk_spin_button_set_numeric(self.to_glib_none().0, numeric.into_glib());
1260        }
1261    }
1262
1263    /// Sets the minimum and maximum allowable values for @self.
1264    ///
1265    /// If the current value is outside this range, it will be adjusted
1266    /// to fit within the range, otherwise it will remain unchanged.
1267    /// ## `min`
1268    /// minimum allowable value
1269    /// ## `max`
1270    /// maximum allowable value
1271    #[doc(alias = "gtk_spin_button_set_range")]
1272    pub fn set_range(&self, min: f64, max: f64) {
1273        unsafe {
1274            ffi::gtk_spin_button_set_range(self.to_glib_none().0, min, max);
1275        }
1276    }
1277
1278    /// Sets the policy as to whether values are corrected to the
1279    /// nearest step increment when a spin button is activated after
1280    /// providing an invalid value.
1281    /// ## `snap_to_ticks`
1282    /// a flag indicating if invalid values should be corrected
1283    #[doc(alias = "gtk_spin_button_set_snap_to_ticks")]
1284    #[doc(alias = "snap-to-ticks")]
1285    pub fn set_snap_to_ticks(&self, snap_to_ticks: bool) {
1286        unsafe {
1287            ffi::gtk_spin_button_set_snap_to_ticks(
1288                self.to_glib_none().0,
1289                snap_to_ticks.into_glib(),
1290            );
1291        }
1292    }
1293
1294    /// Sets the update behavior of a spin button.
1295    ///
1296    /// This determines whether the spin button is always
1297    /// updated or only when a valid value is set.
1298    /// ## `policy`
1299    /// a [`SpinButtonUpdatePolicy`][crate::SpinButtonUpdatePolicy] value
1300    #[doc(alias = "gtk_spin_button_set_update_policy")]
1301    #[doc(alias = "update-policy")]
1302    pub fn set_update_policy(&self, policy: SpinButtonUpdatePolicy) {
1303        unsafe {
1304            ffi::gtk_spin_button_set_update_policy(self.to_glib_none().0, policy.into_glib());
1305        }
1306    }
1307
1308    /// Sets the value of @self.
1309    /// ## `value`
1310    /// the new value
1311    #[doc(alias = "gtk_spin_button_set_value")]
1312    #[doc(alias = "value")]
1313    pub fn set_value(&self, value: f64) {
1314        unsafe {
1315            ffi::gtk_spin_button_set_value(self.to_glib_none().0, value);
1316        }
1317    }
1318
1319    /// Sets the flag that determines if a spin button value wraps
1320    /// around to the opposite limit when the upper or lower limit
1321    /// of the range is exceeded.
1322    /// ## `wrap`
1323    /// a flag indicating if wrapping behavior is performed
1324    #[doc(alias = "gtk_spin_button_set_wrap")]
1325    #[doc(alias = "wrap")]
1326    pub fn set_wrap(&self, wrap: bool) {
1327        unsafe {
1328            ffi::gtk_spin_button_set_wrap(self.to_glib_none().0, wrap.into_glib());
1329        }
1330    }
1331
1332    /// Increment or decrement a spin button’s value in a specified
1333    /// direction by a specified amount.
1334    /// ## `direction`
1335    /// a [`SpinType`][crate::SpinType] indicating the direction to spin
1336    /// ## `increment`
1337    /// step increment to apply in the specified direction
1338    #[doc(alias = "gtk_spin_button_spin")]
1339    pub fn spin(&self, direction: SpinType, increment: f64) {
1340        unsafe {
1341            ffi::gtk_spin_button_spin(self.to_glib_none().0, direction.into_glib(), increment);
1342        }
1343    }
1344
1345    /// Manually force an update of the spin button.
1346    #[doc(alias = "gtk_spin_button_update")]
1347    pub fn update(&self) {
1348        unsafe {
1349            ffi::gtk_spin_button_update(self.to_glib_none().0);
1350        }
1351    }
1352
1353    /// Emitted when the spin button is activated.
1354    ///
1355    /// The keybindings for this signal are all forms of the <kbd>Enter</kbd> key.
1356    ///
1357    /// If the <kbd>Enter</kbd> key results in the value being committed to the
1358    /// spin button, then activation does not occur until <kbd>Enter</kbd> is
1359    /// pressed again.
1360    #[cfg(feature = "v4_14")]
1361    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1362    #[doc(alias = "activate")]
1363    pub fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1364        unsafe extern "C" fn activate_trampoline<F: Fn(&SpinButton) + 'static>(
1365            this: *mut ffi::GtkSpinButton,
1366            f: glib::ffi::gpointer,
1367        ) {
1368            unsafe {
1369                let f: &F = &*(f as *const F);
1370                f(&from_glib_borrow(this))
1371            }
1372        }
1373        unsafe {
1374            let f: Box_<F> = Box_::new(f);
1375            connect_raw(
1376                self.as_ptr() as *mut _,
1377                c"activate".as_ptr(),
1378                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1379                    activate_trampoline::<F> as *const (),
1380                )),
1381                Box_::into_raw(f),
1382            )
1383        }
1384    }
1385
1386    #[cfg(feature = "v4_14")]
1387    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1388    pub fn emit_activate(&self) {
1389        self.emit_by_name::<()>("activate", &[]);
1390    }
1391
1392    /// Emitted when the user initiates a value change.
1393    ///
1394    /// This is a [keybinding signal](class.SignalAction.html).
1395    ///
1396    /// Applications should not connect to it, but may emit it with
1397    /// g_signal_emit_by_name() if they need to control the cursor
1398    /// programmatically.
1399    ///
1400    /// The default bindings for this signal are Up/Down and PageUp/PageDown.
1401    /// ## `scroll`
1402    /// a [`ScrollType`][crate::ScrollType] to specify the speed and amount of change
1403    #[doc(alias = "change-value")]
1404    pub fn connect_change_value<F: Fn(&Self, ScrollType) + 'static>(
1405        &self,
1406        f: F,
1407    ) -> SignalHandlerId {
1408        unsafe extern "C" fn change_value_trampoline<F: Fn(&SpinButton, ScrollType) + 'static>(
1409            this: *mut ffi::GtkSpinButton,
1410            scroll: ffi::GtkScrollType,
1411            f: glib::ffi::gpointer,
1412        ) {
1413            unsafe {
1414                let f: &F = &*(f as *const F);
1415                f(&from_glib_borrow(this), from_glib(scroll))
1416            }
1417        }
1418        unsafe {
1419            let f: Box_<F> = Box_::new(f);
1420            connect_raw(
1421                self.as_ptr() as *mut _,
1422                c"change-value".as_ptr(),
1423                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1424                    change_value_trampoline::<F> as *const (),
1425                )),
1426                Box_::into_raw(f),
1427            )
1428        }
1429    }
1430
1431    pub fn emit_change_value(&self, scroll: ScrollType) {
1432        self.emit_by_name::<()>("change-value", &[&scroll]);
1433    }
1434
1435    /// Emitted to tweak the formatting of the value for display.
1436    ///
1437    /// **⚠️ The following code is in c ⚠️**
1438    ///
1439    /// ```c
1440    /// // show leading zeros
1441    /// static gboolean
1442    /// on_output (GtkSpinButton *spin,
1443    ///            gpointer       data)
1444    /// {
1445    ///    char *text;
1446    ///    int value;
1447    ///
1448    ///    value = gtk_spin_button_get_value_as_int (spin);
1449    ///    text = g_strdup_printf ("%02d", value);
1450    ///    gtk_editable_set_text (GTK_EDITABLE (spin), text):
1451    ///    g_free (text);
1452    ///
1453    ///    return TRUE;
1454    /// }
1455    /// ```
1456    ///
1457    /// # Returns
1458    ///
1459    /// [`true`] if the value has been displayed
1460    #[doc(alias = "output")]
1461    pub fn connect_output<F: Fn(&Self) -> glib::Propagation + 'static>(
1462        &self,
1463        f: F,
1464    ) -> SignalHandlerId {
1465        unsafe extern "C" fn output_trampoline<
1466            F: Fn(&SpinButton) -> glib::Propagation + 'static,
1467        >(
1468            this: *mut ffi::GtkSpinButton,
1469            f: glib::ffi::gpointer,
1470        ) -> glib::ffi::gboolean {
1471            unsafe {
1472                let f: &F = &*(f as *const F);
1473                f(&from_glib_borrow(this)).into_glib()
1474            }
1475        }
1476        unsafe {
1477            let f: Box_<F> = Box_::new(f);
1478            connect_raw(
1479                self.as_ptr() as *mut _,
1480                c"output".as_ptr(),
1481                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1482                    output_trampoline::<F> as *const (),
1483                )),
1484                Box_::into_raw(f),
1485            )
1486        }
1487    }
1488
1489    /// Emitted when the value is changed.
1490    ///
1491    /// Also see the [`output`][struct@crate::SpinButton#output] signal.
1492    #[doc(alias = "value-changed")]
1493    pub fn connect_value_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1494        unsafe extern "C" fn value_changed_trampoline<F: Fn(&SpinButton) + 'static>(
1495            this: *mut ffi::GtkSpinButton,
1496            f: glib::ffi::gpointer,
1497        ) {
1498            unsafe {
1499                let f: &F = &*(f as *const F);
1500                f(&from_glib_borrow(this))
1501            }
1502        }
1503        unsafe {
1504            let f: Box_<F> = Box_::new(f);
1505            connect_raw(
1506                self.as_ptr() as *mut _,
1507                c"value-changed".as_ptr(),
1508                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1509                    value_changed_trampoline::<F> as *const (),
1510                )),
1511                Box_::into_raw(f),
1512            )
1513        }
1514    }
1515
1516    /// Emitted right after the spinbutton wraps from its maximum
1517    /// to its minimum value or vice-versa.
1518    #[doc(alias = "wrapped")]
1519    pub fn connect_wrapped<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1520        unsafe extern "C" fn wrapped_trampoline<F: Fn(&SpinButton) + 'static>(
1521            this: *mut ffi::GtkSpinButton,
1522            f: glib::ffi::gpointer,
1523        ) {
1524            unsafe {
1525                let f: &F = &*(f as *const F);
1526                f(&from_glib_borrow(this))
1527            }
1528        }
1529        unsafe {
1530            let f: Box_<F> = Box_::new(f);
1531            connect_raw(
1532                self.as_ptr() as *mut _,
1533                c"wrapped".as_ptr(),
1534                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1535                    wrapped_trampoline::<F> as *const (),
1536                )),
1537                Box_::into_raw(f),
1538            )
1539        }
1540    }
1541
1542    #[cfg(feature = "v4_14")]
1543    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1544    #[doc(alias = "activates-default")]
1545    pub fn connect_activates_default_notify<F: Fn(&Self) + 'static>(
1546        &self,
1547        f: F,
1548    ) -> SignalHandlerId {
1549        unsafe extern "C" fn notify_activates_default_trampoline<F: Fn(&SpinButton) + 'static>(
1550            this: *mut ffi::GtkSpinButton,
1551            _param_spec: glib::ffi::gpointer,
1552            f: glib::ffi::gpointer,
1553        ) {
1554            unsafe {
1555                let f: &F = &*(f as *const F);
1556                f(&from_glib_borrow(this))
1557            }
1558        }
1559        unsafe {
1560            let f: Box_<F> = Box_::new(f);
1561            connect_raw(
1562                self.as_ptr() as *mut _,
1563                c"notify::activates-default".as_ptr(),
1564                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1565                    notify_activates_default_trampoline::<F> as *const (),
1566                )),
1567                Box_::into_raw(f),
1568            )
1569        }
1570    }
1571
1572    #[doc(alias = "adjustment")]
1573    pub fn connect_adjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1574        unsafe extern "C" fn notify_adjustment_trampoline<F: Fn(&SpinButton) + 'static>(
1575            this: *mut ffi::GtkSpinButton,
1576            _param_spec: glib::ffi::gpointer,
1577            f: glib::ffi::gpointer,
1578        ) {
1579            unsafe {
1580                let f: &F = &*(f as *const F);
1581                f(&from_glib_borrow(this))
1582            }
1583        }
1584        unsafe {
1585            let f: Box_<F> = Box_::new(f);
1586            connect_raw(
1587                self.as_ptr() as *mut _,
1588                c"notify::adjustment".as_ptr(),
1589                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1590                    notify_adjustment_trampoline::<F> as *const (),
1591                )),
1592                Box_::into_raw(f),
1593            )
1594        }
1595    }
1596
1597    #[doc(alias = "climb-rate")]
1598    pub fn connect_climb_rate_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1599        unsafe extern "C" fn notify_climb_rate_trampoline<F: Fn(&SpinButton) + 'static>(
1600            this: *mut ffi::GtkSpinButton,
1601            _param_spec: glib::ffi::gpointer,
1602            f: glib::ffi::gpointer,
1603        ) {
1604            unsafe {
1605                let f: &F = &*(f as *const F);
1606                f(&from_glib_borrow(this))
1607            }
1608        }
1609        unsafe {
1610            let f: Box_<F> = Box_::new(f);
1611            connect_raw(
1612                self.as_ptr() as *mut _,
1613                c"notify::climb-rate".as_ptr(),
1614                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1615                    notify_climb_rate_trampoline::<F> as *const (),
1616                )),
1617                Box_::into_raw(f),
1618            )
1619        }
1620    }
1621
1622    #[doc(alias = "digits")]
1623    pub fn connect_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1624        unsafe extern "C" fn notify_digits_trampoline<F: Fn(&SpinButton) + 'static>(
1625            this: *mut ffi::GtkSpinButton,
1626            _param_spec: glib::ffi::gpointer,
1627            f: glib::ffi::gpointer,
1628        ) {
1629            unsafe {
1630                let f: &F = &*(f as *const F);
1631                f(&from_glib_borrow(this))
1632            }
1633        }
1634        unsafe {
1635            let f: Box_<F> = Box_::new(f);
1636            connect_raw(
1637                self.as_ptr() as *mut _,
1638                c"notify::digits".as_ptr(),
1639                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1640                    notify_digits_trampoline::<F> as *const (),
1641                )),
1642                Box_::into_raw(f),
1643            )
1644        }
1645    }
1646
1647    #[doc(alias = "numeric")]
1648    pub fn connect_numeric_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1649        unsafe extern "C" fn notify_numeric_trampoline<F: Fn(&SpinButton) + 'static>(
1650            this: *mut ffi::GtkSpinButton,
1651            _param_spec: glib::ffi::gpointer,
1652            f: glib::ffi::gpointer,
1653        ) {
1654            unsafe {
1655                let f: &F = &*(f as *const F);
1656                f(&from_glib_borrow(this))
1657            }
1658        }
1659        unsafe {
1660            let f: Box_<F> = Box_::new(f);
1661            connect_raw(
1662                self.as_ptr() as *mut _,
1663                c"notify::numeric".as_ptr(),
1664                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1665                    notify_numeric_trampoline::<F> as *const (),
1666                )),
1667                Box_::into_raw(f),
1668            )
1669        }
1670    }
1671
1672    #[doc(alias = "snap-to-ticks")]
1673    pub fn connect_snap_to_ticks_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1674        unsafe extern "C" fn notify_snap_to_ticks_trampoline<F: Fn(&SpinButton) + 'static>(
1675            this: *mut ffi::GtkSpinButton,
1676            _param_spec: glib::ffi::gpointer,
1677            f: glib::ffi::gpointer,
1678        ) {
1679            unsafe {
1680                let f: &F = &*(f as *const F);
1681                f(&from_glib_borrow(this))
1682            }
1683        }
1684        unsafe {
1685            let f: Box_<F> = Box_::new(f);
1686            connect_raw(
1687                self.as_ptr() as *mut _,
1688                c"notify::snap-to-ticks".as_ptr(),
1689                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1690                    notify_snap_to_ticks_trampoline::<F> as *const (),
1691                )),
1692                Box_::into_raw(f),
1693            )
1694        }
1695    }
1696
1697    #[doc(alias = "update-policy")]
1698    pub fn connect_update_policy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1699        unsafe extern "C" fn notify_update_policy_trampoline<F: Fn(&SpinButton) + 'static>(
1700            this: *mut ffi::GtkSpinButton,
1701            _param_spec: glib::ffi::gpointer,
1702            f: glib::ffi::gpointer,
1703        ) {
1704            unsafe {
1705                let f: &F = &*(f as *const F);
1706                f(&from_glib_borrow(this))
1707            }
1708        }
1709        unsafe {
1710            let f: Box_<F> = Box_::new(f);
1711            connect_raw(
1712                self.as_ptr() as *mut _,
1713                c"notify::update-policy".as_ptr(),
1714                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1715                    notify_update_policy_trampoline::<F> as *const (),
1716                )),
1717                Box_::into_raw(f),
1718            )
1719        }
1720    }
1721
1722    #[doc(alias = "value")]
1723    pub fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1724        unsafe extern "C" fn notify_value_trampoline<F: Fn(&SpinButton) + 'static>(
1725            this: *mut ffi::GtkSpinButton,
1726            _param_spec: glib::ffi::gpointer,
1727            f: glib::ffi::gpointer,
1728        ) {
1729            unsafe {
1730                let f: &F = &*(f as *const F);
1731                f(&from_glib_borrow(this))
1732            }
1733        }
1734        unsafe {
1735            let f: Box_<F> = Box_::new(f);
1736            connect_raw(
1737                self.as_ptr() as *mut _,
1738                c"notify::value".as_ptr(),
1739                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1740                    notify_value_trampoline::<F> as *const (),
1741                )),
1742                Box_::into_raw(f),
1743            )
1744        }
1745    }
1746
1747    #[doc(alias = "wrap")]
1748    pub fn connect_wrap_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1749        unsafe extern "C" fn notify_wrap_trampoline<F: Fn(&SpinButton) + 'static>(
1750            this: *mut ffi::GtkSpinButton,
1751            _param_spec: glib::ffi::gpointer,
1752            f: glib::ffi::gpointer,
1753        ) {
1754            unsafe {
1755                let f: &F = &*(f as *const F);
1756                f(&from_glib_borrow(this))
1757            }
1758        }
1759        unsafe {
1760            let f: Box_<F> = Box_::new(f);
1761            connect_raw(
1762                self.as_ptr() as *mut _,
1763                c"notify::wrap".as_ptr(),
1764                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1765                    notify_wrap_trampoline::<F> as *const (),
1766                )),
1767                Box_::into_raw(f),
1768            )
1769        }
1770    }
1771}
1772
1773impl Default for SpinButton {
1774    fn default() -> Self {
1775        glib::object::Object::new::<Self>()
1776    }
1777}
1778
1779// rustdoc-stripper-ignore-next
1780/// A [builder-pattern] type to construct [`SpinButton`] objects.
1781///
1782/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1783#[must_use = "The builder must be built to be used"]
1784pub struct SpinButtonBuilder {
1785    builder: glib::object::ObjectBuilder<'static, SpinButton>,
1786}
1787
1788impl SpinButtonBuilder {
1789    fn new() -> Self {
1790        Self {
1791            builder: glib::object::Object::builder(),
1792        }
1793    }
1794
1795    /// Whether to activate the default widget when the spin button is activated.
1796    ///
1797    /// See [`activate`][struct@crate::SpinButton#activate] for what counts as activation.
1798    #[cfg(feature = "v4_14")]
1799    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1800    pub fn activates_default(self, activates_default: bool) -> Self {
1801        Self {
1802            builder: self
1803                .builder
1804                .property("activates-default", activates_default),
1805        }
1806    }
1807
1808    /// The adjustment that holds the value of the spin button.
1809    pub fn adjustment(self, adjustment: &impl IsA<Adjustment>) -> Self {
1810        Self {
1811            builder: self
1812                .builder
1813                .property("adjustment", adjustment.clone().upcast()),
1814        }
1815    }
1816
1817    /// The acceleration rate when you hold down a button or key.
1818    pub fn climb_rate(self, climb_rate: f64) -> Self {
1819        Self {
1820            builder: self.builder.property("climb-rate", climb_rate),
1821        }
1822    }
1823
1824    /// The number of decimal places to display.
1825    pub fn digits(self, digits: u32) -> Self {
1826        Self {
1827            builder: self.builder.property("digits", digits),
1828        }
1829    }
1830
1831    /// Whether non-numeric characters should be ignored.
1832    pub fn numeric(self, numeric: bool) -> Self {
1833        Self {
1834            builder: self.builder.property("numeric", numeric),
1835        }
1836    }
1837
1838    /// Whether erroneous values are automatically changed to the spin buttons
1839    /// nearest step increment.
1840    pub fn snap_to_ticks(self, snap_to_ticks: bool) -> Self {
1841        Self {
1842            builder: self.builder.property("snap-to-ticks", snap_to_ticks),
1843        }
1844    }
1845
1846    /// Whether the spin button should update always, or only when the value
1847    /// is acceptable.
1848    pub fn update_policy(self, update_policy: SpinButtonUpdatePolicy) -> Self {
1849        Self {
1850            builder: self.builder.property("update-policy", update_policy),
1851        }
1852    }
1853
1854    /// The current value.
1855    pub fn value(self, value: f64) -> Self {
1856        Self {
1857            builder: self.builder.property("value", value),
1858        }
1859    }
1860
1861    /// Whether a spin button should wrap upon reaching its limits.
1862    pub fn wrap(self, wrap: bool) -> Self {
1863        Self {
1864            builder: self.builder.property("wrap", wrap),
1865        }
1866    }
1867
1868    /// Whether the widget or any of its descendents can accept
1869    /// the input focus.
1870    ///
1871    /// This property is meant to be set by widget implementations,
1872    /// typically in their instance init function.
1873    pub fn can_focus(self, can_focus: bool) -> Self {
1874        Self {
1875            builder: self.builder.property("can-focus", can_focus),
1876        }
1877    }
1878
1879    /// Whether the widget can receive pointer events.
1880    pub fn can_target(self, can_target: bool) -> Self {
1881        Self {
1882            builder: self.builder.property("can-target", can_target),
1883        }
1884    }
1885
1886    /// A list of css classes applied to this widget.
1887    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1888        Self {
1889            builder: self.builder.property("css-classes", css_classes.into()),
1890        }
1891    }
1892
1893    /// The name of this widget in the CSS tree.
1894    ///
1895    /// This property is meant to be set by widget implementations,
1896    /// typically in their instance init function.
1897    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1898        Self {
1899            builder: self.builder.property("css-name", css_name.into()),
1900        }
1901    }
1902
1903    /// The cursor used by @widget.
1904    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1905        Self {
1906            builder: self.builder.property("cursor", cursor.clone()),
1907        }
1908    }
1909
1910    /// Whether the widget should grab focus when it is clicked with the mouse.
1911    ///
1912    /// This property is only relevant for widgets that can take focus.
1913    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1914        Self {
1915            builder: self.builder.property("focus-on-click", focus_on_click),
1916        }
1917    }
1918
1919    /// Whether this widget itself will accept the input focus.
1920    pub fn focusable(self, focusable: bool) -> Self {
1921        Self {
1922            builder: self.builder.property("focusable", focusable),
1923        }
1924    }
1925
1926    /// How to distribute horizontal space if widget gets extra space.
1927    pub fn halign(self, halign: Align) -> Self {
1928        Self {
1929            builder: self.builder.property("halign", halign),
1930        }
1931    }
1932
1933    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1934    /// signal on @widget.
1935    ///
1936    /// A true value indicates that @widget can have a tooltip, in this case
1937    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1938    /// determine whether it will provide a tooltip or not.
1939    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1940        Self {
1941            builder: self.builder.property("has-tooltip", has_tooltip),
1942        }
1943    }
1944
1945    /// Overrides for height request of the widget.
1946    ///
1947    /// If this is -1, the natural request will be used.
1948    pub fn height_request(self, height_request: i32) -> Self {
1949        Self {
1950            builder: self.builder.property("height-request", height_request),
1951        }
1952    }
1953
1954    /// Whether to expand horizontally.
1955    pub fn hexpand(self, hexpand: bool) -> Self {
1956        Self {
1957            builder: self.builder.property("hexpand", hexpand),
1958        }
1959    }
1960
1961    /// Whether to use the `hexpand` property.
1962    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1963        Self {
1964            builder: self.builder.property("hexpand-set", hexpand_set),
1965        }
1966    }
1967
1968    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1969    /// the preferred size of the widget, and allocate its children.
1970    ///
1971    /// This property is meant to be set by widget implementations,
1972    /// typically in their instance init function.
1973    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1974        Self {
1975            builder: self
1976                .builder
1977                .property("layout-manager", layout_manager.clone().upcast()),
1978        }
1979    }
1980
1981    /// Makes this widget act like a modal dialog, with respect to
1982    /// event delivery.
1983    ///
1984    /// Global event controllers will not handle events with targets
1985    /// inside the widget, unless they are set up to ignore propagation
1986    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1987    #[cfg(feature = "v4_18")]
1988    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1989    pub fn limit_events(self, limit_events: bool) -> Self {
1990        Self {
1991            builder: self.builder.property("limit-events", limit_events),
1992        }
1993    }
1994
1995    /// Margin on bottom side of widget.
1996    ///
1997    /// This property adds margin outside of the widget's normal size
1998    /// request, the margin will be added in addition to the size from
1999    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2000    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
2001        Self {
2002            builder: self.builder.property("margin-bottom", margin_bottom),
2003        }
2004    }
2005
2006    /// Margin on end of widget, horizontally.
2007    ///
2008    /// This property supports left-to-right and right-to-left text
2009    /// directions.
2010    ///
2011    /// This property adds margin outside of the widget's normal size
2012    /// request, the margin will be added in addition to the size from
2013    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2014    pub fn margin_end(self, margin_end: i32) -> Self {
2015        Self {
2016            builder: self.builder.property("margin-end", margin_end),
2017        }
2018    }
2019
2020    /// Margin on start of widget, horizontally.
2021    ///
2022    /// This property supports left-to-right and right-to-left text
2023    /// directions.
2024    ///
2025    /// This property adds margin outside of the widget's normal size
2026    /// request, the margin will be added in addition to the size from
2027    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2028    pub fn margin_start(self, margin_start: i32) -> Self {
2029        Self {
2030            builder: self.builder.property("margin-start", margin_start),
2031        }
2032    }
2033
2034    /// Margin on top side of widget.
2035    ///
2036    /// This property adds margin outside of the widget's normal size
2037    /// request, the margin will be added in addition to the size from
2038    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2039    pub fn margin_top(self, margin_top: i32) -> Self {
2040        Self {
2041            builder: self.builder.property("margin-top", margin_top),
2042        }
2043    }
2044
2045    /// The name of the widget.
2046    pub fn name(self, name: impl Into<glib::GString>) -> Self {
2047        Self {
2048            builder: self.builder.property("name", name.into()),
2049        }
2050    }
2051
2052    /// The requested opacity of the widget.
2053    pub fn opacity(self, opacity: f64) -> Self {
2054        Self {
2055            builder: self.builder.property("opacity", opacity),
2056        }
2057    }
2058
2059    /// How content outside the widget's content area is treated.
2060    ///
2061    /// This property is meant to be set by widget implementations,
2062    /// typically in their instance init function.
2063    pub fn overflow(self, overflow: Overflow) -> Self {
2064        Self {
2065            builder: self.builder.property("overflow", overflow),
2066        }
2067    }
2068
2069    /// Whether the widget will receive the default action when it is focused.
2070    pub fn receives_default(self, receives_default: bool) -> Self {
2071        Self {
2072            builder: self.builder.property("receives-default", receives_default),
2073        }
2074    }
2075
2076    /// Whether the widget responds to input.
2077    pub fn sensitive(self, sensitive: bool) -> Self {
2078        Self {
2079            builder: self.builder.property("sensitive", sensitive),
2080        }
2081    }
2082
2083    /// Sets the text of tooltip to be the given string, which is marked up
2084    /// with Pango markup.
2085    ///
2086    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
2087    ///
2088    /// This is a convenience property which will take care of getting the
2089    /// tooltip shown if the given string is not `NULL`:
2090    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2091    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2092    /// the default signal handler.
2093    ///
2094    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2095    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2096    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
2097        Self {
2098            builder: self
2099                .builder
2100                .property("tooltip-markup", tooltip_markup.into()),
2101        }
2102    }
2103
2104    /// Sets the text of tooltip to be the given string.
2105    ///
2106    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
2107    ///
2108    /// This is a convenience property which will take care of getting the
2109    /// tooltip shown if the given string is not `NULL`:
2110    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2111    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2112    /// the default signal handler.
2113    ///
2114    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2115    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2116    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
2117        Self {
2118            builder: self.builder.property("tooltip-text", tooltip_text.into()),
2119        }
2120    }
2121
2122    /// How to distribute vertical space if widget gets extra space.
2123    pub fn valign(self, valign: Align) -> Self {
2124        Self {
2125            builder: self.builder.property("valign", valign),
2126        }
2127    }
2128
2129    /// Whether to expand vertically.
2130    pub fn vexpand(self, vexpand: bool) -> Self {
2131        Self {
2132            builder: self.builder.property("vexpand", vexpand),
2133        }
2134    }
2135
2136    /// Whether to use the `vexpand` property.
2137    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
2138        Self {
2139            builder: self.builder.property("vexpand-set", vexpand_set),
2140        }
2141    }
2142
2143    /// Whether the widget is visible.
2144    pub fn visible(self, visible: bool) -> Self {
2145        Self {
2146            builder: self.builder.property("visible", visible),
2147        }
2148    }
2149
2150    /// Overrides for width request of the widget.
2151    ///
2152    /// If this is -1, the natural request will be used.
2153    pub fn width_request(self, width_request: i32) -> Self {
2154        Self {
2155            builder: self.builder.property("width-request", width_request),
2156        }
2157    }
2158
2159    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
2160    ///
2161    /// The accessible role cannot be changed once set.
2162    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
2163        Self {
2164            builder: self.builder.property("accessible-role", accessible_role),
2165        }
2166    }
2167
2168    /// Indicates whether editing on the cell has been canceled.
2169    pub fn editing_canceled(self, editing_canceled: bool) -> Self {
2170        Self {
2171            builder: self.builder.property("editing-canceled", editing_canceled),
2172        }
2173    }
2174
2175    /// Whether the entry contents can be edited.
2176    pub fn editable(self, editable: bool) -> Self {
2177        Self {
2178            builder: self.builder.property("editable", editable),
2179        }
2180    }
2181
2182    /// If undo/redo should be enabled for the editable.
2183    pub fn enable_undo(self, enable_undo: bool) -> Self {
2184        Self {
2185            builder: self.builder.property("enable-undo", enable_undo),
2186        }
2187    }
2188
2189    /// The desired maximum width of the entry, in characters.
2190    pub fn max_width_chars(self, max_width_chars: i32) -> Self {
2191        Self {
2192            builder: self.builder.property("max-width-chars", max_width_chars),
2193        }
2194    }
2195
2196    /// The contents of the entry.
2197    pub fn text(self, text: impl Into<glib::GString>) -> Self {
2198        Self {
2199            builder: self.builder.property("text", text.into()),
2200        }
2201    }
2202
2203    /// Number of characters to leave space for in the entry.
2204    pub fn width_chars(self, width_chars: i32) -> Self {
2205        Self {
2206            builder: self.builder.property("width-chars", width_chars),
2207        }
2208    }
2209
2210    /// The horizontal alignment, from 0 (left) to 1 (right).
2211    ///
2212    /// Reversed for RTL layouts.
2213    pub fn xalign(self, xalign: f32) -> Self {
2214        Self {
2215            builder: self.builder.property("xalign", xalign),
2216        }
2217    }
2218
2219    /// The orientation of the orientable.
2220    pub fn orientation(self, orientation: Orientation) -> Self {
2221        Self {
2222            builder: self.builder.property("orientation", orientation),
2223        }
2224    }
2225
2226    // rustdoc-stripper-ignore-next
2227    /// Build the [`SpinButton`].
2228    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
2229    pub fn build(self) -> SpinButton {
2230        assert_initialized_main_thread!();
2231        self.builder.build()
2232    }
2233}