gtk4/auto/
scale.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, AccessibleRole, Adjustment, Align, Buildable, ConstraintTarget, LayoutManager,
10    Orientable, Orientation, Overflow, PositionType, Range, Widget,
11};
12use glib::{
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    /// Allows to select a numeric value with a slider control.
23    ///
24    /// <picture>
25    ///   <source srcset="scales-dark.png" media="(prefers-color-scheme: dark)">
26    ///   <img alt="An example GtkScale" src="scales.png">
27    /// </picture>
28    ///
29    /// To use it, you’ll probably want to investigate the methods on its base
30    /// class, [`Range`][crate::Range], in addition to the methods for [`Scale`][crate::Scale] itself.
31    /// To set the value of a scale, you would normally use [`RangeExt::set_value()`][crate::prelude::RangeExt::set_value()].
32    /// To detect changes to the value, you would normally use the
33    /// [`value-changed`][struct@crate::Range#value-changed] signal.
34    ///
35    /// Note that using the same upper and lower bounds for the [`Scale`][crate::Scale] (through
36    /// the [`Range`][crate::Range] methods) will hide the slider itself. This is useful for
37    /// applications that want to show an undeterminate value on the scale, without
38    /// changing the layout of the application (such as movie or music players).
39    ///
40    /// # GtkScale as GtkBuildable
41    ///
42    /// [`Scale`][crate::Scale] supports a custom `<marks>` element, which can contain multiple
43    /// `<mark\>` elements. The “value” and “position” attributes have the same
44    /// meaning as [`ScaleExt::add_mark()`][crate::prelude::ScaleExt::add_mark()] parameters of the same name. If
45    /// the element is not empty, its content is taken as the markup to show at
46    /// the mark. It can be translated with the usual ”translatable” and
47    /// “context” attributes.
48    ///
49    /// # Shortcuts and Gestures
50    ///
51    /// [`PopoverMenu`][crate::PopoverMenu] supports the following keyboard shortcuts:
52    ///
53    /// - Arrow keys, <kbd>+</kbd> and <kbd>-</kbd> will increment or decrement
54    ///   by step, or by page when combined with <kbd>Ctrl</kbd>.
55    /// - <kbd>PgUp</kbd> and <kbd>PgDn</kbd> will increment or decrement by page.
56    /// - <kbd>Home</kbd> and <kbd>End</kbd> will set the minimum or maximum value.
57    ///
58    /// # CSS nodes
59    ///
60    /// ```text
61    /// scale[.fine-tune][.marks-before][.marks-after]
62    /// ├── [value][.top][.right][.bottom][.left]
63    /// ├── marks.top
64    /// │   ├── mark
65    /// │   ┊    ├── [label]
66    /// │   ┊    ╰── indicator
67    /// ┊   ┊
68    /// │   ╰── mark
69    /// ├── marks.bottom
70    /// │   ├── mark
71    /// │   ┊    ├── indicator
72    /// │   ┊    ╰── [label]
73    /// ┊   ┊
74    /// │   ╰── mark
75    /// ╰── trough
76    ///     ├── [fill]
77    ///     ├── [highlight]
78    ///     ╰── slider
79    /// ```
80    ///
81    /// [`Scale`][crate::Scale] has a main CSS node with name scale and a subnode for its contents,
82    /// with subnodes named trough and slider.
83    ///
84    /// The main node gets the style class .fine-tune added when the scale is in
85    /// 'fine-tuning' mode.
86    ///
87    /// If the scale has an origin (see [`ScaleExt::set_has_origin()`][crate::prelude::ScaleExt::set_has_origin()]), there is
88    /// a subnode with name highlight below the trough node that is used for rendering
89    /// the highlighted part of the trough.
90    ///
91    /// If the scale is showing a fill level (see [`RangeExt::set_show_fill_level()`][crate::prelude::RangeExt::set_show_fill_level()]),
92    /// there is a subnode with name fill below the trough node that is used for
93    /// rendering the filled in part of the trough.
94    ///
95    /// If marks are present, there is a marks subnode before or after the trough
96    /// node, below which each mark gets a node with name mark. The marks nodes get
97    /// either the .top or .bottom style class.
98    ///
99    /// The mark node has a subnode named indicator. If the mark has text, it also
100    /// has a subnode named label. When the mark is either above or left of the
101    /// scale, the label subnode is the first when present. Otherwise, the indicator
102    /// subnode is the first.
103    ///
104    /// The main CSS node gets the 'marks-before' and/or 'marks-after' style classes
105    /// added depending on what marks are present.
106    ///
107    /// If the scale is displaying the value (see [`draw-value`][struct@crate::Scale#draw-value]),
108    /// there is subnode with name value. This node will get the .top or .bottom style
109    /// classes similar to the marks node.
110    ///
111    /// # Accessibility
112    ///
113    /// [`Scale`][crate::Scale] uses the [enum@Gtk.AccessibleRole.slider] role.
114    ///
115    /// ## Properties
116    ///
117    ///
118    /// #### `digits`
119    ///  The number of decimal places that are displayed in the value.
120    ///
121    /// Readable | Writeable
122    ///
123    ///
124    /// #### `draw-value`
125    ///  Whether the current value is displayed as a string next to the slider.
126    ///
127    /// Readable | Writeable
128    ///
129    ///
130    /// #### `has-origin`
131    ///  Whether the scale has an origin.
132    ///
133    /// Readable | Writeable
134    ///
135    ///
136    /// #### `value-pos`
137    ///  The position in which the current value is displayed.
138    ///
139    /// Readable | Writeable
140    /// <details><summary><h4>Range</h4></summary>
141    ///
142    ///
143    /// #### `adjustment`
144    ///  The adjustment that is controlled by the range.
145    ///
146    /// Readable | Writeable | Construct
147    ///
148    ///
149    /// #### `fill-level`
150    ///  The fill level (e.g. prebuffering of a network stream).
151    ///
152    /// Readable | Writeable
153    ///
154    ///
155    /// #### `inverted`
156    ///  If [`true`], the direction in which the slider moves is inverted.
157    ///
158    /// Readable | Writeable
159    ///
160    ///
161    /// #### `restrict-to-fill-level`
162    ///  Controls whether slider movement is restricted to an
163    /// upper boundary set by the fill level.
164    ///
165    /// Readable | Writeable
166    ///
167    ///
168    /// #### `round-digits`
169    ///  The number of digits to round the value to when
170    /// it changes.
171    ///
172    /// See [`change-value`][struct@crate::Range#change-value].
173    ///
174    /// Readable | Writeable
175    ///
176    ///
177    /// #### `show-fill-level`
178    ///  Controls whether fill level indicator graphics are displayed
179    /// on the trough.
180    ///
181    /// Readable | Writeable
182    /// </details>
183    /// <details><summary><h4>Widget</h4></summary>
184    ///
185    ///
186    /// #### `can-focus`
187    ///  Whether the widget or any of its descendents can accept
188    /// the input focus.
189    ///
190    /// This property is meant to be set by widget implementations,
191    /// typically in their instance init function.
192    ///
193    /// Readable | Writeable
194    ///
195    ///
196    /// #### `can-target`
197    ///  Whether the widget can receive pointer events.
198    ///
199    /// Readable | Writeable
200    ///
201    ///
202    /// #### `css-classes`
203    ///  A list of css classes applied to this widget.
204    ///
205    /// Readable | Writeable
206    ///
207    ///
208    /// #### `css-name`
209    ///  The name of this widget in the CSS tree.
210    ///
211    /// This property is meant to be set by widget implementations,
212    /// typically in their instance init function.
213    ///
214    /// Readable | Writeable | Construct Only
215    ///
216    ///
217    /// #### `cursor`
218    ///  The cursor used by @widget.
219    ///
220    /// Readable | Writeable
221    ///
222    ///
223    /// #### `focus-on-click`
224    ///  Whether the widget should grab focus when it is clicked with the mouse.
225    ///
226    /// This property is only relevant for widgets that can take focus.
227    ///
228    /// Readable | Writeable
229    ///
230    ///
231    /// #### `focusable`
232    ///  Whether this widget itself will accept the input focus.
233    ///
234    /// Readable | Writeable
235    ///
236    ///
237    /// #### `halign`
238    ///  How to distribute horizontal space if widget gets extra space.
239    ///
240    /// Readable | Writeable
241    ///
242    ///
243    /// #### `has-default`
244    ///  Whether the widget is the default widget.
245    ///
246    /// Readable
247    ///
248    ///
249    /// #### `has-focus`
250    ///  Whether the widget has the input focus.
251    ///
252    /// Readable
253    ///
254    ///
255    /// #### `has-tooltip`
256    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
257    /// signal on @widget.
258    ///
259    /// A true value indicates that @widget can have a tooltip, in this case
260    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
261    /// determine whether it will provide a tooltip or not.
262    ///
263    /// Readable | Writeable
264    ///
265    ///
266    /// #### `height-request`
267    ///  Overrides for height request of the widget.
268    ///
269    /// If this is -1, the natural request will be used.
270    ///
271    /// Readable | Writeable
272    ///
273    ///
274    /// #### `hexpand`
275    ///  Whether to expand horizontally.
276    ///
277    /// Readable | Writeable
278    ///
279    ///
280    /// #### `hexpand-set`
281    ///  Whether to use the `hexpand` property.
282    ///
283    /// Readable | Writeable
284    ///
285    ///
286    /// #### `layout-manager`
287    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
288    /// the preferred size of the widget, and allocate its children.
289    ///
290    /// This property is meant to be set by widget implementations,
291    /// typically in their instance init function.
292    ///
293    /// Readable | Writeable
294    ///
295    ///
296    /// #### `limit-events`
297    ///  Makes this widget act like a modal dialog, with respect to
298    /// event delivery.
299    ///
300    /// Global event controllers will not handle events with targets
301    /// inside the widget, unless they are set up to ignore propagation
302    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
303    ///
304    /// Readable | Writeable
305    ///
306    ///
307    /// #### `margin-bottom`
308    ///  Margin on bottom side of widget.
309    ///
310    /// This property adds margin outside of the widget's normal size
311    /// request, the margin will be added in addition to the size from
312    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
313    ///
314    /// Readable | Writeable
315    ///
316    ///
317    /// #### `margin-end`
318    ///  Margin on end of widget, horizontally.
319    ///
320    /// This property supports left-to-right and right-to-left text
321    /// directions.
322    ///
323    /// This property adds margin outside of the widget's normal size
324    /// request, the margin will be added in addition to the size from
325    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
326    ///
327    /// Readable | Writeable
328    ///
329    ///
330    /// #### `margin-start`
331    ///  Margin on start of widget, horizontally.
332    ///
333    /// This property supports left-to-right and right-to-left text
334    /// directions.
335    ///
336    /// This property adds margin outside of the widget's normal size
337    /// request, the margin will be added in addition to the size from
338    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
339    ///
340    /// Readable | Writeable
341    ///
342    ///
343    /// #### `margin-top`
344    ///  Margin on top side of widget.
345    ///
346    /// This property adds margin outside of the widget's normal size
347    /// request, the margin will be added in addition to the size from
348    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
349    ///
350    /// Readable | Writeable
351    ///
352    ///
353    /// #### `name`
354    ///  The name of the widget.
355    ///
356    /// Readable | Writeable
357    ///
358    ///
359    /// #### `opacity`
360    ///  The requested opacity of the widget.
361    ///
362    /// Readable | Writeable
363    ///
364    ///
365    /// #### `overflow`
366    ///  How content outside the widget's content area is treated.
367    ///
368    /// This property is meant to be set by widget implementations,
369    /// typically in their instance init function.
370    ///
371    /// Readable | Writeable
372    ///
373    ///
374    /// #### `parent`
375    ///  The parent widget of this widget.
376    ///
377    /// Readable
378    ///
379    ///
380    /// #### `receives-default`
381    ///  Whether the widget will receive the default action when it is focused.
382    ///
383    /// Readable | Writeable
384    ///
385    ///
386    /// #### `root`
387    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
388    ///
389    /// This will be `NULL` if the widget is not contained in a root widget.
390    ///
391    /// Readable
392    ///
393    ///
394    /// #### `scale-factor`
395    ///  The scale factor of the widget.
396    ///
397    /// Readable
398    ///
399    ///
400    /// #### `sensitive`
401    ///  Whether the widget responds to input.
402    ///
403    /// Readable | Writeable
404    ///
405    ///
406    /// #### `tooltip-markup`
407    ///  Sets the text of tooltip to be the given string, which is marked up
408    /// with Pango markup.
409    ///
410    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
411    ///
412    /// This is a convenience property which will take care of getting the
413    /// tooltip shown if the given string is not `NULL`:
414    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
415    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
416    /// the default signal handler.
417    ///
418    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
419    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
420    ///
421    /// Readable | Writeable
422    ///
423    ///
424    /// #### `tooltip-text`
425    ///  Sets the text of tooltip to be the given string.
426    ///
427    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
428    ///
429    /// This is a convenience property which will take care of getting the
430    /// tooltip shown if the given string is not `NULL`:
431    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
432    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
433    /// the default signal handler.
434    ///
435    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
436    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
437    ///
438    /// Readable | Writeable
439    ///
440    ///
441    /// #### `valign`
442    ///  How to distribute vertical space if widget gets extra space.
443    ///
444    /// Readable | Writeable
445    ///
446    ///
447    /// #### `vexpand`
448    ///  Whether to expand vertically.
449    ///
450    /// Readable | Writeable
451    ///
452    ///
453    /// #### `vexpand-set`
454    ///  Whether to use the `vexpand` property.
455    ///
456    /// Readable | Writeable
457    ///
458    ///
459    /// #### `visible`
460    ///  Whether the widget is visible.
461    ///
462    /// Readable | Writeable
463    ///
464    ///
465    /// #### `width-request`
466    ///  Overrides for width request of the widget.
467    ///
468    /// If this is -1, the natural request will be used.
469    ///
470    /// Readable | Writeable
471    /// </details>
472    /// <details><summary><h4>Accessible</h4></summary>
473    ///
474    ///
475    /// #### `accessible-role`
476    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
477    ///
478    /// The accessible role cannot be changed once set.
479    ///
480    /// Readable | Writeable
481    /// </details>
482    /// <details><summary><h4>Orientable</h4></summary>
483    ///
484    ///
485    /// #### `orientation`
486    ///  The orientation of the orientable.
487    ///
488    /// Readable | Writeable
489    /// </details>
490    ///
491    /// # Implements
492    ///
493    /// [`ScaleExt`][trait@crate::prelude::ScaleExt], [`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], [`ScaleExtManual`][trait@crate::prelude::ScaleExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
494    #[doc(alias = "GtkScale")]
495    pub struct Scale(Object<ffi::GtkScale, ffi::GtkScaleClass>) @extends Range, Widget, @implements Accessible, Buildable, ConstraintTarget, AccessibleRange, Orientable;
496
497    match fn {
498        type_ => || ffi::gtk_scale_get_type(),
499    }
500}
501
502#[cfg(not(any(feature = "v4_10")))]
503glib::wrapper! {
504    #[doc(alias = "GtkScale")]
505    pub struct Scale(Object<ffi::GtkScale, ffi::GtkScaleClass>) @extends Range, Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable;
506
507    match fn {
508        type_ => || ffi::gtk_scale_get_type(),
509    }
510}
511
512impl Scale {
513    pub const NONE: Option<&'static Scale> = None;
514
515    /// Creates a new [`Scale`][crate::Scale].
516    /// ## `orientation`
517    /// the scale’s orientation.
518    /// ## `adjustment`
519    /// the [`Adjustment`][crate::Adjustment] which sets
520    ///   the range of the scale, or [`None`] to create a new adjustment.
521    ///
522    /// # Returns
523    ///
524    /// a new [`Scale`][crate::Scale]
525    #[doc(alias = "gtk_scale_new")]
526    pub fn new(orientation: Orientation, adjustment: Option<&impl IsA<Adjustment>>) -> Scale {
527        assert_initialized_main_thread!();
528        unsafe {
529            Widget::from_glib_none(ffi::gtk_scale_new(
530                orientation.into_glib(),
531                adjustment.map(|p| p.as_ref()).to_glib_none().0,
532            ))
533            .unsafe_cast()
534        }
535    }
536
537    /// Creates a new scale widget with a range from @min to @max.
538    ///
539    /// The returns scale will have the given orientation and will let the
540    /// user input a number between @min and @max (including @min and @max)
541    /// with the increment @step. @step must be nonzero; it’s the distance
542    /// the slider moves when using the arrow keys to adjust the scale
543    /// value.
544    ///
545    /// Note that the way in which the precision is derived works best if
546    /// @step is a power of ten. If the resulting precision is not suitable
547    /// for your needs, use [`ScaleExt::set_digits()`][crate::prelude::ScaleExt::set_digits()] to correct it.
548    /// ## `orientation`
549    /// the scale’s orientation.
550    /// ## `min`
551    /// minimum value
552    /// ## `max`
553    /// maximum value
554    /// ## `step`
555    /// step increment (tick size) used with keyboard shortcuts
556    ///
557    /// # Returns
558    ///
559    /// a new [`Scale`][crate::Scale]
560    #[doc(alias = "gtk_scale_new_with_range")]
561    #[doc(alias = "new_with_range")]
562    pub fn with_range(orientation: Orientation, min: f64, max: f64, step: f64) -> Scale {
563        assert_initialized_main_thread!();
564        unsafe {
565            Widget::from_glib_none(ffi::gtk_scale_new_with_range(
566                orientation.into_glib(),
567                min,
568                max,
569                step,
570            ))
571            .unsafe_cast()
572        }
573    }
574
575    // rustdoc-stripper-ignore-next
576    /// Creates a new builder-pattern struct instance to construct [`Scale`] objects.
577    ///
578    /// This method returns an instance of [`ScaleBuilder`](crate::builders::ScaleBuilder) which can be used to create [`Scale`] objects.
579    pub fn builder() -> ScaleBuilder {
580        ScaleBuilder::new()
581    }
582}
583
584impl Default for Scale {
585    fn default() -> Self {
586        glib::object::Object::new::<Self>()
587    }
588}
589
590// rustdoc-stripper-ignore-next
591/// A [builder-pattern] type to construct [`Scale`] objects.
592///
593/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
594#[must_use = "The builder must be built to be used"]
595pub struct ScaleBuilder {
596    builder: glib::object::ObjectBuilder<'static, Scale>,
597}
598
599impl ScaleBuilder {
600    fn new() -> Self {
601        Self {
602            builder: glib::object::Object::builder(),
603        }
604    }
605
606    /// The number of decimal places that are displayed in the value.
607    pub fn digits(self, digits: i32) -> Self {
608        Self {
609            builder: self.builder.property("digits", digits),
610        }
611    }
612
613    /// Whether the current value is displayed as a string next to the slider.
614    pub fn draw_value(self, draw_value: bool) -> Self {
615        Self {
616            builder: self.builder.property("draw-value", draw_value),
617        }
618    }
619
620    /// Whether the scale has an origin.
621    pub fn has_origin(self, has_origin: bool) -> Self {
622        Self {
623            builder: self.builder.property("has-origin", has_origin),
624        }
625    }
626
627    /// The position in which the current value is displayed.
628    pub fn value_pos(self, value_pos: PositionType) -> Self {
629        Self {
630            builder: self.builder.property("value-pos", value_pos),
631        }
632    }
633
634    /// The adjustment that is controlled by the range.
635    pub fn adjustment(self, adjustment: &impl IsA<Adjustment>) -> Self {
636        Self {
637            builder: self
638                .builder
639                .property("adjustment", adjustment.clone().upcast()),
640        }
641    }
642
643    /// The fill level (e.g. prebuffering of a network stream).
644    pub fn fill_level(self, fill_level: f64) -> Self {
645        Self {
646            builder: self.builder.property("fill-level", fill_level),
647        }
648    }
649
650    /// If [`true`], the direction in which the slider moves is inverted.
651    pub fn inverted(self, inverted: bool) -> Self {
652        Self {
653            builder: self.builder.property("inverted", inverted),
654        }
655    }
656
657    /// Controls whether slider movement is restricted to an
658    /// upper boundary set by the fill level.
659    pub fn restrict_to_fill_level(self, restrict_to_fill_level: bool) -> Self {
660        Self {
661            builder: self
662                .builder
663                .property("restrict-to-fill-level", restrict_to_fill_level),
664        }
665    }
666
667    /// The number of digits to round the value to when
668    /// it changes.
669    ///
670    /// See [`change-value`][struct@crate::Range#change-value].
671    pub fn round_digits(self, round_digits: i32) -> Self {
672        Self {
673            builder: self.builder.property("round-digits", round_digits),
674        }
675    }
676
677    /// Controls whether fill level indicator graphics are displayed
678    /// on the trough.
679    pub fn show_fill_level(self, show_fill_level: bool) -> Self {
680        Self {
681            builder: self.builder.property("show-fill-level", show_fill_level),
682        }
683    }
684
685    /// Whether the widget or any of its descendents can accept
686    /// the input focus.
687    ///
688    /// This property is meant to be set by widget implementations,
689    /// typically in their instance init function.
690    pub fn can_focus(self, can_focus: bool) -> Self {
691        Self {
692            builder: self.builder.property("can-focus", can_focus),
693        }
694    }
695
696    /// Whether the widget can receive pointer events.
697    pub fn can_target(self, can_target: bool) -> Self {
698        Self {
699            builder: self.builder.property("can-target", can_target),
700        }
701    }
702
703    /// A list of css classes applied to this widget.
704    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
705        Self {
706            builder: self.builder.property("css-classes", css_classes.into()),
707        }
708    }
709
710    /// The name of this widget in the CSS tree.
711    ///
712    /// This property is meant to be set by widget implementations,
713    /// typically in their instance init function.
714    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
715        Self {
716            builder: self.builder.property("css-name", css_name.into()),
717        }
718    }
719
720    /// The cursor used by @widget.
721    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
722        Self {
723            builder: self.builder.property("cursor", cursor.clone()),
724        }
725    }
726
727    /// Whether the widget should grab focus when it is clicked with the mouse.
728    ///
729    /// This property is only relevant for widgets that can take focus.
730    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
731        Self {
732            builder: self.builder.property("focus-on-click", focus_on_click),
733        }
734    }
735
736    /// Whether this widget itself will accept the input focus.
737    pub fn focusable(self, focusable: bool) -> Self {
738        Self {
739            builder: self.builder.property("focusable", focusable),
740        }
741    }
742
743    /// How to distribute horizontal space if widget gets extra space.
744    pub fn halign(self, halign: Align) -> Self {
745        Self {
746            builder: self.builder.property("halign", halign),
747        }
748    }
749
750    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
751    /// signal on @widget.
752    ///
753    /// A true value indicates that @widget can have a tooltip, in this case
754    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
755    /// determine whether it will provide a tooltip or not.
756    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
757        Self {
758            builder: self.builder.property("has-tooltip", has_tooltip),
759        }
760    }
761
762    /// Overrides for height request of the widget.
763    ///
764    /// If this is -1, the natural request will be used.
765    pub fn height_request(self, height_request: i32) -> Self {
766        Self {
767            builder: self.builder.property("height-request", height_request),
768        }
769    }
770
771    /// Whether to expand horizontally.
772    pub fn hexpand(self, hexpand: bool) -> Self {
773        Self {
774            builder: self.builder.property("hexpand", hexpand),
775        }
776    }
777
778    /// Whether to use the `hexpand` property.
779    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
780        Self {
781            builder: self.builder.property("hexpand-set", hexpand_set),
782        }
783    }
784
785    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
786    /// the preferred size of the widget, and allocate its children.
787    ///
788    /// This property is meant to be set by widget implementations,
789    /// typically in their instance init function.
790    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
791        Self {
792            builder: self
793                .builder
794                .property("layout-manager", layout_manager.clone().upcast()),
795        }
796    }
797
798    /// Makes this widget act like a modal dialog, with respect to
799    /// event delivery.
800    ///
801    /// Global event controllers will not handle events with targets
802    /// inside the widget, unless they are set up to ignore propagation
803    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
804    #[cfg(feature = "v4_18")]
805    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
806    pub fn limit_events(self, limit_events: bool) -> Self {
807        Self {
808            builder: self.builder.property("limit-events", limit_events),
809        }
810    }
811
812    /// Margin on bottom side of widget.
813    ///
814    /// This property adds margin outside of the widget's normal size
815    /// request, the margin will be added in addition to the size from
816    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
817    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
818        Self {
819            builder: self.builder.property("margin-bottom", margin_bottom),
820        }
821    }
822
823    /// Margin on end of widget, horizontally.
824    ///
825    /// This property supports left-to-right and right-to-left text
826    /// directions.
827    ///
828    /// This property adds margin outside of the widget's normal size
829    /// request, the margin will be added in addition to the size from
830    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
831    pub fn margin_end(self, margin_end: i32) -> Self {
832        Self {
833            builder: self.builder.property("margin-end", margin_end),
834        }
835    }
836
837    /// Margin on start of widget, horizontally.
838    ///
839    /// This property supports left-to-right and right-to-left text
840    /// directions.
841    ///
842    /// This property adds margin outside of the widget's normal size
843    /// request, the margin will be added in addition to the size from
844    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
845    pub fn margin_start(self, margin_start: i32) -> Self {
846        Self {
847            builder: self.builder.property("margin-start", margin_start),
848        }
849    }
850
851    /// Margin on top side of widget.
852    ///
853    /// This property adds margin outside of the widget's normal size
854    /// request, the margin will be added in addition to the size from
855    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
856    pub fn margin_top(self, margin_top: i32) -> Self {
857        Self {
858            builder: self.builder.property("margin-top", margin_top),
859        }
860    }
861
862    /// The name of the widget.
863    pub fn name(self, name: impl Into<glib::GString>) -> Self {
864        Self {
865            builder: self.builder.property("name", name.into()),
866        }
867    }
868
869    /// The requested opacity of the widget.
870    pub fn opacity(self, opacity: f64) -> Self {
871        Self {
872            builder: self.builder.property("opacity", opacity),
873        }
874    }
875
876    /// How content outside the widget's content area is treated.
877    ///
878    /// This property is meant to be set by widget implementations,
879    /// typically in their instance init function.
880    pub fn overflow(self, overflow: Overflow) -> Self {
881        Self {
882            builder: self.builder.property("overflow", overflow),
883        }
884    }
885
886    /// Whether the widget will receive the default action when it is focused.
887    pub fn receives_default(self, receives_default: bool) -> Self {
888        Self {
889            builder: self.builder.property("receives-default", receives_default),
890        }
891    }
892
893    /// Whether the widget responds to input.
894    pub fn sensitive(self, sensitive: bool) -> Self {
895        Self {
896            builder: self.builder.property("sensitive", sensitive),
897        }
898    }
899
900    /// Sets the text of tooltip to be the given string, which is marked up
901    /// with Pango markup.
902    ///
903    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
904    ///
905    /// This is a convenience property which will take care of getting the
906    /// tooltip shown if the given string is not `NULL`:
907    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
908    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
909    /// the default signal handler.
910    ///
911    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
912    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
913    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
914        Self {
915            builder: self
916                .builder
917                .property("tooltip-markup", tooltip_markup.into()),
918        }
919    }
920
921    /// Sets the text of tooltip to be the given string.
922    ///
923    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
924    ///
925    /// This is a convenience property which will take care of getting the
926    /// tooltip shown if the given string is not `NULL`:
927    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
928    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
929    /// the default signal handler.
930    ///
931    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
932    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
933    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
934        Self {
935            builder: self.builder.property("tooltip-text", tooltip_text.into()),
936        }
937    }
938
939    /// How to distribute vertical space if widget gets extra space.
940    pub fn valign(self, valign: Align) -> Self {
941        Self {
942            builder: self.builder.property("valign", valign),
943        }
944    }
945
946    /// Whether to expand vertically.
947    pub fn vexpand(self, vexpand: bool) -> Self {
948        Self {
949            builder: self.builder.property("vexpand", vexpand),
950        }
951    }
952
953    /// Whether to use the `vexpand` property.
954    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
955        Self {
956            builder: self.builder.property("vexpand-set", vexpand_set),
957        }
958    }
959
960    /// Whether the widget is visible.
961    pub fn visible(self, visible: bool) -> Self {
962        Self {
963            builder: self.builder.property("visible", visible),
964        }
965    }
966
967    /// Overrides for width request of the widget.
968    ///
969    /// If this is -1, the natural request will be used.
970    pub fn width_request(self, width_request: i32) -> Self {
971        Self {
972            builder: self.builder.property("width-request", width_request),
973        }
974    }
975
976    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
977    ///
978    /// The accessible role cannot be changed once set.
979    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
980        Self {
981            builder: self.builder.property("accessible-role", accessible_role),
982        }
983    }
984
985    /// The orientation of the orientable.
986    pub fn orientation(self, orientation: Orientation) -> Self {
987        Self {
988            builder: self.builder.property("orientation", orientation),
989        }
990    }
991
992    // rustdoc-stripper-ignore-next
993    /// Build the [`Scale`].
994    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
995    pub fn build(self) -> Scale {
996        assert_initialized_main_thread!();
997        self.builder.build()
998    }
999}
1000
1001/// Trait containing all [`struct@Scale`] methods.
1002///
1003/// # Implementors
1004///
1005/// [`Scale`][struct@crate::Scale]
1006pub trait ScaleExt: IsA<Scale> + 'static {
1007    /// Adds a mark at @value.
1008    ///
1009    /// A mark is indicated visually by drawing a tick mark next to the scale,
1010    /// and GTK makes it easy for the user to position the scale exactly at the
1011    /// marks value.
1012    ///
1013    /// If @markup is not [`None`], text is shown next to the tick mark.
1014    ///
1015    /// To remove marks from a scale, use [`clear_marks()`][Self::clear_marks()].
1016    /// ## `value`
1017    /// the value at which the mark is placed, must be between
1018    ///   the lower and upper limits of the scales’ adjustment
1019    /// ## `position`
1020    /// where to draw the mark. For a horizontal scale, [`PositionType::Top`][crate::PositionType::Top]
1021    ///   and [`PositionType::Left`][crate::PositionType::Left] are drawn above the scale, anything else below.
1022    ///   For a vertical scale, [`PositionType::Left`][crate::PositionType::Left] and [`PositionType::Top`][crate::PositionType::Top] are drawn to
1023    ///   the left of the scale, anything else to the right.
1024    /// ## `markup`
1025    /// Text to be shown at the mark, using Pango markup
1026    #[doc(alias = "gtk_scale_add_mark")]
1027    fn add_mark(&self, value: f64, position: PositionType, markup: Option<&str>) {
1028        unsafe {
1029            ffi::gtk_scale_add_mark(
1030                self.as_ref().to_glib_none().0,
1031                value,
1032                position.into_glib(),
1033                markup.to_glib_none().0,
1034            );
1035        }
1036    }
1037
1038    /// Removes any marks that have been added.
1039    #[doc(alias = "gtk_scale_clear_marks")]
1040    fn clear_marks(&self) {
1041        unsafe {
1042            ffi::gtk_scale_clear_marks(self.as_ref().to_glib_none().0);
1043        }
1044    }
1045
1046    /// Gets the number of decimal places that are displayed in the value.
1047    ///
1048    /// # Returns
1049    ///
1050    /// the number of decimal places that are displayed
1051    #[doc(alias = "gtk_scale_get_digits")]
1052    #[doc(alias = "get_digits")]
1053    fn digits(&self) -> i32 {
1054        unsafe { ffi::gtk_scale_get_digits(self.as_ref().to_glib_none().0) }
1055    }
1056
1057    /// Returns whether the current value is displayed as a string
1058    /// next to the slider.
1059    ///
1060    /// # Returns
1061    ///
1062    /// whether the current value is displayed as a string
1063    #[doc(alias = "gtk_scale_get_draw_value")]
1064    #[doc(alias = "get_draw_value")]
1065    #[doc(alias = "draw-value")]
1066    fn draws_value(&self) -> bool {
1067        unsafe {
1068            from_glib(ffi::gtk_scale_get_draw_value(
1069                self.as_ref().to_glib_none().0,
1070            ))
1071        }
1072    }
1073
1074    /// Returns whether the scale has an origin.
1075    ///
1076    /// # Returns
1077    ///
1078    /// [`true`] if the scale has an origin.
1079    #[doc(alias = "gtk_scale_get_has_origin")]
1080    #[doc(alias = "get_has_origin")]
1081    #[doc(alias = "has-origin")]
1082    fn has_origin(&self) -> bool {
1083        unsafe {
1084            from_glib(ffi::gtk_scale_get_has_origin(
1085                self.as_ref().to_glib_none().0,
1086            ))
1087        }
1088    }
1089
1090    /// Gets the [`pango::Layout`][crate::pango::Layout] used to display the scale.
1091    ///
1092    /// The returned object is owned by the scale so does not need
1093    /// to be freed by the caller.
1094    ///
1095    /// # Returns
1096    ///
1097    /// the [`pango::Layout`][crate::pango::Layout]
1098    ///   for this scale, or [`None`] if the [`draw-value`][struct@crate::Scale#draw-value]
1099    ///   property is [`false`].
1100    #[doc(alias = "gtk_scale_get_layout")]
1101    #[doc(alias = "get_layout")]
1102    fn layout(&self) -> Option<pango::Layout> {
1103        unsafe { from_glib_none(ffi::gtk_scale_get_layout(self.as_ref().to_glib_none().0)) }
1104    }
1105
1106    /// Obtains the coordinates where the scale will draw the
1107    /// [`pango::Layout`][crate::pango::Layout] representing the text in the scale.
1108    ///
1109    /// Remember when using the [`pango::Layout`][crate::pango::Layout] function you need to
1110    /// convert to and from pixels using `PANGO_PIXELS()` or `PANGO_SCALE`.
1111    ///
1112    /// If the [`draw-value`][struct@crate::Scale#draw-value] property is [`false`], the return
1113    /// values are undefined.
1114    ///
1115    /// # Returns
1116    ///
1117    ///
1118    /// ## `x`
1119    /// location to store X offset of layout
1120    ///
1121    /// ## `y`
1122    /// location to store Y offset of layout
1123    #[doc(alias = "gtk_scale_get_layout_offsets")]
1124    #[doc(alias = "get_layout_offsets")]
1125    fn layout_offsets(&self) -> (i32, i32) {
1126        unsafe {
1127            let mut x = std::mem::MaybeUninit::uninit();
1128            let mut y = std::mem::MaybeUninit::uninit();
1129            ffi::gtk_scale_get_layout_offsets(
1130                self.as_ref().to_glib_none().0,
1131                x.as_mut_ptr(),
1132                y.as_mut_ptr(),
1133            );
1134            (x.assume_init(), y.assume_init())
1135        }
1136    }
1137
1138    /// Gets the position in which the current value is displayed.
1139    ///
1140    /// # Returns
1141    ///
1142    /// the position in which the current value is displayed
1143    #[doc(alias = "gtk_scale_get_value_pos")]
1144    #[doc(alias = "get_value_pos")]
1145    #[doc(alias = "value-pos")]
1146    fn value_pos(&self) -> PositionType {
1147        unsafe { from_glib(ffi::gtk_scale_get_value_pos(self.as_ref().to_glib_none().0)) }
1148    }
1149
1150    /// Sets the number of decimal places that are displayed in the value.
1151    ///
1152    /// Also causes the value of the adjustment to be rounded to this number
1153    /// of digits, so the retrieved value matches the displayed one, if
1154    /// [`draw-value`][struct@crate::Scale#draw-value] is [`true`] when the value changes. If
1155    /// you want to enforce rounding the value when [`draw-value`][struct@crate::Scale#draw-value]
1156    /// is [`false`], you can set [`round-digits`][struct@crate::Range#round-digits] instead.
1157    ///
1158    /// Note that rounding to a small number of digits can interfere with
1159    /// the smooth autoscrolling that is built into [`Scale`][crate::Scale]. As an alternative,
1160    /// you can use [`set_format_value_func()`][Self::set_format_value_func()] to format the displayed
1161    /// value yourself.
1162    /// ## `digits`
1163    /// the number of decimal places to display,
1164    ///   e.g. use 1 to display 1.0, 2 to display 1.00, etc
1165    #[doc(alias = "gtk_scale_set_digits")]
1166    #[doc(alias = "digits")]
1167    fn set_digits(&self, digits: i32) {
1168        unsafe {
1169            ffi::gtk_scale_set_digits(self.as_ref().to_glib_none().0, digits);
1170        }
1171    }
1172
1173    /// Specifies whether the current value is displayed as a string next
1174    /// to the slider.
1175    /// ## `draw_value`
1176    /// [`true`] to draw the value
1177    #[doc(alias = "gtk_scale_set_draw_value")]
1178    #[doc(alias = "draw-value")]
1179    fn set_draw_value(&self, draw_value: bool) {
1180        unsafe {
1181            ffi::gtk_scale_set_draw_value(self.as_ref().to_glib_none().0, draw_value.into_glib());
1182        }
1183    }
1184
1185    /// @func allows you to change how the scale value is displayed.
1186    ///
1187    /// The given function will return an allocated string representing
1188    /// @value. That string will then be used to display the scale's value.
1189    ///
1190    /// If #NULL is passed as @func, the value will be displayed on
1191    /// its own, rounded according to the value of the
1192    /// [`digits`][struct@crate::Scale#digits] property.
1193    /// ## `func`
1194    /// function
1195    ///   that formats the value
1196    /// ## `destroy_notify`
1197    /// destroy function for @user_data
1198    #[doc(alias = "gtk_scale_set_format_value_func")]
1199    fn set_format_value_func<P: Fn(&Scale, f64) -> String + 'static>(&self, func: P) {
1200        let func_data: Box_<P> = Box_::new(func);
1201        unsafe extern "C" fn func_func<P: Fn(&Scale, f64) -> String + 'static>(
1202            scale: *mut ffi::GtkScale,
1203            value: std::ffi::c_double,
1204            user_data: glib::ffi::gpointer,
1205        ) -> *mut std::ffi::c_char {
1206            let scale = from_glib_borrow(scale);
1207            let callback = &*(user_data as *mut P);
1208            (*callback)(&scale, value).to_glib_full()
1209        }
1210        let func = Some(func_func::<P> as _);
1211        unsafe extern "C" fn destroy_notify_func<P: Fn(&Scale, f64) -> String + 'static>(
1212            data: glib::ffi::gpointer,
1213        ) {
1214            let _callback = Box_::from_raw(data as *mut P);
1215        }
1216        let destroy_call3 = Some(destroy_notify_func::<P> as _);
1217        let super_callback0: Box_<P> = func_data;
1218        unsafe {
1219            ffi::gtk_scale_set_format_value_func(
1220                self.as_ref().to_glib_none().0,
1221                func,
1222                Box_::into_raw(super_callback0) as *mut _,
1223                destroy_call3,
1224            );
1225        }
1226    }
1227
1228    /// Sets whether the scale has an origin.
1229    ///
1230    /// If [`has-origin`][struct@crate::Scale#has-origin] is set to [`true`] (the default),
1231    /// the scale will highlight the part of the trough between the origin
1232    /// (bottom or left side) and the current value.
1233    /// ## `has_origin`
1234    /// [`true`] if the scale has an origin
1235    #[doc(alias = "gtk_scale_set_has_origin")]
1236    #[doc(alias = "has-origin")]
1237    fn set_has_origin(&self, has_origin: bool) {
1238        unsafe {
1239            ffi::gtk_scale_set_has_origin(self.as_ref().to_glib_none().0, has_origin.into_glib());
1240        }
1241    }
1242
1243    /// Sets the position in which the current value is displayed.
1244    /// ## `pos`
1245    /// the position in which the current value is displayed
1246    #[doc(alias = "gtk_scale_set_value_pos")]
1247    #[doc(alias = "value-pos")]
1248    fn set_value_pos(&self, pos: PositionType) {
1249        unsafe {
1250            ffi::gtk_scale_set_value_pos(self.as_ref().to_glib_none().0, pos.into_glib());
1251        }
1252    }
1253
1254    #[doc(alias = "digits")]
1255    fn connect_digits_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1256        unsafe extern "C" fn notify_digits_trampoline<P: IsA<Scale>, F: Fn(&P) + 'static>(
1257            this: *mut ffi::GtkScale,
1258            _param_spec: glib::ffi::gpointer,
1259            f: glib::ffi::gpointer,
1260        ) {
1261            let f: &F = &*(f as *const F);
1262            f(Scale::from_glib_borrow(this).unsafe_cast_ref())
1263        }
1264        unsafe {
1265            let f: Box_<F> = Box_::new(f);
1266            connect_raw(
1267                self.as_ptr() as *mut _,
1268                c"notify::digits".as_ptr() as *const _,
1269                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1270                    notify_digits_trampoline::<Self, F> as *const (),
1271                )),
1272                Box_::into_raw(f),
1273            )
1274        }
1275    }
1276
1277    #[doc(alias = "draw-value")]
1278    fn connect_draw_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1279        unsafe extern "C" fn notify_draw_value_trampoline<P: IsA<Scale>, F: Fn(&P) + 'static>(
1280            this: *mut ffi::GtkScale,
1281            _param_spec: glib::ffi::gpointer,
1282            f: glib::ffi::gpointer,
1283        ) {
1284            let f: &F = &*(f as *const F);
1285            f(Scale::from_glib_borrow(this).unsafe_cast_ref())
1286        }
1287        unsafe {
1288            let f: Box_<F> = Box_::new(f);
1289            connect_raw(
1290                self.as_ptr() as *mut _,
1291                c"notify::draw-value".as_ptr() as *const _,
1292                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1293                    notify_draw_value_trampoline::<Self, F> as *const (),
1294                )),
1295                Box_::into_raw(f),
1296            )
1297        }
1298    }
1299
1300    #[doc(alias = "has-origin")]
1301    fn connect_has_origin_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1302        unsafe extern "C" fn notify_has_origin_trampoline<P: IsA<Scale>, F: Fn(&P) + 'static>(
1303            this: *mut ffi::GtkScale,
1304            _param_spec: glib::ffi::gpointer,
1305            f: glib::ffi::gpointer,
1306        ) {
1307            let f: &F = &*(f as *const F);
1308            f(Scale::from_glib_borrow(this).unsafe_cast_ref())
1309        }
1310        unsafe {
1311            let f: Box_<F> = Box_::new(f);
1312            connect_raw(
1313                self.as_ptr() as *mut _,
1314                c"notify::has-origin".as_ptr() as *const _,
1315                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1316                    notify_has_origin_trampoline::<Self, F> as *const (),
1317                )),
1318                Box_::into_raw(f),
1319            )
1320        }
1321    }
1322
1323    #[doc(alias = "value-pos")]
1324    fn connect_value_pos_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1325        unsafe extern "C" fn notify_value_pos_trampoline<P: IsA<Scale>, F: Fn(&P) + 'static>(
1326            this: *mut ffi::GtkScale,
1327            _param_spec: glib::ffi::gpointer,
1328            f: glib::ffi::gpointer,
1329        ) {
1330            let f: &F = &*(f as *const F);
1331            f(Scale::from_glib_borrow(this).unsafe_cast_ref())
1332        }
1333        unsafe {
1334            let f: Box_<F> = Box_::new(f);
1335            connect_raw(
1336                self.as_ptr() as *mut _,
1337                c"notify::value-pos".as_ptr() as *const _,
1338                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1339                    notify_value_pos_trampoline::<Self, F> as *const (),
1340                )),
1341                Box_::into_raw(f),
1342            )
1343        }
1344    }
1345}
1346
1347impl<O: IsA<Scale>> ScaleExt for O {}