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