gtk4/auto/range.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::{Adjustment, Buildable, ConstraintTarget, Orientable, ScrollType, Widget, ffi};
9use glib::{
10 object::ObjectType as _,
11 prelude::*,
12 signal::{SignalHandlerId, connect_raw},
13 translate::*,
14};
15use std::boxed::Box as Box_;
16
17#[cfg(feature = "v4_10")]
18#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
19glib::wrapper! {
20 /// key while
21 /// dragging, or initiating the drag with a long-press will enable the
22 /// fine-tuning mode.
23 ///
24 /// ## Properties
25 ///
26 ///
27 /// #### `adjustment`
28 /// The adjustment that is controlled by the range.
29 ///
30 /// Readable | Writable | Construct
31 ///
32 ///
33 /// #### `fill-level`
34 /// The fill level (e.g. prebuffering of a network stream).
35 ///
36 /// Readable | Writable
37 ///
38 ///
39 /// #### `inverted`
40 /// If [`true`], the direction in which the slider moves is inverted.
41 ///
42 /// Readable | Writable
43 ///
44 ///
45 /// #### `restrict-to-fill-level`
46 /// Controls whether slider movement is restricted to an
47 /// upper boundary set by the fill level.
48 ///
49 /// Readable | Writable
50 ///
51 ///
52 /// #### `round-digits`
53 /// The number of digits to round the value to when
54 /// it changes.
55 ///
56 /// See [`change-value`][struct@crate::Range#change-value].
57 ///
58 /// Readable | Writable
59 ///
60 ///
61 /// #### `show-fill-level`
62 /// Controls whether fill level indicator graphics are displayed
63 /// on the trough.
64 ///
65 /// Readable | Writable
66 /// <details><summary><h4>Widget</h4></summary>
67 ///
68 ///
69 /// #### `can-focus`
70 /// Whether the widget or any of its descendents can accept
71 /// the input focus.
72 ///
73 /// This property is meant to be set by widget implementations,
74 /// typically in their instance init function.
75 ///
76 /// Readable | Writable
77 ///
78 ///
79 /// #### `can-target`
80 /// Whether the widget can receive pointer events.
81 ///
82 /// Readable | Writable
83 ///
84 ///
85 /// #### `css-classes`
86 /// A list of css classes applied to this widget.
87 ///
88 /// Readable | Writable
89 ///
90 ///
91 /// #### `css-name`
92 /// The name of this widget in the CSS tree.
93 ///
94 /// This property is meant to be set by widget implementations,
95 /// typically in their instance init function.
96 ///
97 /// Readable | Writable | Construct Only
98 ///
99 ///
100 /// #### `cursor`
101 /// The cursor used by @widget.
102 ///
103 /// Readable | Writable
104 ///
105 ///
106 /// #### `focus-on-click`
107 /// Whether the widget should grab focus when it is clicked with the mouse.
108 ///
109 /// This property is only relevant for widgets that can take focus.
110 ///
111 /// Readable | Writable
112 ///
113 ///
114 /// #### `focusable`
115 /// Whether this widget itself will accept the input focus.
116 ///
117 /// Readable | Writable
118 ///
119 ///
120 /// #### `halign`
121 /// How to distribute horizontal space if widget gets extra space.
122 ///
123 /// Readable | Writable
124 ///
125 ///
126 /// #### `has-default`
127 /// Whether the widget is the default widget.
128 ///
129 /// Readable
130 ///
131 ///
132 /// #### `has-focus`
133 /// Whether the widget has the input focus.
134 ///
135 /// Readable
136 ///
137 ///
138 /// #### `has-tooltip`
139 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
140 /// signal on @widget.
141 ///
142 /// A true value indicates that @widget can have a tooltip, in this case
143 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
144 /// determine whether it will provide a tooltip or not.
145 ///
146 /// Readable | Writable
147 ///
148 ///
149 /// #### `height-request`
150 /// Overrides for height request of the widget.
151 ///
152 /// If this is -1, the natural request will be used.
153 ///
154 /// Readable | Writable
155 ///
156 ///
157 /// #### `hexpand`
158 /// Whether to expand horizontally.
159 ///
160 /// Readable | Writable
161 ///
162 ///
163 /// #### `hexpand-set`
164 /// Whether to use the `hexpand` property.
165 ///
166 /// Readable | Writable
167 ///
168 ///
169 /// #### `layout-manager`
170 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
171 /// the preferred size of the widget, and allocate its children.
172 ///
173 /// This property is meant to be set by widget implementations,
174 /// typically in their instance init function.
175 ///
176 /// Readable | Writable
177 ///
178 ///
179 /// #### `limit-events`
180 /// Makes this widget act like a modal dialog, with respect to
181 /// event delivery.
182 ///
183 /// Global event controllers will not handle events with targets
184 /// inside the widget, unless they are set up to ignore propagation
185 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
186 ///
187 /// Readable | Writable
188 ///
189 ///
190 /// #### `margin-bottom`
191 /// Margin on bottom side of widget.
192 ///
193 /// This property adds margin outside of the widget's normal size
194 /// request, the margin will be added in addition to the size from
195 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
196 ///
197 /// Readable | Writable
198 ///
199 ///
200 /// #### `margin-end`
201 /// Margin on end of widget, horizontally.
202 ///
203 /// This property supports left-to-right and right-to-left text
204 /// directions.
205 ///
206 /// This property adds margin outside of the widget's normal size
207 /// request, the margin will be added in addition to the size from
208 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
209 ///
210 /// Readable | Writable
211 ///
212 ///
213 /// #### `margin-start`
214 /// Margin on start of widget, horizontally.
215 ///
216 /// This property supports left-to-right and right-to-left text
217 /// directions.
218 ///
219 /// This property adds margin outside of the widget's normal size
220 /// request, the margin will be added in addition to the size from
221 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
222 ///
223 /// Readable | Writable
224 ///
225 ///
226 /// #### `margin-top`
227 /// Margin on top side of widget.
228 ///
229 /// This property adds margin outside of the widget's normal size
230 /// request, the margin will be added in addition to the size from
231 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
232 ///
233 /// Readable | Writable
234 ///
235 ///
236 /// #### `name`
237 /// The name of the widget.
238 ///
239 /// Readable | Writable
240 ///
241 ///
242 /// #### `opacity`
243 /// The requested opacity of the widget.
244 ///
245 /// Readable | Writable
246 ///
247 ///
248 /// #### `overflow`
249 /// How content outside the widget's content area is treated.
250 ///
251 /// This property is meant to be set by widget implementations,
252 /// typically in their instance init function.
253 ///
254 /// Readable | Writable
255 ///
256 ///
257 /// #### `parent`
258 /// The parent widget of this widget.
259 ///
260 /// Readable
261 ///
262 ///
263 /// #### `receives-default`
264 /// Whether the widget will receive the default action when it is focused.
265 ///
266 /// Readable | Writable
267 ///
268 ///
269 /// #### `root`
270 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
271 ///
272 /// This will be `NULL` if the widget is not contained in a root widget.
273 ///
274 /// Readable
275 ///
276 ///
277 /// #### `scale-factor`
278 /// The scale factor of the widget.
279 ///
280 /// Readable
281 ///
282 ///
283 /// #### `sensitive`
284 /// Whether the widget responds to input.
285 ///
286 /// Readable | Writable
287 ///
288 ///
289 /// #### `tooltip-markup`
290 /// Sets the text of tooltip to be the given string, which is marked up
291 /// with Pango markup.
292 ///
293 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
294 ///
295 /// This is a convenience property which will take care of getting the
296 /// tooltip shown if the given string is not `NULL`:
297 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
298 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
299 /// the default signal handler.
300 ///
301 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
302 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
303 ///
304 /// Readable | Writable
305 ///
306 ///
307 /// #### `tooltip-text`
308 /// Sets the text of tooltip to be the given string.
309 ///
310 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
311 ///
312 /// This is a convenience property which will take care of getting the
313 /// tooltip shown if the given string is not `NULL`:
314 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
315 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
316 /// the default signal handler.
317 ///
318 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
319 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
320 ///
321 /// Readable | Writable
322 ///
323 ///
324 /// #### `valign`
325 /// How to distribute vertical space if widget gets extra space.
326 ///
327 /// Readable | Writable
328 ///
329 ///
330 /// #### `vexpand`
331 /// Whether to expand vertically.
332 ///
333 /// Readable | Writable
334 ///
335 ///
336 /// #### `vexpand-set`
337 /// Whether to use the `vexpand` property.
338 ///
339 /// Readable | Writable
340 ///
341 ///
342 /// #### `visible`
343 /// Whether the widget is visible.
344 ///
345 /// Readable | Writable
346 ///
347 ///
348 /// #### `width-request`
349 /// Overrides for width request of the widget.
350 ///
351 /// If this is -1, the natural request will be used.
352 ///
353 /// Readable | Writable
354 /// </details>
355 /// <details><summary><h4>Accessible</h4></summary>
356 ///
357 ///
358 /// #### `accessible-role`
359 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
360 ///
361 /// The accessible role cannot be changed once set.
362 ///
363 /// Readable | Writable
364 /// </details>
365 /// <details><summary><h4>Orientable</h4></summary>
366 ///
367 ///
368 /// #### `orientation`
369 /// The orientation of the orientable.
370 ///
371 /// Readable | Writable
372 /// </details>
373 ///
374 /// ## Signals
375 ///
376 ///
377 /// #### `adjust-bounds`
378 /// Emitted before clamping a value, to give the application a
379 /// chance to adjust the bounds.
380 ///
381 ///
382 ///
383 ///
384 /// #### `change-value`
385 /// Emitted when a scroll action is performed on a range.
386 ///
387 /// It allows an application to determine the type of scroll event
388 /// that occurred and the resultant new value. The application can
389 /// handle the event itself and return [`true`] to prevent further
390 /// processing. Or, by returning [`false`], it can pass the event to
391 /// other handlers until the default GTK handler is reached.
392 ///
393 /// The value parameter is unrounded. An application that overrides
394 /// the ::change-value signal is responsible for clamping the value
395 /// to the desired number of decimal digits; the default GTK
396 /// handler clamps the value based on [`round-digits`][struct@crate::Range#round-digits].
397 ///
398 ///
399 ///
400 ///
401 /// #### `move-slider`
402 /// Virtual function that moves the slider.
403 ///
404 /// Used for keybindings.
405 ///
406 /// Action
407 ///
408 ///
409 /// #### `value-changed`
410 /// Emitted when the range value changes.
411 ///
412 ///
413 /// <details><summary><h4>Widget</h4></summary>
414 ///
415 ///
416 /// #### `destroy`
417 /// Signals that all holders of a reference to the widget should release
418 /// the reference that they hold.
419 ///
420 /// May result in finalization of the widget if all references are released.
421 ///
422 /// This signal is not suitable for saving widget state.
423 ///
424 ///
425 ///
426 ///
427 /// #### `direction-changed`
428 /// Emitted when the text direction of a widget changes.
429 ///
430 ///
431 ///
432 ///
433 /// #### `hide`
434 /// Emitted when @widget is hidden.
435 ///
436 ///
437 ///
438 ///
439 /// #### `keynav-failed`
440 /// Emitted if keyboard navigation fails.
441 ///
442 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
443 ///
444 ///
445 ///
446 ///
447 /// #### `map`
448 /// Emitted when @widget is going to be mapped.
449 ///
450 /// A widget is mapped when the widget is visible (which is controlled with
451 /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
452 /// are also visible.
453 ///
454 /// The `::map` signal can be used to determine whether a widget will be drawn,
455 /// for instance it can resume an animation that was stopped during the
456 /// emission of [`unmap`][struct@crate::Widget#unmap].
457 ///
458 ///
459 ///
460 ///
461 /// #### `mnemonic-activate`
462 /// Emitted when a widget is activated via a mnemonic.
463 ///
464 /// The default handler for this signal activates @widget if @group_cycling
465 /// is false, or just makes @widget grab focus if @group_cycling is true.
466 ///
467 ///
468 ///
469 ///
470 /// #### `move-focus`
471 /// to move backward.
472 ///
473 /// Action
474 ///
475 ///
476 /// #### `query-tooltip`
477 /// Emitted when the widget’s tooltip is about to be shown.
478 ///
479 /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
480 /// is true and the hover timeout has expired with the cursor hovering
481 /// above @widget; or emitted when @widget got focus in keyboard mode.
482 ///
483 /// Using the given coordinates, the signal handler should determine
484 /// whether a tooltip should be shown for @widget. If this is the case
485 /// true should be returned, false otherwise. Note that if @keyboard_mode
486 /// is true, the values of @x and @y are undefined and should not be used.
487 ///
488 /// The signal handler is free to manipulate @tooltip with the therefore
489 /// destined function calls.
490 ///
491 ///
492 ///
493 ///
494 /// #### `realize`
495 /// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
496 ///
497 /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
498 /// or the widget has been mapped (that is, it is going to be drawn).
499 ///
500 ///
501 ///
502 ///
503 /// #### `show`
504 /// Emitted when @widget is shown.
505 ///
506 ///
507 ///
508 ///
509 /// #### `state-flags-changed`
510 /// Emitted when the widget state changes.
511 ///
512 /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
513 ///
514 ///
515 ///
516 ///
517 /// #### `unmap`
518 /// Emitted when @widget is going to be unmapped.
519 ///
520 /// A widget is unmapped when either it or any of its parents up to the
521 /// toplevel widget have been set as hidden.
522 ///
523 /// As `::unmap` indicates that a widget will not be shown any longer,
524 /// it can be used to, for example, stop an animation on the widget.
525 ///
526 ///
527 ///
528 ///
529 /// #### `unrealize`
530 /// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
531 ///
532 /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
533 /// or the widget has been unmapped (that is, it is going to be hidden).
534 ///
535 ///
536 /// </details>
537 ///
538 /// # Implements
539 ///
540 /// [`RangeExt`][trait@crate::prelude::RangeExt], [`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], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
541 #[doc(alias = "GtkRange")]
542 pub struct Range(Object<ffi::GtkRange, ffi::GtkRangeClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, AccessibleRange, Orientable;
543
544 match fn {
545 type_ => || ffi::gtk_range_get_type(),
546 }
547}
548
549#[cfg(not(feature = "v4_10"))]
550glib::wrapper! {
551 #[doc(alias = "GtkRange")]
552 pub struct Range(Object<ffi::GtkRange, ffi::GtkRangeClass>) @extends Widget, @implements Buildable, ConstraintTarget, Orientable;
553
554 match fn {
555 type_ => || ffi::gtk_range_get_type(),
556 }
557}
558
559impl Range {
560 pub const NONE: Option<&'static Range> = None;
561}
562
563/// Trait containing all [`struct@Range`] methods.
564///
565/// # Implementors
566///
567/// [`Range`][struct@crate::Range], [`Scale`][struct@crate::Scale]
568pub trait RangeExt: IsA<Range> + 'static {
569 /// Get the adjustment which is the “model” object for [`Range`][crate::Range].
570 ///
571 /// # Returns
572 ///
573 /// a [`Adjustment`][crate::Adjustment]
574 #[doc(alias = "gtk_range_get_adjustment")]
575 #[doc(alias = "get_adjustment")]
576 fn adjustment(&self) -> Adjustment {
577 unsafe {
578 from_glib_none(ffi::gtk_range_get_adjustment(
579 self.as_ref().to_glib_none().0,
580 ))
581 }
582 }
583
584 /// Gets the current position of the fill level indicator.
585 ///
586 /// # Returns
587 ///
588 /// The current fill level
589 #[doc(alias = "gtk_range_get_fill_level")]
590 #[doc(alias = "get_fill_level")]
591 #[doc(alias = "fill-level")]
592 fn fill_level(&self) -> f64 {
593 unsafe { ffi::gtk_range_get_fill_level(self.as_ref().to_glib_none().0) }
594 }
595
596 /// Gets whether the [`Range`][crate::Range] respects text direction.
597 ///
598 /// See [`set_flippable()`][Self::set_flippable()].
599 ///
600 /// # Returns
601 ///
602 /// [`true`] if the range is flippable
603 #[doc(alias = "gtk_range_get_flippable")]
604 #[doc(alias = "get_flippable")]
605 fn is_flippable(&self) -> bool {
606 unsafe { from_glib(ffi::gtk_range_get_flippable(self.as_ref().to_glib_none().0)) }
607 }
608
609 /// Gets whether the range is inverted.
610 ///
611 /// See [`set_inverted()`][Self::set_inverted()].
612 ///
613 /// # Returns
614 ///
615 /// [`true`] if the range is inverted
616 #[doc(alias = "gtk_range_get_inverted")]
617 #[doc(alias = "get_inverted")]
618 #[doc(alias = "inverted")]
619 fn is_inverted(&self) -> bool {
620 unsafe { from_glib(ffi::gtk_range_get_inverted(self.as_ref().to_glib_none().0)) }
621 }
622
623 /// This function returns the area that contains the range’s trough,
624 /// in coordinates relative to @self's origin.
625 ///
626 /// This function is useful mainly for [`Range`][crate::Range] subclasses.
627 ///
628 /// # Returns
629 ///
630 ///
631 /// ## `range_rect`
632 /// return location for the range rectangle
633 #[doc(alias = "gtk_range_get_range_rect")]
634 #[doc(alias = "get_range_rect")]
635 fn range_rect(&self) -> gdk::Rectangle {
636 unsafe {
637 let mut range_rect = gdk::Rectangle::uninitialized();
638 ffi::gtk_range_get_range_rect(
639 self.as_ref().to_glib_none().0,
640 range_rect.to_glib_none_mut().0,
641 );
642 range_rect
643 }
644 }
645
646 /// Gets whether the range is restricted to the fill level.
647 ///
648 /// # Returns
649 ///
650 /// [`true`] if @self is restricted to the fill level.
651 #[doc(alias = "gtk_range_get_restrict_to_fill_level")]
652 #[doc(alias = "get_restrict_to_fill_level")]
653 #[doc(alias = "restrict-to-fill-level")]
654 fn restricts_to_fill_level(&self) -> bool {
655 unsafe {
656 from_glib(ffi::gtk_range_get_restrict_to_fill_level(
657 self.as_ref().to_glib_none().0,
658 ))
659 }
660 }
661
662 /// Gets the number of digits to round the value to when
663 /// it changes.
664 ///
665 /// See [`change-value`][struct@crate::Range#change-value].
666 ///
667 /// # Returns
668 ///
669 /// the number of digits to round to
670 #[doc(alias = "gtk_range_get_round_digits")]
671 #[doc(alias = "get_round_digits")]
672 #[doc(alias = "round-digits")]
673 fn round_digits(&self) -> i32 {
674 unsafe { ffi::gtk_range_get_round_digits(self.as_ref().to_glib_none().0) }
675 }
676
677 /// Gets whether the range displays the fill level graphically.
678 ///
679 /// # Returns
680 ///
681 /// [`true`] if @self shows the fill level.
682 #[doc(alias = "gtk_range_get_show_fill_level")]
683 #[doc(alias = "get_show_fill_level")]
684 #[doc(alias = "show-fill-level")]
685 fn shows_fill_level(&self) -> bool {
686 unsafe {
687 from_glib(ffi::gtk_range_get_show_fill_level(
688 self.as_ref().to_glib_none().0,
689 ))
690 }
691 }
692
693 /// window coordinates.
694 ///
695 /// This function is useful mainly for [`Range`][crate::Range] subclasses.
696 ///
697 /// # Returns
698 ///
699 ///
700 /// ## `slider_start`
701 /// return location for the slider's start
702 ///
703 /// ## `slider_end`
704 /// return location for the slider's end
705 #[doc(alias = "gtk_range_get_slider_range")]
706 #[doc(alias = "get_slider_range")]
707 fn slider_range(&self) -> (i32, i32) {
708 unsafe {
709 let mut slider_start = std::mem::MaybeUninit::uninit();
710 let mut slider_end = std::mem::MaybeUninit::uninit();
711 ffi::gtk_range_get_slider_range(
712 self.as_ref().to_glib_none().0,
713 slider_start.as_mut_ptr(),
714 slider_end.as_mut_ptr(),
715 );
716 (slider_start.assume_init(), slider_end.assume_init())
717 }
718 }
719
720 /// This function is useful mainly for [`Range`][crate::Range] subclasses.
721 ///
722 /// See [`set_slider_size_fixed()`][Self::set_slider_size_fixed()].
723 ///
724 /// # Returns
725 ///
726 /// whether the range’s slider has a fixed size.
727 #[doc(alias = "gtk_range_get_slider_size_fixed")]
728 #[doc(alias = "get_slider_size_fixed")]
729 fn is_slider_size_fixed(&self) -> bool {
730 unsafe {
731 from_glib(ffi::gtk_range_get_slider_size_fixed(
732 self.as_ref().to_glib_none().0,
733 ))
734 }
735 }
736
737 /// Gets the current value of the range.
738 ///
739 /// # Returns
740 ///
741 /// current value of the range.
742 #[doc(alias = "gtk_range_get_value")]
743 #[doc(alias = "get_value")]
744 fn value(&self) -> f64 {
745 unsafe { ffi::gtk_range_get_value(self.as_ref().to_glib_none().0) }
746 }
747
748 /// Sets the adjustment to be used as the “model” object for the [`Range`][crate::Range]
749 ///
750 /// The adjustment indicates the current range value, the minimum and
751 /// maximum range values, the step/page increments used for keybindings
752 /// and scrolling, and the page size.
753 ///
754 /// The page size is normally 0 for [`Scale`][crate::Scale] and nonzero for [`Scrollbar`][crate::Scrollbar],
755 /// and indicates the size of the visible area of the widget being scrolled.
756 /// The page size affects the size of the scrollbar slider.
757 /// ## `adjustment`
758 /// a [`Adjustment`][crate::Adjustment]
759 #[doc(alias = "gtk_range_set_adjustment")]
760 #[doc(alias = "adjustment")]
761 fn set_adjustment(&self, adjustment: &impl IsA<Adjustment>) {
762 unsafe {
763 ffi::gtk_range_set_adjustment(
764 self.as_ref().to_glib_none().0,
765 adjustment.as_ref().to_glib_none().0,
766 );
767 }
768 }
769
770 /// Set the new position of the fill level indicator.
771 ///
772 /// The “fill level” is probably best described by its most prominent
773 /// use case, which is an indicator for the amount of pre-buffering in
774 /// a streaming media player. In that use case, the value of the range
775 /// would indicate the current play position, and the fill level would
776 /// be the position up to which the file/stream has been downloaded.
777 ///
778 /// This amount of prebuffering can be displayed on the range’s trough
779 /// and is themeable separately from the trough. To enable fill level
780 /// display, use [`set_show_fill_level()`][Self::set_show_fill_level()]. The range defaults
781 /// to not showing the fill level.
782 ///
783 /// Additionally, it’s possible to restrict the range’s slider position
784 /// to values which are smaller than the fill level. This is controlled
785 /// by [`set_restrict_to_fill_level()`][Self::set_restrict_to_fill_level()] and is by default
786 /// enabled.
787 /// ## `fill_level`
788 /// the new position of the fill level indicator
789 #[doc(alias = "gtk_range_set_fill_level")]
790 #[doc(alias = "fill-level")]
791 fn set_fill_level(&self, fill_level: f64) {
792 unsafe {
793 ffi::gtk_range_set_fill_level(self.as_ref().to_glib_none().0, fill_level);
794 }
795 }
796
797 /// Sets whether the [`Range`][crate::Range] respects text direction.
798 ///
799 /// If a range is flippable, it will switch its direction
800 /// if it is horizontal and its direction is [`TextDirection::Rtl`][crate::TextDirection::Rtl].
801 ///
802 /// See [`WidgetExt::direction()`][crate::prelude::WidgetExt::direction()].
803 /// ## `flippable`
804 /// [`true`] to make the range flippable
805 #[doc(alias = "gtk_range_set_flippable")]
806 fn set_flippable(&self, flippable: bool) {
807 unsafe {
808 ffi::gtk_range_set_flippable(self.as_ref().to_glib_none().0, flippable.into_glib());
809 }
810 }
811
812 /// Sets the step and page sizes for the range.
813 ///
814 /// The step size is used when the user clicks the [`Scrollbar`][crate::Scrollbar]
815 /// arrows or moves a [`Scale`][crate::Scale] via arrow keys. The page size
816 /// is used for example when moving via Page Up or Page Down keys.
817 /// ## `step`
818 /// step size
819 /// ## `page`
820 /// page size
821 #[doc(alias = "gtk_range_set_increments")]
822 fn set_increments(&self, step: f64, page: f64) {
823 unsafe {
824 ffi::gtk_range_set_increments(self.as_ref().to_glib_none().0, step, page);
825 }
826 }
827
828 /// Sets whether to invert the range.
829 ///
830 /// Ranges normally move from lower to higher values as the
831 /// slider moves from top to bottom or left to right. Inverted
832 /// ranges have higher values at the top or on the right rather
833 /// than on the bottom or left.
834 /// ## `setting`
835 /// [`true`] to invert the range
836 #[doc(alias = "gtk_range_set_inverted")]
837 #[doc(alias = "inverted")]
838 fn set_inverted(&self, setting: bool) {
839 unsafe {
840 ffi::gtk_range_set_inverted(self.as_ref().to_glib_none().0, setting.into_glib());
841 }
842 }
843
844 /// Sets the allowable values in the [`Range`][crate::Range].
845 ///
846 /// The range value is clamped to be between @min and @max.
847 /// (If the range has a non-zero page size, it is clamped
848 /// between @min and @max - page-size.)
849 /// ## `min`
850 /// minimum range value
851 /// ## `max`
852 /// maximum range value
853 #[doc(alias = "gtk_range_set_range")]
854 fn set_range(&self, min: f64, max: f64) {
855 unsafe {
856 ffi::gtk_range_set_range(self.as_ref().to_glib_none().0, min, max);
857 }
858 }
859
860 /// Sets whether the slider is restricted to the fill level.
861 ///
862 /// See [`set_fill_level()`][Self::set_fill_level()] for a general description
863 /// of the fill level concept.
864 /// ## `restrict_to_fill_level`
865 /// Whether the fill level restricts slider movement.
866 #[doc(alias = "gtk_range_set_restrict_to_fill_level")]
867 #[doc(alias = "restrict-to-fill-level")]
868 fn set_restrict_to_fill_level(&self, restrict_to_fill_level: bool) {
869 unsafe {
870 ffi::gtk_range_set_restrict_to_fill_level(
871 self.as_ref().to_glib_none().0,
872 restrict_to_fill_level.into_glib(),
873 );
874 }
875 }
876
877 /// Sets the number of digits to round the value to when
878 /// it changes.
879 ///
880 /// See [`change-value`][struct@crate::Range#change-value].
881 /// ## `round_digits`
882 /// the precision in digits, or -1
883 #[doc(alias = "gtk_range_set_round_digits")]
884 #[doc(alias = "round-digits")]
885 fn set_round_digits(&self, round_digits: i32) {
886 unsafe {
887 ffi::gtk_range_set_round_digits(self.as_ref().to_glib_none().0, round_digits);
888 }
889 }
890
891 /// Sets whether a graphical fill level is show on the trough.
892 ///
893 /// See [`set_fill_level()`][Self::set_fill_level()] for a general description
894 /// of the fill level concept.
895 /// ## `show_fill_level`
896 /// Whether a fill level indicator graphics is shown.
897 #[doc(alias = "gtk_range_set_show_fill_level")]
898 #[doc(alias = "show-fill-level")]
899 fn set_show_fill_level(&self, show_fill_level: bool) {
900 unsafe {
901 ffi::gtk_range_set_show_fill_level(
902 self.as_ref().to_glib_none().0,
903 show_fill_level.into_glib(),
904 );
905 }
906 }
907
908 /// Sets whether the range’s slider has a fixed size, or a size that
909 /// depends on its adjustment’s page size.
910 ///
911 /// This function is useful mainly for [`Range`][crate::Range] subclasses.
912 /// ## `size_fixed`
913 /// [`true`] to make the slider size constant
914 #[doc(alias = "gtk_range_set_slider_size_fixed")]
915 fn set_slider_size_fixed(&self, size_fixed: bool) {
916 unsafe {
917 ffi::gtk_range_set_slider_size_fixed(
918 self.as_ref().to_glib_none().0,
919 size_fixed.into_glib(),
920 );
921 }
922 }
923
924 /// Sets the current value of the range.
925 ///
926 /// If the value is outside the minimum or maximum range values,
927 /// it will be clamped to fit inside them. The range emits the
928 /// [`value-changed`][struct@crate::Range#value-changed] signal if the value changes.
929 /// ## `value`
930 /// new value of the range
931 #[doc(alias = "gtk_range_set_value")]
932 fn set_value(&self, value: f64) {
933 unsafe {
934 ffi::gtk_range_set_value(self.as_ref().to_glib_none().0, value);
935 }
936 }
937
938 /// Emitted before clamping a value, to give the application a
939 /// chance to adjust the bounds.
940 /// ## `value`
941 /// the value before we clamp
942 #[doc(alias = "adjust-bounds")]
943 fn connect_adjust_bounds<F: Fn(&Self, f64) + 'static>(&self, f: F) -> SignalHandlerId {
944 unsafe extern "C" fn adjust_bounds_trampoline<P: IsA<Range>, F: Fn(&P, f64) + 'static>(
945 this: *mut ffi::GtkRange,
946 value: std::ffi::c_double,
947 f: glib::ffi::gpointer,
948 ) {
949 unsafe {
950 let f: &F = &*(f as *const F);
951 f(Range::from_glib_borrow(this).unsafe_cast_ref(), value)
952 }
953 }
954 unsafe {
955 let f: Box_<F> = Box_::new(f);
956 connect_raw(
957 self.as_ptr() as *mut _,
958 c"adjust-bounds".as_ptr(),
959 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
960 adjust_bounds_trampoline::<Self, F> as *const (),
961 )),
962 Box_::into_raw(f),
963 )
964 }
965 }
966
967 /// Emitted when a scroll action is performed on a range.
968 ///
969 /// It allows an application to determine the type of scroll event
970 /// that occurred and the resultant new value. The application can
971 /// handle the event itself and return [`true`] to prevent further
972 /// processing. Or, by returning [`false`], it can pass the event to
973 /// other handlers until the default GTK handler is reached.
974 ///
975 /// The value parameter is unrounded. An application that overrides
976 /// the ::change-value signal is responsible for clamping the value
977 /// to the desired number of decimal digits; the default GTK
978 /// handler clamps the value based on [`round-digits`][struct@crate::Range#round-digits].
979 /// ## `scroll`
980 /// the type of scroll action that was performed
981 /// ## `value`
982 /// the new value resulting from the scroll action
983 ///
984 /// # Returns
985 ///
986 /// [`true`] to prevent other handlers from being invoked for
987 /// the signal, [`false`] to propagate the signal further
988 #[doc(alias = "change-value")]
989 fn connect_change_value<F: Fn(&Self, ScrollType, f64) -> glib::Propagation + 'static>(
990 &self,
991 f: F,
992 ) -> SignalHandlerId {
993 unsafe extern "C" fn change_value_trampoline<
994 P: IsA<Range>,
995 F: Fn(&P, ScrollType, f64) -> glib::Propagation + 'static,
996 >(
997 this: *mut ffi::GtkRange,
998 scroll: ffi::GtkScrollType,
999 value: std::ffi::c_double,
1000 f: glib::ffi::gpointer,
1001 ) -> glib::ffi::gboolean {
1002 unsafe {
1003 let f: &F = &*(f as *const F);
1004 f(
1005 Range::from_glib_borrow(this).unsafe_cast_ref(),
1006 from_glib(scroll),
1007 value,
1008 )
1009 .into_glib()
1010 }
1011 }
1012 unsafe {
1013 let f: Box_<F> = Box_::new(f);
1014 connect_raw(
1015 self.as_ptr() as *mut _,
1016 c"change-value".as_ptr(),
1017 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1018 change_value_trampoline::<Self, F> as *const (),
1019 )),
1020 Box_::into_raw(f),
1021 )
1022 }
1023 }
1024
1025 /// Virtual function that moves the slider.
1026 ///
1027 /// Used for keybindings.
1028 /// ## `step`
1029 /// how to move the slider
1030 #[doc(alias = "move-slider")]
1031 fn connect_move_slider<F: Fn(&Self, ScrollType) + 'static>(&self, f: F) -> SignalHandlerId {
1032 unsafe extern "C" fn move_slider_trampoline<
1033 P: IsA<Range>,
1034 F: Fn(&P, ScrollType) + 'static,
1035 >(
1036 this: *mut ffi::GtkRange,
1037 step: ffi::GtkScrollType,
1038 f: glib::ffi::gpointer,
1039 ) {
1040 unsafe {
1041 let f: &F = &*(f as *const F);
1042 f(
1043 Range::from_glib_borrow(this).unsafe_cast_ref(),
1044 from_glib(step),
1045 )
1046 }
1047 }
1048 unsafe {
1049 let f: Box_<F> = Box_::new(f);
1050 connect_raw(
1051 self.as_ptr() as *mut _,
1052 c"move-slider".as_ptr(),
1053 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1054 move_slider_trampoline::<Self, F> as *const (),
1055 )),
1056 Box_::into_raw(f),
1057 )
1058 }
1059 }
1060
1061 fn emit_move_slider(&self, step: ScrollType) {
1062 self.emit_by_name::<()>("move-slider", &[&step]);
1063 }
1064
1065 /// Emitted when the range value changes.
1066 #[doc(alias = "value-changed")]
1067 fn connect_value_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1068 unsafe extern "C" fn value_changed_trampoline<P: IsA<Range>, F: Fn(&P) + 'static>(
1069 this: *mut ffi::GtkRange,
1070 f: glib::ffi::gpointer,
1071 ) {
1072 unsafe {
1073 let f: &F = &*(f as *const F);
1074 f(Range::from_glib_borrow(this).unsafe_cast_ref())
1075 }
1076 }
1077 unsafe {
1078 let f: Box_<F> = Box_::new(f);
1079 connect_raw(
1080 self.as_ptr() as *mut _,
1081 c"value-changed".as_ptr(),
1082 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1083 value_changed_trampoline::<Self, F> as *const (),
1084 )),
1085 Box_::into_raw(f),
1086 )
1087 }
1088 }
1089
1090 #[doc(alias = "adjustment")]
1091 fn connect_adjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1092 unsafe extern "C" fn notify_adjustment_trampoline<P: IsA<Range>, F: Fn(&P) + 'static>(
1093 this: *mut ffi::GtkRange,
1094 _param_spec: glib::ffi::gpointer,
1095 f: glib::ffi::gpointer,
1096 ) {
1097 unsafe {
1098 let f: &F = &*(f as *const F);
1099 f(Range::from_glib_borrow(this).unsafe_cast_ref())
1100 }
1101 }
1102 unsafe {
1103 let f: Box_<F> = Box_::new(f);
1104 connect_raw(
1105 self.as_ptr() as *mut _,
1106 c"notify::adjustment".as_ptr(),
1107 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1108 notify_adjustment_trampoline::<Self, F> as *const (),
1109 )),
1110 Box_::into_raw(f),
1111 )
1112 }
1113 }
1114
1115 #[doc(alias = "fill-level")]
1116 fn connect_fill_level_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1117 unsafe extern "C" fn notify_fill_level_trampoline<P: IsA<Range>, F: Fn(&P) + 'static>(
1118 this: *mut ffi::GtkRange,
1119 _param_spec: glib::ffi::gpointer,
1120 f: glib::ffi::gpointer,
1121 ) {
1122 unsafe {
1123 let f: &F = &*(f as *const F);
1124 f(Range::from_glib_borrow(this).unsafe_cast_ref())
1125 }
1126 }
1127 unsafe {
1128 let f: Box_<F> = Box_::new(f);
1129 connect_raw(
1130 self.as_ptr() as *mut _,
1131 c"notify::fill-level".as_ptr(),
1132 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1133 notify_fill_level_trampoline::<Self, F> as *const (),
1134 )),
1135 Box_::into_raw(f),
1136 )
1137 }
1138 }
1139
1140 #[doc(alias = "inverted")]
1141 fn connect_inverted_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1142 unsafe extern "C" fn notify_inverted_trampoline<P: IsA<Range>, F: Fn(&P) + 'static>(
1143 this: *mut ffi::GtkRange,
1144 _param_spec: glib::ffi::gpointer,
1145 f: glib::ffi::gpointer,
1146 ) {
1147 unsafe {
1148 let f: &F = &*(f as *const F);
1149 f(Range::from_glib_borrow(this).unsafe_cast_ref())
1150 }
1151 }
1152 unsafe {
1153 let f: Box_<F> = Box_::new(f);
1154 connect_raw(
1155 self.as_ptr() as *mut _,
1156 c"notify::inverted".as_ptr(),
1157 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1158 notify_inverted_trampoline::<Self, F> as *const (),
1159 )),
1160 Box_::into_raw(f),
1161 )
1162 }
1163 }
1164
1165 #[doc(alias = "restrict-to-fill-level")]
1166 fn connect_restrict_to_fill_level_notify<F: Fn(&Self) + 'static>(
1167 &self,
1168 f: F,
1169 ) -> SignalHandlerId {
1170 unsafe extern "C" fn notify_restrict_to_fill_level_trampoline<
1171 P: IsA<Range>,
1172 F: Fn(&P) + 'static,
1173 >(
1174 this: *mut ffi::GtkRange,
1175 _param_spec: glib::ffi::gpointer,
1176 f: glib::ffi::gpointer,
1177 ) {
1178 unsafe {
1179 let f: &F = &*(f as *const F);
1180 f(Range::from_glib_borrow(this).unsafe_cast_ref())
1181 }
1182 }
1183 unsafe {
1184 let f: Box_<F> = Box_::new(f);
1185 connect_raw(
1186 self.as_ptr() as *mut _,
1187 c"notify::restrict-to-fill-level".as_ptr(),
1188 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1189 notify_restrict_to_fill_level_trampoline::<Self, F> as *const (),
1190 )),
1191 Box_::into_raw(f),
1192 )
1193 }
1194 }
1195
1196 #[doc(alias = "round-digits")]
1197 fn connect_round_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1198 unsafe extern "C" fn notify_round_digits_trampoline<P: IsA<Range>, F: Fn(&P) + 'static>(
1199 this: *mut ffi::GtkRange,
1200 _param_spec: glib::ffi::gpointer,
1201 f: glib::ffi::gpointer,
1202 ) {
1203 unsafe {
1204 let f: &F = &*(f as *const F);
1205 f(Range::from_glib_borrow(this).unsafe_cast_ref())
1206 }
1207 }
1208 unsafe {
1209 let f: Box_<F> = Box_::new(f);
1210 connect_raw(
1211 self.as_ptr() as *mut _,
1212 c"notify::round-digits".as_ptr(),
1213 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1214 notify_round_digits_trampoline::<Self, F> as *const (),
1215 )),
1216 Box_::into_raw(f),
1217 )
1218 }
1219 }
1220
1221 #[doc(alias = "show-fill-level")]
1222 fn connect_show_fill_level_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1223 unsafe extern "C" fn notify_show_fill_level_trampoline<
1224 P: IsA<Range>,
1225 F: Fn(&P) + 'static,
1226 >(
1227 this: *mut ffi::GtkRange,
1228 _param_spec: glib::ffi::gpointer,
1229 f: glib::ffi::gpointer,
1230 ) {
1231 unsafe {
1232 let f: &F = &*(f as *const F);
1233 f(Range::from_glib_borrow(this).unsafe_cast_ref())
1234 }
1235 }
1236 unsafe {
1237 let f: Box_<F> = Box_::new(f);
1238 connect_raw(
1239 self.as_ptr() as *mut _,
1240 c"notify::show-fill-level".as_ptr(),
1241 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1242 notify_show_fill_level_trampoline::<Self, F> as *const (),
1243 )),
1244 Box_::into_raw(f),
1245 )
1246 }
1247 }
1248}
1249
1250impl<O: IsA<Range>> RangeExt for O {}