Skip to main content

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    Accessible, AccessibleRole, Adjustment, Align, Buildable, ConstraintTarget, LayoutManager,
10    Orientable, Orientation, Overflow, Widget, ffi,
11};
12use glib::{
13    prelude::*,
14    signal::{SignalHandlerId, connect_raw},
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            unsafe {
468                let f: &F = &*(f as *const F);
469                f(&from_glib_borrow(this))
470            }
471        }
472        unsafe {
473            let f: Box_<F> = Box_::new(f);
474            connect_raw(
475                self.as_ptr() as *mut _,
476                c"notify::adjustment".as_ptr() as *const _,
477                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
478                    notify_adjustment_trampoline::<F> as *const (),
479                )),
480                Box_::into_raw(f),
481            )
482        }
483    }
484}
485
486impl Default for Scrollbar {
487    fn default() -> Self {
488        glib::object::Object::new::<Self>()
489    }
490}
491
492// rustdoc-stripper-ignore-next
493/// A [builder-pattern] type to construct [`Scrollbar`] objects.
494///
495/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
496#[must_use = "The builder must be built to be used"]
497pub struct ScrollbarBuilder {
498    builder: glib::object::ObjectBuilder<'static, Scrollbar>,
499}
500
501impl ScrollbarBuilder {
502    fn new() -> Self {
503        Self {
504            builder: glib::object::Object::builder(),
505        }
506    }
507
508    /// The [`Adjustment`][crate::Adjustment] controlled by this scrollbar.
509    pub fn adjustment(self, adjustment: &impl IsA<Adjustment>) -> Self {
510        Self {
511            builder: self
512                .builder
513                .property("adjustment", adjustment.clone().upcast()),
514        }
515    }
516
517    /// Whether the widget or any of its descendents can accept
518    /// the input focus.
519    ///
520    /// This property is meant to be set by widget implementations,
521    /// typically in their instance init function.
522    pub fn can_focus(self, can_focus: bool) -> Self {
523        Self {
524            builder: self.builder.property("can-focus", can_focus),
525        }
526    }
527
528    /// Whether the widget can receive pointer events.
529    pub fn can_target(self, can_target: bool) -> Self {
530        Self {
531            builder: self.builder.property("can-target", can_target),
532        }
533    }
534
535    /// A list of css classes applied to this widget.
536    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
537        Self {
538            builder: self.builder.property("css-classes", css_classes.into()),
539        }
540    }
541
542    /// The name of this widget in the CSS tree.
543    ///
544    /// This property is meant to be set by widget implementations,
545    /// typically in their instance init function.
546    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
547        Self {
548            builder: self.builder.property("css-name", css_name.into()),
549        }
550    }
551
552    /// The cursor used by @widget.
553    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
554        Self {
555            builder: self.builder.property("cursor", cursor.clone()),
556        }
557    }
558
559    /// Whether the widget should grab focus when it is clicked with the mouse.
560    ///
561    /// This property is only relevant for widgets that can take focus.
562    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
563        Self {
564            builder: self.builder.property("focus-on-click", focus_on_click),
565        }
566    }
567
568    /// Whether this widget itself will accept the input focus.
569    pub fn focusable(self, focusable: bool) -> Self {
570        Self {
571            builder: self.builder.property("focusable", focusable),
572        }
573    }
574
575    /// How to distribute horizontal space if widget gets extra space.
576    pub fn halign(self, halign: Align) -> Self {
577        Self {
578            builder: self.builder.property("halign", halign),
579        }
580    }
581
582    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
583    /// signal on @widget.
584    ///
585    /// A true value indicates that @widget can have a tooltip, in this case
586    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
587    /// determine whether it will provide a tooltip or not.
588    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
589        Self {
590            builder: self.builder.property("has-tooltip", has_tooltip),
591        }
592    }
593
594    /// Overrides for height request of the widget.
595    ///
596    /// If this is -1, the natural request will be used.
597    pub fn height_request(self, height_request: i32) -> Self {
598        Self {
599            builder: self.builder.property("height-request", height_request),
600        }
601    }
602
603    /// Whether to expand horizontally.
604    pub fn hexpand(self, hexpand: bool) -> Self {
605        Self {
606            builder: self.builder.property("hexpand", hexpand),
607        }
608    }
609
610    /// Whether to use the `hexpand` property.
611    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
612        Self {
613            builder: self.builder.property("hexpand-set", hexpand_set),
614        }
615    }
616
617    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
618    /// the preferred size of the widget, and allocate its children.
619    ///
620    /// This property is meant to be set by widget implementations,
621    /// typically in their instance init function.
622    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
623        Self {
624            builder: self
625                .builder
626                .property("layout-manager", layout_manager.clone().upcast()),
627        }
628    }
629
630    /// Makes this widget act like a modal dialog, with respect to
631    /// event delivery.
632    ///
633    /// Global event controllers will not handle events with targets
634    /// inside the widget, unless they are set up to ignore propagation
635    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
636    #[cfg(feature = "v4_18")]
637    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
638    pub fn limit_events(self, limit_events: bool) -> Self {
639        Self {
640            builder: self.builder.property("limit-events", limit_events),
641        }
642    }
643
644    /// Margin on bottom side of widget.
645    ///
646    /// This property adds margin outside of the widget's normal size
647    /// request, the margin will be added in addition to the size from
648    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
649    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
650        Self {
651            builder: self.builder.property("margin-bottom", margin_bottom),
652        }
653    }
654
655    /// Margin on end of widget, horizontally.
656    ///
657    /// This property supports left-to-right and right-to-left text
658    /// directions.
659    ///
660    /// This property adds margin outside of the widget's normal size
661    /// request, the margin will be added in addition to the size from
662    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
663    pub fn margin_end(self, margin_end: i32) -> Self {
664        Self {
665            builder: self.builder.property("margin-end", margin_end),
666        }
667    }
668
669    /// Margin on start of widget, horizontally.
670    ///
671    /// This property supports left-to-right and right-to-left text
672    /// directions.
673    ///
674    /// This property adds margin outside of the widget's normal size
675    /// request, the margin will be added in addition to the size from
676    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
677    pub fn margin_start(self, margin_start: i32) -> Self {
678        Self {
679            builder: self.builder.property("margin-start", margin_start),
680        }
681    }
682
683    /// Margin on top side of widget.
684    ///
685    /// This property adds margin outside of the widget's normal size
686    /// request, the margin will be added in addition to the size from
687    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
688    pub fn margin_top(self, margin_top: i32) -> Self {
689        Self {
690            builder: self.builder.property("margin-top", margin_top),
691        }
692    }
693
694    /// The name of the widget.
695    pub fn name(self, name: impl Into<glib::GString>) -> Self {
696        Self {
697            builder: self.builder.property("name", name.into()),
698        }
699    }
700
701    /// The requested opacity of the widget.
702    pub fn opacity(self, opacity: f64) -> Self {
703        Self {
704            builder: self.builder.property("opacity", opacity),
705        }
706    }
707
708    /// How content outside the widget's content area is treated.
709    ///
710    /// This property is meant to be set by widget implementations,
711    /// typically in their instance init function.
712    pub fn overflow(self, overflow: Overflow) -> Self {
713        Self {
714            builder: self.builder.property("overflow", overflow),
715        }
716    }
717
718    /// Whether the widget will receive the default action when it is focused.
719    pub fn receives_default(self, receives_default: bool) -> Self {
720        Self {
721            builder: self.builder.property("receives-default", receives_default),
722        }
723    }
724
725    /// Whether the widget responds to input.
726    pub fn sensitive(self, sensitive: bool) -> Self {
727        Self {
728            builder: self.builder.property("sensitive", sensitive),
729        }
730    }
731
732    /// Sets the text of tooltip to be the given string, which is marked up
733    /// with Pango markup.
734    ///
735    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
736    ///
737    /// This is a convenience property which will take care of getting the
738    /// tooltip shown if the given string is not `NULL`:
739    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
740    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
741    /// the default signal handler.
742    ///
743    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
744    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
745    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
746        Self {
747            builder: self
748                .builder
749                .property("tooltip-markup", tooltip_markup.into()),
750        }
751    }
752
753    /// Sets the text of tooltip to be the given string.
754    ///
755    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
756    ///
757    /// This is a convenience property which will take care of getting the
758    /// tooltip shown if the given string is not `NULL`:
759    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
760    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
761    /// the default signal handler.
762    ///
763    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
764    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
765    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
766        Self {
767            builder: self.builder.property("tooltip-text", tooltip_text.into()),
768        }
769    }
770
771    /// How to distribute vertical space if widget gets extra space.
772    pub fn valign(self, valign: Align) -> Self {
773        Self {
774            builder: self.builder.property("valign", valign),
775        }
776    }
777
778    /// Whether to expand vertically.
779    pub fn vexpand(self, vexpand: bool) -> Self {
780        Self {
781            builder: self.builder.property("vexpand", vexpand),
782        }
783    }
784
785    /// Whether to use the `vexpand` property.
786    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
787        Self {
788            builder: self.builder.property("vexpand-set", vexpand_set),
789        }
790    }
791
792    /// Whether the widget is visible.
793    pub fn visible(self, visible: bool) -> Self {
794        Self {
795            builder: self.builder.property("visible", visible),
796        }
797    }
798
799    /// Overrides for width request of the widget.
800    ///
801    /// If this is -1, the natural request will be used.
802    pub fn width_request(self, width_request: i32) -> Self {
803        Self {
804            builder: self.builder.property("width-request", width_request),
805        }
806    }
807
808    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
809    ///
810    /// The accessible role cannot be changed once set.
811    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
812        Self {
813            builder: self.builder.property("accessible-role", accessible_role),
814        }
815    }
816
817    /// The orientation of the orientable.
818    pub fn orientation(self, orientation: Orientation) -> Self {
819        Self {
820            builder: self.builder.property("orientation", orientation),
821        }
822    }
823
824    // rustdoc-stripper-ignore-next
825    /// Build the [`Scrollbar`].
826    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
827    pub fn build(self) -> Scrollbar {
828        assert_initialized_main_thread!();
829        self.builder.build()
830    }
831}