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 /// 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 /// #### `cursor-position`
519 /// The current position of the insertion cursor in chars.
520 ///
521 /// Readable
522 ///
523 ///
524 /// #### `editable`
525 /// Whether the entry contents can be edited.
526 ///
527 /// Readable | Writeable
528 ///
529 ///
530 /// #### `enable-undo`
531 /// If undo/redo should be enabled for the editable.
532 ///
533 /// Readable | Writeable
534 ///
535 ///
536 /// #### `max-width-chars`
537 /// The desired maximum width of the entry, in characters.
538 ///
539 /// Readable | Writeable
540 ///
541 ///
542 /// #### `selection-bound`
543 /// The position of the opposite end of the selection from the cursor in chars.
544 ///
545 /// Readable
546 ///
547 ///
548 /// #### `text`
549 /// The contents of the entry.
550 ///
551 /// Readable | Writeable
552 ///
553 ///
554 /// #### `width-chars`
555 /// Number of characters to leave space for in the entry.
556 ///
557 /// Readable | Writeable
558 ///
559 ///
560 /// #### `xalign`
561 /// The horizontal alignment, from 0 (left) to 1 (right).
562 ///
563 /// Reversed for RTL layouts.
564 ///
565 /// Readable | Writeable
566 /// </details>
567 /// <details><summary><h4>Orientable</h4></summary>
568 ///
569 ///
570 /// #### `orientation`
571 /// The orientation of the orientable.
572 ///
573 /// Readable | Writeable
574 /// </details>
575 ///
576 /// ## Signals
577 ///
578 ///
579 /// #### `activate`
580 /// Emitted when the spin button is activated.
581 ///
582 /// The keybindings for this signal are all forms of the <kbd>Enter</kbd> key.
583 ///
584 /// If the <kbd>Enter</kbd> key results in the value being committed to the
585 /// spin button, then activation does not occur until <kbd>Enter</kbd> is
586 /// pressed again.
587 ///
588 /// Action
589 ///
590 ///
591 /// #### `change-value`
592 /// Emitted when the user initiates a value change.
593 ///
594 /// This is a [keybinding signal](class.SignalAction.html).
595 ///
596 /// Applications should not connect to it, but may emit it with
597 /// g_signal_emit_by_name() if they need to control the cursor
598 /// programmatically.
599 ///
600 /// The default bindings for this signal are Up/Down and PageUp/PageDown.
601 ///
602 /// Action
603 ///
604 ///
605 /// #### `input`
606 /// Emitted to convert the users input into a double value.
607 ///
608 /// The signal handler is expected to use [`EditableExt::text()`][crate::prelude::EditableExt::text()]
609 /// to retrieve the text of the spinbutton and set @new_value to the
610 /// new value.
611 ///
612 /// The default conversion uses g_strtod().
613 ///
614 ///
615 ///
616 ///
617 /// #### `output`
618 /// Emitted to tweak the formatting of the value for display.
619 ///
620 /// **⚠️ The following code is in c ⚠️**
621 ///
622 /// ```c
623 /// // show leading zeros
624 /// static gboolean
625 /// on_output (GtkSpinButton *spin,
626 /// gpointer data)
627 /// {
628 /// char *text;
629 /// int value;
630 ///
631 /// value = gtk_spin_button_get_value_as_int (spin);
632 /// text = g_strdup_printf ("%02d", value);
633 /// gtk_editable_set_text (GTK_EDITABLE (spin), text):
634 /// g_free (text);
635 ///
636 /// return TRUE;
637 /// }
638 /// ```
639 ///
640 ///
641 ///
642 ///
643 /// #### `value-changed`
644 /// Emitted when the value is changed.
645 ///
646 /// Also see the [`output`][struct@crate::SpinButton#output] signal.
647 ///
648 ///
649 ///
650 ///
651 /// #### `wrapped`
652 /// Emitted right after the spinbutton wraps from its maximum
653 /// to its minimum value or vice-versa.
654 ///
655 ///
656 /// <details><summary><h4>Widget</h4></summary>
657 ///
658 ///
659 /// #### `destroy`
660 /// Signals that all holders of a reference to the widget should release
661 /// the reference that they hold.
662 ///
663 /// May result in finalization of the widget if all references are released.
664 ///
665 /// This signal is not suitable for saving widget state.
666 ///
667 ///
668 ///
669 ///
670 /// #### `direction-changed`
671 /// Emitted when the text direction of a widget changes.
672 ///
673 ///
674 ///
675 ///
676 /// #### `hide`
677 /// Emitted when @widget is hidden.
678 ///
679 ///
680 ///
681 ///
682 /// #### `keynav-failed`
683 /// Emitted if keyboard navigation fails.
684 ///
685 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
686 ///
687 ///
688 ///
689 ///
690 /// #### `map`
691 /// Emitted when @widget is going to be mapped.
692 ///
693 /// A widget is mapped when the widget is visible (which is controlled with
694 /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
695 /// are also visible.
696 ///
697 /// The `::map` signal can be used to determine whether a widget will be drawn,
698 /// for instance it can resume an animation that was stopped during the
699 /// emission of [`unmap`][struct@crate::Widget#unmap].
700 ///
701 ///
702 ///
703 ///
704 /// #### `mnemonic-activate`
705 /// Emitted when a widget is activated via a mnemonic.
706 ///
707 /// The default handler for this signal activates @widget if @group_cycling
708 /// is false, or just makes @widget grab focus if @group_cycling is true.
709 ///
710 ///
711 ///
712 ///
713 /// #### `move-focus`
714 /// Emitted when the focus is moved.
715 ///
716 /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
717 ///
718 /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
719 /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
720 ///
721 /// Action
722 ///
723 ///
724 /// #### `query-tooltip`
725 /// Emitted when the widget’s tooltip is about to be shown.
726 ///
727 /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
728 /// is true and the hover timeout has expired with the cursor hovering
729 /// above @widget; or emitted when @widget got focus in keyboard mode.
730 ///
731 /// Using the given coordinates, the signal handler should determine
732 /// whether a tooltip should be shown for @widget. If this is the case
733 /// true should be returned, false otherwise. Note that if @keyboard_mode
734 /// is true, the values of @x and @y are undefined and should not be used.
735 ///
736 /// The signal handler is free to manipulate @tooltip with the therefore
737 /// destined function calls.
738 ///
739 ///
740 ///
741 ///
742 /// #### `realize`
743 /// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
744 ///
745 /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
746 /// or the widget has been mapped (that is, it is going to be drawn).
747 ///
748 ///
749 ///
750 ///
751 /// #### `show`
752 /// Emitted when @widget is shown.
753 ///
754 ///
755 ///
756 ///
757 /// #### `state-flags-changed`
758 /// Emitted when the widget state changes.
759 ///
760 /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
761 ///
762 ///
763 ///
764 ///
765 /// #### `unmap`
766 /// Emitted when @widget is going to be unmapped.
767 ///
768 /// A widget is unmapped when either it or any of its parents up to the
769 /// toplevel widget have been set as hidden.
770 ///
771 /// As `::unmap` indicates that a widget will not be shown any longer,
772 /// it can be used to, for example, stop an animation on the widget.
773 ///
774 ///
775 ///
776 ///
777 /// #### `unrealize`
778 /// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
779 ///
780 /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
781 /// or the widget has been unmapped (that is, it is going to be hidden).
782 ///
783 ///
784 /// </details>
785 /// <details><summary><h4>CellEditable</h4></summary>
786 ///
787 ///
788 /// #### `editing-done`
789 /// This signal is a sign for the cell renderer to update its
790 /// value from the @cell_editable.
791 ///
792 /// Implementations of [`CellEditable`][crate::CellEditable] are responsible for
793 /// emitting this signal when they are done editing, e.g.
794 /// [`Entry`][crate::Entry] emits this signal when the user presses Enter. Typical things to
795 /// do in a handler for ::editing-done are to capture the edited value,
796 /// disconnect the @cell_editable from signals on the [`CellRenderer`][crate::CellRenderer], etc.
797 ///
798 /// gtk_cell_editable_editing_done() is a convenience method
799 /// for emitting `GtkCellEditable::editing-done`.
800 ///
801 ///
802 ///
803 ///
804 /// #### `remove-widget`
805 /// This signal is meant to indicate that the cell is finished
806 /// editing, and the @cell_editable widget is being removed and may
807 /// subsequently be destroyed.
808 ///
809 /// Implementations of [`CellEditable`][crate::CellEditable] are responsible for
810 /// emitting this signal when they are done editing. It must
811 /// be emitted after the `GtkCellEditable::editing-done` signal,
812 /// to give the cell renderer a chance to update the cell's value
813 /// before the widget is removed.
814 ///
815 /// gtk_cell_editable_remove_widget() is a convenience method
816 /// for emitting `GtkCellEditable::remove-widget`.
817 ///
818 ///
819 /// </details>
820 /// <details><summary><h4>Editable</h4></summary>
821 ///
822 ///
823 /// #### `changed`
824 /// Emitted at the end of a single user-visible operation on the
825 /// contents.
826 ///
827 /// E.g., a paste operation that replaces the contents of the
828 /// selection will cause only one signal emission (even though it
829 /// is implemented by first deleting the selection, then inserting
830 /// the new content, and may cause multiple ::notify::text signals
831 /// to be emitted).
832 ///
833 ///
834 ///
835 ///
836 /// #### `delete-text`
837 /// Emitted when text is deleted from the widget by the user.
838 ///
839 /// The default handler for this signal will normally be responsible for
840 /// deleting the text, so by connecting to this signal and then stopping
841 /// the signal with g_signal_stop_emission(), it is possible to modify the
842 /// range of deleted text, or prevent it from being deleted entirely.
843 ///
844 /// The @start_pos and @end_pos parameters are interpreted as for
845 /// [`EditableExt::delete_text()`][crate::prelude::EditableExt::delete_text()].
846 ///
847 ///
848 ///
849 ///
850 /// #### `insert-text`
851 /// Emitted when text is inserted into the widget by the user.
852 ///
853 /// The default handler for this signal will normally be responsible
854 /// for inserting the text, so by connecting to this signal and then
855 /// stopping the signal with g_signal_stop_emission(), it is possible
856 /// to modify the inserted text, or prevent it from being inserted entirely.
857 ///
858 ///
859 /// </details>
860 ///
861 /// # Implements
862 ///
863 /// [`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]
864 #[doc(alias = "GtkSpinButton")]
865 pub struct SpinButton(Object<ffi::GtkSpinButton>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, AccessibleRange, CellEditable, Editable, Orientable;
866
867 match fn {
868 type_ => || ffi::gtk_spin_button_get_type(),
869 }
870}
871
872#[cfg(not(any(feature = "v4_10")))]
873glib::wrapper! {
874 #[doc(alias = "GtkSpinButton")]
875 pub struct SpinButton(Object<ffi::GtkSpinButton>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, CellEditable, Editable, Orientable;
876
877 match fn {
878 type_ => || ffi::gtk_spin_button_get_type(),
879 }
880}
881
882impl SpinButton {
883 /// Creates a new [`SpinButton`][crate::SpinButton].
884 /// ## `adjustment`
885 /// the [`Adjustment`][crate::Adjustment] that this spin button should use
886 /// ## `climb_rate`
887 /// specifies by how much the rate of change in the value will
888 /// accelerate if you continue to hold down an up/down button or arrow key
889 /// ## `digits`
890 /// the number of decimal places to display
891 ///
892 /// # Returns
893 ///
894 /// The new [`SpinButton`][crate::SpinButton]
895 #[doc(alias = "gtk_spin_button_new")]
896 pub fn new(
897 adjustment: Option<&impl IsA<Adjustment>>,
898 climb_rate: f64,
899 digits: u32,
900 ) -> SpinButton {
901 assert_initialized_main_thread!();
902 unsafe {
903 Widget::from_glib_none(ffi::gtk_spin_button_new(
904 adjustment.map(|p| p.as_ref()).to_glib_none().0,
905 climb_rate,
906 digits,
907 ))
908 .unsafe_cast()
909 }
910 }
911
912 /// Creates a new [`SpinButton`][crate::SpinButton] with the given properties.
913 ///
914 /// This is a convenience constructor that allows creation
915 /// of a numeric [`SpinButton`][crate::SpinButton] without manually creating
916 /// an adjustment. The value is initially set to the minimum
917 /// value and a page increment of 10 * @step is the default.
918 /// The precision of the spin button is equivalent to the
919 /// precision of @step.
920 ///
921 /// Note that the way in which the precision is derived works
922 /// best if @step is a power of ten. If the resulting precision
923 /// is not suitable for your needs, use
924 /// [`set_digits()`][Self::set_digits()] to correct it.
925 /// ## `min`
926 /// Minimum allowable value
927 /// ## `max`
928 /// Maximum allowable value
929 /// ## `step`
930 /// Increment added or subtracted by spinning the widget
931 ///
932 /// # Returns
933 ///
934 /// The new [`SpinButton`][crate::SpinButton]
935 #[doc(alias = "gtk_spin_button_new_with_range")]
936 #[doc(alias = "new_with_range")]
937 pub fn with_range(min: f64, max: f64, step: f64) -> SpinButton {
938 assert_initialized_main_thread!();
939 unsafe {
940 Widget::from_glib_none(ffi::gtk_spin_button_new_with_range(min, max, step))
941 .unsafe_cast()
942 }
943 }
944
945 // rustdoc-stripper-ignore-next
946 /// Creates a new builder-pattern struct instance to construct [`SpinButton`] objects.
947 ///
948 /// This method returns an instance of [`SpinButtonBuilder`](crate::builders::SpinButtonBuilder) which can be used to create [`SpinButton`] objects.
949 pub fn builder() -> SpinButtonBuilder {
950 SpinButtonBuilder::new()
951 }
952
953 /// Changes the properties of an existing spin button.
954 ///
955 /// The adjustment, climb rate, and number of decimal places
956 /// are updated accordingly.
957 /// ## `adjustment`
958 /// a [`Adjustment`][crate::Adjustment] to replace the spin button’s
959 /// existing adjustment, or [`None`] to leave its current adjustment unchanged
960 /// ## `climb_rate`
961 /// the new climb rate
962 /// ## `digits`
963 /// the number of decimal places to display in the spin button
964 #[doc(alias = "gtk_spin_button_configure")]
965 pub fn configure(
966 &self,
967 adjustment: Option<&impl IsA<Adjustment>>,
968 climb_rate: f64,
969 digits: u32,
970 ) {
971 unsafe {
972 ffi::gtk_spin_button_configure(
973 self.to_glib_none().0,
974 adjustment.map(|p| p.as_ref()).to_glib_none().0,
975 climb_rate,
976 digits,
977 );
978 }
979 }
980
981 /// Retrieves the value set by [`set_activates_default()`][Self::set_activates_default()].
982 ///
983 /// # Returns
984 ///
985 /// [`true`] if the spin button will activate the default widget
986 #[cfg(feature = "v4_14")]
987 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
988 #[doc(alias = "gtk_spin_button_get_activates_default")]
989 #[doc(alias = "get_activates_default")]
990 #[doc(alias = "activates-default")]
991 pub fn activates_default(&self) -> bool {
992 unsafe {
993 from_glib(ffi::gtk_spin_button_get_activates_default(
994 self.to_glib_none().0,
995 ))
996 }
997 }
998
999 /// Get the adjustment associated with a [`SpinButton`][crate::SpinButton].
1000 ///
1001 /// # Returns
1002 ///
1003 /// the [`Adjustment`][crate::Adjustment] of @self
1004 #[doc(alias = "gtk_spin_button_get_adjustment")]
1005 #[doc(alias = "get_adjustment")]
1006 pub fn adjustment(&self) -> Adjustment {
1007 unsafe { from_glib_none(ffi::gtk_spin_button_get_adjustment(self.to_glib_none().0)) }
1008 }
1009
1010 /// Returns the acceleration rate for repeated changes.
1011 ///
1012 /// # Returns
1013 ///
1014 /// the acceleration rate
1015 #[doc(alias = "gtk_spin_button_get_climb_rate")]
1016 #[doc(alias = "get_climb_rate")]
1017 #[doc(alias = "climb-rate")]
1018 pub fn climb_rate(&self) -> f64 {
1019 unsafe { ffi::gtk_spin_button_get_climb_rate(self.to_glib_none().0) }
1020 }
1021
1022 /// Fetches the precision of @self.
1023 ///
1024 /// # Returns
1025 ///
1026 /// the current precision
1027 #[doc(alias = "gtk_spin_button_get_digits")]
1028 #[doc(alias = "get_digits")]
1029 pub fn digits(&self) -> u32 {
1030 unsafe { ffi::gtk_spin_button_get_digits(self.to_glib_none().0) }
1031 }
1032
1033 /// Gets the current step and page the increments
1034 /// used by @self.
1035 ///
1036 /// See [`set_increments()`][Self::set_increments()].
1037 ///
1038 /// # Returns
1039 ///
1040 ///
1041 /// ## `step`
1042 /// location to store step increment
1043 ///
1044 /// ## `page`
1045 /// location to store page increment
1046 #[doc(alias = "gtk_spin_button_get_increments")]
1047 #[doc(alias = "get_increments")]
1048 pub fn increments(&self) -> (f64, f64) {
1049 unsafe {
1050 let mut step = std::mem::MaybeUninit::uninit();
1051 let mut page = std::mem::MaybeUninit::uninit();
1052 ffi::gtk_spin_button_get_increments(
1053 self.to_glib_none().0,
1054 step.as_mut_ptr(),
1055 page.as_mut_ptr(),
1056 );
1057 (step.assume_init(), page.assume_init())
1058 }
1059 }
1060
1061 /// Returns whether non-numeric text can be typed into the spin button.
1062 ///
1063 /// # Returns
1064 ///
1065 /// [`true`] if only numeric text can be entered
1066 #[doc(alias = "gtk_spin_button_get_numeric")]
1067 #[doc(alias = "get_numeric")]
1068 #[doc(alias = "numeric")]
1069 pub fn is_numeric(&self) -> bool {
1070 unsafe { from_glib(ffi::gtk_spin_button_get_numeric(self.to_glib_none().0)) }
1071 }
1072
1073 /// Gets the range allowed for @self.
1074 ///
1075 /// See [`set_range()`][Self::set_range()].
1076 ///
1077 /// # Returns
1078 ///
1079 ///
1080 /// ## `min`
1081 /// location to store minimum allowed value
1082 ///
1083 /// ## `max`
1084 /// location to store maximum allowed value
1085 #[doc(alias = "gtk_spin_button_get_range")]
1086 #[doc(alias = "get_range")]
1087 pub fn range(&self) -> (f64, f64) {
1088 unsafe {
1089 let mut min = std::mem::MaybeUninit::uninit();
1090 let mut max = std::mem::MaybeUninit::uninit();
1091 ffi::gtk_spin_button_get_range(
1092 self.to_glib_none().0,
1093 min.as_mut_ptr(),
1094 max.as_mut_ptr(),
1095 );
1096 (min.assume_init(), max.assume_init())
1097 }
1098 }
1099
1100 /// Returns whether the values are corrected to the nearest step.
1101 ///
1102 /// # Returns
1103 ///
1104 /// [`true`] if values are snapped to the nearest step
1105 #[doc(alias = "gtk_spin_button_get_snap_to_ticks")]
1106 #[doc(alias = "get_snap_to_ticks")]
1107 #[doc(alias = "snap-to-ticks")]
1108 pub fn snaps_to_ticks(&self) -> bool {
1109 unsafe {
1110 from_glib(ffi::gtk_spin_button_get_snap_to_ticks(
1111 self.to_glib_none().0,
1112 ))
1113 }
1114 }
1115
1116 /// Gets the update behavior of a spin button.
1117 ///
1118 /// See [`set_update_policy()`][Self::set_update_policy()].
1119 ///
1120 /// # Returns
1121 ///
1122 /// the current update policy
1123 #[doc(alias = "gtk_spin_button_get_update_policy")]
1124 #[doc(alias = "get_update_policy")]
1125 #[doc(alias = "update-policy")]
1126 pub fn update_policy(&self) -> SpinButtonUpdatePolicy {
1127 unsafe {
1128 from_glib(ffi::gtk_spin_button_get_update_policy(
1129 self.to_glib_none().0,
1130 ))
1131 }
1132 }
1133
1134 /// Get the value in the @self.
1135 ///
1136 /// # Returns
1137 ///
1138 /// the value of @self
1139 #[doc(alias = "gtk_spin_button_get_value")]
1140 #[doc(alias = "get_value")]
1141 pub fn value(&self) -> f64 {
1142 unsafe { ffi::gtk_spin_button_get_value(self.to_glib_none().0) }
1143 }
1144
1145 /// Get the value @self represented as an integer.
1146 ///
1147 /// # Returns
1148 ///
1149 /// the value of @self
1150 #[doc(alias = "gtk_spin_button_get_value_as_int")]
1151 #[doc(alias = "get_value_as_int")]
1152 pub fn value_as_int(&self) -> i32 {
1153 unsafe { ffi::gtk_spin_button_get_value_as_int(self.to_glib_none().0) }
1154 }
1155
1156 /// Returns whether the spin button’s value wraps around to the
1157 /// opposite limit when the upper or lower limit of the range is
1158 /// exceeded.
1159 ///
1160 /// # Returns
1161 ///
1162 /// [`true`] if the spin button wraps around
1163 #[doc(alias = "gtk_spin_button_get_wrap")]
1164 #[doc(alias = "get_wrap")]
1165 #[doc(alias = "wrap")]
1166 pub fn wraps(&self) -> bool {
1167 unsafe { from_glib(ffi::gtk_spin_button_get_wrap(self.to_glib_none().0)) }
1168 }
1169
1170 /// Sets whether activating the spin button will activate the default
1171 /// widget for the window containing the spin button.
1172 ///
1173 /// See [`activate`][struct@crate::SpinButton#activate] for what counts as activation.
1174 /// ## `activates_default`
1175 /// [`true`] to activate window’s default widget on activation
1176 #[cfg(feature = "v4_14")]
1177 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1178 #[doc(alias = "gtk_spin_button_set_activates_default")]
1179 #[doc(alias = "activates-default")]
1180 pub fn set_activates_default(&self, activates_default: bool) {
1181 unsafe {
1182 ffi::gtk_spin_button_set_activates_default(
1183 self.to_glib_none().0,
1184 activates_default.into_glib(),
1185 );
1186 }
1187 }
1188
1189 /// Replaces the [`Adjustment`][crate::Adjustment] associated with @self.
1190 /// ## `adjustment`
1191 /// a [`Adjustment`][crate::Adjustment] to replace the existing adjustment
1192 #[doc(alias = "gtk_spin_button_set_adjustment")]
1193 #[doc(alias = "adjustment")]
1194 pub fn set_adjustment(&self, adjustment: &impl IsA<Adjustment>) {
1195 unsafe {
1196 ffi::gtk_spin_button_set_adjustment(
1197 self.to_glib_none().0,
1198 adjustment.as_ref().to_glib_none().0,
1199 );
1200 }
1201 }
1202
1203 /// Sets the acceleration rate for repeated changes when you
1204 /// hold down a button or key.
1205 /// ## `climb_rate`
1206 /// the rate of acceleration, must be >= 0
1207 #[doc(alias = "gtk_spin_button_set_climb_rate")]
1208 #[doc(alias = "climb-rate")]
1209 pub fn set_climb_rate(&self, climb_rate: f64) {
1210 unsafe {
1211 ffi::gtk_spin_button_set_climb_rate(self.to_glib_none().0, climb_rate);
1212 }
1213 }
1214
1215 /// Set the precision to be displayed by @self.
1216 ///
1217 /// Up to 20 digit precision is allowed.
1218 /// ## `digits`
1219 /// the number of digits after the decimal point to be
1220 /// displayed for the spin button’s value
1221 #[doc(alias = "gtk_spin_button_set_digits")]
1222 #[doc(alias = "digits")]
1223 pub fn set_digits(&self, digits: u32) {
1224 unsafe {
1225 ffi::gtk_spin_button_set_digits(self.to_glib_none().0, digits);
1226 }
1227 }
1228
1229 /// Sets the step and page increments for spin_button.
1230 ///
1231 /// This affects how quickly the value changes when
1232 /// the spin button’s arrows are activated.
1233 /// ## `step`
1234 /// increment applied for a button 1 press.
1235 /// ## `page`
1236 /// increment applied for a button 2 press.
1237 #[doc(alias = "gtk_spin_button_set_increments")]
1238 pub fn set_increments(&self, step: f64, page: f64) {
1239 unsafe {
1240 ffi::gtk_spin_button_set_increments(self.to_glib_none().0, step, page);
1241 }
1242 }
1243
1244 /// Sets the flag that determines if non-numeric text can be typed
1245 /// into the spin button.
1246 /// ## `numeric`
1247 /// flag indicating if only numeric entry is allowed
1248 #[doc(alias = "gtk_spin_button_set_numeric")]
1249 #[doc(alias = "numeric")]
1250 pub fn set_numeric(&self, numeric: bool) {
1251 unsafe {
1252 ffi::gtk_spin_button_set_numeric(self.to_glib_none().0, numeric.into_glib());
1253 }
1254 }
1255
1256 /// Sets the minimum and maximum allowable values for @self.
1257 ///
1258 /// If the current value is outside this range, it will be adjusted
1259 /// to fit within the range, otherwise it will remain unchanged.
1260 /// ## `min`
1261 /// minimum allowable value
1262 /// ## `max`
1263 /// maximum allowable value
1264 #[doc(alias = "gtk_spin_button_set_range")]
1265 pub fn set_range(&self, min: f64, max: f64) {
1266 unsafe {
1267 ffi::gtk_spin_button_set_range(self.to_glib_none().0, min, max);
1268 }
1269 }
1270
1271 /// Sets the policy as to whether values are corrected to the
1272 /// nearest step increment when a spin button is activated after
1273 /// providing an invalid value.
1274 /// ## `snap_to_ticks`
1275 /// a flag indicating if invalid values should be corrected
1276 #[doc(alias = "gtk_spin_button_set_snap_to_ticks")]
1277 #[doc(alias = "snap-to-ticks")]
1278 pub fn set_snap_to_ticks(&self, snap_to_ticks: bool) {
1279 unsafe {
1280 ffi::gtk_spin_button_set_snap_to_ticks(
1281 self.to_glib_none().0,
1282 snap_to_ticks.into_glib(),
1283 );
1284 }
1285 }
1286
1287 /// Sets the update behavior of a spin button.
1288 ///
1289 /// This determines whether the spin button is always
1290 /// updated or only when a valid value is set.
1291 /// ## `policy`
1292 /// a [`SpinButtonUpdatePolicy`][crate::SpinButtonUpdatePolicy] value
1293 #[doc(alias = "gtk_spin_button_set_update_policy")]
1294 #[doc(alias = "update-policy")]
1295 pub fn set_update_policy(&self, policy: SpinButtonUpdatePolicy) {
1296 unsafe {
1297 ffi::gtk_spin_button_set_update_policy(self.to_glib_none().0, policy.into_glib());
1298 }
1299 }
1300
1301 /// Sets the value of @self.
1302 /// ## `value`
1303 /// the new value
1304 #[doc(alias = "gtk_spin_button_set_value")]
1305 #[doc(alias = "value")]
1306 pub fn set_value(&self, value: f64) {
1307 unsafe {
1308 ffi::gtk_spin_button_set_value(self.to_glib_none().0, value);
1309 }
1310 }
1311
1312 /// Sets the flag that determines if a spin button value wraps
1313 /// around to the opposite limit when the upper or lower limit
1314 /// of the range is exceeded.
1315 /// ## `wrap`
1316 /// a flag indicating if wrapping behavior is performed
1317 #[doc(alias = "gtk_spin_button_set_wrap")]
1318 #[doc(alias = "wrap")]
1319 pub fn set_wrap(&self, wrap: bool) {
1320 unsafe {
1321 ffi::gtk_spin_button_set_wrap(self.to_glib_none().0, wrap.into_glib());
1322 }
1323 }
1324
1325 /// Increment or decrement a spin button’s value in a specified
1326 /// direction by a specified amount.
1327 /// ## `direction`
1328 /// a [`SpinType`][crate::SpinType] indicating the direction to spin
1329 /// ## `increment`
1330 /// step increment to apply in the specified direction
1331 #[doc(alias = "gtk_spin_button_spin")]
1332 pub fn spin(&self, direction: SpinType, increment: f64) {
1333 unsafe {
1334 ffi::gtk_spin_button_spin(self.to_glib_none().0, direction.into_glib(), increment);
1335 }
1336 }
1337
1338 /// Manually force an update of the spin button.
1339 #[doc(alias = "gtk_spin_button_update")]
1340 pub fn update(&self) {
1341 unsafe {
1342 ffi::gtk_spin_button_update(self.to_glib_none().0);
1343 }
1344 }
1345
1346 /// Emitted when the spin button is activated.
1347 ///
1348 /// The keybindings for this signal are all forms of the <kbd>Enter</kbd> key.
1349 ///
1350 /// If the <kbd>Enter</kbd> key results in the value being committed to the
1351 /// spin button, then activation does not occur until <kbd>Enter</kbd> is
1352 /// pressed again.
1353 #[cfg(feature = "v4_14")]
1354 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1355 #[doc(alias = "activate")]
1356 pub fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1357 unsafe extern "C" fn activate_trampoline<F: Fn(&SpinButton) + 'static>(
1358 this: *mut ffi::GtkSpinButton,
1359 f: glib::ffi::gpointer,
1360 ) {
1361 let f: &F = &*(f as *const F);
1362 f(&from_glib_borrow(this))
1363 }
1364 unsafe {
1365 let f: Box_<F> = Box_::new(f);
1366 connect_raw(
1367 self.as_ptr() as *mut _,
1368 c"activate".as_ptr() as *const _,
1369 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1370 activate_trampoline::<F> as *const (),
1371 )),
1372 Box_::into_raw(f),
1373 )
1374 }
1375 }
1376
1377 #[cfg(feature = "v4_14")]
1378 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1379 pub fn emit_activate(&self) {
1380 self.emit_by_name::<()>("activate", &[]);
1381 }
1382
1383 /// Emitted when the user initiates a value change.
1384 ///
1385 /// This is a [keybinding signal](class.SignalAction.html).
1386 ///
1387 /// Applications should not connect to it, but may emit it with
1388 /// g_signal_emit_by_name() if they need to control the cursor
1389 /// programmatically.
1390 ///
1391 /// The default bindings for this signal are Up/Down and PageUp/PageDown.
1392 /// ## `scroll`
1393 /// a [`ScrollType`][crate::ScrollType] to specify the speed and amount of change
1394 #[doc(alias = "change-value")]
1395 pub fn connect_change_value<F: Fn(&Self, ScrollType) + 'static>(
1396 &self,
1397 f: F,
1398 ) -> SignalHandlerId {
1399 unsafe extern "C" fn change_value_trampoline<F: Fn(&SpinButton, ScrollType) + 'static>(
1400 this: *mut ffi::GtkSpinButton,
1401 scroll: ffi::GtkScrollType,
1402 f: glib::ffi::gpointer,
1403 ) {
1404 let f: &F = &*(f as *const F);
1405 f(&from_glib_borrow(this), from_glib(scroll))
1406 }
1407 unsafe {
1408 let f: Box_<F> = Box_::new(f);
1409 connect_raw(
1410 self.as_ptr() as *mut _,
1411 c"change-value".as_ptr() as *const _,
1412 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1413 change_value_trampoline::<F> as *const (),
1414 )),
1415 Box_::into_raw(f),
1416 )
1417 }
1418 }
1419
1420 pub fn emit_change_value(&self, scroll: ScrollType) {
1421 self.emit_by_name::<()>("change-value", &[&scroll]);
1422 }
1423
1424 /// Emitted to tweak the formatting of the value for display.
1425 ///
1426 /// **⚠️ The following code is in c ⚠️**
1427 ///
1428 /// ```c
1429 /// // show leading zeros
1430 /// static gboolean
1431 /// on_output (GtkSpinButton *spin,
1432 /// gpointer data)
1433 /// {
1434 /// char *text;
1435 /// int value;
1436 ///
1437 /// value = gtk_spin_button_get_value_as_int (spin);
1438 /// text = g_strdup_printf ("%02d", value);
1439 /// gtk_editable_set_text (GTK_EDITABLE (spin), text):
1440 /// g_free (text);
1441 ///
1442 /// return TRUE;
1443 /// }
1444 /// ```
1445 ///
1446 /// # Returns
1447 ///
1448 /// [`true`] if the value has been displayed
1449 #[doc(alias = "output")]
1450 pub fn connect_output<F: Fn(&Self) -> glib::Propagation + 'static>(
1451 &self,
1452 f: F,
1453 ) -> SignalHandlerId {
1454 unsafe extern "C" fn output_trampoline<
1455 F: Fn(&SpinButton) -> glib::Propagation + 'static,
1456 >(
1457 this: *mut ffi::GtkSpinButton,
1458 f: glib::ffi::gpointer,
1459 ) -> glib::ffi::gboolean {
1460 let f: &F = &*(f as *const F);
1461 f(&from_glib_borrow(this)).into_glib()
1462 }
1463 unsafe {
1464 let f: Box_<F> = Box_::new(f);
1465 connect_raw(
1466 self.as_ptr() as *mut _,
1467 c"output".as_ptr() as *const _,
1468 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1469 output_trampoline::<F> as *const (),
1470 )),
1471 Box_::into_raw(f),
1472 )
1473 }
1474 }
1475
1476 /// Emitted when the value is changed.
1477 ///
1478 /// Also see the [`output`][struct@crate::SpinButton#output] signal.
1479 #[doc(alias = "value-changed")]
1480 pub fn connect_value_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1481 unsafe extern "C" fn value_changed_trampoline<F: Fn(&SpinButton) + 'static>(
1482 this: *mut ffi::GtkSpinButton,
1483 f: glib::ffi::gpointer,
1484 ) {
1485 let f: &F = &*(f as *const F);
1486 f(&from_glib_borrow(this))
1487 }
1488 unsafe {
1489 let f: Box_<F> = Box_::new(f);
1490 connect_raw(
1491 self.as_ptr() as *mut _,
1492 c"value-changed".as_ptr() as *const _,
1493 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1494 value_changed_trampoline::<F> as *const (),
1495 )),
1496 Box_::into_raw(f),
1497 )
1498 }
1499 }
1500
1501 /// Emitted right after the spinbutton wraps from its maximum
1502 /// to its minimum value or vice-versa.
1503 #[doc(alias = "wrapped")]
1504 pub fn connect_wrapped<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1505 unsafe extern "C" fn wrapped_trampoline<F: Fn(&SpinButton) + 'static>(
1506 this: *mut ffi::GtkSpinButton,
1507 f: glib::ffi::gpointer,
1508 ) {
1509 let f: &F = &*(f as *const F);
1510 f(&from_glib_borrow(this))
1511 }
1512 unsafe {
1513 let f: Box_<F> = Box_::new(f);
1514 connect_raw(
1515 self.as_ptr() as *mut _,
1516 c"wrapped".as_ptr() as *const _,
1517 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1518 wrapped_trampoline::<F> as *const (),
1519 )),
1520 Box_::into_raw(f),
1521 )
1522 }
1523 }
1524
1525 #[cfg(feature = "v4_14")]
1526 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1527 #[doc(alias = "activates-default")]
1528 pub fn connect_activates_default_notify<F: Fn(&Self) + 'static>(
1529 &self,
1530 f: F,
1531 ) -> SignalHandlerId {
1532 unsafe extern "C" fn notify_activates_default_trampoline<F: Fn(&SpinButton) + 'static>(
1533 this: *mut ffi::GtkSpinButton,
1534 _param_spec: glib::ffi::gpointer,
1535 f: glib::ffi::gpointer,
1536 ) {
1537 let f: &F = &*(f as *const F);
1538 f(&from_glib_borrow(this))
1539 }
1540 unsafe {
1541 let f: Box_<F> = Box_::new(f);
1542 connect_raw(
1543 self.as_ptr() as *mut _,
1544 c"notify::activates-default".as_ptr() as *const _,
1545 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1546 notify_activates_default_trampoline::<F> as *const (),
1547 )),
1548 Box_::into_raw(f),
1549 )
1550 }
1551 }
1552
1553 #[doc(alias = "adjustment")]
1554 pub fn connect_adjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1555 unsafe extern "C" fn notify_adjustment_trampoline<F: Fn(&SpinButton) + 'static>(
1556 this: *mut ffi::GtkSpinButton,
1557 _param_spec: glib::ffi::gpointer,
1558 f: glib::ffi::gpointer,
1559 ) {
1560 let f: &F = &*(f as *const F);
1561 f(&from_glib_borrow(this))
1562 }
1563 unsafe {
1564 let f: Box_<F> = Box_::new(f);
1565 connect_raw(
1566 self.as_ptr() as *mut _,
1567 c"notify::adjustment".as_ptr() as *const _,
1568 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1569 notify_adjustment_trampoline::<F> as *const (),
1570 )),
1571 Box_::into_raw(f),
1572 )
1573 }
1574 }
1575
1576 #[doc(alias = "climb-rate")]
1577 pub fn connect_climb_rate_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1578 unsafe extern "C" fn notify_climb_rate_trampoline<F: Fn(&SpinButton) + 'static>(
1579 this: *mut ffi::GtkSpinButton,
1580 _param_spec: glib::ffi::gpointer,
1581 f: glib::ffi::gpointer,
1582 ) {
1583 let f: &F = &*(f as *const F);
1584 f(&from_glib_borrow(this))
1585 }
1586 unsafe {
1587 let f: Box_<F> = Box_::new(f);
1588 connect_raw(
1589 self.as_ptr() as *mut _,
1590 c"notify::climb-rate".as_ptr() as *const _,
1591 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1592 notify_climb_rate_trampoline::<F> as *const (),
1593 )),
1594 Box_::into_raw(f),
1595 )
1596 }
1597 }
1598
1599 #[doc(alias = "digits")]
1600 pub fn connect_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1601 unsafe extern "C" fn notify_digits_trampoline<F: Fn(&SpinButton) + 'static>(
1602 this: *mut ffi::GtkSpinButton,
1603 _param_spec: glib::ffi::gpointer,
1604 f: glib::ffi::gpointer,
1605 ) {
1606 let f: &F = &*(f as *const F);
1607 f(&from_glib_borrow(this))
1608 }
1609 unsafe {
1610 let f: Box_<F> = Box_::new(f);
1611 connect_raw(
1612 self.as_ptr() as *mut _,
1613 c"notify::digits".as_ptr() as *const _,
1614 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1615 notify_digits_trampoline::<F> as *const (),
1616 )),
1617 Box_::into_raw(f),
1618 )
1619 }
1620 }
1621
1622 #[doc(alias = "numeric")]
1623 pub fn connect_numeric_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1624 unsafe extern "C" fn notify_numeric_trampoline<F: Fn(&SpinButton) + 'static>(
1625 this: *mut ffi::GtkSpinButton,
1626 _param_spec: glib::ffi::gpointer,
1627 f: glib::ffi::gpointer,
1628 ) {
1629 let f: &F = &*(f as *const F);
1630 f(&from_glib_borrow(this))
1631 }
1632 unsafe {
1633 let f: Box_<F> = Box_::new(f);
1634 connect_raw(
1635 self.as_ptr() as *mut _,
1636 c"notify::numeric".as_ptr() as *const _,
1637 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1638 notify_numeric_trampoline::<F> as *const (),
1639 )),
1640 Box_::into_raw(f),
1641 )
1642 }
1643 }
1644
1645 #[doc(alias = "snap-to-ticks")]
1646 pub fn connect_snap_to_ticks_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1647 unsafe extern "C" fn notify_snap_to_ticks_trampoline<F: Fn(&SpinButton) + 'static>(
1648 this: *mut ffi::GtkSpinButton,
1649 _param_spec: glib::ffi::gpointer,
1650 f: glib::ffi::gpointer,
1651 ) {
1652 let f: &F = &*(f as *const F);
1653 f(&from_glib_borrow(this))
1654 }
1655 unsafe {
1656 let f: Box_<F> = Box_::new(f);
1657 connect_raw(
1658 self.as_ptr() as *mut _,
1659 c"notify::snap-to-ticks".as_ptr() as *const _,
1660 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1661 notify_snap_to_ticks_trampoline::<F> as *const (),
1662 )),
1663 Box_::into_raw(f),
1664 )
1665 }
1666 }
1667
1668 #[doc(alias = "update-policy")]
1669 pub fn connect_update_policy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1670 unsafe extern "C" fn notify_update_policy_trampoline<F: Fn(&SpinButton) + 'static>(
1671 this: *mut ffi::GtkSpinButton,
1672 _param_spec: glib::ffi::gpointer,
1673 f: glib::ffi::gpointer,
1674 ) {
1675 let f: &F = &*(f as *const F);
1676 f(&from_glib_borrow(this))
1677 }
1678 unsafe {
1679 let f: Box_<F> = Box_::new(f);
1680 connect_raw(
1681 self.as_ptr() as *mut _,
1682 c"notify::update-policy".as_ptr() as *const _,
1683 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1684 notify_update_policy_trampoline::<F> as *const (),
1685 )),
1686 Box_::into_raw(f),
1687 )
1688 }
1689 }
1690
1691 #[doc(alias = "value")]
1692 pub fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1693 unsafe extern "C" fn notify_value_trampoline<F: Fn(&SpinButton) + 'static>(
1694 this: *mut ffi::GtkSpinButton,
1695 _param_spec: glib::ffi::gpointer,
1696 f: glib::ffi::gpointer,
1697 ) {
1698 let f: &F = &*(f as *const F);
1699 f(&from_glib_borrow(this))
1700 }
1701 unsafe {
1702 let f: Box_<F> = Box_::new(f);
1703 connect_raw(
1704 self.as_ptr() as *mut _,
1705 c"notify::value".as_ptr() as *const _,
1706 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1707 notify_value_trampoline::<F> as *const (),
1708 )),
1709 Box_::into_raw(f),
1710 )
1711 }
1712 }
1713
1714 #[doc(alias = "wrap")]
1715 pub fn connect_wrap_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1716 unsafe extern "C" fn notify_wrap_trampoline<F: Fn(&SpinButton) + 'static>(
1717 this: *mut ffi::GtkSpinButton,
1718 _param_spec: glib::ffi::gpointer,
1719 f: glib::ffi::gpointer,
1720 ) {
1721 let f: &F = &*(f as *const F);
1722 f(&from_glib_borrow(this))
1723 }
1724 unsafe {
1725 let f: Box_<F> = Box_::new(f);
1726 connect_raw(
1727 self.as_ptr() as *mut _,
1728 c"notify::wrap".as_ptr() as *const _,
1729 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1730 notify_wrap_trampoline::<F> as *const (),
1731 )),
1732 Box_::into_raw(f),
1733 )
1734 }
1735 }
1736}
1737
1738impl Default for SpinButton {
1739 fn default() -> Self {
1740 glib::object::Object::new::<Self>()
1741 }
1742}
1743
1744// rustdoc-stripper-ignore-next
1745/// A [builder-pattern] type to construct [`SpinButton`] objects.
1746///
1747/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1748#[must_use = "The builder must be built to be used"]
1749pub struct SpinButtonBuilder {
1750 builder: glib::object::ObjectBuilder<'static, SpinButton>,
1751}
1752
1753impl SpinButtonBuilder {
1754 fn new() -> Self {
1755 Self {
1756 builder: glib::object::Object::builder(),
1757 }
1758 }
1759
1760 /// Whether to activate the default widget when the spin button is activated.
1761 ///
1762 /// See [`activate`][struct@crate::SpinButton#activate] for what counts as activation.
1763 #[cfg(feature = "v4_14")]
1764 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1765 pub fn activates_default(self, activates_default: bool) -> Self {
1766 Self {
1767 builder: self
1768 .builder
1769 .property("activates-default", activates_default),
1770 }
1771 }
1772
1773 /// The adjustment that holds the value of the spin button.
1774 pub fn adjustment(self, adjustment: &impl IsA<Adjustment>) -> Self {
1775 Self {
1776 builder: self
1777 .builder
1778 .property("adjustment", adjustment.clone().upcast()),
1779 }
1780 }
1781
1782 /// The acceleration rate when you hold down a button or key.
1783 pub fn climb_rate(self, climb_rate: f64) -> Self {
1784 Self {
1785 builder: self.builder.property("climb-rate", climb_rate),
1786 }
1787 }
1788
1789 /// The number of decimal places to display.
1790 pub fn digits(self, digits: u32) -> Self {
1791 Self {
1792 builder: self.builder.property("digits", digits),
1793 }
1794 }
1795
1796 /// Whether non-numeric characters should be ignored.
1797 pub fn numeric(self, numeric: bool) -> Self {
1798 Self {
1799 builder: self.builder.property("numeric", numeric),
1800 }
1801 }
1802
1803 /// Whether erroneous values are automatically changed to the spin buttons
1804 /// nearest step increment.
1805 pub fn snap_to_ticks(self, snap_to_ticks: bool) -> Self {
1806 Self {
1807 builder: self.builder.property("snap-to-ticks", snap_to_ticks),
1808 }
1809 }
1810
1811 /// Whether the spin button should update always, or only when the value
1812 /// is acceptable.
1813 pub fn update_policy(self, update_policy: SpinButtonUpdatePolicy) -> Self {
1814 Self {
1815 builder: self.builder.property("update-policy", update_policy),
1816 }
1817 }
1818
1819 /// The current value.
1820 pub fn value(self, value: f64) -> Self {
1821 Self {
1822 builder: self.builder.property("value", value),
1823 }
1824 }
1825
1826 /// Whether a spin button should wrap upon reaching its limits.
1827 pub fn wrap(self, wrap: bool) -> Self {
1828 Self {
1829 builder: self.builder.property("wrap", wrap),
1830 }
1831 }
1832
1833 /// Whether the widget or any of its descendents can accept
1834 /// the input focus.
1835 ///
1836 /// This property is meant to be set by widget implementations,
1837 /// typically in their instance init function.
1838 pub fn can_focus(self, can_focus: bool) -> Self {
1839 Self {
1840 builder: self.builder.property("can-focus", can_focus),
1841 }
1842 }
1843
1844 /// Whether the widget can receive pointer events.
1845 pub fn can_target(self, can_target: bool) -> Self {
1846 Self {
1847 builder: self.builder.property("can-target", can_target),
1848 }
1849 }
1850
1851 /// A list of css classes applied to this widget.
1852 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1853 Self {
1854 builder: self.builder.property("css-classes", css_classes.into()),
1855 }
1856 }
1857
1858 /// The name of this widget in the CSS tree.
1859 ///
1860 /// This property is meant to be set by widget implementations,
1861 /// typically in their instance init function.
1862 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1863 Self {
1864 builder: self.builder.property("css-name", css_name.into()),
1865 }
1866 }
1867
1868 /// The cursor used by @widget.
1869 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1870 Self {
1871 builder: self.builder.property("cursor", cursor.clone()),
1872 }
1873 }
1874
1875 /// Whether the widget should grab focus when it is clicked with the mouse.
1876 ///
1877 /// This property is only relevant for widgets that can take focus.
1878 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1879 Self {
1880 builder: self.builder.property("focus-on-click", focus_on_click),
1881 }
1882 }
1883
1884 /// Whether this widget itself will accept the input focus.
1885 pub fn focusable(self, focusable: bool) -> Self {
1886 Self {
1887 builder: self.builder.property("focusable", focusable),
1888 }
1889 }
1890
1891 /// How to distribute horizontal space if widget gets extra space.
1892 pub fn halign(self, halign: Align) -> Self {
1893 Self {
1894 builder: self.builder.property("halign", halign),
1895 }
1896 }
1897
1898 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1899 /// signal on @widget.
1900 ///
1901 /// A true value indicates that @widget can have a tooltip, in this case
1902 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1903 /// determine whether it will provide a tooltip or not.
1904 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1905 Self {
1906 builder: self.builder.property("has-tooltip", has_tooltip),
1907 }
1908 }
1909
1910 /// Overrides for height request of the widget.
1911 ///
1912 /// If this is -1, the natural request will be used.
1913 pub fn height_request(self, height_request: i32) -> Self {
1914 Self {
1915 builder: self.builder.property("height-request", height_request),
1916 }
1917 }
1918
1919 /// Whether to expand horizontally.
1920 pub fn hexpand(self, hexpand: bool) -> Self {
1921 Self {
1922 builder: self.builder.property("hexpand", hexpand),
1923 }
1924 }
1925
1926 /// Whether to use the `hexpand` property.
1927 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1928 Self {
1929 builder: self.builder.property("hexpand-set", hexpand_set),
1930 }
1931 }
1932
1933 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1934 /// the preferred size of the widget, and allocate its children.
1935 ///
1936 /// This property is meant to be set by widget implementations,
1937 /// typically in their instance init function.
1938 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1939 Self {
1940 builder: self
1941 .builder
1942 .property("layout-manager", layout_manager.clone().upcast()),
1943 }
1944 }
1945
1946 /// Makes this widget act like a modal dialog, with respect to
1947 /// event delivery.
1948 ///
1949 /// Global event controllers will not handle events with targets
1950 /// inside the widget, unless they are set up to ignore propagation
1951 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1952 #[cfg(feature = "v4_18")]
1953 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1954 pub fn limit_events(self, limit_events: bool) -> Self {
1955 Self {
1956 builder: self.builder.property("limit-events", limit_events),
1957 }
1958 }
1959
1960 /// Margin on bottom side of widget.
1961 ///
1962 /// This property adds margin outside of the widget's normal size
1963 /// request, the margin will be added in addition to the size from
1964 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1965 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1966 Self {
1967 builder: self.builder.property("margin-bottom", margin_bottom),
1968 }
1969 }
1970
1971 /// Margin on end of widget, horizontally.
1972 ///
1973 /// This property supports left-to-right and right-to-left text
1974 /// directions.
1975 ///
1976 /// This property adds margin outside of the widget's normal size
1977 /// request, the margin will be added in addition to the size from
1978 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1979 pub fn margin_end(self, margin_end: i32) -> Self {
1980 Self {
1981 builder: self.builder.property("margin-end", margin_end),
1982 }
1983 }
1984
1985 /// Margin on start of widget, horizontally.
1986 ///
1987 /// This property supports left-to-right and right-to-left text
1988 /// directions.
1989 ///
1990 /// This property adds margin outside of the widget's normal size
1991 /// request, the margin will be added in addition to the size from
1992 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1993 pub fn margin_start(self, margin_start: i32) -> Self {
1994 Self {
1995 builder: self.builder.property("margin-start", margin_start),
1996 }
1997 }
1998
1999 /// Margin on top side of widget.
2000 ///
2001 /// This property adds margin outside of the widget's normal size
2002 /// request, the margin will be added in addition to the size from
2003 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2004 pub fn margin_top(self, margin_top: i32) -> Self {
2005 Self {
2006 builder: self.builder.property("margin-top", margin_top),
2007 }
2008 }
2009
2010 /// The name of the widget.
2011 pub fn name(self, name: impl Into<glib::GString>) -> Self {
2012 Self {
2013 builder: self.builder.property("name", name.into()),
2014 }
2015 }
2016
2017 /// The requested opacity of the widget.
2018 pub fn opacity(self, opacity: f64) -> Self {
2019 Self {
2020 builder: self.builder.property("opacity", opacity),
2021 }
2022 }
2023
2024 /// How content outside the widget's content area is treated.
2025 ///
2026 /// This property is meant to be set by widget implementations,
2027 /// typically in their instance init function.
2028 pub fn overflow(self, overflow: Overflow) -> Self {
2029 Self {
2030 builder: self.builder.property("overflow", overflow),
2031 }
2032 }
2033
2034 /// Whether the widget will receive the default action when it is focused.
2035 pub fn receives_default(self, receives_default: bool) -> Self {
2036 Self {
2037 builder: self.builder.property("receives-default", receives_default),
2038 }
2039 }
2040
2041 /// Whether the widget responds to input.
2042 pub fn sensitive(self, sensitive: bool) -> Self {
2043 Self {
2044 builder: self.builder.property("sensitive", sensitive),
2045 }
2046 }
2047
2048 /// Sets the text of tooltip to be the given string, which is marked up
2049 /// with Pango markup.
2050 ///
2051 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
2052 ///
2053 /// This is a convenience property which will take care of getting the
2054 /// tooltip shown if the given string is not `NULL`:
2055 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2056 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2057 /// the default signal handler.
2058 ///
2059 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2060 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2061 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
2062 Self {
2063 builder: self
2064 .builder
2065 .property("tooltip-markup", tooltip_markup.into()),
2066 }
2067 }
2068
2069 /// Sets the text of tooltip to be the given string.
2070 ///
2071 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
2072 ///
2073 /// This is a convenience property which will take care of getting the
2074 /// tooltip shown if the given string is not `NULL`:
2075 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2076 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2077 /// the default signal handler.
2078 ///
2079 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2080 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2081 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
2082 Self {
2083 builder: self.builder.property("tooltip-text", tooltip_text.into()),
2084 }
2085 }
2086
2087 /// How to distribute vertical space if widget gets extra space.
2088 pub fn valign(self, valign: Align) -> Self {
2089 Self {
2090 builder: self.builder.property("valign", valign),
2091 }
2092 }
2093
2094 /// Whether to expand vertically.
2095 pub fn vexpand(self, vexpand: bool) -> Self {
2096 Self {
2097 builder: self.builder.property("vexpand", vexpand),
2098 }
2099 }
2100
2101 /// Whether to use the `vexpand` property.
2102 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
2103 Self {
2104 builder: self.builder.property("vexpand-set", vexpand_set),
2105 }
2106 }
2107
2108 /// Whether the widget is visible.
2109 pub fn visible(self, visible: bool) -> Self {
2110 Self {
2111 builder: self.builder.property("visible", visible),
2112 }
2113 }
2114
2115 /// Overrides for width request of the widget.
2116 ///
2117 /// If this is -1, the natural request will be used.
2118 pub fn width_request(self, width_request: i32) -> Self {
2119 Self {
2120 builder: self.builder.property("width-request", width_request),
2121 }
2122 }
2123
2124 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
2125 ///
2126 /// The accessible role cannot be changed once set.
2127 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
2128 Self {
2129 builder: self.builder.property("accessible-role", accessible_role),
2130 }
2131 }
2132
2133 /// Indicates whether editing on the cell has been canceled.
2134 pub fn editing_canceled(self, editing_canceled: bool) -> Self {
2135 Self {
2136 builder: self.builder.property("editing-canceled", editing_canceled),
2137 }
2138 }
2139
2140 /// Whether the entry contents can be edited.
2141 pub fn editable(self, editable: bool) -> Self {
2142 Self {
2143 builder: self.builder.property("editable", editable),
2144 }
2145 }
2146
2147 /// If undo/redo should be enabled for the editable.
2148 pub fn enable_undo(self, enable_undo: bool) -> Self {
2149 Self {
2150 builder: self.builder.property("enable-undo", enable_undo),
2151 }
2152 }
2153
2154 /// The desired maximum width of the entry, in characters.
2155 pub fn max_width_chars(self, max_width_chars: i32) -> Self {
2156 Self {
2157 builder: self.builder.property("max-width-chars", max_width_chars),
2158 }
2159 }
2160
2161 /// The contents of the entry.
2162 pub fn text(self, text: impl Into<glib::GString>) -> Self {
2163 Self {
2164 builder: self.builder.property("text", text.into()),
2165 }
2166 }
2167
2168 /// Number of characters to leave space for in the entry.
2169 pub fn width_chars(self, width_chars: i32) -> Self {
2170 Self {
2171 builder: self.builder.property("width-chars", width_chars),
2172 }
2173 }
2174
2175 /// The horizontal alignment, from 0 (left) to 1 (right).
2176 ///
2177 /// Reversed for RTL layouts.
2178 pub fn xalign(self, xalign: f32) -> Self {
2179 Self {
2180 builder: self.builder.property("xalign", xalign),
2181 }
2182 }
2183
2184 /// The orientation of the orientable.
2185 pub fn orientation(self, orientation: Orientation) -> Self {
2186 Self {
2187 builder: self.builder.property("orientation", orientation),
2188 }
2189 }
2190
2191 // rustdoc-stripper-ignore-next
2192 /// Build the [`SpinButton`].
2193 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
2194 pub fn build(self) -> SpinButton {
2195 assert_initialized_main_thread!();
2196 self.builder.build()
2197 }
2198}