Skip to main content

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