Skip to main content

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