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