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