gtk4/auto/
viewport.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_12")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
7use crate::ScrollInfo;
8use crate::{
9    ffi, Accessible, AccessibleRole, Adjustment, Align, Buildable, ConstraintTarget, LayoutManager,
10    Overflow, Scrollable, ScrollablePolicy, Widget,
11};
12use glib::{
13    prelude::*,
14    signal::{connect_raw, SignalHandlerId},
15    translate::*,
16};
17use std::boxed::Box as Box_;
18
19glib::wrapper! {
20    /// [`Viewport`][crate::Viewport] implements scrollability for widgets that lack their
21    /// own scrolling capabilities.
22    ///
23    /// Use [`Viewport`][crate::Viewport] to scroll child widgets such as [`Grid`][crate::Grid],
24    /// [`Box`][crate::Box], and so on.
25    ///
26    /// The [`Viewport`][crate::Viewport] will start scrolling content only if allocated
27    /// less than the child widget’s minimum size in a given orientation.
28    ///
29    /// # CSS nodes
30    ///
31    /// [`Viewport`][crate::Viewport] has a single CSS node with name `viewport`.
32    ///
33    /// # Accessibility
34    ///
35    /// Until GTK 4.10, [`Viewport`][crate::Viewport] used the `GTK_ACCESSIBLE_ROLE_GROUP` role.
36    ///
37    /// Starting from GTK 4.12, [`Viewport`][crate::Viewport] uses the `GTK_ACCESSIBLE_ROLE_GENERIC` role.
38    ///
39    /// ## Properties
40    ///
41    ///
42    /// #### `child`
43    ///  The child widget.
44    ///
45    /// Readable | Writeable
46    ///
47    ///
48    /// #### `scroll-to-focus`
49    ///  Whether to scroll when the focus changes.
50    ///
51    /// Before 4.6.2, this property was mistakenly defaulting to FALSE, so if your
52    /// code needs to work with older versions, consider setting it explicitly to
53    /// TRUE.
54    ///
55    /// Readable | Writeable
56    /// <details><summary><h4>Widget</h4></summary>
57    ///
58    ///
59    /// #### `can-focus`
60    ///  Whether the widget or any of its descendents can accept
61    /// the input focus.
62    ///
63    /// This property is meant to be set by widget implementations,
64    /// typically in their instance init function.
65    ///
66    /// Readable | Writeable
67    ///
68    ///
69    /// #### `can-target`
70    ///  Whether the widget can receive pointer events.
71    ///
72    /// Readable | Writeable
73    ///
74    ///
75    /// #### `css-classes`
76    ///  A list of css classes applied to this widget.
77    ///
78    /// Readable | Writeable
79    ///
80    ///
81    /// #### `css-name`
82    ///  The name of this widget in the CSS tree.
83    ///
84    /// This property is meant to be set by widget implementations,
85    /// typically in their instance init function.
86    ///
87    /// Readable | Writeable | Construct Only
88    ///
89    ///
90    /// #### `cursor`
91    ///  The cursor used by @widget.
92    ///
93    /// Readable | Writeable
94    ///
95    ///
96    /// #### `focus-on-click`
97    ///  Whether the widget should grab focus when it is clicked with the mouse.
98    ///
99    /// This property is only relevant for widgets that can take focus.
100    ///
101    /// Readable | Writeable
102    ///
103    ///
104    /// #### `focusable`
105    ///  Whether this widget itself will accept the input focus.
106    ///
107    /// Readable | Writeable
108    ///
109    ///
110    /// #### `halign`
111    ///  How to distribute horizontal space if widget gets extra space.
112    ///
113    /// Readable | Writeable
114    ///
115    ///
116    /// #### `has-default`
117    ///  Whether the widget is the default widget.
118    ///
119    /// Readable
120    ///
121    ///
122    /// #### `has-focus`
123    ///  Whether the widget has the input focus.
124    ///
125    /// Readable
126    ///
127    ///
128    /// #### `has-tooltip`
129    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
130    /// signal on @widget.
131    ///
132    /// A true value indicates that @widget can have a tooltip, in this case
133    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
134    /// determine whether it will provide a tooltip or not.
135    ///
136    /// Readable | Writeable
137    ///
138    ///
139    /// #### `height-request`
140    ///  Overrides for height request of the widget.
141    ///
142    /// If this is -1, the natural request will be used.
143    ///
144    /// Readable | Writeable
145    ///
146    ///
147    /// #### `hexpand`
148    ///  Whether to expand horizontally.
149    ///
150    /// Readable | Writeable
151    ///
152    ///
153    /// #### `hexpand-set`
154    ///  Whether to use the `hexpand` property.
155    ///
156    /// Readable | Writeable
157    ///
158    ///
159    /// #### `layout-manager`
160    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
161    /// the preferred size of the widget, and allocate its children.
162    ///
163    /// This property is meant to be set by widget implementations,
164    /// typically in their instance init function.
165    ///
166    /// Readable | Writeable
167    ///
168    ///
169    /// #### `limit-events`
170    ///  Makes this widget act like a modal dialog, with respect to
171    /// event delivery.
172    ///
173    /// Global event controllers will not handle events with targets
174    /// inside the widget, unless they are set up to ignore propagation
175    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
176    ///
177    /// Readable | Writeable
178    ///
179    ///
180    /// #### `margin-bottom`
181    ///  Margin on bottom side of widget.
182    ///
183    /// This property adds margin outside of the widget's normal size
184    /// request, the margin will be added in addition to the size from
185    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
186    ///
187    /// Readable | Writeable
188    ///
189    ///
190    /// #### `margin-end`
191    ///  Margin on end of widget, horizontally.
192    ///
193    /// This property supports left-to-right and right-to-left text
194    /// directions.
195    ///
196    /// This property adds margin outside of the widget's normal size
197    /// request, the margin will be added in addition to the size from
198    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
199    ///
200    /// Readable | Writeable
201    ///
202    ///
203    /// #### `margin-start`
204    ///  Margin on start of widget, horizontally.
205    ///
206    /// This property supports left-to-right and right-to-left text
207    /// directions.
208    ///
209    /// This property adds margin outside of the widget's normal size
210    /// request, the margin will be added in addition to the size from
211    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
212    ///
213    /// Readable | Writeable
214    ///
215    ///
216    /// #### `margin-top`
217    ///  Margin on top side of widget.
218    ///
219    /// This property adds margin outside of the widget's normal size
220    /// request, the margin will be added in addition to the size from
221    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
222    ///
223    /// Readable | Writeable
224    ///
225    ///
226    /// #### `name`
227    ///  The name of the widget.
228    ///
229    /// Readable | Writeable
230    ///
231    ///
232    /// #### `opacity`
233    ///  The requested opacity of the widget.
234    ///
235    /// Readable | Writeable
236    ///
237    ///
238    /// #### `overflow`
239    ///  How content outside the widget's content area is treated.
240    ///
241    /// This property is meant to be set by widget implementations,
242    /// typically in their instance init function.
243    ///
244    /// Readable | Writeable
245    ///
246    ///
247    /// #### `parent`
248    ///  The parent widget of this widget.
249    ///
250    /// Readable
251    ///
252    ///
253    /// #### `receives-default`
254    ///  Whether the widget will receive the default action when it is focused.
255    ///
256    /// Readable | Writeable
257    ///
258    ///
259    /// #### `root`
260    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
261    ///
262    /// This will be `NULL` if the widget is not contained in a root widget.
263    ///
264    /// Readable
265    ///
266    ///
267    /// #### `scale-factor`
268    ///  The scale factor of the widget.
269    ///
270    /// Readable
271    ///
272    ///
273    /// #### `sensitive`
274    ///  Whether the widget responds to input.
275    ///
276    /// Readable | Writeable
277    ///
278    ///
279    /// #### `tooltip-markup`
280    ///  Sets the text of tooltip to be the given string, which is marked up
281    /// with Pango markup.
282    ///
283    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
284    ///
285    /// This is a convenience property which will take care of getting the
286    /// tooltip shown if the given string is not `NULL`:
287    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
288    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
289    /// the default signal handler.
290    ///
291    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
292    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
293    ///
294    /// Readable | Writeable
295    ///
296    ///
297    /// #### `tooltip-text`
298    ///  Sets the text of tooltip to be the given string.
299    ///
300    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
301    ///
302    /// This is a convenience property which will take care of getting the
303    /// tooltip shown if the given string is not `NULL`:
304    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
305    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
306    /// the default signal handler.
307    ///
308    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
309    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
310    ///
311    /// Readable | Writeable
312    ///
313    ///
314    /// #### `valign`
315    ///  How to distribute vertical space if widget gets extra space.
316    ///
317    /// Readable | Writeable
318    ///
319    ///
320    /// #### `vexpand`
321    ///  Whether to expand vertically.
322    ///
323    /// Readable | Writeable
324    ///
325    ///
326    /// #### `vexpand-set`
327    ///  Whether to use the `vexpand` property.
328    ///
329    /// Readable | Writeable
330    ///
331    ///
332    /// #### `visible`
333    ///  Whether the widget is visible.
334    ///
335    /// Readable | Writeable
336    ///
337    ///
338    /// #### `width-request`
339    ///  Overrides for width request of the widget.
340    ///
341    /// If this is -1, the natural request will be used.
342    ///
343    /// Readable | Writeable
344    /// </details>
345    /// <details><summary><h4>Accessible</h4></summary>
346    ///
347    ///
348    /// #### `accessible-role`
349    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
350    ///
351    /// The accessible role cannot be changed once set.
352    ///
353    /// Readable | Writeable
354    /// </details>
355    /// <details><summary><h4>Scrollable</h4></summary>
356    ///
357    ///
358    /// #### `hadjustment`
359    ///  Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget.
360    ///
361    /// This adjustment is shared between the scrollable widget and its parent.
362    ///
363    /// Readable | Writeable | Construct
364    ///
365    ///
366    /// #### `hscroll-policy`
367    ///  Determines when horizontal scrolling should start.
368    ///
369    /// Readable | Writeable
370    ///
371    ///
372    /// #### `vadjustment`
373    ///  Vertical [`Adjustment`][crate::Adjustment] of the scrollable widget.
374    ///
375    /// This adjustment is shared between the scrollable widget and its parent.
376    ///
377    /// Readable | Writeable | Construct
378    ///
379    ///
380    /// #### `vscroll-policy`
381    ///  Determines when vertical scrolling should start.
382    ///
383    /// Readable | Writeable
384    /// </details>
385    ///
386    /// # Implements
387    ///
388    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`ScrollableExt`][trait@crate::prelude::ScrollableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
389    #[doc(alias = "GtkViewport")]
390    pub struct Viewport(Object<ffi::GtkViewport>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Scrollable;
391
392    match fn {
393        type_ => || ffi::gtk_viewport_get_type(),
394    }
395}
396
397impl Viewport {
398    /// Creates a new [`Viewport`][crate::Viewport].
399    ///
400    /// The new viewport uses the given adjustments, or default
401    /// adjustments if none are given.
402    /// ## `hadjustment`
403    /// horizontal adjustment
404    /// ## `vadjustment`
405    /// vertical adjustment
406    ///
407    /// # Returns
408    ///
409    /// a new [`Viewport`][crate::Viewport]
410    #[doc(alias = "gtk_viewport_new")]
411    pub fn new(
412        hadjustment: Option<&impl IsA<Adjustment>>,
413        vadjustment: Option<&impl IsA<Adjustment>>,
414    ) -> Viewport {
415        assert_initialized_main_thread!();
416        unsafe {
417            Widget::from_glib_none(ffi::gtk_viewport_new(
418                hadjustment.map(|p| p.as_ref()).to_glib_none().0,
419                vadjustment.map(|p| p.as_ref()).to_glib_none().0,
420            ))
421            .unsafe_cast()
422        }
423    }
424
425    // rustdoc-stripper-ignore-next
426    /// Creates a new builder-pattern struct instance to construct [`Viewport`] objects.
427    ///
428    /// This method returns an instance of [`ViewportBuilder`](crate::builders::ViewportBuilder) which can be used to create [`Viewport`] objects.
429    pub fn builder() -> ViewportBuilder {
430        ViewportBuilder::new()
431    }
432
433    /// Gets the child widget of @self.
434    ///
435    /// # Returns
436    ///
437    /// the child widget of @self
438    #[doc(alias = "gtk_viewport_get_child")]
439    #[doc(alias = "get_child")]
440    pub fn child(&self) -> Option<Widget> {
441        unsafe { from_glib_none(ffi::gtk_viewport_get_child(self.to_glib_none().0)) }
442    }
443
444    /// Gets whether the viewport is scrolling to keep the focused
445    /// child in view.
446    ///
447    /// # Returns
448    ///
449    /// [`true`] if the viewport keeps the focus child scrolled to view
450    #[doc(alias = "gtk_viewport_get_scroll_to_focus")]
451    #[doc(alias = "get_scroll_to_focus")]
452    #[doc(alias = "scroll-to-focus")]
453    pub fn is_scroll_to_focus(&self) -> bool {
454        unsafe { from_glib(ffi::gtk_viewport_get_scroll_to_focus(self.to_glib_none().0)) }
455    }
456
457    /// Scrolls a descendant of the viewport into view.
458    ///
459    /// The viewport and the descendant must be visible and mapped for
460    /// this function to work, otherwise no scrolling will be performed.
461    /// ## `descendant`
462    /// a descendant widget of the viewport
463    /// ## `scroll`
464    /// details of how to perform
465    ///   the scroll operation or NULL to scroll into view
466    #[cfg(feature = "v4_12")]
467    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
468    #[doc(alias = "gtk_viewport_scroll_to")]
469    pub fn scroll_to(&self, descendant: &impl IsA<Widget>, scroll: Option<ScrollInfo>) {
470        unsafe {
471            ffi::gtk_viewport_scroll_to(
472                self.to_glib_none().0,
473                descendant.as_ref().to_glib_none().0,
474                scroll.into_glib_ptr(),
475            );
476        }
477    }
478
479    /// Sets the child widget of @self.
480    /// ## `child`
481    /// the child widget
482    #[doc(alias = "gtk_viewport_set_child")]
483    #[doc(alias = "child")]
484    pub fn set_child(&self, child: Option<&impl IsA<Widget>>) {
485        unsafe {
486            ffi::gtk_viewport_set_child(
487                self.to_glib_none().0,
488                child.map(|p| p.as_ref()).to_glib_none().0,
489            );
490        }
491    }
492
493    /// Sets whether the viewport should automatically scroll
494    /// to keep the focused child in view.
495    /// ## `scroll_to_focus`
496    /// whether to keep the focus widget scrolled to view
497    #[doc(alias = "gtk_viewport_set_scroll_to_focus")]
498    #[doc(alias = "scroll-to-focus")]
499    pub fn set_scroll_to_focus(&self, scroll_to_focus: bool) {
500        unsafe {
501            ffi::gtk_viewport_set_scroll_to_focus(
502                self.to_glib_none().0,
503                scroll_to_focus.into_glib(),
504            );
505        }
506    }
507
508    #[doc(alias = "child")]
509    pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
510        unsafe extern "C" fn notify_child_trampoline<F: Fn(&Viewport) + 'static>(
511            this: *mut ffi::GtkViewport,
512            _param_spec: glib::ffi::gpointer,
513            f: glib::ffi::gpointer,
514        ) {
515            let f: &F = &*(f as *const F);
516            f(&from_glib_borrow(this))
517        }
518        unsafe {
519            let f: Box_<F> = Box_::new(f);
520            connect_raw(
521                self.as_ptr() as *mut _,
522                b"notify::child\0".as_ptr() as *const _,
523                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
524                    notify_child_trampoline::<F> as *const (),
525                )),
526                Box_::into_raw(f),
527            )
528        }
529    }
530
531    #[doc(alias = "scroll-to-focus")]
532    pub fn connect_scroll_to_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
533        unsafe extern "C" fn notify_scroll_to_focus_trampoline<F: Fn(&Viewport) + 'static>(
534            this: *mut ffi::GtkViewport,
535            _param_spec: glib::ffi::gpointer,
536            f: glib::ffi::gpointer,
537        ) {
538            let f: &F = &*(f as *const F);
539            f(&from_glib_borrow(this))
540        }
541        unsafe {
542            let f: Box_<F> = Box_::new(f);
543            connect_raw(
544                self.as_ptr() as *mut _,
545                b"notify::scroll-to-focus\0".as_ptr() as *const _,
546                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
547                    notify_scroll_to_focus_trampoline::<F> as *const (),
548                )),
549                Box_::into_raw(f),
550            )
551        }
552    }
553}
554
555impl Default for Viewport {
556    fn default() -> Self {
557        glib::object::Object::new::<Self>()
558    }
559}
560
561// rustdoc-stripper-ignore-next
562/// A [builder-pattern] type to construct [`Viewport`] objects.
563///
564/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
565#[must_use = "The builder must be built to be used"]
566pub struct ViewportBuilder {
567    builder: glib::object::ObjectBuilder<'static, Viewport>,
568}
569
570impl ViewportBuilder {
571    fn new() -> Self {
572        Self {
573            builder: glib::object::Object::builder(),
574        }
575    }
576
577    /// The child widget.
578    pub fn child(self, child: &impl IsA<Widget>) -> Self {
579        Self {
580            builder: self.builder.property("child", child.clone().upcast()),
581        }
582    }
583
584    /// Whether to scroll when the focus changes.
585    ///
586    /// Before 4.6.2, this property was mistakenly defaulting to FALSE, so if your
587    /// code needs to work with older versions, consider setting it explicitly to
588    /// TRUE.
589    pub fn scroll_to_focus(self, scroll_to_focus: bool) -> Self {
590        Self {
591            builder: self.builder.property("scroll-to-focus", scroll_to_focus),
592        }
593    }
594
595    /// Whether the widget or any of its descendents can accept
596    /// the input focus.
597    ///
598    /// This property is meant to be set by widget implementations,
599    /// typically in their instance init function.
600    pub fn can_focus(self, can_focus: bool) -> Self {
601        Self {
602            builder: self.builder.property("can-focus", can_focus),
603        }
604    }
605
606    /// Whether the widget can receive pointer events.
607    pub fn can_target(self, can_target: bool) -> Self {
608        Self {
609            builder: self.builder.property("can-target", can_target),
610        }
611    }
612
613    /// A list of css classes applied to this widget.
614    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
615        Self {
616            builder: self.builder.property("css-classes", css_classes.into()),
617        }
618    }
619
620    /// The name of this widget in the CSS tree.
621    ///
622    /// This property is meant to be set by widget implementations,
623    /// typically in their instance init function.
624    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
625        Self {
626            builder: self.builder.property("css-name", css_name.into()),
627        }
628    }
629
630    /// The cursor used by @widget.
631    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
632        Self {
633            builder: self.builder.property("cursor", cursor.clone()),
634        }
635    }
636
637    /// Whether the widget should grab focus when it is clicked with the mouse.
638    ///
639    /// This property is only relevant for widgets that can take focus.
640    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
641        Self {
642            builder: self.builder.property("focus-on-click", focus_on_click),
643        }
644    }
645
646    /// Whether this widget itself will accept the input focus.
647    pub fn focusable(self, focusable: bool) -> Self {
648        Self {
649            builder: self.builder.property("focusable", focusable),
650        }
651    }
652
653    /// How to distribute horizontal space if widget gets extra space.
654    pub fn halign(self, halign: Align) -> Self {
655        Self {
656            builder: self.builder.property("halign", halign),
657        }
658    }
659
660    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
661    /// signal on @widget.
662    ///
663    /// A true value indicates that @widget can have a tooltip, in this case
664    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
665    /// determine whether it will provide a tooltip or not.
666    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
667        Self {
668            builder: self.builder.property("has-tooltip", has_tooltip),
669        }
670    }
671
672    /// Overrides for height request of the widget.
673    ///
674    /// If this is -1, the natural request will be used.
675    pub fn height_request(self, height_request: i32) -> Self {
676        Self {
677            builder: self.builder.property("height-request", height_request),
678        }
679    }
680
681    /// Whether to expand horizontally.
682    pub fn hexpand(self, hexpand: bool) -> Self {
683        Self {
684            builder: self.builder.property("hexpand", hexpand),
685        }
686    }
687
688    /// Whether to use the `hexpand` property.
689    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
690        Self {
691            builder: self.builder.property("hexpand-set", hexpand_set),
692        }
693    }
694
695    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
696    /// the preferred size of the widget, and allocate its children.
697    ///
698    /// This property is meant to be set by widget implementations,
699    /// typically in their instance init function.
700    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
701        Self {
702            builder: self
703                .builder
704                .property("layout-manager", layout_manager.clone().upcast()),
705        }
706    }
707
708    /// Makes this widget act like a modal dialog, with respect to
709    /// event delivery.
710    ///
711    /// Global event controllers will not handle events with targets
712    /// inside the widget, unless they are set up to ignore propagation
713    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
714    #[cfg(feature = "v4_18")]
715    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
716    pub fn limit_events(self, limit_events: bool) -> Self {
717        Self {
718            builder: self.builder.property("limit-events", limit_events),
719        }
720    }
721
722    /// Margin on bottom side of widget.
723    ///
724    /// This property adds margin outside of the widget's normal size
725    /// request, the margin will be added in addition to the size from
726    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
727    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
728        Self {
729            builder: self.builder.property("margin-bottom", margin_bottom),
730        }
731    }
732
733    /// Margin on end of widget, horizontally.
734    ///
735    /// This property supports left-to-right and right-to-left text
736    /// directions.
737    ///
738    /// This property adds margin outside of the widget's normal size
739    /// request, the margin will be added in addition to the size from
740    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
741    pub fn margin_end(self, margin_end: i32) -> Self {
742        Self {
743            builder: self.builder.property("margin-end", margin_end),
744        }
745    }
746
747    /// Margin on start of widget, horizontally.
748    ///
749    /// This property supports left-to-right and right-to-left text
750    /// directions.
751    ///
752    /// This property adds margin outside of the widget's normal size
753    /// request, the margin will be added in addition to the size from
754    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
755    pub fn margin_start(self, margin_start: i32) -> Self {
756        Self {
757            builder: self.builder.property("margin-start", margin_start),
758        }
759    }
760
761    /// Margin on top side of widget.
762    ///
763    /// This property adds margin outside of the widget's normal size
764    /// request, the margin will be added in addition to the size from
765    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
766    pub fn margin_top(self, margin_top: i32) -> Self {
767        Self {
768            builder: self.builder.property("margin-top", margin_top),
769        }
770    }
771
772    /// The name of the widget.
773    pub fn name(self, name: impl Into<glib::GString>) -> Self {
774        Self {
775            builder: self.builder.property("name", name.into()),
776        }
777    }
778
779    /// The requested opacity of the widget.
780    pub fn opacity(self, opacity: f64) -> Self {
781        Self {
782            builder: self.builder.property("opacity", opacity),
783        }
784    }
785
786    /// How content outside the widget's content area is treated.
787    ///
788    /// This property is meant to be set by widget implementations,
789    /// typically in their instance init function.
790    pub fn overflow(self, overflow: Overflow) -> Self {
791        Self {
792            builder: self.builder.property("overflow", overflow),
793        }
794    }
795
796    /// Whether the widget will receive the default action when it is focused.
797    pub fn receives_default(self, receives_default: bool) -> Self {
798        Self {
799            builder: self.builder.property("receives-default", receives_default),
800        }
801    }
802
803    /// Whether the widget responds to input.
804    pub fn sensitive(self, sensitive: bool) -> Self {
805        Self {
806            builder: self.builder.property("sensitive", sensitive),
807        }
808    }
809
810    /// Sets the text of tooltip to be the given string, which is marked up
811    /// with Pango markup.
812    ///
813    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
814    ///
815    /// This is a convenience property which will take care of getting the
816    /// tooltip shown if the given string is not `NULL`:
817    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
818    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
819    /// the default signal handler.
820    ///
821    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
822    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
823    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
824        Self {
825            builder: self
826                .builder
827                .property("tooltip-markup", tooltip_markup.into()),
828        }
829    }
830
831    /// Sets the text of tooltip to be the given string.
832    ///
833    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
834    ///
835    /// This is a convenience property which will take care of getting the
836    /// tooltip shown if the given string is not `NULL`:
837    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
838    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
839    /// the default signal handler.
840    ///
841    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
842    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
843    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
844        Self {
845            builder: self.builder.property("tooltip-text", tooltip_text.into()),
846        }
847    }
848
849    /// How to distribute vertical space if widget gets extra space.
850    pub fn valign(self, valign: Align) -> Self {
851        Self {
852            builder: self.builder.property("valign", valign),
853        }
854    }
855
856    /// Whether to expand vertically.
857    pub fn vexpand(self, vexpand: bool) -> Self {
858        Self {
859            builder: self.builder.property("vexpand", vexpand),
860        }
861    }
862
863    /// Whether to use the `vexpand` property.
864    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
865        Self {
866            builder: self.builder.property("vexpand-set", vexpand_set),
867        }
868    }
869
870    /// Whether the widget is visible.
871    pub fn visible(self, visible: bool) -> Self {
872        Self {
873            builder: self.builder.property("visible", visible),
874        }
875    }
876
877    /// Overrides for width request of the widget.
878    ///
879    /// If this is -1, the natural request will be used.
880    pub fn width_request(self, width_request: i32) -> Self {
881        Self {
882            builder: self.builder.property("width-request", width_request),
883        }
884    }
885
886    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
887    ///
888    /// The accessible role cannot be changed once set.
889    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
890        Self {
891            builder: self.builder.property("accessible-role", accessible_role),
892        }
893    }
894
895    /// Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget.
896    ///
897    /// This adjustment is shared between the scrollable widget and its parent.
898    pub fn hadjustment(self, hadjustment: &impl IsA<Adjustment>) -> Self {
899        Self {
900            builder: self
901                .builder
902                .property("hadjustment", hadjustment.clone().upcast()),
903        }
904    }
905
906    /// Determines when horizontal scrolling should start.
907    pub fn hscroll_policy(self, hscroll_policy: ScrollablePolicy) -> Self {
908        Self {
909            builder: self.builder.property("hscroll-policy", hscroll_policy),
910        }
911    }
912
913    /// Vertical [`Adjustment`][crate::Adjustment] of the scrollable widget.
914    ///
915    /// This adjustment is shared between the scrollable widget and its parent.
916    pub fn vadjustment(self, vadjustment: &impl IsA<Adjustment>) -> Self {
917        Self {
918            builder: self
919                .builder
920                .property("vadjustment", vadjustment.clone().upcast()),
921        }
922    }
923
924    /// Determines when vertical scrolling should start.
925    pub fn vscroll_policy(self, vscroll_policy: ScrollablePolicy) -> Self {
926        Self {
927            builder: self.builder.property("vscroll-policy", vscroll_policy),
928        }
929    }
930
931    // rustdoc-stripper-ignore-next
932    /// Build the [`Viewport`].
933    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
934    pub fn build(self) -> Viewport {
935        assert_initialized_main_thread!();
936        self.builder.build()
937    }
938}