Skip to main content

gtk4/auto/
scale_button.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::{
9    AccessibleRole, Adjustment, Align, Buildable, Button, ConstraintTarget, LayoutManager,
10    Orientable, Orientation, Overflow, Widget, ffi,
11};
12use glib::{
13    object::ObjectType as _,
14    prelude::*,
15    signal::{SignalHandlerId, connect_raw},
16    translate::*,
17};
18use std::boxed::Box as Box_;
19
20#[cfg(feature = "v4_10")]
21#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
22glib::wrapper! {
23    ///
24    /// ```text
25    ///
26    /// [`ScaleButton`][crate::ScaleButton] has a single CSS node with name scalebutton and `.scale`
27    /// style class, and contains a `button` node with a `.toggle` style class.
28    ///
29    /// ## Properties
30    ///
31    ///
32    /// #### `active`
33    ///  If the scale button should be pressed in.
34    ///
35    /// Readable
36    ///
37    ///
38    /// #### `adjustment`
39    ///  The [`Adjustment`][crate::Adjustment] that is used as the model.
40    ///
41    /// Readable | Writable
42    ///
43    ///
44    /// #### `has-frame`
45    ///  If the scale button has a frame.
46    ///
47    /// Readable | Writable
48    ///
49    ///
50    /// #### `icons`
51    ///  The names of the icons to be used by the scale button.
52    ///
53    /// The first item in the array will be used in the button
54    /// when the current value is the lowest value, the second
55    /// item for the highest value. All the subsequent icons will
56    /// be used for all the other values, spread evenly over the
57    /// range of values.
58    ///
59    /// If there's only one icon name in the @icons array, it will
60    /// be used for all the values. If only two icon names are in
61    /// the @icons array, the first one will be used for the bottom
62    /// 50% of the scale, and the second one for the top 50%.
63    ///
64    /// It is recommended to use at least 3 icons so that the
65    /// [`ScaleButton`][crate::ScaleButton] reflects the current value of the scale
66    /// better for the users.
67    ///
68    /// Readable | Writable
69    ///
70    ///
71    /// #### `value`
72    ///  The value of the scale.
73    ///
74    /// Readable | Writable
75    /// <details><summary><h4>Widget</h4></summary>
76    ///
77    ///
78    /// #### `can-focus`
79    ///  Whether the widget or any of its descendents can accept
80    /// the input focus.
81    ///
82    /// This property is meant to be set by widget implementations,
83    /// typically in their instance init function.
84    ///
85    /// Readable | Writable
86    ///
87    ///
88    /// #### `can-target`
89    ///  Whether the widget can receive pointer events.
90    ///
91    /// Readable | Writable
92    ///
93    ///
94    /// #### `css-classes`
95    ///  A list of css classes applied to this widget.
96    ///
97    /// Readable | Writable
98    ///
99    ///
100    /// #### `css-name`
101    ///  The name of this widget in the CSS tree.
102    ///
103    /// This property is meant to be set by widget implementations,
104    /// typically in their instance init function.
105    ///
106    /// Readable | Writable | Construct Only
107    ///
108    ///
109    /// #### `cursor`
110    ///  The cursor used by @widget.
111    ///
112    /// Readable | Writable
113    ///
114    ///
115    /// #### `focus-on-click`
116    ///  Whether the widget should grab focus when it is clicked with the mouse.
117    ///
118    /// This property is only relevant for widgets that can take focus.
119    ///
120    /// Readable | Writable
121    ///
122    ///
123    /// #### `focusable`
124    ///  Whether this widget itself will accept the input focus.
125    ///
126    /// Readable | Writable
127    ///
128    ///
129    /// #### `halign`
130    ///  How to distribute horizontal space if widget gets extra space.
131    ///
132    /// Readable | Writable
133    ///
134    ///
135    /// #### `has-default`
136    ///  Whether the widget is the default widget.
137    ///
138    /// Readable
139    ///
140    ///
141    /// #### `has-focus`
142    ///  Whether the widget has the input focus.
143    ///
144    /// Readable
145    ///
146    ///
147    /// #### `has-tooltip`
148    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
149    /// signal on @widget.
150    ///
151    /// A true value indicates that @widget can have a tooltip, in this case
152    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
153    /// determine whether it will provide a tooltip or not.
154    ///
155    /// Readable | Writable
156    ///
157    ///
158    /// #### `height-request`
159    ///  Overrides for height request of the widget.
160    ///
161    /// If this is -1, the natural request will be used.
162    ///
163    /// Readable | Writable
164    ///
165    ///
166    /// #### `hexpand`
167    ///  Whether to expand horizontally.
168    ///
169    /// Readable | Writable
170    ///
171    ///
172    /// #### `hexpand-set`
173    ///  Whether to use the `hexpand` property.
174    ///
175    /// Readable | Writable
176    ///
177    ///
178    /// #### `layout-manager`
179    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
180    /// the preferred size of the widget, and allocate its children.
181    ///
182    /// This property is meant to be set by widget implementations,
183    /// typically in their instance init function.
184    ///
185    /// Readable | Writable
186    ///
187    ///
188    /// #### `limit-events`
189    ///  Makes this widget act like a modal dialog, with respect to
190    /// event delivery.
191    ///
192    /// Global event controllers will not handle events with targets
193    /// inside the widget, unless they are set up to ignore propagation
194    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
195    ///
196    /// Readable | Writable
197    ///
198    ///
199    /// #### `margin-bottom`
200    ///  Margin on bottom side of widget.
201    ///
202    /// This property adds margin outside of the widget's normal size
203    /// request, the margin will be added in addition to the size from
204    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
205    ///
206    /// Readable | Writable
207    ///
208    ///
209    /// #### `margin-end`
210    ///  Margin on end of widget, horizontally.
211    ///
212    /// This property supports left-to-right and right-to-left text
213    /// directions.
214    ///
215    /// This property adds margin outside of the widget's normal size
216    /// request, the margin will be added in addition to the size from
217    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
218    ///
219    /// Readable | Writable
220    ///
221    ///
222    /// #### `margin-start`
223    ///  Margin on start of widget, horizontally.
224    ///
225    /// This property supports left-to-right and right-to-left text
226    /// directions.
227    ///
228    /// This property adds margin outside of the widget's normal size
229    /// request, the margin will be added in addition to the size from
230    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
231    ///
232    /// Readable | Writable
233    ///
234    ///
235    /// #### `margin-top`
236    ///  Margin on top side of widget.
237    ///
238    /// This property adds margin outside of the widget's normal size
239    /// request, the margin will be added in addition to the size from
240    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
241    ///
242    /// Readable | Writable
243    ///
244    ///
245    /// #### `name`
246    ///  The name of the widget.
247    ///
248    /// Readable | Writable
249    ///
250    ///
251    /// #### `opacity`
252    ///  The requested opacity of the widget.
253    ///
254    /// Readable | Writable
255    ///
256    ///
257    /// #### `overflow`
258    ///  How content outside the widget's content area is treated.
259    ///
260    /// This property is meant to be set by widget implementations,
261    /// typically in their instance init function.
262    ///
263    /// Readable | Writable
264    ///
265    ///
266    /// #### `parent`
267    ///  The parent widget of this widget.
268    ///
269    /// Readable
270    ///
271    ///
272    /// #### `receives-default`
273    ///  Whether the widget will receive the default action when it is focused.
274    ///
275    /// Readable | Writable
276    ///
277    ///
278    /// #### `root`
279    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
280    ///
281    /// This will be `NULL` if the widget is not contained in a root widget.
282    ///
283    /// Readable
284    ///
285    ///
286    /// #### `scale-factor`
287    ///  The scale factor of the widget.
288    ///
289    /// Readable
290    ///
291    ///
292    /// #### `sensitive`
293    ///  Whether the widget responds to input.
294    ///
295    /// Readable | Writable
296    ///
297    ///
298    /// #### `tooltip-markup`
299    ///  Sets the text of tooltip to be the given string, which is marked up
300    /// with Pango markup.
301    ///
302    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
303    ///
304    /// This is a convenience property which will take care of getting the
305    /// tooltip shown if the given string is not `NULL`:
306    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
307    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
308    /// the default signal handler.
309    ///
310    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
311    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
312    ///
313    /// Readable | Writable
314    ///
315    ///
316    /// #### `tooltip-text`
317    ///  Sets the text of tooltip to be the given string.
318    ///
319    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
320    ///
321    /// This is a convenience property which will take care of getting the
322    /// tooltip shown if the given string is not `NULL`:
323    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
324    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
325    /// the default signal handler.
326    ///
327    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
328    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
329    ///
330    /// Readable | Writable
331    ///
332    ///
333    /// #### `valign`
334    ///  How to distribute vertical space if widget gets extra space.
335    ///
336    /// Readable | Writable
337    ///
338    ///
339    /// #### `vexpand`
340    ///  Whether to expand vertically.
341    ///
342    /// Readable | Writable
343    ///
344    ///
345    /// #### `vexpand-set`
346    ///  Whether to use the `vexpand` property.
347    ///
348    /// Readable | Writable
349    ///
350    ///
351    /// #### `visible`
352    ///  Whether the widget is visible.
353    ///
354    /// Readable | Writable
355    ///
356    ///
357    /// #### `width-request`
358    ///  Overrides for width request of the widget.
359    ///
360    /// If this is -1, the natural request will be used.
361    ///
362    /// Readable | Writable
363    /// </details>
364    /// <details><summary><h4>Accessible</h4></summary>
365    ///
366    ///
367    /// #### `accessible-role`
368    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
369    ///
370    /// The accessible role cannot be changed once set.
371    ///
372    /// Readable | Writable
373    /// </details>
374    /// <details><summary><h4>Orientable</h4></summary>
375    ///
376    ///
377    /// #### `orientation`
378    ///  The orientation of the orientable.
379    ///
380    /// Readable | Writable
381    /// </details>
382    ///
383    /// ## Signals
384    ///
385    ///
386    /// #### `popdown`
387    ///  .
388    ///
389    /// Action
390    ///
391    ///
392    /// #### `popup`
393    ///  .
394    ///
395    /// Action
396    ///
397    ///
398    /// #### `value-changed`
399    ///  Emitted when the value field has changed.
400    ///
401    ///
402    /// <details><summary><h4>Widget</h4></summary>
403    ///
404    ///
405    /// #### `destroy`
406    ///  Signals that all holders of a reference to the widget should release
407    /// the reference that they hold.
408    ///
409    /// May result in finalization of the widget if all references are released.
410    ///
411    /// This signal is not suitable for saving widget state.
412    ///
413    ///
414    ///
415    ///
416    /// #### `direction-changed`
417    ///  Emitted when the text direction of a widget changes.
418    ///
419    ///
420    ///
421    ///
422    /// #### `hide`
423    ///  Emitted when @widget is hidden.
424    ///
425    ///
426    ///
427    ///
428    /// #### `keynav-failed`
429    ///  Emitted if keyboard navigation fails.
430    ///
431    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
432    ///
433    ///
434    ///
435    ///
436    /// #### `map`
437    ///  Emitted when @widget is going to be mapped.
438    ///
439    /// A widget is mapped when the widget is visible (which is controlled with
440    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
441    /// are also visible.
442    ///
443    /// The `::map` signal can be used to determine whether a widget will be drawn,
444    /// for instance it can resume an animation that was stopped during the
445    /// emission of [`unmap`][struct@crate::Widget#unmap].
446    ///
447    ///
448    ///
449    ///
450    /// #### `mnemonic-activate`
451    ///  Emitted when a widget is activated via a mnemonic.
452    ///
453    /// The default handler for this signal activates @widget if @group_cycling
454    /// is false, or just makes @widget grab focus if @group_cycling is true.
455    ///
456    ///
457    ///
458    ///
459    /// #### `move-focus`
460    ///   to move backward.
461    ///
462    /// Action
463    ///
464    ///
465    /// #### `query-tooltip`
466    ///  Emitted when the widget’s tooltip is about to be shown.
467    ///
468    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
469    /// is true and the hover timeout has expired with the cursor hovering
470    /// above @widget; or emitted when @widget got focus in keyboard mode.
471    ///
472    /// Using the given coordinates, the signal handler should determine
473    /// whether a tooltip should be shown for @widget. If this is the case
474    /// true should be returned, false otherwise. Note that if @keyboard_mode
475    /// is true, the values of @x and @y are undefined and should not be used.
476    ///
477    /// The signal handler is free to manipulate @tooltip with the therefore
478    /// destined function calls.
479    ///
480    ///
481    ///
482    ///
483    /// #### `realize`
484    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
485    ///
486    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
487    /// or the widget has been mapped (that is, it is going to be drawn).
488    ///
489    ///
490    ///
491    ///
492    /// #### `show`
493    ///  Emitted when @widget is shown.
494    ///
495    ///
496    ///
497    ///
498    /// #### `state-flags-changed`
499    ///  Emitted when the widget state changes.
500    ///
501    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
502    ///
503    ///
504    ///
505    ///
506    /// #### `unmap`
507    ///  Emitted when @widget is going to be unmapped.
508    ///
509    /// A widget is unmapped when either it or any of its parents up to the
510    /// toplevel widget have been set as hidden.
511    ///
512    /// As `::unmap` indicates that a widget will not be shown any longer,
513    /// it can be used to, for example, stop an animation on the widget.
514    ///
515    ///
516    ///
517    ///
518    /// #### `unrealize`
519    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
520    ///
521    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
522    /// or the widget has been unmapped (that is, it is going to be hidden).
523    ///
524    ///
525    /// </details>
526    ///
527    /// # Implements
528    ///
529    /// [`ScaleButtonExt`][trait@crate::prelude::ScaleButtonExt], [`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]
530    #[doc(alias = "GtkScaleButton")]
531    pub struct ScaleButton(Object<ffi::GtkScaleButton, ffi::GtkScaleButtonClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, AccessibleRange, Orientable;
532
533    match fn {
534        type_ => || ffi::gtk_scale_button_get_type(),
535    }
536}
537
538#[cfg(not(feature = "v4_10"))]
539glib::wrapper! {
540    #[doc(alias = "GtkScaleButton")]
541    pub struct ScaleButton(Object<ffi::GtkScaleButton, ffi::GtkScaleButtonClass>) @extends Widget, @implements Buildable, ConstraintTarget, Orientable;
542
543    match fn {
544        type_ => || ffi::gtk_scale_button_get_type(),
545    }
546}
547
548impl ScaleButton {
549    pub const NONE: Option<&'static ScaleButton> = None;
550
551    /// Creates a [`ScaleButton`][crate::ScaleButton].
552    ///
553    /// The new scale button has a range between @min and @max,
554    /// with a stepping of @step.
555    /// ## `min`
556    /// the minimum value of the scale (usually 0)
557    /// ## `max`
558    /// the maximum value of the scale (usually 100)
559    /// ## `step`
560    /// the stepping of value when a scroll-wheel event,
561    ///   or up/down arrow event occurs (usually 2)
562    /// ## `icons`
563    /// a [`None`]-terminated
564    ///   array of icon names, or [`None`] if you want to set the list
565    ///   later with gtk_scale_button_set_icons()
566    ///
567    /// # Returns
568    ///
569    /// a new [`ScaleButton`][crate::ScaleButton]
570    #[doc(alias = "gtk_scale_button_new")]
571    pub fn new(min: f64, max: f64, step: f64, icons: &[&str]) -> ScaleButton {
572        assert_initialized_main_thread!();
573        unsafe {
574            Widget::from_glib_none(ffi::gtk_scale_button_new(
575                min,
576                max,
577                step,
578                icons.to_glib_none().0,
579            ))
580            .unsafe_cast()
581        }
582    }
583
584    // rustdoc-stripper-ignore-next
585    /// Creates a new builder-pattern struct instance to construct [`ScaleButton`] objects.
586    ///
587    /// This method returns an instance of [`ScaleButtonBuilder`](crate::builders::ScaleButtonBuilder) which can be used to create [`ScaleButton`] objects.
588    pub fn builder() -> ScaleButtonBuilder {
589        ScaleButtonBuilder::new()
590    }
591}
592
593impl Default for ScaleButton {
594    fn default() -> Self {
595        glib::object::Object::new::<Self>()
596    }
597}
598
599// rustdoc-stripper-ignore-next
600/// A [builder-pattern] type to construct [`ScaleButton`] objects.
601///
602/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
603#[must_use = "The builder must be built to be used"]
604pub struct ScaleButtonBuilder {
605    builder: glib::object::ObjectBuilder<'static, ScaleButton>,
606}
607
608impl ScaleButtonBuilder {
609    fn new() -> Self {
610        Self {
611            builder: glib::object::Object::builder(),
612        }
613    }
614
615    /// The [`Adjustment`][crate::Adjustment] that is used as the model.
616    pub fn adjustment(self, adjustment: &impl IsA<Adjustment>) -> Self {
617        Self {
618            builder: self
619                .builder
620                .property("adjustment", adjustment.clone().upcast()),
621        }
622    }
623
624    /// If the scale button has a frame.
625    #[cfg(feature = "v4_14")]
626    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
627    pub fn has_frame(self, has_frame: bool) -> Self {
628        Self {
629            builder: self.builder.property("has-frame", has_frame),
630        }
631    }
632
633    /// The names of the icons to be used by the scale button.
634    ///
635    /// The first item in the array will be used in the button
636    /// when the current value is the lowest value, the second
637    /// item for the highest value. All the subsequent icons will
638    /// be used for all the other values, spread evenly over the
639    /// range of values.
640    ///
641    /// If there's only one icon name in the @icons array, it will
642    /// be used for all the values. If only two icon names are in
643    /// the @icons array, the first one will be used for the bottom
644    /// 50% of the scale, and the second one for the top 50%.
645    ///
646    /// It is recommended to use at least 3 icons so that the
647    /// [`ScaleButton`][crate::ScaleButton] reflects the current value of the scale
648    /// better for the users.
649    pub fn icons(self, icons: impl Into<glib::StrV>) -> Self {
650        Self {
651            builder: self.builder.property("icons", icons.into()),
652        }
653    }
654
655    /// The value of the scale.
656    pub fn value(self, value: f64) -> Self {
657        Self {
658            builder: self.builder.property("value", value),
659        }
660    }
661
662    /// Whether the widget or any of its descendents can accept
663    /// the input focus.
664    ///
665    /// This property is meant to be set by widget implementations,
666    /// typically in their instance init function.
667    pub fn can_focus(self, can_focus: bool) -> Self {
668        Self {
669            builder: self.builder.property("can-focus", can_focus),
670        }
671    }
672
673    /// Whether the widget can receive pointer events.
674    pub fn can_target(self, can_target: bool) -> Self {
675        Self {
676            builder: self.builder.property("can-target", can_target),
677        }
678    }
679
680    /// A list of css classes applied to this widget.
681    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
682        Self {
683            builder: self.builder.property("css-classes", css_classes.into()),
684        }
685    }
686
687    /// The name of this widget in the CSS tree.
688    ///
689    /// This property is meant to be set by widget implementations,
690    /// typically in their instance init function.
691    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
692        Self {
693            builder: self.builder.property("css-name", css_name.into()),
694        }
695    }
696
697    /// The cursor used by @widget.
698    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
699        Self {
700            builder: self.builder.property("cursor", cursor.clone()),
701        }
702    }
703
704    /// Whether the widget should grab focus when it is clicked with the mouse.
705    ///
706    /// This property is only relevant for widgets that can take focus.
707    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
708        Self {
709            builder: self.builder.property("focus-on-click", focus_on_click),
710        }
711    }
712
713    /// Whether this widget itself will accept the input focus.
714    pub fn focusable(self, focusable: bool) -> Self {
715        Self {
716            builder: self.builder.property("focusable", focusable),
717        }
718    }
719
720    /// How to distribute horizontal space if widget gets extra space.
721    pub fn halign(self, halign: Align) -> Self {
722        Self {
723            builder: self.builder.property("halign", halign),
724        }
725    }
726
727    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
728    /// signal on @widget.
729    ///
730    /// A true value indicates that @widget can have a tooltip, in this case
731    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
732    /// determine whether it will provide a tooltip or not.
733    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
734        Self {
735            builder: self.builder.property("has-tooltip", has_tooltip),
736        }
737    }
738
739    /// Overrides for height request of the widget.
740    ///
741    /// If this is -1, the natural request will be used.
742    pub fn height_request(self, height_request: i32) -> Self {
743        Self {
744            builder: self.builder.property("height-request", height_request),
745        }
746    }
747
748    /// Whether to expand horizontally.
749    pub fn hexpand(self, hexpand: bool) -> Self {
750        Self {
751            builder: self.builder.property("hexpand", hexpand),
752        }
753    }
754
755    /// Whether to use the `hexpand` property.
756    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
757        Self {
758            builder: self.builder.property("hexpand-set", hexpand_set),
759        }
760    }
761
762    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
763    /// the preferred size of the widget, and allocate its children.
764    ///
765    /// This property is meant to be set by widget implementations,
766    /// typically in their instance init function.
767    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
768        Self {
769            builder: self
770                .builder
771                .property("layout-manager", layout_manager.clone().upcast()),
772        }
773    }
774
775    /// Makes this widget act like a modal dialog, with respect to
776    /// event delivery.
777    ///
778    /// Global event controllers will not handle events with targets
779    /// inside the widget, unless they are set up to ignore propagation
780    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
781    #[cfg(feature = "v4_18")]
782    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
783    pub fn limit_events(self, limit_events: bool) -> Self {
784        Self {
785            builder: self.builder.property("limit-events", limit_events),
786        }
787    }
788
789    /// Margin on bottom side of widget.
790    ///
791    /// This property adds margin outside of the widget's normal size
792    /// request, the margin will be added in addition to the size from
793    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
794    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
795        Self {
796            builder: self.builder.property("margin-bottom", margin_bottom),
797        }
798    }
799
800    /// Margin on end of widget, horizontally.
801    ///
802    /// This property supports left-to-right and right-to-left text
803    /// directions.
804    ///
805    /// This property adds margin outside of the widget's normal size
806    /// request, the margin will be added in addition to the size from
807    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
808    pub fn margin_end(self, margin_end: i32) -> Self {
809        Self {
810            builder: self.builder.property("margin-end", margin_end),
811        }
812    }
813
814    /// Margin on start of widget, horizontally.
815    ///
816    /// This property supports left-to-right and right-to-left text
817    /// directions.
818    ///
819    /// This property adds margin outside of the widget's normal size
820    /// request, the margin will be added in addition to the size from
821    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
822    pub fn margin_start(self, margin_start: i32) -> Self {
823        Self {
824            builder: self.builder.property("margin-start", margin_start),
825        }
826    }
827
828    /// Margin on top side of widget.
829    ///
830    /// This property adds margin outside of the widget's normal size
831    /// request, the margin will be added in addition to the size from
832    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
833    pub fn margin_top(self, margin_top: i32) -> Self {
834        Self {
835            builder: self.builder.property("margin-top", margin_top),
836        }
837    }
838
839    /// The name of the widget.
840    pub fn name(self, name: impl Into<glib::GString>) -> Self {
841        Self {
842            builder: self.builder.property("name", name.into()),
843        }
844    }
845
846    /// The requested opacity of the widget.
847    pub fn opacity(self, opacity: f64) -> Self {
848        Self {
849            builder: self.builder.property("opacity", opacity),
850        }
851    }
852
853    /// How content outside the widget's content area is treated.
854    ///
855    /// This property is meant to be set by widget implementations,
856    /// typically in their instance init function.
857    pub fn overflow(self, overflow: Overflow) -> Self {
858        Self {
859            builder: self.builder.property("overflow", overflow),
860        }
861    }
862
863    /// Whether the widget will receive the default action when it is focused.
864    pub fn receives_default(self, receives_default: bool) -> Self {
865        Self {
866            builder: self.builder.property("receives-default", receives_default),
867        }
868    }
869
870    /// Whether the widget responds to input.
871    pub fn sensitive(self, sensitive: bool) -> Self {
872        Self {
873            builder: self.builder.property("sensitive", sensitive),
874        }
875    }
876
877    /// Sets the text of tooltip to be the given string, which is marked up
878    /// with Pango markup.
879    ///
880    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
881    ///
882    /// This is a convenience property which will take care of getting the
883    /// tooltip shown if the given string is not `NULL`:
884    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
885    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
886    /// the default signal handler.
887    ///
888    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
889    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
890    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
891        Self {
892            builder: self
893                .builder
894                .property("tooltip-markup", tooltip_markup.into()),
895        }
896    }
897
898    /// Sets the text of tooltip to be the given string.
899    ///
900    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
901    ///
902    /// This is a convenience property which will take care of getting the
903    /// tooltip shown if the given string is not `NULL`:
904    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
905    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
906    /// the default signal handler.
907    ///
908    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
909    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
910    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
911        Self {
912            builder: self.builder.property("tooltip-text", tooltip_text.into()),
913        }
914    }
915
916    /// How to distribute vertical space if widget gets extra space.
917    pub fn valign(self, valign: Align) -> Self {
918        Self {
919            builder: self.builder.property("valign", valign),
920        }
921    }
922
923    /// Whether to expand vertically.
924    pub fn vexpand(self, vexpand: bool) -> Self {
925        Self {
926            builder: self.builder.property("vexpand", vexpand),
927        }
928    }
929
930    /// Whether to use the `vexpand` property.
931    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
932        Self {
933            builder: self.builder.property("vexpand-set", vexpand_set),
934        }
935    }
936
937    /// Whether the widget is visible.
938    pub fn visible(self, visible: bool) -> Self {
939        Self {
940            builder: self.builder.property("visible", visible),
941        }
942    }
943
944    /// Overrides for width request of the widget.
945    ///
946    /// If this is -1, the natural request will be used.
947    pub fn width_request(self, width_request: i32) -> Self {
948        Self {
949            builder: self.builder.property("width-request", width_request),
950        }
951    }
952
953    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
954    ///
955    /// The accessible role cannot be changed once set.
956    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
957        Self {
958            builder: self.builder.property("accessible-role", accessible_role),
959        }
960    }
961
962    /// The orientation of the orientable.
963    pub fn orientation(self, orientation: Orientation) -> Self {
964        Self {
965            builder: self.builder.property("orientation", orientation),
966        }
967    }
968
969    // rustdoc-stripper-ignore-next
970    /// Build the [`ScaleButton`].
971    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
972    pub fn build(self) -> ScaleButton {
973        assert_initialized_main_thread!();
974        self.builder.build()
975    }
976}
977
978/// Trait containing all [`struct@ScaleButton`] methods.
979///
980/// # Implementors
981///
982/// [`ScaleButton`][struct@crate::ScaleButton], [`VolumeButton`][struct@crate::VolumeButton]
983pub trait ScaleButtonExt: IsA<ScaleButton> + 'static {
984    /// Queries a [`ScaleButton`][crate::ScaleButton] and returns its current state.
985    ///
986    /// Returns [`true`] if the scale button is pressed in and [`false`]
987    /// if it is raised.
988    ///
989    /// # Returns
990    ///
991    /// whether the button is pressed
992    #[cfg(feature = "v4_10")]
993    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
994    #[doc(alias = "gtk_scale_button_get_active")]
995    #[doc(alias = "get_active")]
996    #[doc(alias = "active")]
997    fn is_active(&self) -> bool {
998        unsafe {
999            from_glib(ffi::gtk_scale_button_get_active(
1000                self.as_ref().to_glib_none().0,
1001            ))
1002        }
1003    }
1004
1005    /// Gets the [`Adjustment`][crate::Adjustment] associated with the [`ScaleButton`][crate::ScaleButton]’s scale.
1006    ///
1007    /// See [`RangeExt::adjustment()`][crate::prelude::RangeExt::adjustment()] for details.
1008    ///
1009    /// # Returns
1010    ///
1011    /// the adjustment associated with the scale
1012    #[doc(alias = "gtk_scale_button_get_adjustment")]
1013    #[doc(alias = "get_adjustment")]
1014    fn adjustment(&self) -> Adjustment {
1015        unsafe {
1016            from_glib_none(ffi::gtk_scale_button_get_adjustment(
1017                self.as_ref().to_glib_none().0,
1018            ))
1019        }
1020    }
1021
1022    /// Returns whether the button has a frame.
1023    ///
1024    /// # Returns
1025    ///
1026    /// [`true`] if the button has a frame
1027    #[cfg(feature = "v4_14")]
1028    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1029    #[doc(alias = "gtk_scale_button_get_has_frame")]
1030    #[doc(alias = "get_has_frame")]
1031    #[doc(alias = "has-frame")]
1032    fn has_frame(&self) -> bool {
1033        unsafe {
1034            from_glib(ffi::gtk_scale_button_get_has_frame(
1035                self.as_ref().to_glib_none().0,
1036            ))
1037        }
1038    }
1039
1040    /// Retrieves the minus button of the [`ScaleButton`][crate::ScaleButton].
1041    ///
1042    /// # Returns
1043    ///
1044    /// the minus button
1045    ///   of the [`ScaleButton`][crate::ScaleButton]
1046    #[doc(alias = "gtk_scale_button_get_minus_button")]
1047    #[doc(alias = "get_minus_button")]
1048    fn minus_button(&self) -> Button {
1049        unsafe {
1050            from_glib_none(ffi::gtk_scale_button_get_minus_button(
1051                self.as_ref().to_glib_none().0,
1052            ))
1053        }
1054    }
1055
1056    /// Retrieves the plus button of the [`ScaleButton`][crate::ScaleButton]
1057    ///
1058    /// # Returns
1059    ///
1060    /// the plus button
1061    ///   of the [`ScaleButton`][crate::ScaleButton]
1062    #[doc(alias = "gtk_scale_button_get_plus_button")]
1063    #[doc(alias = "get_plus_button")]
1064    fn plus_button(&self) -> Button {
1065        unsafe {
1066            from_glib_none(ffi::gtk_scale_button_get_plus_button(
1067                self.as_ref().to_glib_none().0,
1068            ))
1069        }
1070    }
1071
1072    /// Retrieves the popup of the [`ScaleButton`][crate::ScaleButton].
1073    ///
1074    /// # Returns
1075    ///
1076    /// the popup of the [`ScaleButton`][crate::ScaleButton]
1077    #[doc(alias = "gtk_scale_button_get_popup")]
1078    #[doc(alias = "get_popup")]
1079    fn popup(&self) -> Widget {
1080        unsafe {
1081            from_glib_none(ffi::gtk_scale_button_get_popup(
1082                self.as_ref().to_glib_none().0,
1083            ))
1084        }
1085    }
1086
1087    /// Gets the current value of the scale button.
1088    ///
1089    /// # Returns
1090    ///
1091    /// current value of the scale button
1092    #[doc(alias = "gtk_scale_button_get_value")]
1093    #[doc(alias = "get_value")]
1094    fn value(&self) -> f64 {
1095        unsafe { ffi::gtk_scale_button_get_value(self.as_ref().to_glib_none().0) }
1096    }
1097
1098    /// Sets the [`Adjustment`][crate::Adjustment] to be used as a model
1099    /// for the [`ScaleButton`][crate::ScaleButton]’s scale.
1100    ///
1101    /// See [`RangeExt::set_adjustment()`][crate::prelude::RangeExt::set_adjustment()] for details.
1102    /// ## `adjustment`
1103    /// a [`Adjustment`][crate::Adjustment]
1104    #[doc(alias = "gtk_scale_button_set_adjustment")]
1105    #[doc(alias = "adjustment")]
1106    fn set_adjustment(&self, adjustment: &impl IsA<Adjustment>) {
1107        unsafe {
1108            ffi::gtk_scale_button_set_adjustment(
1109                self.as_ref().to_glib_none().0,
1110                adjustment.as_ref().to_glib_none().0,
1111            );
1112        }
1113    }
1114
1115    /// Sets the style of the button.
1116    /// ## `has_frame`
1117    /// whether the button should have a visible frame
1118    #[cfg(feature = "v4_14")]
1119    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1120    #[doc(alias = "gtk_scale_button_set_has_frame")]
1121    #[doc(alias = "has-frame")]
1122    fn set_has_frame(&self, has_frame: bool) {
1123        unsafe {
1124            ffi::gtk_scale_button_set_has_frame(
1125                self.as_ref().to_glib_none().0,
1126                has_frame.into_glib(),
1127            );
1128        }
1129    }
1130
1131    /// Sets the icons to be used by the scale button.
1132    /// ## `icons`
1133    /// a [`None`]-terminated array of icon names
1134    #[doc(alias = "gtk_scale_button_set_icons")]
1135    #[doc(alias = "icons")]
1136    fn set_icons(&self, icons: &[&str]) {
1137        unsafe {
1138            ffi::gtk_scale_button_set_icons(self.as_ref().to_glib_none().0, icons.to_glib_none().0);
1139        }
1140    }
1141
1142    /// Sets the current value of the scale.
1143    ///
1144    /// If the value is outside the minimum or maximum range values,
1145    /// it will be clamped to fit inside them.
1146    ///
1147    /// The scale button emits the [`value-changed`][struct@crate::ScaleButton#value-changed]
1148    /// signal if the value changes.
1149    /// ## `value`
1150    /// new value of the scale button
1151    #[doc(alias = "gtk_scale_button_set_value")]
1152    #[doc(alias = "value")]
1153    fn set_value(&self, value: f64) {
1154        unsafe {
1155            ffi::gtk_scale_button_set_value(self.as_ref().to_glib_none().0, value);
1156        }
1157    }
1158
1159    /// The names of the icons to be used by the scale button.
1160    ///
1161    /// The first item in the array will be used in the button
1162    /// when the current value is the lowest value, the second
1163    /// item for the highest value. All the subsequent icons will
1164    /// be used for all the other values, spread evenly over the
1165    /// range of values.
1166    ///
1167    /// If there's only one icon name in the @icons array, it will
1168    /// be used for all the values. If only two icon names are in
1169    /// the @icons array, the first one will be used for the bottom
1170    /// 50% of the scale, and the second one for the top 50%.
1171    ///
1172    /// It is recommended to use at least 3 icons so that the
1173    /// [`ScaleButton`][crate::ScaleButton] reflects the current value of the scale
1174    /// better for the users.
1175    fn icons(&self) -> Vec<glib::GString> {
1176        ObjectExt::property(self.as_ref(), "icons")
1177    }
1178
1179    /// .
1180    #[doc(alias = "popdown")]
1181    fn connect_popdown<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1182        unsafe extern "C" fn popdown_trampoline<P: IsA<ScaleButton>, F: Fn(&P) + 'static>(
1183            this: *mut ffi::GtkScaleButton,
1184            f: glib::ffi::gpointer,
1185        ) {
1186            unsafe {
1187                let f: &F = &*(f as *const F);
1188                f(ScaleButton::from_glib_borrow(this).unsafe_cast_ref())
1189            }
1190        }
1191        unsafe {
1192            let f: Box_<F> = Box_::new(f);
1193            connect_raw(
1194                self.as_ptr() as *mut _,
1195                c"popdown".as_ptr(),
1196                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1197                    popdown_trampoline::<Self, F> as *const (),
1198                )),
1199                Box_::into_raw(f),
1200            )
1201        }
1202    }
1203
1204    fn emit_popdown(&self) {
1205        self.emit_by_name::<()>("popdown", &[]);
1206    }
1207
1208    /// .
1209    #[doc(alias = "popup")]
1210    fn connect_popup<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1211        unsafe extern "C" fn popup_trampoline<P: IsA<ScaleButton>, F: Fn(&P) + 'static>(
1212            this: *mut ffi::GtkScaleButton,
1213            f: glib::ffi::gpointer,
1214        ) {
1215            unsafe {
1216                let f: &F = &*(f as *const F);
1217                f(ScaleButton::from_glib_borrow(this).unsafe_cast_ref())
1218            }
1219        }
1220        unsafe {
1221            let f: Box_<F> = Box_::new(f);
1222            connect_raw(
1223                self.as_ptr() as *mut _,
1224                c"popup".as_ptr(),
1225                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1226                    popup_trampoline::<Self, F> as *const (),
1227                )),
1228                Box_::into_raw(f),
1229            )
1230        }
1231    }
1232
1233    fn emit_popup(&self) {
1234        self.emit_by_name::<()>("popup", &[]);
1235    }
1236
1237    /// Emitted when the value field has changed.
1238    /// ## `value`
1239    /// the new value
1240    #[doc(alias = "value-changed")]
1241    fn connect_value_changed<F: Fn(&Self, f64) + 'static>(&self, f: F) -> SignalHandlerId {
1242        unsafe extern "C" fn value_changed_trampoline<
1243            P: IsA<ScaleButton>,
1244            F: Fn(&P, f64) + 'static,
1245        >(
1246            this: *mut ffi::GtkScaleButton,
1247            value: std::ffi::c_double,
1248            f: glib::ffi::gpointer,
1249        ) {
1250            unsafe {
1251                let f: &F = &*(f as *const F);
1252                f(ScaleButton::from_glib_borrow(this).unsafe_cast_ref(), value)
1253            }
1254        }
1255        unsafe {
1256            let f: Box_<F> = Box_::new(f);
1257            connect_raw(
1258                self.as_ptr() as *mut _,
1259                c"value-changed".as_ptr(),
1260                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1261                    value_changed_trampoline::<Self, F> as *const (),
1262                )),
1263                Box_::into_raw(f),
1264            )
1265        }
1266    }
1267
1268    #[cfg(feature = "v4_10")]
1269    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
1270    #[doc(alias = "active")]
1271    fn connect_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1272        unsafe extern "C" fn notify_active_trampoline<P: IsA<ScaleButton>, F: Fn(&P) + 'static>(
1273            this: *mut ffi::GtkScaleButton,
1274            _param_spec: glib::ffi::gpointer,
1275            f: glib::ffi::gpointer,
1276        ) {
1277            unsafe {
1278                let f: &F = &*(f as *const F);
1279                f(ScaleButton::from_glib_borrow(this).unsafe_cast_ref())
1280            }
1281        }
1282        unsafe {
1283            let f: Box_<F> = Box_::new(f);
1284            connect_raw(
1285                self.as_ptr() as *mut _,
1286                c"notify::active".as_ptr(),
1287                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1288                    notify_active_trampoline::<Self, F> as *const (),
1289                )),
1290                Box_::into_raw(f),
1291            )
1292        }
1293    }
1294
1295    #[doc(alias = "adjustment")]
1296    fn connect_adjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1297        unsafe extern "C" fn notify_adjustment_trampoline<
1298            P: IsA<ScaleButton>,
1299            F: Fn(&P) + 'static,
1300        >(
1301            this: *mut ffi::GtkScaleButton,
1302            _param_spec: glib::ffi::gpointer,
1303            f: glib::ffi::gpointer,
1304        ) {
1305            unsafe {
1306                let f: &F = &*(f as *const F);
1307                f(ScaleButton::from_glib_borrow(this).unsafe_cast_ref())
1308            }
1309        }
1310        unsafe {
1311            let f: Box_<F> = Box_::new(f);
1312            connect_raw(
1313                self.as_ptr() as *mut _,
1314                c"notify::adjustment".as_ptr(),
1315                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1316                    notify_adjustment_trampoline::<Self, F> as *const (),
1317                )),
1318                Box_::into_raw(f),
1319            )
1320        }
1321    }
1322
1323    #[cfg(feature = "v4_14")]
1324    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
1325    #[doc(alias = "has-frame")]
1326    fn connect_has_frame_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1327        unsafe extern "C" fn notify_has_frame_trampoline<
1328            P: IsA<ScaleButton>,
1329            F: Fn(&P) + 'static,
1330        >(
1331            this: *mut ffi::GtkScaleButton,
1332            _param_spec: glib::ffi::gpointer,
1333            f: glib::ffi::gpointer,
1334        ) {
1335            unsafe {
1336                let f: &F = &*(f as *const F);
1337                f(ScaleButton::from_glib_borrow(this).unsafe_cast_ref())
1338            }
1339        }
1340        unsafe {
1341            let f: Box_<F> = Box_::new(f);
1342            connect_raw(
1343                self.as_ptr() as *mut _,
1344                c"notify::has-frame".as_ptr(),
1345                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1346                    notify_has_frame_trampoline::<Self, F> as *const (),
1347                )),
1348                Box_::into_raw(f),
1349            )
1350        }
1351    }
1352
1353    #[doc(alias = "icons")]
1354    fn connect_icons_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1355        unsafe extern "C" fn notify_icons_trampoline<P: IsA<ScaleButton>, F: Fn(&P) + 'static>(
1356            this: *mut ffi::GtkScaleButton,
1357            _param_spec: glib::ffi::gpointer,
1358            f: glib::ffi::gpointer,
1359        ) {
1360            unsafe {
1361                let f: &F = &*(f as *const F);
1362                f(ScaleButton::from_glib_borrow(this).unsafe_cast_ref())
1363            }
1364        }
1365        unsafe {
1366            let f: Box_<F> = Box_::new(f);
1367            connect_raw(
1368                self.as_ptr() as *mut _,
1369                c"notify::icons".as_ptr(),
1370                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1371                    notify_icons_trampoline::<Self, F> as *const (),
1372                )),
1373                Box_::into_raw(f),
1374            )
1375        }
1376    }
1377
1378    #[doc(alias = "value")]
1379    fn connect_value_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1380        unsafe extern "C" fn notify_value_trampoline<P: IsA<ScaleButton>, F: Fn(&P) + 'static>(
1381            this: *mut ffi::GtkScaleButton,
1382            _param_spec: glib::ffi::gpointer,
1383            f: glib::ffi::gpointer,
1384        ) {
1385            unsafe {
1386                let f: &F = &*(f as *const F);
1387                f(ScaleButton::from_glib_borrow(this).unsafe_cast_ref())
1388            }
1389        }
1390        unsafe {
1391            let f: Box_<F> = Box_::new(f);
1392            connect_raw(
1393                self.as_ptr() as *mut _,
1394                c"notify::value".as_ptr(),
1395                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1396                    notify_value_trampoline::<Self, F> as *const (),
1397                )),
1398                Box_::into_raw(f),
1399            )
1400        }
1401    }
1402}
1403
1404impl<O: IsA<ScaleButton>> ScaleButtonExt for O {}