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