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