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 | Writable | Construct
42    ///
43    ///
44    /// #### `fill-level`
45    ///  The fill level (e.g. prebuffering of a network stream).
46    ///
47    /// Readable | Writable
48    ///
49    ///
50    /// #### `inverted`
51    ///  If [`true`], the direction in which the slider moves is inverted.
52    ///
53    /// Readable | Writable
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 | Writable
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 | Writable
70    ///
71    ///
72    /// #### `show-fill-level`
73    ///  Controls whether fill level indicator graphics are displayed
74    /// on the trough.
75    ///
76    /// Readable | Writable
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 | Writable
88    ///
89    ///
90    /// #### `can-target`
91    ///  Whether the widget can receive pointer events.
92    ///
93    /// Readable | Writable
94    ///
95    ///
96    /// #### `css-classes`
97    ///  A list of css classes applied to this widget.
98    ///
99    /// Readable | Writable
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 | Writable | Construct Only
109    ///
110    ///
111    /// #### `cursor`
112    ///  The cursor used by @widget.
113    ///
114    /// Readable | Writable
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 | Writable
123    ///
124    ///
125    /// #### `focusable`
126    ///  Whether this widget itself will accept the input focus.
127    ///
128    /// Readable | Writable
129    ///
130    ///
131    /// #### `halign`
132    ///  How to distribute horizontal space if widget gets extra space.
133    ///
134    /// Readable | Writable
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 | Writable
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 | Writable
166    ///
167    ///
168    /// #### `hexpand`
169    ///  Whether to expand horizontally.
170    ///
171    /// Readable | Writable
172    ///
173    ///
174    /// #### `hexpand-set`
175    ///  Whether to use the `hexpand` property.
176    ///
177    /// Readable | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
245    ///
246    ///
247    /// #### `name`
248    ///  The name of the widget.
249    ///
250    /// Readable | Writable
251    ///
252    ///
253    /// #### `opacity`
254    ///  The requested opacity of the widget.
255    ///
256    /// Readable | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
333    ///
334    ///
335    /// #### `valign`
336    ///  How to distribute vertical space if widget gets extra space.
337    ///
338    /// Readable | Writable
339    ///
340    ///
341    /// #### `vexpand`
342    ///  Whether to expand vertically.
343    ///
344    /// Readable | Writable
345    ///
346    ///
347    /// #### `vexpand-set`
348    ///  Whether to use the `vexpand` property.
349    ///
350    /// Readable | Writable
351    ///
352    ///
353    /// #### `visible`
354    ///  Whether the widget is visible.
355    ///
356    /// Readable | Writable
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 | Writable
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 | Writable
375    /// </details>
376    /// <details><summary><h4>Orientable</h4></summary>
377    ///
378    ///
379    /// #### `orientation`
380    ///  The orientation of the orientable.
381    ///
382    /// Readable | Writable
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"))]
566glib::wrapper! {
567    #[doc(alias = "GtkRange")]
568    pub struct Range(Object<ffi::GtkRange, ffi::GtkRangeClass>) @extends Widget, @implements Buildable, ConstraintTarget, Orientable;
569
570    match fn {
571        type_ => || ffi::gtk_range_get_type(),
572    }
573}
574
575impl Range {
576    pub const NONE: Option<&'static Range> = None;
577}
578
579/// Trait containing all [`struct@Range`] methods.
580///
581/// # Implementors
582///
583/// [`Range`][struct@crate::Range], [`Scale`][struct@crate::Scale]
584pub trait RangeExt: IsA<Range> + 'static {
585    /// Get the adjustment which is the “model” object for [`Range`][crate::Range].
586    ///
587    /// # Returns
588    ///
589    /// a [`Adjustment`][crate::Adjustment]
590    #[doc(alias = "gtk_range_get_adjustment")]
591    #[doc(alias = "get_adjustment")]
592    fn adjustment(&self) -> Adjustment {
593        unsafe {
594            from_glib_none(ffi::gtk_range_get_adjustment(
595                self.as_ref().to_glib_none().0,
596            ))
597        }
598    }
599
600    /// Gets the current position of the fill level indicator.
601    ///
602    /// # Returns
603    ///
604    /// The current fill level
605    #[doc(alias = "gtk_range_get_fill_level")]
606    #[doc(alias = "get_fill_level")]
607    #[doc(alias = "fill-level")]
608    fn fill_level(&self) -> f64 {
609        unsafe { ffi::gtk_range_get_fill_level(self.as_ref().to_glib_none().0) }
610    }
611
612    /// Gets whether the [`Range`][crate::Range] respects text direction.
613    ///
614    /// See [`set_flippable()`][Self::set_flippable()].
615    ///
616    /// # Returns
617    ///
618    /// [`true`] if the range is flippable
619    #[doc(alias = "gtk_range_get_flippable")]
620    #[doc(alias = "get_flippable")]
621    fn is_flippable(&self) -> bool {
622        unsafe { from_glib(ffi::gtk_range_get_flippable(self.as_ref().to_glib_none().0)) }
623    }
624
625    /// Gets whether the range is inverted.
626    ///
627    /// See [`set_inverted()`][Self::set_inverted()].
628    ///
629    /// # Returns
630    ///
631    /// [`true`] if the range is inverted
632    #[doc(alias = "gtk_range_get_inverted")]
633    #[doc(alias = "get_inverted")]
634    #[doc(alias = "inverted")]
635    fn is_inverted(&self) -> bool {
636        unsafe { from_glib(ffi::gtk_range_get_inverted(self.as_ref().to_glib_none().0)) }
637    }
638
639    /// This function returns the area that contains the range’s trough,
640    /// in coordinates relative to @self's origin.
641    ///
642    /// This function is useful mainly for [`Range`][crate::Range] subclasses.
643    ///
644    /// # Returns
645    ///
646    ///
647    /// ## `range_rect`
648    /// return location for the range rectangle
649    #[doc(alias = "gtk_range_get_range_rect")]
650    #[doc(alias = "get_range_rect")]
651    fn range_rect(&self) -> gdk::Rectangle {
652        unsafe {
653            let mut range_rect = gdk::Rectangle::uninitialized();
654            ffi::gtk_range_get_range_rect(
655                self.as_ref().to_glib_none().0,
656                range_rect.to_glib_none_mut().0,
657            );
658            range_rect
659        }
660    }
661
662    /// Gets whether the range is restricted to the fill level.
663    ///
664    /// # Returns
665    ///
666    /// [`true`] if @self is restricted to the fill level.
667    #[doc(alias = "gtk_range_get_restrict_to_fill_level")]
668    #[doc(alias = "get_restrict_to_fill_level")]
669    #[doc(alias = "restrict-to-fill-level")]
670    fn restricts_to_fill_level(&self) -> bool {
671        unsafe {
672            from_glib(ffi::gtk_range_get_restrict_to_fill_level(
673                self.as_ref().to_glib_none().0,
674            ))
675        }
676    }
677
678    /// Gets the number of digits to round the value to when
679    /// it changes.
680    ///
681    /// See [`change-value`][struct@crate::Range#change-value].
682    ///
683    /// # Returns
684    ///
685    /// the number of digits to round to
686    #[doc(alias = "gtk_range_get_round_digits")]
687    #[doc(alias = "get_round_digits")]
688    #[doc(alias = "round-digits")]
689    fn round_digits(&self) -> i32 {
690        unsafe { ffi::gtk_range_get_round_digits(self.as_ref().to_glib_none().0) }
691    }
692
693    /// Gets whether the range displays the fill level graphically.
694    ///
695    /// # Returns
696    ///
697    /// [`true`] if @self shows the fill level.
698    #[doc(alias = "gtk_range_get_show_fill_level")]
699    #[doc(alias = "get_show_fill_level")]
700    #[doc(alias = "show-fill-level")]
701    fn shows_fill_level(&self) -> bool {
702        unsafe {
703            from_glib(ffi::gtk_range_get_show_fill_level(
704                self.as_ref().to_glib_none().0,
705            ))
706        }
707    }
708
709    /// This function returns sliders range along the long dimension,
710    /// in widget->window coordinates.
711    ///
712    /// This function is useful mainly for [`Range`][crate::Range] subclasses.
713    ///
714    /// # Returns
715    ///
716    ///
717    /// ## `slider_start`
718    /// return location for the slider's start
719    ///
720    /// ## `slider_end`
721    /// return location for the slider's end
722    #[doc(alias = "gtk_range_get_slider_range")]
723    #[doc(alias = "get_slider_range")]
724    fn slider_range(&self) -> (i32, i32) {
725        unsafe {
726            let mut slider_start = std::mem::MaybeUninit::uninit();
727            let mut slider_end = std::mem::MaybeUninit::uninit();
728            ffi::gtk_range_get_slider_range(
729                self.as_ref().to_glib_none().0,
730                slider_start.as_mut_ptr(),
731                slider_end.as_mut_ptr(),
732            );
733            (slider_start.assume_init(), slider_end.assume_init())
734        }
735    }
736
737    /// This function is useful mainly for [`Range`][crate::Range] subclasses.
738    ///
739    /// See [`set_slider_size_fixed()`][Self::set_slider_size_fixed()].
740    ///
741    /// # Returns
742    ///
743    /// whether the range’s slider has a fixed size.
744    #[doc(alias = "gtk_range_get_slider_size_fixed")]
745    #[doc(alias = "get_slider_size_fixed")]
746    fn is_slider_size_fixed(&self) -> bool {
747        unsafe {
748            from_glib(ffi::gtk_range_get_slider_size_fixed(
749                self.as_ref().to_glib_none().0,
750            ))
751        }
752    }
753
754    /// Gets the current value of the range.
755    ///
756    /// # Returns
757    ///
758    /// current value of the range.
759    #[doc(alias = "gtk_range_get_value")]
760    #[doc(alias = "get_value")]
761    fn value(&self) -> f64 {
762        unsafe { ffi::gtk_range_get_value(self.as_ref().to_glib_none().0) }
763    }
764
765    /// Sets the adjustment to be used as the “model” object for the [`Range`][crate::Range]
766    ///
767    /// The adjustment indicates the current range value, the minimum and
768    /// maximum range values, the step/page increments used for keybindings
769    /// and scrolling, and the page size.
770    ///
771    /// The page size is normally 0 for [`Scale`][crate::Scale] and nonzero for [`Scrollbar`][crate::Scrollbar],
772    /// and indicates the size of the visible area of the widget being scrolled.
773    /// The page size affects the size of the scrollbar slider.
774    /// ## `adjustment`
775    /// a [`Adjustment`][crate::Adjustment]
776    #[doc(alias = "gtk_range_set_adjustment")]
777    #[doc(alias = "adjustment")]
778    fn set_adjustment(&self, adjustment: &impl IsA<Adjustment>) {
779        unsafe {
780            ffi::gtk_range_set_adjustment(
781                self.as_ref().to_glib_none().0,
782                adjustment.as_ref().to_glib_none().0,
783            );
784        }
785    }
786
787    /// Set the new position of the fill level indicator.
788    ///
789    /// The “fill level” is probably best described by its most prominent
790    /// use case, which is an indicator for the amount of pre-buffering in
791    /// a streaming media player. In that use case, the value of the range
792    /// would indicate the current play position, and the fill level would
793    /// be the position up to which the file/stream has been downloaded.
794    ///
795    /// This amount of prebuffering can be displayed on the range’s trough
796    /// and is themeable separately from the trough. To enable fill level
797    /// display, use [`set_show_fill_level()`][Self::set_show_fill_level()]. The range defaults
798    /// to not showing the fill level.
799    ///
800    /// Additionally, it’s possible to restrict the range’s slider position
801    /// to values which are smaller than the fill level. This is controlled
802    /// by [`set_restrict_to_fill_level()`][Self::set_restrict_to_fill_level()] and is by default
803    /// enabled.
804    /// ## `fill_level`
805    /// the new position of the fill level indicator
806    #[doc(alias = "gtk_range_set_fill_level")]
807    #[doc(alias = "fill-level")]
808    fn set_fill_level(&self, fill_level: f64) {
809        unsafe {
810            ffi::gtk_range_set_fill_level(self.as_ref().to_glib_none().0, fill_level);
811        }
812    }
813
814    /// Sets whether the [`Range`][crate::Range] respects text direction.
815    ///
816    /// If a range is flippable, it will switch its direction
817    /// if it is horizontal and its direction is [`TextDirection::Rtl`][crate::TextDirection::Rtl].
818    ///
819    /// See [`WidgetExt::direction()`][crate::prelude::WidgetExt::direction()].
820    /// ## `flippable`
821    /// [`true`] to make the range flippable
822    #[doc(alias = "gtk_range_set_flippable")]
823    fn set_flippable(&self, flippable: bool) {
824        unsafe {
825            ffi::gtk_range_set_flippable(self.as_ref().to_glib_none().0, flippable.into_glib());
826        }
827    }
828
829    /// Sets the step and page sizes for the range.
830    ///
831    /// The step size is used when the user clicks the [`Scrollbar`][crate::Scrollbar]
832    /// arrows or moves a [`Scale`][crate::Scale] via arrow keys. The page size
833    /// is used for example when moving via Page Up or Page Down keys.
834    /// ## `step`
835    /// step size
836    /// ## `page`
837    /// page size
838    #[doc(alias = "gtk_range_set_increments")]
839    fn set_increments(&self, step: f64, page: f64) {
840        unsafe {
841            ffi::gtk_range_set_increments(self.as_ref().to_glib_none().0, step, page);
842        }
843    }
844
845    /// Sets whether to invert the range.
846    ///
847    /// Ranges normally move from lower to higher values as the
848    /// slider moves from top to bottom or left to right. Inverted
849    /// ranges have higher values at the top or on the right rather
850    /// than on the bottom or left.
851    /// ## `setting`
852    /// [`true`] to invert the range
853    #[doc(alias = "gtk_range_set_inverted")]
854    #[doc(alias = "inverted")]
855    fn set_inverted(&self, setting: bool) {
856        unsafe {
857            ffi::gtk_range_set_inverted(self.as_ref().to_glib_none().0, setting.into_glib());
858        }
859    }
860
861    /// Sets the allowable values in the [`Range`][crate::Range].
862    ///
863    /// The range value is clamped to be between @min and @max.
864    /// (If the range has a non-zero page size, it is clamped
865    /// between @min and @max - page-size.)
866    /// ## `min`
867    /// minimum range value
868    /// ## `max`
869    /// maximum range value
870    #[doc(alias = "gtk_range_set_range")]
871    fn set_range(&self, min: f64, max: f64) {
872        unsafe {
873            ffi::gtk_range_set_range(self.as_ref().to_glib_none().0, min, max);
874        }
875    }
876
877    /// Sets whether the slider is restricted to the fill level.
878    ///
879    /// See [`set_fill_level()`][Self::set_fill_level()] for a general description
880    /// of the fill level concept.
881    /// ## `restrict_to_fill_level`
882    /// Whether the fill level restricts slider movement.
883    #[doc(alias = "gtk_range_set_restrict_to_fill_level")]
884    #[doc(alias = "restrict-to-fill-level")]
885    fn set_restrict_to_fill_level(&self, restrict_to_fill_level: bool) {
886        unsafe {
887            ffi::gtk_range_set_restrict_to_fill_level(
888                self.as_ref().to_glib_none().0,
889                restrict_to_fill_level.into_glib(),
890            );
891        }
892    }
893
894    /// Sets the number of digits to round the value to when
895    /// it changes.
896    ///
897    /// See [`change-value`][struct@crate::Range#change-value].
898    /// ## `round_digits`
899    /// the precision in digits, or -1
900    #[doc(alias = "gtk_range_set_round_digits")]
901    #[doc(alias = "round-digits")]
902    fn set_round_digits(&self, round_digits: i32) {
903        unsafe {
904            ffi::gtk_range_set_round_digits(self.as_ref().to_glib_none().0, round_digits);
905        }
906    }
907
908    /// Sets whether a graphical fill level is show on the trough.
909    ///
910    /// See [`set_fill_level()`][Self::set_fill_level()] for a general description
911    /// of the fill level concept.
912    /// ## `show_fill_level`
913    /// Whether a fill level indicator graphics is shown.
914    #[doc(alias = "gtk_range_set_show_fill_level")]
915    #[doc(alias = "show-fill-level")]
916    fn set_show_fill_level(&self, show_fill_level: bool) {
917        unsafe {
918            ffi::gtk_range_set_show_fill_level(
919                self.as_ref().to_glib_none().0,
920                show_fill_level.into_glib(),
921            );
922        }
923    }
924
925    /// Sets whether the range’s slider has a fixed size, or a size that
926    /// depends on its adjustment’s page size.
927    ///
928    /// This function is useful mainly for [`Range`][crate::Range] subclasses.
929    /// ## `size_fixed`
930    /// [`true`] to make the slider size constant
931    #[doc(alias = "gtk_range_set_slider_size_fixed")]
932    fn set_slider_size_fixed(&self, size_fixed: bool) {
933        unsafe {
934            ffi::gtk_range_set_slider_size_fixed(
935                self.as_ref().to_glib_none().0,
936                size_fixed.into_glib(),
937            );
938        }
939    }
940
941    /// Sets the current value of the range.
942    ///
943    /// If the value is outside the minimum or maximum range values,
944    /// it will be clamped to fit inside them. The range emits the
945    /// [`value-changed`][struct@crate::Range#value-changed] signal if the value changes.
946    /// ## `value`
947    /// new value of the range
948    #[doc(alias = "gtk_range_set_value")]
949    fn set_value(&self, value: f64) {
950        unsafe {
951            ffi::gtk_range_set_value(self.as_ref().to_glib_none().0, value);
952        }
953    }
954
955    /// Emitted before clamping a value, to give the application a
956    /// chance to adjust the bounds.
957    /// ## `value`
958    /// the value before we clamp
959    #[doc(alias = "adjust-bounds")]
960    fn connect_adjust_bounds<F: Fn(&Self, f64) + 'static>(&self, f: F) -> SignalHandlerId {
961        unsafe extern "C" fn adjust_bounds_trampoline<P: IsA<Range>, F: Fn(&P, f64) + 'static>(
962            this: *mut ffi::GtkRange,
963            value: std::ffi::c_double,
964            f: glib::ffi::gpointer,
965        ) {
966            unsafe {
967                let f: &F = &*(f as *const F);
968                f(Range::from_glib_borrow(this).unsafe_cast_ref(), value)
969            }
970        }
971        unsafe {
972            let f: Box_<F> = Box_::new(f);
973            connect_raw(
974                self.as_ptr() as *mut _,
975                c"adjust-bounds".as_ptr(),
976                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
977                    adjust_bounds_trampoline::<Self, F> as *const (),
978                )),
979                Box_::into_raw(f),
980            )
981        }
982    }
983
984    /// Emitted when a scroll action is performed on a range.
985    ///
986    /// It allows an application to determine the type of scroll event
987    /// that occurred and the resultant new value. The application can
988    /// handle the event itself and return [`true`] to prevent further
989    /// processing. Or, by returning [`false`], it can pass the event to
990    /// other handlers until the default GTK handler is reached.
991    ///
992    /// The value parameter is unrounded. An application that overrides
993    /// the ::change-value signal is responsible for clamping the value
994    /// to the desired number of decimal digits; the default GTK
995    /// handler clamps the value based on [`round-digits`][struct@crate::Range#round-digits].
996    /// ## `scroll`
997    /// the type of scroll action that was performed
998    /// ## `value`
999    /// the new value resulting from the scroll action
1000    ///
1001    /// # Returns
1002    ///
1003    /// [`true`] to prevent other handlers from being invoked for
1004    ///     the signal, [`false`] to propagate the signal further
1005    #[doc(alias = "change-value")]
1006    fn connect_change_value<F: Fn(&Self, ScrollType, f64) -> glib::Propagation + 'static>(
1007        &self,
1008        f: F,
1009    ) -> SignalHandlerId {
1010        unsafe extern "C" fn change_value_trampoline<
1011            P: IsA<Range>,
1012            F: Fn(&P, ScrollType, f64) -> glib::Propagation + 'static,
1013        >(
1014            this: *mut ffi::GtkRange,
1015            scroll: ffi::GtkScrollType,
1016            value: std::ffi::c_double,
1017            f: glib::ffi::gpointer,
1018        ) -> glib::ffi::gboolean {
1019            unsafe {
1020                let f: &F = &*(f as *const F);
1021                f(
1022                    Range::from_glib_borrow(this).unsafe_cast_ref(),
1023                    from_glib(scroll),
1024                    value,
1025                )
1026                .into_glib()
1027            }
1028        }
1029        unsafe {
1030            let f: Box_<F> = Box_::new(f);
1031            connect_raw(
1032                self.as_ptr() as *mut _,
1033                c"change-value".as_ptr(),
1034                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1035                    change_value_trampoline::<Self, F> as *const (),
1036                )),
1037                Box_::into_raw(f),
1038            )
1039        }
1040    }
1041
1042    /// Virtual function that moves the slider.
1043    ///
1044    /// Used for keybindings.
1045    /// ## `step`
1046    /// how to move the slider
1047    #[doc(alias = "move-slider")]
1048    fn connect_move_slider<F: Fn(&Self, ScrollType) + 'static>(&self, f: F) -> SignalHandlerId {
1049        unsafe extern "C" fn move_slider_trampoline<
1050            P: IsA<Range>,
1051            F: Fn(&P, ScrollType) + 'static,
1052        >(
1053            this: *mut ffi::GtkRange,
1054            step: ffi::GtkScrollType,
1055            f: glib::ffi::gpointer,
1056        ) {
1057            unsafe {
1058                let f: &F = &*(f as *const F);
1059                f(
1060                    Range::from_glib_borrow(this).unsafe_cast_ref(),
1061                    from_glib(step),
1062                )
1063            }
1064        }
1065        unsafe {
1066            let f: Box_<F> = Box_::new(f);
1067            connect_raw(
1068                self.as_ptr() as *mut _,
1069                c"move-slider".as_ptr(),
1070                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1071                    move_slider_trampoline::<Self, F> as *const (),
1072                )),
1073                Box_::into_raw(f),
1074            )
1075        }
1076    }
1077
1078    fn emit_move_slider(&self, step: ScrollType) {
1079        self.emit_by_name::<()>("move-slider", &[&step]);
1080    }
1081
1082    /// Emitted when the range value changes.
1083    #[doc(alias = "value-changed")]
1084    fn connect_value_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1085        unsafe extern "C" fn value_changed_trampoline<P: IsA<Range>, F: Fn(&P) + 'static>(
1086            this: *mut ffi::GtkRange,
1087            f: glib::ffi::gpointer,
1088        ) {
1089            unsafe {
1090                let f: &F = &*(f as *const F);
1091                f(Range::from_glib_borrow(this).unsafe_cast_ref())
1092            }
1093        }
1094        unsafe {
1095            let f: Box_<F> = Box_::new(f);
1096            connect_raw(
1097                self.as_ptr() as *mut _,
1098                c"value-changed".as_ptr(),
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            unsafe {
1115                let f: &F = &*(f as *const F);
1116                f(Range::from_glib_borrow(this).unsafe_cast_ref())
1117            }
1118        }
1119        unsafe {
1120            let f: Box_<F> = Box_::new(f);
1121            connect_raw(
1122                self.as_ptr() as *mut _,
1123                c"notify::adjustment".as_ptr(),
1124                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1125                    notify_adjustment_trampoline::<Self, F> as *const (),
1126                )),
1127                Box_::into_raw(f),
1128            )
1129        }
1130    }
1131
1132    #[doc(alias = "fill-level")]
1133    fn connect_fill_level_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1134        unsafe extern "C" fn notify_fill_level_trampoline<P: IsA<Range>, F: Fn(&P) + 'static>(
1135            this: *mut ffi::GtkRange,
1136            _param_spec: glib::ffi::gpointer,
1137            f: glib::ffi::gpointer,
1138        ) {
1139            unsafe {
1140                let f: &F = &*(f as *const F);
1141                f(Range::from_glib_borrow(this).unsafe_cast_ref())
1142            }
1143        }
1144        unsafe {
1145            let f: Box_<F> = Box_::new(f);
1146            connect_raw(
1147                self.as_ptr() as *mut _,
1148                c"notify::fill-level".as_ptr(),
1149                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1150                    notify_fill_level_trampoline::<Self, F> as *const (),
1151                )),
1152                Box_::into_raw(f),
1153            )
1154        }
1155    }
1156
1157    #[doc(alias = "inverted")]
1158    fn connect_inverted_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1159        unsafe extern "C" fn notify_inverted_trampoline<P: IsA<Range>, F: Fn(&P) + 'static>(
1160            this: *mut ffi::GtkRange,
1161            _param_spec: glib::ffi::gpointer,
1162            f: glib::ffi::gpointer,
1163        ) {
1164            unsafe {
1165                let f: &F = &*(f as *const F);
1166                f(Range::from_glib_borrow(this).unsafe_cast_ref())
1167            }
1168        }
1169        unsafe {
1170            let f: Box_<F> = Box_::new(f);
1171            connect_raw(
1172                self.as_ptr() as *mut _,
1173                c"notify::inverted".as_ptr(),
1174                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1175                    notify_inverted_trampoline::<Self, F> as *const (),
1176                )),
1177                Box_::into_raw(f),
1178            )
1179        }
1180    }
1181
1182    #[doc(alias = "restrict-to-fill-level")]
1183    fn connect_restrict_to_fill_level_notify<F: Fn(&Self) + 'static>(
1184        &self,
1185        f: F,
1186    ) -> SignalHandlerId {
1187        unsafe extern "C" fn notify_restrict_to_fill_level_trampoline<
1188            P: IsA<Range>,
1189            F: Fn(&P) + 'static,
1190        >(
1191            this: *mut ffi::GtkRange,
1192            _param_spec: glib::ffi::gpointer,
1193            f: glib::ffi::gpointer,
1194        ) {
1195            unsafe {
1196                let f: &F = &*(f as *const F);
1197                f(Range::from_glib_borrow(this).unsafe_cast_ref())
1198            }
1199        }
1200        unsafe {
1201            let f: Box_<F> = Box_::new(f);
1202            connect_raw(
1203                self.as_ptr() as *mut _,
1204                c"notify::restrict-to-fill-level".as_ptr(),
1205                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1206                    notify_restrict_to_fill_level_trampoline::<Self, F> as *const (),
1207                )),
1208                Box_::into_raw(f),
1209            )
1210        }
1211    }
1212
1213    #[doc(alias = "round-digits")]
1214    fn connect_round_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1215        unsafe extern "C" fn notify_round_digits_trampoline<P: IsA<Range>, F: Fn(&P) + 'static>(
1216            this: *mut ffi::GtkRange,
1217            _param_spec: glib::ffi::gpointer,
1218            f: glib::ffi::gpointer,
1219        ) {
1220            unsafe {
1221                let f: &F = &*(f as *const F);
1222                f(Range::from_glib_borrow(this).unsafe_cast_ref())
1223            }
1224        }
1225        unsafe {
1226            let f: Box_<F> = Box_::new(f);
1227            connect_raw(
1228                self.as_ptr() as *mut _,
1229                c"notify::round-digits".as_ptr(),
1230                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1231                    notify_round_digits_trampoline::<Self, F> as *const (),
1232                )),
1233                Box_::into_raw(f),
1234            )
1235        }
1236    }
1237
1238    #[doc(alias = "show-fill-level")]
1239    fn connect_show_fill_level_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1240        unsafe extern "C" fn notify_show_fill_level_trampoline<
1241            P: IsA<Range>,
1242            F: Fn(&P) + 'static,
1243        >(
1244            this: *mut ffi::GtkRange,
1245            _param_spec: glib::ffi::gpointer,
1246            f: glib::ffi::gpointer,
1247        ) {
1248            unsafe {
1249                let f: &F = &*(f as *const F);
1250                f(Range::from_glib_borrow(this).unsafe_cast_ref())
1251            }
1252        }
1253        unsafe {
1254            let f: Box_<F> = Box_::new(f);
1255            connect_raw(
1256                self.as_ptr() as *mut _,
1257                c"notify::show-fill-level".as_ptr(),
1258                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1259                    notify_show_fill_level_trampoline::<Self, F> as *const (),
1260                )),
1261                Box_::into_raw(f),
1262            )
1263        }
1264    }
1265}
1266
1267impl<O: IsA<Range>> RangeExt for O {}