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