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 /// #### `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 unsafe {
1362 let f: &F = &*(f as *const F);
1363 f(&from_glib_borrow(this))
1364 }
1365 }
1366 unsafe {
1367 let f: Box_<F> = Box_::new(f);
1368 connect_raw(
1369 self.as_ptr() as *mut _,
1370 c"activate".as_ptr() as *const _,
1371 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1372 activate_trampoline::<F> as *const (),
1373 )),
1374 Box_::into_raw(f),
1375 )
1376 }
1377 }
1378
1379 #[cfg(feature = "v4_14")]
1380 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1381 pub fn emit_activate(&self) {
1382 self.emit_by_name::<()>("activate", &[]);
1383 }
1384
1385 /// Emitted when the user initiates a value change.
1386 ///
1387 /// This is a [keybinding signal](class.SignalAction.html).
1388 ///
1389 /// Applications should not connect to it, but may emit it with
1390 /// g_signal_emit_by_name() if they need to control the cursor
1391 /// programmatically.
1392 ///
1393 /// The default bindings for this signal are Up/Down and PageUp/PageDown.
1394 /// ## `scroll`
1395 /// a [`ScrollType`][crate::ScrollType] to specify the speed and amount of change
1396 #[doc(alias = "change-value")]
1397 pub fn connect_change_value<F: Fn(&Self, ScrollType) + 'static>(
1398 &self,
1399 f: F,
1400 ) -> SignalHandlerId {
1401 unsafe extern "C" fn change_value_trampoline<F: Fn(&SpinButton, ScrollType) + 'static>(
1402 this: *mut ffi::GtkSpinButton,
1403 scroll: ffi::GtkScrollType,
1404 f: glib::ffi::gpointer,
1405 ) {
1406 unsafe {
1407 let f: &F = &*(f as *const F);
1408 f(&from_glib_borrow(this), from_glib(scroll))
1409 }
1410 }
1411 unsafe {
1412 let f: Box_<F> = Box_::new(f);
1413 connect_raw(
1414 self.as_ptr() as *mut _,
1415 c"change-value".as_ptr() as *const _,
1416 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1417 change_value_trampoline::<F> as *const (),
1418 )),
1419 Box_::into_raw(f),
1420 )
1421 }
1422 }
1423
1424 pub fn emit_change_value(&self, scroll: ScrollType) {
1425 self.emit_by_name::<()>("change-value", &[&scroll]);
1426 }
1427
1428 /// Emitted to tweak the formatting of the value for display.
1429 ///
1430 /// **⚠️ The following code is in c ⚠️**
1431 ///
1432 /// ```c
1433 /// // show leading zeros
1434 /// static gboolean
1435 /// on_output (GtkSpinButton *spin,
1436 /// gpointer data)
1437 /// {
1438 /// char *text;
1439 /// int value;
1440 ///
1441 /// value = gtk_spin_button_get_value_as_int (spin);
1442 /// text = g_strdup_printf ("%02d", value);
1443 /// gtk_editable_set_text (GTK_EDITABLE (spin), text):
1444 /// g_free (text);
1445 ///
1446 /// return TRUE;
1447 /// }
1448 /// ```
1449 ///
1450 /// # Returns
1451 ///
1452 /// [`true`] if the value has been displayed
1453 #[doc(alias = "output")]
1454 pub fn connect_output<F: Fn(&Self) -> glib::Propagation + 'static>(
1455 &self,
1456 f: F,
1457 ) -> SignalHandlerId {
1458 unsafe extern "C" fn output_trampoline<
1459 F: Fn(&SpinButton) -> glib::Propagation + 'static,
1460 >(
1461 this: *mut ffi::GtkSpinButton,
1462 f: glib::ffi::gpointer,
1463 ) -> glib::ffi::gboolean {
1464 unsafe {
1465 let f: &F = &*(f as *const F);
1466 f(&from_glib_borrow(this)).into_glib()
1467 }
1468 }
1469 unsafe {
1470 let f: Box_<F> = Box_::new(f);
1471 connect_raw(
1472 self.as_ptr() as *mut _,
1473 c"output".as_ptr() as *const _,
1474 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1475 output_trampoline::<F> as *const (),
1476 )),
1477 Box_::into_raw(f),
1478 )
1479 }
1480 }
1481
1482 /// Emitted when the value is changed.
1483 ///
1484 /// Also see the [`output`][struct@crate::SpinButton#output] signal.
1485 #[doc(alias = "value-changed")]
1486 pub fn connect_value_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1487 unsafe extern "C" fn value_changed_trampoline<F: Fn(&SpinButton) + 'static>(
1488 this: *mut ffi::GtkSpinButton,
1489 f: glib::ffi::gpointer,
1490 ) {
1491 unsafe {
1492 let f: &F = &*(f as *const F);
1493 f(&from_glib_borrow(this))
1494 }
1495 }
1496 unsafe {
1497 let f: Box_<F> = Box_::new(f);
1498 connect_raw(
1499 self.as_ptr() as *mut _,
1500 c"value-changed".as_ptr() as *const _,
1501 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1502 value_changed_trampoline::<F> as *const (),
1503 )),
1504 Box_::into_raw(f),
1505 )
1506 }
1507 }
1508
1509 /// Emitted right after the spinbutton wraps from its maximum
1510 /// to its minimum value or vice-versa.
1511 #[doc(alias = "wrapped")]
1512 pub fn connect_wrapped<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1513 unsafe extern "C" fn wrapped_trampoline<F: Fn(&SpinButton) + 'static>(
1514 this: *mut ffi::GtkSpinButton,
1515 f: glib::ffi::gpointer,
1516 ) {
1517 unsafe {
1518 let f: &F = &*(f as *const F);
1519 f(&from_glib_borrow(this))
1520 }
1521 }
1522 unsafe {
1523 let f: Box_<F> = Box_::new(f);
1524 connect_raw(
1525 self.as_ptr() as *mut _,
1526 c"wrapped".as_ptr() as *const _,
1527 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1528 wrapped_trampoline::<F> as *const (),
1529 )),
1530 Box_::into_raw(f),
1531 )
1532 }
1533 }
1534
1535 #[cfg(feature = "v4_14")]
1536 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1537 #[doc(alias = "activates-default")]
1538 pub fn connect_activates_default_notify<F: Fn(&Self) + 'static>(
1539 &self,
1540 f: F,
1541 ) -> SignalHandlerId {
1542 unsafe extern "C" fn notify_activates_default_trampoline<F: Fn(&SpinButton) + 'static>(
1543 this: *mut ffi::GtkSpinButton,
1544 _param_spec: glib::ffi::gpointer,
1545 f: glib::ffi::gpointer,
1546 ) {
1547 unsafe {
1548 let f: &F = &*(f as *const F);
1549 f(&from_glib_borrow(this))
1550 }
1551 }
1552 unsafe {
1553 let f: Box_<F> = Box_::new(f);
1554 connect_raw(
1555 self.as_ptr() as *mut _,
1556 c"notify::activates-default".as_ptr() as *const _,
1557 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1558 notify_activates_default_trampoline::<F> as *const (),
1559 )),
1560 Box_::into_raw(f),
1561 )
1562 }
1563 }
1564
1565 #[doc(alias = "adjustment")]
1566 pub fn connect_adjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1567 unsafe extern "C" fn notify_adjustment_trampoline<F: Fn(&SpinButton) + 'static>(
1568 this: *mut ffi::GtkSpinButton,
1569 _param_spec: glib::ffi::gpointer,
1570 f: glib::ffi::gpointer,
1571 ) {
1572 unsafe {
1573 let f: &F = &*(f as *const F);
1574 f(&from_glib_borrow(this))
1575 }
1576 }
1577 unsafe {
1578 let f: Box_<F> = Box_::new(f);
1579 connect_raw(
1580 self.as_ptr() as *mut _,
1581 c"notify::adjustment".as_ptr() as *const _,
1582 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1583 notify_adjustment_trampoline::<F> as *const (),
1584 )),
1585 Box_::into_raw(f),
1586 )
1587 }
1588 }
1589
1590 #[doc(alias = "climb-rate")]
1591 pub fn connect_climb_rate_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1592 unsafe extern "C" fn notify_climb_rate_trampoline<F: Fn(&SpinButton) + 'static>(
1593 this: *mut ffi::GtkSpinButton,
1594 _param_spec: glib::ffi::gpointer,
1595 f: glib::ffi::gpointer,
1596 ) {
1597 unsafe {
1598 let f: &F = &*(f as *const F);
1599 f(&from_glib_borrow(this))
1600 }
1601 }
1602 unsafe {
1603 let f: Box_<F> = Box_::new(f);
1604 connect_raw(
1605 self.as_ptr() as *mut _,
1606 c"notify::climb-rate".as_ptr() as *const _,
1607 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1608 notify_climb_rate_trampoline::<F> as *const (),
1609 )),
1610 Box_::into_raw(f),
1611 )
1612 }
1613 }
1614
1615 #[doc(alias = "digits")]
1616 pub fn connect_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1617 unsafe extern "C" fn notify_digits_trampoline<F: Fn(&SpinButton) + 'static>(
1618 this: *mut ffi::GtkSpinButton,
1619 _param_spec: glib::ffi::gpointer,
1620 f: glib::ffi::gpointer,
1621 ) {
1622 unsafe {
1623 let f: &F = &*(f as *const F);
1624 f(&from_glib_borrow(this))
1625 }
1626 }
1627 unsafe {
1628 let f: Box_<F> = Box_::new(f);
1629 connect_raw(
1630 self.as_ptr() as *mut _,
1631 c"notify::digits".as_ptr() as *const _,
1632 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1633 notify_digits_trampoline::<F> as *const (),
1634 )),
1635 Box_::into_raw(f),
1636 )
1637 }
1638 }
1639
1640 #[doc(alias = "numeric")]
1641 pub fn connect_numeric_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1642 unsafe extern "C" fn notify_numeric_trampoline<F: Fn(&SpinButton) + 'static>(
1643 this: *mut ffi::GtkSpinButton,
1644 _param_spec: glib::ffi::gpointer,
1645 f: glib::ffi::gpointer,
1646 ) {
1647 unsafe {
1648 let f: &F = &*(f as *const F);
1649 f(&from_glib_borrow(this))
1650 }
1651 }
1652 unsafe {
1653 let f: Box_<F> = Box_::new(f);
1654 connect_raw(
1655 self.as_ptr() as *mut _,
1656 c"notify::numeric".as_ptr() as *const _,
1657 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1658 notify_numeric_trampoline::<F> as *const (),
1659 )),
1660 Box_::into_raw(f),
1661 )
1662 }
1663 }
1664
1665 #[doc(alias = "snap-to-ticks")]
1666 pub fn connect_snap_to_ticks_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1667 unsafe extern "C" fn notify_snap_to_ticks_trampoline<F: Fn(&SpinButton) + 'static>(
1668 this: *mut ffi::GtkSpinButton,
1669 _param_spec: glib::ffi::gpointer,
1670 f: glib::ffi::gpointer,
1671 ) {
1672 unsafe {
1673 let f: &F = &*(f as *const F);
1674 f(&from_glib_borrow(this))
1675 }
1676 }
1677 unsafe {
1678 let f: Box_<F> = Box_::new(f);
1679 connect_raw(
1680 self.as_ptr() as *mut _,
1681 c"notify::snap-to-ticks".as_ptr() as *const _,
1682 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1683 notify_snap_to_ticks_trampoline::<F> as *const (),
1684 )),
1685 Box_::into_raw(f),
1686 )
1687 }
1688 }
1689
1690 #[doc(alias = "update-policy")]
1691 pub fn connect_update_policy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1692 unsafe extern "C" fn notify_update_policy_trampoline<F: Fn(&SpinButton) + 'static>(
1693 this: *mut ffi::GtkSpinButton,
1694 _param_spec: glib::ffi::gpointer,
1695 f: glib::ffi::gpointer,
1696 ) {
1697 unsafe {
1698 let f: &F = &*(f as *const F);
1699 f(&from_glib_borrow(this))
1700 }
1701 }
1702 unsafe {
1703 let f: Box_<F> = Box_::new(f);
1704 connect_raw(
1705 self.as_ptr() as *mut _,
1706 c"notify::update-policy".as_ptr() as *const _,
1707 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1708 notify_update_policy_trampoline::<F> as *const (),
1709 )),
1710 Box_::into_raw(f),
1711 )
1712 }
1713 }
1714
1715 #[doc(alias = "value")]
1716 pub fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1717 unsafe extern "C" fn notify_value_trampoline<F: Fn(&SpinButton) + 'static>(
1718 this: *mut ffi::GtkSpinButton,
1719 _param_spec: glib::ffi::gpointer,
1720 f: glib::ffi::gpointer,
1721 ) {
1722 unsafe {
1723 let f: &F = &*(f as *const F);
1724 f(&from_glib_borrow(this))
1725 }
1726 }
1727 unsafe {
1728 let f: Box_<F> = Box_::new(f);
1729 connect_raw(
1730 self.as_ptr() as *mut _,
1731 c"notify::value".as_ptr() as *const _,
1732 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1733 notify_value_trampoline::<F> as *const (),
1734 )),
1735 Box_::into_raw(f),
1736 )
1737 }
1738 }
1739
1740 #[doc(alias = "wrap")]
1741 pub fn connect_wrap_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1742 unsafe extern "C" fn notify_wrap_trampoline<F: Fn(&SpinButton) + 'static>(
1743 this: *mut ffi::GtkSpinButton,
1744 _param_spec: glib::ffi::gpointer,
1745 f: glib::ffi::gpointer,
1746 ) {
1747 unsafe {
1748 let f: &F = &*(f as *const F);
1749 f(&from_glib_borrow(this))
1750 }
1751 }
1752 unsafe {
1753 let f: Box_<F> = Box_::new(f);
1754 connect_raw(
1755 self.as_ptr() as *mut _,
1756 c"notify::wrap".as_ptr() as *const _,
1757 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1758 notify_wrap_trampoline::<F> as *const (),
1759 )),
1760 Box_::into_raw(f),
1761 )
1762 }
1763 }
1764}
1765
1766impl Default for SpinButton {
1767 fn default() -> Self {
1768 glib::object::Object::new::<Self>()
1769 }
1770}
1771
1772// rustdoc-stripper-ignore-next
1773/// A [builder-pattern] type to construct [`SpinButton`] objects.
1774///
1775/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1776#[must_use = "The builder must be built to be used"]
1777pub struct SpinButtonBuilder {
1778 builder: glib::object::ObjectBuilder<'static, SpinButton>,
1779}
1780
1781impl SpinButtonBuilder {
1782 fn new() -> Self {
1783 Self {
1784 builder: glib::object::Object::builder(),
1785 }
1786 }
1787
1788 /// Whether to activate the default widget when the spin button is activated.
1789 ///
1790 /// See [`activate`][struct@crate::SpinButton#activate] for what counts as activation.
1791 #[cfg(feature = "v4_14")]
1792 #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1793 pub fn activates_default(self, activates_default: bool) -> Self {
1794 Self {
1795 builder: self
1796 .builder
1797 .property("activates-default", activates_default),
1798 }
1799 }
1800
1801 /// The adjustment that holds the value of the spin button.
1802 pub fn adjustment(self, adjustment: &impl IsA<Adjustment>) -> Self {
1803 Self {
1804 builder: self
1805 .builder
1806 .property("adjustment", adjustment.clone().upcast()),
1807 }
1808 }
1809
1810 /// The acceleration rate when you hold down a button or key.
1811 pub fn climb_rate(self, climb_rate: f64) -> Self {
1812 Self {
1813 builder: self.builder.property("climb-rate", climb_rate),
1814 }
1815 }
1816
1817 /// The number of decimal places to display.
1818 pub fn digits(self, digits: u32) -> Self {
1819 Self {
1820 builder: self.builder.property("digits", digits),
1821 }
1822 }
1823
1824 /// Whether non-numeric characters should be ignored.
1825 pub fn numeric(self, numeric: bool) -> Self {
1826 Self {
1827 builder: self.builder.property("numeric", numeric),
1828 }
1829 }
1830
1831 /// Whether erroneous values are automatically changed to the spin buttons
1832 /// nearest step increment.
1833 pub fn snap_to_ticks(self, snap_to_ticks: bool) -> Self {
1834 Self {
1835 builder: self.builder.property("snap-to-ticks", snap_to_ticks),
1836 }
1837 }
1838
1839 /// Whether the spin button should update always, or only when the value
1840 /// is acceptable.
1841 pub fn update_policy(self, update_policy: SpinButtonUpdatePolicy) -> Self {
1842 Self {
1843 builder: self.builder.property("update-policy", update_policy),
1844 }
1845 }
1846
1847 /// The current value.
1848 pub fn value(self, value: f64) -> Self {
1849 Self {
1850 builder: self.builder.property("value", value),
1851 }
1852 }
1853
1854 /// Whether a spin button should wrap upon reaching its limits.
1855 pub fn wrap(self, wrap: bool) -> Self {
1856 Self {
1857 builder: self.builder.property("wrap", wrap),
1858 }
1859 }
1860
1861 /// Whether the widget or any of its descendents can accept
1862 /// the input focus.
1863 ///
1864 /// This property is meant to be set by widget implementations,
1865 /// typically in their instance init function.
1866 pub fn can_focus(self, can_focus: bool) -> Self {
1867 Self {
1868 builder: self.builder.property("can-focus", can_focus),
1869 }
1870 }
1871
1872 /// Whether the widget can receive pointer events.
1873 pub fn can_target(self, can_target: bool) -> Self {
1874 Self {
1875 builder: self.builder.property("can-target", can_target),
1876 }
1877 }
1878
1879 /// A list of css classes applied to this widget.
1880 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1881 Self {
1882 builder: self.builder.property("css-classes", css_classes.into()),
1883 }
1884 }
1885
1886 /// The name of this widget in the CSS tree.
1887 ///
1888 /// This property is meant to be set by widget implementations,
1889 /// typically in their instance init function.
1890 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1891 Self {
1892 builder: self.builder.property("css-name", css_name.into()),
1893 }
1894 }
1895
1896 /// The cursor used by @widget.
1897 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1898 Self {
1899 builder: self.builder.property("cursor", cursor.clone()),
1900 }
1901 }
1902
1903 /// Whether the widget should grab focus when it is clicked with the mouse.
1904 ///
1905 /// This property is only relevant for widgets that can take focus.
1906 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1907 Self {
1908 builder: self.builder.property("focus-on-click", focus_on_click),
1909 }
1910 }
1911
1912 /// Whether this widget itself will accept the input focus.
1913 pub fn focusable(self, focusable: bool) -> Self {
1914 Self {
1915 builder: self.builder.property("focusable", focusable),
1916 }
1917 }
1918
1919 /// How to distribute horizontal space if widget gets extra space.
1920 pub fn halign(self, halign: Align) -> Self {
1921 Self {
1922 builder: self.builder.property("halign", halign),
1923 }
1924 }
1925
1926 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1927 /// signal on @widget.
1928 ///
1929 /// A true value indicates that @widget can have a tooltip, in this case
1930 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1931 /// determine whether it will provide a tooltip or not.
1932 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1933 Self {
1934 builder: self.builder.property("has-tooltip", has_tooltip),
1935 }
1936 }
1937
1938 /// Overrides for height request of the widget.
1939 ///
1940 /// If this is -1, the natural request will be used.
1941 pub fn height_request(self, height_request: i32) -> Self {
1942 Self {
1943 builder: self.builder.property("height-request", height_request),
1944 }
1945 }
1946
1947 /// Whether to expand horizontally.
1948 pub fn hexpand(self, hexpand: bool) -> Self {
1949 Self {
1950 builder: self.builder.property("hexpand", hexpand),
1951 }
1952 }
1953
1954 /// Whether to use the `hexpand` property.
1955 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1956 Self {
1957 builder: self.builder.property("hexpand-set", hexpand_set),
1958 }
1959 }
1960
1961 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1962 /// the preferred size of the widget, and allocate its children.
1963 ///
1964 /// This property is meant to be set by widget implementations,
1965 /// typically in their instance init function.
1966 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1967 Self {
1968 builder: self
1969 .builder
1970 .property("layout-manager", layout_manager.clone().upcast()),
1971 }
1972 }
1973
1974 /// Makes this widget act like a modal dialog, with respect to
1975 /// event delivery.
1976 ///
1977 /// Global event controllers will not handle events with targets
1978 /// inside the widget, unless they are set up to ignore propagation
1979 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1980 #[cfg(feature = "v4_18")]
1981 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1982 pub fn limit_events(self, limit_events: bool) -> Self {
1983 Self {
1984 builder: self.builder.property("limit-events", limit_events),
1985 }
1986 }
1987
1988 /// Margin on bottom side of widget.
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_bottom(self, margin_bottom: i32) -> Self {
1994 Self {
1995 builder: self.builder.property("margin-bottom", margin_bottom),
1996 }
1997 }
1998
1999 /// Margin on end of widget, horizontally.
2000 ///
2001 /// This property supports left-to-right and right-to-left text
2002 /// directions.
2003 ///
2004 /// This property adds margin outside of the widget's normal size
2005 /// request, the margin will be added in addition to the size from
2006 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2007 pub fn margin_end(self, margin_end: i32) -> Self {
2008 Self {
2009 builder: self.builder.property("margin-end", margin_end),
2010 }
2011 }
2012
2013 /// Margin on start of widget, horizontally.
2014 ///
2015 /// This property supports left-to-right and right-to-left text
2016 /// directions.
2017 ///
2018 /// This property adds margin outside of the widget's normal size
2019 /// request, the margin will be added in addition to the size from
2020 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2021 pub fn margin_start(self, margin_start: i32) -> Self {
2022 Self {
2023 builder: self.builder.property("margin-start", margin_start),
2024 }
2025 }
2026
2027 /// Margin on top side of widget.
2028 ///
2029 /// This property adds margin outside of the widget's normal size
2030 /// request, the margin will be added in addition to the size from
2031 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2032 pub fn margin_top(self, margin_top: i32) -> Self {
2033 Self {
2034 builder: self.builder.property("margin-top", margin_top),
2035 }
2036 }
2037
2038 /// The name of the widget.
2039 pub fn name(self, name: impl Into<glib::GString>) -> Self {
2040 Self {
2041 builder: self.builder.property("name", name.into()),
2042 }
2043 }
2044
2045 /// The requested opacity of the widget.
2046 pub fn opacity(self, opacity: f64) -> Self {
2047 Self {
2048 builder: self.builder.property("opacity", opacity),
2049 }
2050 }
2051
2052 /// How content outside the widget's content area is treated.
2053 ///
2054 /// This property is meant to be set by widget implementations,
2055 /// typically in their instance init function.
2056 pub fn overflow(self, overflow: Overflow) -> Self {
2057 Self {
2058 builder: self.builder.property("overflow", overflow),
2059 }
2060 }
2061
2062 /// Whether the widget will receive the default action when it is focused.
2063 pub fn receives_default(self, receives_default: bool) -> Self {
2064 Self {
2065 builder: self.builder.property("receives-default", receives_default),
2066 }
2067 }
2068
2069 /// Whether the widget responds to input.
2070 pub fn sensitive(self, sensitive: bool) -> Self {
2071 Self {
2072 builder: self.builder.property("sensitive", sensitive),
2073 }
2074 }
2075
2076 /// Sets the text of tooltip to be the given string, which is marked up
2077 /// with Pango markup.
2078 ///
2079 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
2080 ///
2081 /// This is a convenience property which will take care of getting the
2082 /// tooltip shown if the given string is not `NULL`:
2083 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2084 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2085 /// the default signal handler.
2086 ///
2087 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2088 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2089 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
2090 Self {
2091 builder: self
2092 .builder
2093 .property("tooltip-markup", tooltip_markup.into()),
2094 }
2095 }
2096
2097 /// Sets the text of tooltip to be the given string.
2098 ///
2099 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
2100 ///
2101 /// This is a convenience property which will take care of getting the
2102 /// tooltip shown if the given string is not `NULL`:
2103 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2104 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2105 /// the default signal handler.
2106 ///
2107 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2108 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2109 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
2110 Self {
2111 builder: self.builder.property("tooltip-text", tooltip_text.into()),
2112 }
2113 }
2114
2115 /// How to distribute vertical space if widget gets extra space.
2116 pub fn valign(self, valign: Align) -> Self {
2117 Self {
2118 builder: self.builder.property("valign", valign),
2119 }
2120 }
2121
2122 /// Whether to expand vertically.
2123 pub fn vexpand(self, vexpand: bool) -> Self {
2124 Self {
2125 builder: self.builder.property("vexpand", vexpand),
2126 }
2127 }
2128
2129 /// Whether to use the `vexpand` property.
2130 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
2131 Self {
2132 builder: self.builder.property("vexpand-set", vexpand_set),
2133 }
2134 }
2135
2136 /// Whether the widget is visible.
2137 pub fn visible(self, visible: bool) -> Self {
2138 Self {
2139 builder: self.builder.property("visible", visible),
2140 }
2141 }
2142
2143 /// Overrides for width request of the widget.
2144 ///
2145 /// If this is -1, the natural request will be used.
2146 pub fn width_request(self, width_request: i32) -> Self {
2147 Self {
2148 builder: self.builder.property("width-request", width_request),
2149 }
2150 }
2151
2152 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
2153 ///
2154 /// The accessible role cannot be changed once set.
2155 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
2156 Self {
2157 builder: self.builder.property("accessible-role", accessible_role),
2158 }
2159 }
2160
2161 /// Indicates whether editing on the cell has been canceled.
2162 pub fn editing_canceled(self, editing_canceled: bool) -> Self {
2163 Self {
2164 builder: self.builder.property("editing-canceled", editing_canceled),
2165 }
2166 }
2167
2168 /// Whether the entry contents can be edited.
2169 pub fn editable(self, editable: bool) -> Self {
2170 Self {
2171 builder: self.builder.property("editable", editable),
2172 }
2173 }
2174
2175 /// If undo/redo should be enabled for the editable.
2176 pub fn enable_undo(self, enable_undo: bool) -> Self {
2177 Self {
2178 builder: self.builder.property("enable-undo", enable_undo),
2179 }
2180 }
2181
2182 /// The desired maximum width of the entry, in characters.
2183 pub fn max_width_chars(self, max_width_chars: i32) -> Self {
2184 Self {
2185 builder: self.builder.property("max-width-chars", max_width_chars),
2186 }
2187 }
2188
2189 /// The contents of the entry.
2190 pub fn text(self, text: impl Into<glib::GString>) -> Self {
2191 Self {
2192 builder: self.builder.property("text", text.into()),
2193 }
2194 }
2195
2196 /// Number of characters to leave space for in the entry.
2197 pub fn width_chars(self, width_chars: i32) -> Self {
2198 Self {
2199 builder: self.builder.property("width-chars", width_chars),
2200 }
2201 }
2202
2203 /// The horizontal alignment, from 0 (left) to 1 (right).
2204 ///
2205 /// Reversed for RTL layouts.
2206 pub fn xalign(self, xalign: f32) -> Self {
2207 Self {
2208 builder: self.builder.property("xalign", xalign),
2209 }
2210 }
2211
2212 /// The orientation of the orientable.
2213 pub fn orientation(self, orientation: Orientation) -> Self {
2214 Self {
2215 builder: self.builder.property("orientation", orientation),
2216 }
2217 }
2218
2219 // rustdoc-stripper-ignore-next
2220 /// Build the [`SpinButton`].
2221 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
2222 pub fn build(self) -> SpinButton {
2223 assert_initialized_main_thread!();
2224 self.builder.build()
2225 }
2226}