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 Accessible, AccessibleRole, Adjustment, Align, Buildable, ConstraintTarget, LayoutManager,
10 Overflow, Scrollable, ScrollablePolicy, Widget, ffi,
11};
12use glib::{
13 prelude::*,
14 signal::{SignalHandlerId, connect_raw},
15 translate::*,
16};
17use std::boxed::Box as Box_;
18
19glib::wrapper! {
20 /// Implements scrollability for widgets that don't support scrolling
21 /// on their own.
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 [enum@Gtk.AccessibleRole.group] role.
36 ///
37 /// Starting from GTK 4.12, [`Viewport`][crate::Viewport] uses the [enum@Gtk.AccessibleRole.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 unsafe {
516 let f: &F = &*(f as *const F);
517 f(&from_glib_borrow(this))
518 }
519 }
520 unsafe {
521 let f: Box_<F> = Box_::new(f);
522 connect_raw(
523 self.as_ptr() as *mut _,
524 c"notify::child".as_ptr() as *const _,
525 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
526 notify_child_trampoline::<F> as *const (),
527 )),
528 Box_::into_raw(f),
529 )
530 }
531 }
532
533 #[doc(alias = "scroll-to-focus")]
534 pub fn connect_scroll_to_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
535 unsafe extern "C" fn notify_scroll_to_focus_trampoline<F: Fn(&Viewport) + 'static>(
536 this: *mut ffi::GtkViewport,
537 _param_spec: glib::ffi::gpointer,
538 f: glib::ffi::gpointer,
539 ) {
540 unsafe {
541 let f: &F = &*(f as *const F);
542 f(&from_glib_borrow(this))
543 }
544 }
545 unsafe {
546 let f: Box_<F> = Box_::new(f);
547 connect_raw(
548 self.as_ptr() as *mut _,
549 c"notify::scroll-to-focus".as_ptr() as *const _,
550 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
551 notify_scroll_to_focus_trampoline::<F> as *const (),
552 )),
553 Box_::into_raw(f),
554 )
555 }
556 }
557}
558
559impl Default for Viewport {
560 fn default() -> Self {
561 glib::object::Object::new::<Self>()
562 }
563}
564
565// rustdoc-stripper-ignore-next
566/// A [builder-pattern] type to construct [`Viewport`] objects.
567///
568/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
569#[must_use = "The builder must be built to be used"]
570pub struct ViewportBuilder {
571 builder: glib::object::ObjectBuilder<'static, Viewport>,
572}
573
574impl ViewportBuilder {
575 fn new() -> Self {
576 Self {
577 builder: glib::object::Object::builder(),
578 }
579 }
580
581 /// The child widget.
582 pub fn child(self, child: &impl IsA<Widget>) -> Self {
583 Self {
584 builder: self.builder.property("child", child.clone().upcast()),
585 }
586 }
587
588 /// Whether to scroll when the focus changes.
589 ///
590 /// Before 4.6.2, this property was mistakenly defaulting to FALSE, so if your
591 /// code needs to work with older versions, consider setting it explicitly to
592 /// TRUE.
593 pub fn scroll_to_focus(self, scroll_to_focus: bool) -> Self {
594 Self {
595 builder: self.builder.property("scroll-to-focus", scroll_to_focus),
596 }
597 }
598
599 /// Whether the widget or any of its descendents can accept
600 /// the input focus.
601 ///
602 /// This property is meant to be set by widget implementations,
603 /// typically in their instance init function.
604 pub fn can_focus(self, can_focus: bool) -> Self {
605 Self {
606 builder: self.builder.property("can-focus", can_focus),
607 }
608 }
609
610 /// Whether the widget can receive pointer events.
611 pub fn can_target(self, can_target: bool) -> Self {
612 Self {
613 builder: self.builder.property("can-target", can_target),
614 }
615 }
616
617 /// A list of css classes applied to this widget.
618 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
619 Self {
620 builder: self.builder.property("css-classes", css_classes.into()),
621 }
622 }
623
624 /// The name of this widget in the CSS tree.
625 ///
626 /// This property is meant to be set by widget implementations,
627 /// typically in their instance init function.
628 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
629 Self {
630 builder: self.builder.property("css-name", css_name.into()),
631 }
632 }
633
634 /// The cursor used by @widget.
635 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
636 Self {
637 builder: self.builder.property("cursor", cursor.clone()),
638 }
639 }
640
641 /// Whether the widget should grab focus when it is clicked with the mouse.
642 ///
643 /// This property is only relevant for widgets that can take focus.
644 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
645 Self {
646 builder: self.builder.property("focus-on-click", focus_on_click),
647 }
648 }
649
650 /// Whether this widget itself will accept the input focus.
651 pub fn focusable(self, focusable: bool) -> Self {
652 Self {
653 builder: self.builder.property("focusable", focusable),
654 }
655 }
656
657 /// How to distribute horizontal space if widget gets extra space.
658 pub fn halign(self, halign: Align) -> Self {
659 Self {
660 builder: self.builder.property("halign", halign),
661 }
662 }
663
664 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
665 /// signal on @widget.
666 ///
667 /// A true value indicates that @widget can have a tooltip, in this case
668 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
669 /// determine whether it will provide a tooltip or not.
670 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
671 Self {
672 builder: self.builder.property("has-tooltip", has_tooltip),
673 }
674 }
675
676 /// Overrides for height request of the widget.
677 ///
678 /// If this is -1, the natural request will be used.
679 pub fn height_request(self, height_request: i32) -> Self {
680 Self {
681 builder: self.builder.property("height-request", height_request),
682 }
683 }
684
685 /// Whether to expand horizontally.
686 pub fn hexpand(self, hexpand: bool) -> Self {
687 Self {
688 builder: self.builder.property("hexpand", hexpand),
689 }
690 }
691
692 /// Whether to use the `hexpand` property.
693 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
694 Self {
695 builder: self.builder.property("hexpand-set", hexpand_set),
696 }
697 }
698
699 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
700 /// the preferred size of the widget, and allocate its children.
701 ///
702 /// This property is meant to be set by widget implementations,
703 /// typically in their instance init function.
704 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
705 Self {
706 builder: self
707 .builder
708 .property("layout-manager", layout_manager.clone().upcast()),
709 }
710 }
711
712 /// Makes this widget act like a modal dialog, with respect to
713 /// event delivery.
714 ///
715 /// Global event controllers will not handle events with targets
716 /// inside the widget, unless they are set up to ignore propagation
717 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
718 #[cfg(feature = "v4_18")]
719 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
720 pub fn limit_events(self, limit_events: bool) -> Self {
721 Self {
722 builder: self.builder.property("limit-events", limit_events),
723 }
724 }
725
726 /// Margin on bottom side of widget.
727 ///
728 /// This property adds margin outside of the widget's normal size
729 /// request, the margin will be added in addition to the size from
730 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
731 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
732 Self {
733 builder: self.builder.property("margin-bottom", margin_bottom),
734 }
735 }
736
737 /// Margin on end of widget, horizontally.
738 ///
739 /// This property supports left-to-right and right-to-left text
740 /// directions.
741 ///
742 /// This property adds margin outside of the widget's normal size
743 /// request, the margin will be added in addition to the size from
744 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
745 pub fn margin_end(self, margin_end: i32) -> Self {
746 Self {
747 builder: self.builder.property("margin-end", margin_end),
748 }
749 }
750
751 /// Margin on start of widget, horizontally.
752 ///
753 /// This property supports left-to-right and right-to-left text
754 /// directions.
755 ///
756 /// This property adds margin outside of the widget's normal size
757 /// request, the margin will be added in addition to the size from
758 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
759 pub fn margin_start(self, margin_start: i32) -> Self {
760 Self {
761 builder: self.builder.property("margin-start", margin_start),
762 }
763 }
764
765 /// Margin on top side of widget.
766 ///
767 /// This property adds margin outside of the widget's normal size
768 /// request, the margin will be added in addition to the size from
769 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
770 pub fn margin_top(self, margin_top: i32) -> Self {
771 Self {
772 builder: self.builder.property("margin-top", margin_top),
773 }
774 }
775
776 /// The name of the widget.
777 pub fn name(self, name: impl Into<glib::GString>) -> Self {
778 Self {
779 builder: self.builder.property("name", name.into()),
780 }
781 }
782
783 /// The requested opacity of the widget.
784 pub fn opacity(self, opacity: f64) -> Self {
785 Self {
786 builder: self.builder.property("opacity", opacity),
787 }
788 }
789
790 /// How content outside the widget's content area is treated.
791 ///
792 /// This property is meant to be set by widget implementations,
793 /// typically in their instance init function.
794 pub fn overflow(self, overflow: Overflow) -> Self {
795 Self {
796 builder: self.builder.property("overflow", overflow),
797 }
798 }
799
800 /// Whether the widget will receive the default action when it is focused.
801 pub fn receives_default(self, receives_default: bool) -> Self {
802 Self {
803 builder: self.builder.property("receives-default", receives_default),
804 }
805 }
806
807 /// Whether the widget responds to input.
808 pub fn sensitive(self, sensitive: bool) -> Self {
809 Self {
810 builder: self.builder.property("sensitive", sensitive),
811 }
812 }
813
814 /// Sets the text of tooltip to be the given string, which is marked up
815 /// with Pango markup.
816 ///
817 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
818 ///
819 /// This is a convenience property which will take care of getting the
820 /// tooltip shown if the given string is not `NULL`:
821 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
822 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
823 /// the default signal handler.
824 ///
825 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
826 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
827 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
828 Self {
829 builder: self
830 .builder
831 .property("tooltip-markup", tooltip_markup.into()),
832 }
833 }
834
835 /// Sets the text of tooltip to be the given string.
836 ///
837 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
838 ///
839 /// This is a convenience property which will take care of getting the
840 /// tooltip shown if the given string is not `NULL`:
841 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
842 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
843 /// the default signal handler.
844 ///
845 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
846 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
847 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
848 Self {
849 builder: self.builder.property("tooltip-text", tooltip_text.into()),
850 }
851 }
852
853 /// How to distribute vertical space if widget gets extra space.
854 pub fn valign(self, valign: Align) -> Self {
855 Self {
856 builder: self.builder.property("valign", valign),
857 }
858 }
859
860 /// Whether to expand vertically.
861 pub fn vexpand(self, vexpand: bool) -> Self {
862 Self {
863 builder: self.builder.property("vexpand", vexpand),
864 }
865 }
866
867 /// Whether to use the `vexpand` property.
868 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
869 Self {
870 builder: self.builder.property("vexpand-set", vexpand_set),
871 }
872 }
873
874 /// Whether the widget is visible.
875 pub fn visible(self, visible: bool) -> Self {
876 Self {
877 builder: self.builder.property("visible", visible),
878 }
879 }
880
881 /// Overrides for width request of the widget.
882 ///
883 /// If this is -1, the natural request will be used.
884 pub fn width_request(self, width_request: i32) -> Self {
885 Self {
886 builder: self.builder.property("width-request", width_request),
887 }
888 }
889
890 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
891 ///
892 /// The accessible role cannot be changed once set.
893 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
894 Self {
895 builder: self.builder.property("accessible-role", accessible_role),
896 }
897 }
898
899 /// Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget.
900 ///
901 /// This adjustment is shared between the scrollable widget and its parent.
902 pub fn hadjustment(self, hadjustment: &impl IsA<Adjustment>) -> Self {
903 Self {
904 builder: self
905 .builder
906 .property("hadjustment", hadjustment.clone().upcast()),
907 }
908 }
909
910 /// Determines when horizontal scrolling should start.
911 pub fn hscroll_policy(self, hscroll_policy: ScrollablePolicy) -> Self {
912 Self {
913 builder: self.builder.property("hscroll-policy", hscroll_policy),
914 }
915 }
916
917 /// Vertical [`Adjustment`][crate::Adjustment] of the scrollable widget.
918 ///
919 /// This adjustment is shared between the scrollable widget and its parent.
920 pub fn vadjustment(self, vadjustment: &impl IsA<Adjustment>) -> Self {
921 Self {
922 builder: self
923 .builder
924 .property("vadjustment", vadjustment.clone().upcast()),
925 }
926 }
927
928 /// Determines when vertical scrolling should start.
929 pub fn vscroll_policy(self, vscroll_policy: ScrollablePolicy) -> Self {
930 Self {
931 builder: self.builder.property("vscroll-policy", vscroll_policy),
932 }
933 }
934
935 // rustdoc-stripper-ignore-next
936 /// Build the [`Viewport`].
937 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
938 pub fn build(self) -> Viewport {
939 assert_initialized_main_thread!();
940 self.builder.build()
941 }
942}