gtk4/auto/
scrollbar.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, 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    /// The [`Scrollbar`][crate::Scrollbar] widget is a horizontal or vertical scrollbar.
23    ///
24    /// ![An example GtkScrollbar](scrollbar.png)
25    ///
26    /// Its position and movement are controlled by the adjustment that is passed to
27    /// or created by [`new()`][Self::new()]. See [`Adjustment`][crate::Adjustment] for more
28    /// details. The [`value`][struct@crate::Adjustment#value] field sets the position of the
29    /// thumb and must be between [`lower`][struct@crate::Adjustment#lower] and
30    /// [`upper`][struct@crate::Adjustment#upper] - [`page-size`][struct@crate::Adjustment#page-size].
31    /// The [`page-size`][struct@crate::Adjustment#page-size] represents the size of the visible
32    /// scrollable area.
33    ///
34    /// The fields [`step-increment`][struct@crate::Adjustment#step-increment] and
35    /// [`page-increment`][struct@crate::Adjustment#page-increment] fields are added to or subtracted
36    /// from the [`value`][struct@crate::Adjustment#value] when the user asks to move by a step
37    /// (using e.g. the cursor arrow keys) or by a page (using e.g. the Page Down/Up
38    /// keys).
39    ///
40    /// # CSS nodes
41    ///
42    /// ```text
43    /// scrollbar
44    /// ╰── range[.fine-tune]
45    ///     ╰── trough
46    ///         ╰── slider
47    /// ```
48    ///
49    /// [`Scrollbar`][crate::Scrollbar] has a main CSS node with name scrollbar and a subnode for its
50    /// contents. The main node gets the .horizontal or .vertical style classes applied,
51    /// depending on the scrollbar's orientation.
52    ///
53    /// The range node gets the style class .fine-tune added when the scrollbar is
54    /// in 'fine-tuning' mode.
55    ///
56    /// Other style classes that may be added to scrollbars inside
57    /// [`ScrolledWindow`][crate::ScrolledWindow] include the positional classes (.left, .right,
58    /// .top, .bottom) and style classes related to overlay scrolling (.overlay-indicator,
59    /// .dragging, .hovering).
60    ///
61    /// # Accessibility
62    ///
63    /// [`Scrollbar`][crate::Scrollbar] uses the [`AccessibleRole::Scrollbar`][crate::AccessibleRole::Scrollbar] role.
64    ///
65    /// ## Properties
66    ///
67    ///
68    /// #### `adjustment`
69    ///  The [`Adjustment`][crate::Adjustment] controlled by this scrollbar.
70    ///
71    /// Readable | Writeable | Construct
72    /// <details><summary><h4>Widget</h4></summary>
73    ///
74    ///
75    /// #### `can-focus`
76    ///  Whether the widget or any of its descendents can accept
77    /// the input focus.
78    ///
79    /// This property is meant to be set by widget implementations,
80    /// typically in their instance init function.
81    ///
82    /// Readable | Writeable
83    ///
84    ///
85    /// #### `can-target`
86    ///  Whether the widget can receive pointer events.
87    ///
88    /// Readable | Writeable
89    ///
90    ///
91    /// #### `css-classes`
92    ///  A list of css classes applied to this widget.
93    ///
94    /// Readable | Writeable
95    ///
96    ///
97    /// #### `css-name`
98    ///  The name of this widget in the CSS tree.
99    ///
100    /// This property is meant to be set by widget implementations,
101    /// typically in their instance init function.
102    ///
103    /// Readable | Writeable | Construct Only
104    ///
105    ///
106    /// #### `cursor`
107    ///  The cursor used by @widget.
108    ///
109    /// Readable | Writeable
110    ///
111    ///
112    /// #### `focus-on-click`
113    ///  Whether the widget should grab focus when it is clicked with the mouse.
114    ///
115    /// This property is only relevant for widgets that can take focus.
116    ///
117    /// Readable | Writeable
118    ///
119    ///
120    /// #### `focusable`
121    ///  Whether this widget itself will accept the input focus.
122    ///
123    /// Readable | Writeable
124    ///
125    ///
126    /// #### `halign`
127    ///  How to distribute horizontal space if widget gets extra space.
128    ///
129    /// Readable | Writeable
130    ///
131    ///
132    /// #### `has-default`
133    ///  Whether the widget is the default widget.
134    ///
135    /// Readable
136    ///
137    ///
138    /// #### `has-focus`
139    ///  Whether the widget has the input focus.
140    ///
141    /// Readable
142    ///
143    ///
144    /// #### `has-tooltip`
145    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
146    /// signal on @widget.
147    ///
148    /// A true value indicates that @widget can have a tooltip, in this case
149    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
150    /// determine whether it will provide a tooltip or not.
151    ///
152    /// Readable | Writeable
153    ///
154    ///
155    /// #### `height-request`
156    ///  Overrides for height request of the widget.
157    ///
158    /// If this is -1, the natural request will be used.
159    ///
160    /// Readable | Writeable
161    ///
162    ///
163    /// #### `hexpand`
164    ///  Whether to expand horizontally.
165    ///
166    /// Readable | Writeable
167    ///
168    ///
169    /// #### `hexpand-set`
170    ///  Whether to use the `hexpand` property.
171    ///
172    /// Readable | Writeable
173    ///
174    ///
175    /// #### `layout-manager`
176    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
177    /// the preferred size of the widget, and allocate its children.
178    ///
179    /// This property is meant to be set by widget implementations,
180    /// typically in their instance init function.
181    ///
182    /// Readable | Writeable
183    ///
184    ///
185    /// #### `limit-events`
186    ///  Makes this widget act like a modal dialog, with respect to
187    /// event delivery.
188    ///
189    /// Global event controllers will not handle events with targets
190    /// inside the widget, unless they are set up to ignore propagation
191    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
192    ///
193    /// Readable | Writeable
194    ///
195    ///
196    /// #### `margin-bottom`
197    ///  Margin on bottom side of widget.
198    ///
199    /// This property adds margin outside of the widget's normal size
200    /// request, the margin will be added in addition to the size from
201    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
202    ///
203    /// Readable | Writeable
204    ///
205    ///
206    /// #### `margin-end`
207    ///  Margin on end of widget, horizontally.
208    ///
209    /// This property supports left-to-right and right-to-left text
210    /// directions.
211    ///
212    /// This property adds margin outside of the widget's normal size
213    /// request, the margin will be added in addition to the size from
214    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
215    ///
216    /// Readable | Writeable
217    ///
218    ///
219    /// #### `margin-start`
220    ///  Margin on start of widget, horizontally.
221    ///
222    /// This property supports left-to-right and right-to-left text
223    /// directions.
224    ///
225    /// This property adds margin outside of the widget's normal size
226    /// request, the margin will be added in addition to the size from
227    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
228    ///
229    /// Readable | Writeable
230    ///
231    ///
232    /// #### `margin-top`
233    ///  Margin on top side of widget.
234    ///
235    /// This property adds margin outside of the widget's normal size
236    /// request, the margin will be added in addition to the size from
237    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
238    ///
239    /// Readable | Writeable
240    ///
241    ///
242    /// #### `name`
243    ///  The name of the widget.
244    ///
245    /// Readable | Writeable
246    ///
247    ///
248    /// #### `opacity`
249    ///  The requested opacity of the widget.
250    ///
251    /// Readable | Writeable
252    ///
253    ///
254    /// #### `overflow`
255    ///  How content outside the widget's content area is treated.
256    ///
257    /// This property is meant to be set by widget implementations,
258    /// typically in their instance init function.
259    ///
260    /// Readable | Writeable
261    ///
262    ///
263    /// #### `parent`
264    ///  The parent widget of this widget.
265    ///
266    /// Readable
267    ///
268    ///
269    /// #### `receives-default`
270    ///  Whether the widget will receive the default action when it is focused.
271    ///
272    /// Readable | Writeable
273    ///
274    ///
275    /// #### `root`
276    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
277    ///
278    /// This will be `NULL` if the widget is not contained in a root widget.
279    ///
280    /// Readable
281    ///
282    ///
283    /// #### `scale-factor`
284    ///  The scale factor of the widget.
285    ///
286    /// Readable
287    ///
288    ///
289    /// #### `sensitive`
290    ///  Whether the widget responds to input.
291    ///
292    /// Readable | Writeable
293    ///
294    ///
295    /// #### `tooltip-markup`
296    ///  Sets the text of tooltip to be the given string, which is marked up
297    /// with Pango markup.
298    ///
299    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
300    ///
301    /// This is a convenience property which will take care of getting the
302    /// tooltip shown if the given string is not `NULL`:
303    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
304    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
305    /// the default signal handler.
306    ///
307    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
308    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
309    ///
310    /// Readable | Writeable
311    ///
312    ///
313    /// #### `tooltip-text`
314    ///  Sets the text of tooltip to be the given string.
315    ///
316    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
317    ///
318    /// This is a convenience property which will take care of getting the
319    /// tooltip shown if the given string is not `NULL`:
320    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
321    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
322    /// the default signal handler.
323    ///
324    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
325    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
326    ///
327    /// Readable | Writeable
328    ///
329    ///
330    /// #### `valign`
331    ///  How to distribute vertical space if widget gets extra space.
332    ///
333    /// Readable | Writeable
334    ///
335    ///
336    /// #### `vexpand`
337    ///  Whether to expand vertically.
338    ///
339    /// Readable | Writeable
340    ///
341    ///
342    /// #### `vexpand-set`
343    ///  Whether to use the `vexpand` property.
344    ///
345    /// Readable | Writeable
346    ///
347    ///
348    /// #### `visible`
349    ///  Whether the widget is visible.
350    ///
351    /// Readable | Writeable
352    ///
353    ///
354    /// #### `width-request`
355    ///  Overrides for width request of the widget.
356    ///
357    /// If this is -1, the natural request will be used.
358    ///
359    /// Readable | Writeable
360    /// </details>
361    /// <details><summary><h4>Accessible</h4></summary>
362    ///
363    ///
364    /// #### `accessible-role`
365    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
366    ///
367    /// The accessible role cannot be changed once set.
368    ///
369    /// Readable | Writeable
370    /// </details>
371    /// <details><summary><h4>Orientable</h4></summary>
372    ///
373    ///
374    /// #### `orientation`
375    ///  The orientation of the orientable.
376    ///
377    /// Readable | Writeable
378    /// </details>
379    ///
380    /// # Implements
381    ///
382    /// [`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]
383    #[doc(alias = "GtkScrollbar")]
384    pub struct Scrollbar(Object<ffi::GtkScrollbar>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, AccessibleRange, Orientable;
385
386    match fn {
387        type_ => || ffi::gtk_scrollbar_get_type(),
388    }
389}
390
391#[cfg(not(any(feature = "v4_10")))]
392glib::wrapper! {
393    #[doc(alias = "GtkScrollbar")]
394    pub struct Scrollbar(Object<ffi::GtkScrollbar>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable;
395
396    match fn {
397        type_ => || ffi::gtk_scrollbar_get_type(),
398    }
399}
400
401impl Scrollbar {
402    /// Creates a new scrollbar with the given orientation.
403    /// ## `orientation`
404    /// the scrollbar’s orientation.
405    /// ## `adjustment`
406    /// the [`Adjustment`][crate::Adjustment] to use, or [`None`]
407    ///   to create a new adjustment.
408    ///
409    /// # Returns
410    ///
411    /// the new [`Scrollbar`][crate::Scrollbar].
412    #[doc(alias = "gtk_scrollbar_new")]
413    pub fn new(orientation: Orientation, adjustment: Option<&impl IsA<Adjustment>>) -> Scrollbar {
414        assert_initialized_main_thread!();
415        unsafe {
416            Widget::from_glib_none(ffi::gtk_scrollbar_new(
417                orientation.into_glib(),
418                adjustment.map(|p| p.as_ref()).to_glib_none().0,
419            ))
420            .unsafe_cast()
421        }
422    }
423
424    // rustdoc-stripper-ignore-next
425    /// Creates a new builder-pattern struct instance to construct [`Scrollbar`] objects.
426    ///
427    /// This method returns an instance of [`ScrollbarBuilder`](crate::builders::ScrollbarBuilder) which can be used to create [`Scrollbar`] objects.
428    pub fn builder() -> ScrollbarBuilder {
429        ScrollbarBuilder::new()
430    }
431
432    /// Returns the scrollbar's adjustment.
433    ///
434    /// # Returns
435    ///
436    /// the scrollbar's adjustment
437    #[doc(alias = "gtk_scrollbar_get_adjustment")]
438    #[doc(alias = "get_adjustment")]
439    pub fn adjustment(&self) -> Adjustment {
440        unsafe { from_glib_none(ffi::gtk_scrollbar_get_adjustment(self.to_glib_none().0)) }
441    }
442
443    /// Makes the scrollbar use the given adjustment.
444    /// ## `adjustment`
445    /// the adjustment to set
446    #[doc(alias = "gtk_scrollbar_set_adjustment")]
447    #[doc(alias = "adjustment")]
448    pub fn set_adjustment(&self, adjustment: Option<&impl IsA<Adjustment>>) {
449        unsafe {
450            ffi::gtk_scrollbar_set_adjustment(
451                self.to_glib_none().0,
452                adjustment.map(|p| p.as_ref()).to_glib_none().0,
453            );
454        }
455    }
456
457    #[doc(alias = "adjustment")]
458    pub fn connect_adjustment_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
459        unsafe extern "C" fn notify_adjustment_trampoline<F: Fn(&Scrollbar) + 'static>(
460            this: *mut ffi::GtkScrollbar,
461            _param_spec: glib::ffi::gpointer,
462            f: glib::ffi::gpointer,
463        ) {
464            let f: &F = &*(f as *const F);
465            f(&from_glib_borrow(this))
466        }
467        unsafe {
468            let f: Box_<F> = Box_::new(f);
469            connect_raw(
470                self.as_ptr() as *mut _,
471                b"notify::adjustment\0".as_ptr() as *const _,
472                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
473                    notify_adjustment_trampoline::<F> as *const (),
474                )),
475                Box_::into_raw(f),
476            )
477        }
478    }
479}
480
481impl Default for Scrollbar {
482    fn default() -> Self {
483        glib::object::Object::new::<Self>()
484    }
485}
486
487// rustdoc-stripper-ignore-next
488/// A [builder-pattern] type to construct [`Scrollbar`] objects.
489///
490/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
491#[must_use = "The builder must be built to be used"]
492pub struct ScrollbarBuilder {
493    builder: glib::object::ObjectBuilder<'static, Scrollbar>,
494}
495
496impl ScrollbarBuilder {
497    fn new() -> Self {
498        Self {
499            builder: glib::object::Object::builder(),
500        }
501    }
502
503    /// The [`Adjustment`][crate::Adjustment] controlled by this scrollbar.
504    pub fn adjustment(self, adjustment: &impl IsA<Adjustment>) -> Self {
505        Self {
506            builder: self
507                .builder
508                .property("adjustment", adjustment.clone().upcast()),
509        }
510    }
511
512    /// Whether the widget or any of its descendents can accept
513    /// the input focus.
514    ///
515    /// This property is meant to be set by widget implementations,
516    /// typically in their instance init function.
517    pub fn can_focus(self, can_focus: bool) -> Self {
518        Self {
519            builder: self.builder.property("can-focus", can_focus),
520        }
521    }
522
523    /// Whether the widget can receive pointer events.
524    pub fn can_target(self, can_target: bool) -> Self {
525        Self {
526            builder: self.builder.property("can-target", can_target),
527        }
528    }
529
530    /// A list of css classes applied to this widget.
531    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
532        Self {
533            builder: self.builder.property("css-classes", css_classes.into()),
534        }
535    }
536
537    /// The name of this widget in the CSS tree.
538    ///
539    /// This property is meant to be set by widget implementations,
540    /// typically in their instance init function.
541    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
542        Self {
543            builder: self.builder.property("css-name", css_name.into()),
544        }
545    }
546
547    /// The cursor used by @widget.
548    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
549        Self {
550            builder: self.builder.property("cursor", cursor.clone()),
551        }
552    }
553
554    /// Whether the widget should grab focus when it is clicked with the mouse.
555    ///
556    /// This property is only relevant for widgets that can take focus.
557    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
558        Self {
559            builder: self.builder.property("focus-on-click", focus_on_click),
560        }
561    }
562
563    /// Whether this widget itself will accept the input focus.
564    pub fn focusable(self, focusable: bool) -> Self {
565        Self {
566            builder: self.builder.property("focusable", focusable),
567        }
568    }
569
570    /// How to distribute horizontal space if widget gets extra space.
571    pub fn halign(self, halign: Align) -> Self {
572        Self {
573            builder: self.builder.property("halign", halign),
574        }
575    }
576
577    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
578    /// signal on @widget.
579    ///
580    /// A true value indicates that @widget can have a tooltip, in this case
581    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
582    /// determine whether it will provide a tooltip or not.
583    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
584        Self {
585            builder: self.builder.property("has-tooltip", has_tooltip),
586        }
587    }
588
589    /// Overrides for height request of the widget.
590    ///
591    /// If this is -1, the natural request will be used.
592    pub fn height_request(self, height_request: i32) -> Self {
593        Self {
594            builder: self.builder.property("height-request", height_request),
595        }
596    }
597
598    /// Whether to expand horizontally.
599    pub fn hexpand(self, hexpand: bool) -> Self {
600        Self {
601            builder: self.builder.property("hexpand", hexpand),
602        }
603    }
604
605    /// Whether to use the `hexpand` property.
606    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
607        Self {
608            builder: self.builder.property("hexpand-set", hexpand_set),
609        }
610    }
611
612    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
613    /// the preferred size of the widget, and allocate its children.
614    ///
615    /// This property is meant to be set by widget implementations,
616    /// typically in their instance init function.
617    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
618        Self {
619            builder: self
620                .builder
621                .property("layout-manager", layout_manager.clone().upcast()),
622        }
623    }
624
625    /// Makes this widget act like a modal dialog, with respect to
626    /// event delivery.
627    ///
628    /// Global event controllers will not handle events with targets
629    /// inside the widget, unless they are set up to ignore propagation
630    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
631    #[cfg(feature = "v4_18")]
632    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
633    pub fn limit_events(self, limit_events: bool) -> Self {
634        Self {
635            builder: self.builder.property("limit-events", limit_events),
636        }
637    }
638
639    /// Margin on bottom side of widget.
640    ///
641    /// This property adds margin outside of the widget's normal size
642    /// request, the margin will be added in addition to the size from
643    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
644    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
645        Self {
646            builder: self.builder.property("margin-bottom", margin_bottom),
647        }
648    }
649
650    /// Margin on end of widget, horizontally.
651    ///
652    /// This property supports left-to-right and right-to-left text
653    /// directions.
654    ///
655    /// This property adds margin outside of the widget's normal size
656    /// request, the margin will be added in addition to the size from
657    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
658    pub fn margin_end(self, margin_end: i32) -> Self {
659        Self {
660            builder: self.builder.property("margin-end", margin_end),
661        }
662    }
663
664    /// Margin on start of widget, horizontally.
665    ///
666    /// This property supports left-to-right and right-to-left text
667    /// directions.
668    ///
669    /// This property adds margin outside of the widget's normal size
670    /// request, the margin will be added in addition to the size from
671    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
672    pub fn margin_start(self, margin_start: i32) -> Self {
673        Self {
674            builder: self.builder.property("margin-start", margin_start),
675        }
676    }
677
678    /// Margin on top side of widget.
679    ///
680    /// This property adds margin outside of the widget's normal size
681    /// request, the margin will be added in addition to the size from
682    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
683    pub fn margin_top(self, margin_top: i32) -> Self {
684        Self {
685            builder: self.builder.property("margin-top", margin_top),
686        }
687    }
688
689    /// The name of the widget.
690    pub fn name(self, name: impl Into<glib::GString>) -> Self {
691        Self {
692            builder: self.builder.property("name", name.into()),
693        }
694    }
695
696    /// The requested opacity of the widget.
697    pub fn opacity(self, opacity: f64) -> Self {
698        Self {
699            builder: self.builder.property("opacity", opacity),
700        }
701    }
702
703    /// How content outside the widget's content area is treated.
704    ///
705    /// This property is meant to be set by widget implementations,
706    /// typically in their instance init function.
707    pub fn overflow(self, overflow: Overflow) -> Self {
708        Self {
709            builder: self.builder.property("overflow", overflow),
710        }
711    }
712
713    /// Whether the widget will receive the default action when it is focused.
714    pub fn receives_default(self, receives_default: bool) -> Self {
715        Self {
716            builder: self.builder.property("receives-default", receives_default),
717        }
718    }
719
720    /// Whether the widget responds to input.
721    pub fn sensitive(self, sensitive: bool) -> Self {
722        Self {
723            builder: self.builder.property("sensitive", sensitive),
724        }
725    }
726
727    /// Sets the text of tooltip to be the given string, which is marked up
728    /// with Pango markup.
729    ///
730    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
731    ///
732    /// This is a convenience property which will take care of getting the
733    /// tooltip shown if the given string is not `NULL`:
734    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
735    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
736    /// the default signal handler.
737    ///
738    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
739    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
740    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
741        Self {
742            builder: self
743                .builder
744                .property("tooltip-markup", tooltip_markup.into()),
745        }
746    }
747
748    /// Sets the text of tooltip to be the given string.
749    ///
750    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
751    ///
752    /// This is a convenience property which will take care of getting the
753    /// tooltip shown if the given string is not `NULL`:
754    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
755    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
756    /// the default signal handler.
757    ///
758    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
759    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
760    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
761        Self {
762            builder: self.builder.property("tooltip-text", tooltip_text.into()),
763        }
764    }
765
766    /// How to distribute vertical space if widget gets extra space.
767    pub fn valign(self, valign: Align) -> Self {
768        Self {
769            builder: self.builder.property("valign", valign),
770        }
771    }
772
773    /// Whether to expand vertically.
774    pub fn vexpand(self, vexpand: bool) -> Self {
775        Self {
776            builder: self.builder.property("vexpand", vexpand),
777        }
778    }
779
780    /// Whether to use the `vexpand` property.
781    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
782        Self {
783            builder: self.builder.property("vexpand-set", vexpand_set),
784        }
785    }
786
787    /// Whether the widget is visible.
788    pub fn visible(self, visible: bool) -> Self {
789        Self {
790            builder: self.builder.property("visible", visible),
791        }
792    }
793
794    /// Overrides for width request of the widget.
795    ///
796    /// If this is -1, the natural request will be used.
797    pub fn width_request(self, width_request: i32) -> Self {
798        Self {
799            builder: self.builder.property("width-request", width_request),
800        }
801    }
802
803    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
804    ///
805    /// The accessible role cannot be changed once set.
806    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
807        Self {
808            builder: self.builder.property("accessible-role", accessible_role),
809        }
810    }
811
812    /// The orientation of the orientable.
813    pub fn orientation(self, orientation: Orientation) -> Self {
814        Self {
815            builder: self.builder.property("orientation", orientation),
816        }
817    }
818
819    // rustdoc-stripper-ignore-next
820    /// Build the [`Scrollbar`].
821    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
822    pub fn build(self) -> Scrollbar {
823        assert_initialized_main_thread!();
824        self.builder.build()
825    }
826}