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