gtk4/auto/stack.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;
8use crate::{
9 AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow, SelectionModel,
10 StackPage, StackTransitionType, Widget, ffi,
11};
12use glib::{
13 prelude::*,
14 signal::{SignalHandlerId, connect_raw},
15 translate::*,
16};
17use std::boxed::Box as Box_;
18
19#[cfg(feature = "v4_10")]
20#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
21glib::wrapper! {
22 ///
23 /// ```text
24 ///
25 /// # CSS nodes
26 ///
27 /// [`Stack`][crate::Stack] has a single CSS node named stack.
28 ///
29 /// # Accessibility
30 ///
31 /// [`Stack`][crate::Stack] uses the [enum@Gtk.AccessibleRole.tab_panel] role for the stack
32 /// pages, which are the accessible parent objects of the child widgets.
33 ///
34 /// ## Properties
35 ///
36 ///
37 /// #### `hhomogeneous`
38 /// [`true`] if the stack allocates the same width for all children.
39 ///
40 /// Readable | Writable
41 ///
42 ///
43 /// #### `interpolate-size`
44 /// Whether or not the size should smoothly change during the transition.
45 ///
46 /// Readable | Writable
47 ///
48 ///
49 /// #### `pages`
50 /// A selection model with the stack pages.
51 ///
52 /// Readable
53 ///
54 ///
55 /// #### `transition-duration`
56 /// The animation duration, in milliseconds.
57 ///
58 /// Readable | Writable
59 ///
60 ///
61 /// #### `transition-running`
62 /// Whether or not the transition is currently running.
63 ///
64 /// Readable
65 ///
66 ///
67 /// #### `transition-type`
68 /// The type of animation used to transition.
69 ///
70 /// Readable | Writable
71 ///
72 ///
73 /// #### `vhomogeneous`
74 /// [`true`] if the stack allocates the same height for all children.
75 ///
76 /// Readable | Writable
77 ///
78 ///
79 /// #### `visible-child`
80 /// The widget currently visible in the stack.
81 ///
82 /// Readable | Writable
83 ///
84 ///
85 /// #### `visible-child-name`
86 /// The name of the widget currently visible in the stack.
87 ///
88 /// Readable | Writable
89 /// <details><summary><h4>Widget</h4></summary>
90 ///
91 ///
92 /// #### `can-focus`
93 /// Whether the widget or any of its descendents can accept
94 /// the input focus.
95 ///
96 /// This property is meant to be set by widget implementations,
97 /// typically in their instance init function.
98 ///
99 /// Readable | Writable
100 ///
101 ///
102 /// #### `can-target`
103 /// Whether the widget can receive pointer events.
104 ///
105 /// Readable | Writable
106 ///
107 ///
108 /// #### `css-classes`
109 /// A list of css classes applied to this widget.
110 ///
111 /// Readable | Writable
112 ///
113 ///
114 /// #### `css-name`
115 /// The name of this widget in the CSS tree.
116 ///
117 /// This property is meant to be set by widget implementations,
118 /// typically in their instance init function.
119 ///
120 /// Readable | Writable | Construct Only
121 ///
122 ///
123 /// #### `cursor`
124 /// The cursor used by @widget.
125 ///
126 /// Readable | Writable
127 ///
128 ///
129 /// #### `focus-on-click`
130 /// Whether the widget should grab focus when it is clicked with the mouse.
131 ///
132 /// This property is only relevant for widgets that can take focus.
133 ///
134 /// Readable | Writable
135 ///
136 ///
137 /// #### `focusable`
138 /// Whether this widget itself will accept the input focus.
139 ///
140 /// Readable | Writable
141 ///
142 ///
143 /// #### `halign`
144 /// How to distribute horizontal space if widget gets extra space.
145 ///
146 /// Readable | Writable
147 ///
148 ///
149 /// #### `has-default`
150 /// Whether the widget is the default widget.
151 ///
152 /// Readable
153 ///
154 ///
155 /// #### `has-focus`
156 /// Whether the widget has the input focus.
157 ///
158 /// Readable
159 ///
160 ///
161 /// #### `has-tooltip`
162 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
163 /// signal on @widget.
164 ///
165 /// A true value indicates that @widget can have a tooltip, in this case
166 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
167 /// determine whether it will provide a tooltip or not.
168 ///
169 /// Readable | Writable
170 ///
171 ///
172 /// #### `height-request`
173 /// Overrides for height request of the widget.
174 ///
175 /// If this is -1, the natural request will be used.
176 ///
177 /// Readable | Writable
178 ///
179 ///
180 /// #### `hexpand`
181 /// Whether to expand horizontally.
182 ///
183 /// Readable | Writable
184 ///
185 ///
186 /// #### `hexpand-set`
187 /// Whether to use the `hexpand` property.
188 ///
189 /// Readable | Writable
190 ///
191 ///
192 /// #### `layout-manager`
193 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
194 /// the preferred size of the widget, and allocate its children.
195 ///
196 /// This property is meant to be set by widget implementations,
197 /// typically in their instance init function.
198 ///
199 /// Readable | Writable
200 ///
201 ///
202 /// #### `limit-events`
203 /// Makes this widget act like a modal dialog, with respect to
204 /// event delivery.
205 ///
206 /// Global event controllers will not handle events with targets
207 /// inside the widget, unless they are set up to ignore propagation
208 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
209 ///
210 /// Readable | Writable
211 ///
212 ///
213 /// #### `margin-bottom`
214 /// Margin on bottom side of widget.
215 ///
216 /// This property adds margin outside of the widget's normal size
217 /// request, the margin will be added in addition to the size from
218 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
219 ///
220 /// Readable | Writable
221 ///
222 ///
223 /// #### `margin-end`
224 /// Margin on end of widget, horizontally.
225 ///
226 /// This property supports left-to-right and right-to-left text
227 /// directions.
228 ///
229 /// This property adds margin outside of the widget's normal size
230 /// request, the margin will be added in addition to the size from
231 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
232 ///
233 /// Readable | Writable
234 ///
235 ///
236 /// #### `margin-start`
237 /// Margin on start of widget, horizontally.
238 ///
239 /// This property supports left-to-right and right-to-left text
240 /// directions.
241 ///
242 /// This property adds margin outside of the widget's normal size
243 /// request, the margin will be added in addition to the size from
244 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
245 ///
246 /// Readable | Writable
247 ///
248 ///
249 /// #### `margin-top`
250 /// Margin on top side of widget.
251 ///
252 /// This property adds margin outside of the widget's normal size
253 /// request, the margin will be added in addition to the size from
254 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
255 ///
256 /// Readable | Writable
257 ///
258 ///
259 /// #### `name`
260 /// The name of the widget.
261 ///
262 /// Readable | Writable
263 ///
264 ///
265 /// #### `opacity`
266 /// The requested opacity of the widget.
267 ///
268 /// Readable | Writable
269 ///
270 ///
271 /// #### `overflow`
272 /// How content outside the widget's content area is treated.
273 ///
274 /// This property is meant to be set by widget implementations,
275 /// typically in their instance init function.
276 ///
277 /// Readable | Writable
278 ///
279 ///
280 /// #### `parent`
281 /// The parent widget of this widget.
282 ///
283 /// Readable
284 ///
285 ///
286 /// #### `receives-default`
287 /// Whether the widget will receive the default action when it is focused.
288 ///
289 /// Readable | Writable
290 ///
291 ///
292 /// #### `root`
293 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
294 ///
295 /// This will be `NULL` if the widget is not contained in a root widget.
296 ///
297 /// Readable
298 ///
299 ///
300 /// #### `scale-factor`
301 /// The scale factor of the widget.
302 ///
303 /// Readable
304 ///
305 ///
306 /// #### `sensitive`
307 /// Whether the widget responds to input.
308 ///
309 /// Readable | Writable
310 ///
311 ///
312 /// #### `tooltip-markup`
313 /// Sets the text of tooltip to be the given string, which is marked up
314 /// with Pango markup.
315 ///
316 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
317 ///
318 /// This is a convenience property which will take care of getting the
319 /// tooltip shown if the given string is not `NULL`:
320 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
321 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
322 /// the default signal handler.
323 ///
324 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
325 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
326 ///
327 /// Readable | Writable
328 ///
329 ///
330 /// #### `tooltip-text`
331 /// Sets the text of tooltip to be the given string.
332 ///
333 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
334 ///
335 /// This is a convenience property which will take care of getting the
336 /// tooltip shown if the given string is not `NULL`:
337 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
338 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
339 /// the default signal handler.
340 ///
341 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
342 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
343 ///
344 /// Readable | Writable
345 ///
346 ///
347 /// #### `valign`
348 /// How to distribute vertical space if widget gets extra space.
349 ///
350 /// Readable | Writable
351 ///
352 ///
353 /// #### `vexpand`
354 /// Whether to expand vertically.
355 ///
356 /// Readable | Writable
357 ///
358 ///
359 /// #### `vexpand-set`
360 /// Whether to use the `vexpand` property.
361 ///
362 /// Readable | Writable
363 ///
364 ///
365 /// #### `visible`
366 /// Whether the widget is visible.
367 ///
368 /// Readable | Writable
369 ///
370 ///
371 /// #### `width-request`
372 /// Overrides for width request of the widget.
373 ///
374 /// If this is -1, the natural request will be used.
375 ///
376 /// Readable | Writable
377 /// </details>
378 /// <details><summary><h4>Accessible</h4></summary>
379 ///
380 ///
381 /// #### `accessible-role`
382 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
383 ///
384 /// The accessible role cannot be changed once set.
385 ///
386 /// Readable | Writable
387 /// </details>
388 ///
389 /// # Implements
390 ///
391 /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
392 #[doc(alias = "GtkStack")]
393 pub struct Stack(Object<ffi::GtkStack>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
394
395 match fn {
396 type_ => || ffi::gtk_stack_get_type(),
397 }
398}
399
400#[cfg(not(feature = "v4_10"))]
401glib::wrapper! {
402 #[doc(alias = "GtkStack")]
403 pub struct Stack(Object<ffi::GtkStack>) @extends Widget, @implements Buildable, ConstraintTarget;
404
405 match fn {
406 type_ => || ffi::gtk_stack_get_type(),
407 }
408}
409
410impl Stack {
411 /// Creates a new [`Stack`][crate::Stack].
412 ///
413 /// # Returns
414 ///
415 /// a new [`Stack`][crate::Stack]
416 #[doc(alias = "gtk_stack_new")]
417 pub fn new() -> Stack {
418 assert_initialized_main_thread!();
419 unsafe { Widget::from_glib_none(ffi::gtk_stack_new()).unsafe_cast() }
420 }
421
422 // rustdoc-stripper-ignore-next
423 /// Creates a new builder-pattern struct instance to construct [`Stack`] objects.
424 ///
425 /// This method returns an instance of [`StackBuilder`](crate::builders::StackBuilder) which can be used to create [`Stack`] objects.
426 pub fn builder() -> StackBuilder {
427 StackBuilder::new()
428 }
429
430 /// Adds a child to @self.
431 /// ## `child`
432 /// the widget to add
433 ///
434 /// # Returns
435 ///
436 /// the [`StackPage`][crate::StackPage] for @child
437 #[doc(alias = "gtk_stack_add_child")]
438 pub fn add_child(&self, child: &impl IsA<Widget>) -> StackPage {
439 unsafe {
440 from_glib_none(ffi::gtk_stack_add_child(
441 self.to_glib_none().0,
442 child.as_ref().to_glib_none().0,
443 ))
444 }
445 }
446
447 /// Adds a child to @self.
448 ///
449 /// The child is identified by the @name.
450 /// ## `child`
451 /// the widget to add
452 /// ## `name`
453 /// the name for @child
454 ///
455 /// # Returns
456 ///
457 /// the [`StackPage`][crate::StackPage] for @child
458 #[doc(alias = "gtk_stack_add_named")]
459 pub fn add_named(&self, child: &impl IsA<Widget>, name: Option<&str>) -> StackPage {
460 unsafe {
461 from_glib_none(ffi::gtk_stack_add_named(
462 self.to_glib_none().0,
463 child.as_ref().to_glib_none().0,
464 name.to_glib_none().0,
465 ))
466 }
467 }
468
469 /// Adds a child to @self.
470 ///
471 /// The child is identified by the @name. The @title
472 /// will be used by [`StackSwitcher`][crate::StackSwitcher] to represent
473 /// @child in a tab bar, so it should be short.
474 /// ## `child`
475 /// the widget to add
476 /// ## `name`
477 /// the name for @child
478 /// ## `title`
479 /// a human-readable title for @child
480 ///
481 /// # Returns
482 ///
483 /// the [`StackPage`][crate::StackPage] for @child
484 #[doc(alias = "gtk_stack_add_titled")]
485 pub fn add_titled(
486 &self,
487 child: &impl IsA<Widget>,
488 name: Option<&str>,
489 title: &str,
490 ) -> StackPage {
491 unsafe {
492 from_glib_none(ffi::gtk_stack_add_titled(
493 self.to_glib_none().0,
494 child.as_ref().to_glib_none().0,
495 name.to_glib_none().0,
496 title.to_glib_none().0,
497 ))
498 }
499 }
500
501 /// Finds the child with the name given as the argument.
502 ///
503 /// Returns [`None`] if there is no child with this name.
504 /// ## `name`
505 /// the name of the child to find
506 ///
507 /// # Returns
508 ///
509 /// the requested child
510 /// of the [`Stack`][crate::Stack]
511 #[doc(alias = "gtk_stack_get_child_by_name")]
512 #[doc(alias = "get_child_by_name")]
513 pub fn child_by_name(&self, name: &str) -> Option<Widget> {
514 unsafe {
515 from_glib_none(ffi::gtk_stack_get_child_by_name(
516 self.to_glib_none().0,
517 name.to_glib_none().0,
518 ))
519 }
520 }
521
522 /// Gets whether @self is horizontally homogeneous.
523 ///
524 /// # Returns
525 ///
526 /// whether @self is horizontally homogeneous.
527 #[doc(alias = "gtk_stack_get_hhomogeneous")]
528 #[doc(alias = "get_hhomogeneous")]
529 #[doc(alias = "hhomogeneous")]
530 pub fn is_hhomogeneous(&self) -> bool {
531 unsafe { from_glib(ffi::gtk_stack_get_hhomogeneous(self.to_glib_none().0)) }
532 }
533
534 /// Returns whether the [`Stack`][crate::Stack] is set up to interpolate between
535 /// the sizes of children on page switch.
536 ///
537 /// # Returns
538 ///
539 /// [`true`] if child sizes are interpolated
540 #[doc(alias = "gtk_stack_get_interpolate_size")]
541 #[doc(alias = "get_interpolate_size")]
542 #[doc(alias = "interpolate-size")]
543 pub fn interpolates_size(&self) -> bool {
544 unsafe { from_glib(ffi::gtk_stack_get_interpolate_size(self.to_glib_none().0)) }
545 }
546
547 /// Returns the [`StackPage`][crate::StackPage] object for @child.
548 /// ## `child`
549 /// a child of @self
550 ///
551 /// # Returns
552 ///
553 /// the [`StackPage`][crate::StackPage] for @child
554 #[doc(alias = "gtk_stack_get_page")]
555 #[doc(alias = "get_page")]
556 pub fn page(&self, child: &impl IsA<Widget>) -> StackPage {
557 unsafe {
558 from_glib_none(ffi::gtk_stack_get_page(
559 self.to_glib_none().0,
560 child.as_ref().to_glib_none().0,
561 ))
562 }
563 }
564
565 /// Returns a `GListModel` that contains the pages of the stack.
566 ///
567 /// This can be used to keep an up-to-date view. The model also
568 /// implements [`SelectionModel`][crate::SelectionModel] and can be used to track
569 /// and modify the visible page.
570 ///
571 /// # Returns
572 ///
573 /// a [`SelectionModel`][crate::SelectionModel] for the stack's children
574 #[doc(alias = "gtk_stack_get_pages")]
575 #[doc(alias = "get_pages")]
576 pub fn pages(&self) -> SelectionModel {
577 unsafe { from_glib_full(ffi::gtk_stack_get_pages(self.to_glib_none().0)) }
578 }
579
580 /// Returns the amount of time (in milliseconds) that
581 /// transitions between pages in @self will take.
582 ///
583 /// # Returns
584 ///
585 /// the transition duration
586 #[doc(alias = "gtk_stack_get_transition_duration")]
587 #[doc(alias = "get_transition_duration")]
588 #[doc(alias = "transition-duration")]
589 pub fn transition_duration(&self) -> u32 {
590 unsafe { ffi::gtk_stack_get_transition_duration(self.to_glib_none().0) }
591 }
592
593 /// Returns whether the @self is currently in a transition from one page to
594 /// another.
595 ///
596 /// # Returns
597 ///
598 /// [`true`] if the transition is currently running, [`false`] otherwise.
599 #[doc(alias = "gtk_stack_get_transition_running")]
600 #[doc(alias = "get_transition_running")]
601 #[doc(alias = "transition-running")]
602 pub fn is_transition_running(&self) -> bool {
603 unsafe { from_glib(ffi::gtk_stack_get_transition_running(self.to_glib_none().0)) }
604 }
605
606 /// Gets the type of animation that will be used
607 /// for transitions between pages in @self.
608 ///
609 /// # Returns
610 ///
611 /// the current transition type of @self
612 #[doc(alias = "gtk_stack_get_transition_type")]
613 #[doc(alias = "get_transition_type")]
614 #[doc(alias = "transition-type")]
615 pub fn transition_type(&self) -> StackTransitionType {
616 unsafe { from_glib(ffi::gtk_stack_get_transition_type(self.to_glib_none().0)) }
617 }
618
619 /// Gets whether @self is vertically homogeneous.
620 ///
621 /// # Returns
622 ///
623 /// whether @self is vertically homogeneous.
624 #[doc(alias = "gtk_stack_get_vhomogeneous")]
625 #[doc(alias = "get_vhomogeneous")]
626 #[doc(alias = "vhomogeneous")]
627 pub fn is_vhomogeneous(&self) -> bool {
628 unsafe { from_glib(ffi::gtk_stack_get_vhomogeneous(self.to_glib_none().0)) }
629 }
630
631 /// Gets the currently visible child of @self.
632 ///
633 /// Returns [`None`] if there are no visible children.
634 ///
635 /// # Returns
636 ///
637 /// the visible child of the [`Stack`][crate::Stack]
638 #[doc(alias = "gtk_stack_get_visible_child")]
639 #[doc(alias = "get_visible_child")]
640 #[doc(alias = "visible-child")]
641 pub fn visible_child(&self) -> Option<Widget> {
642 unsafe { from_glib_none(ffi::gtk_stack_get_visible_child(self.to_glib_none().0)) }
643 }
644
645 /// Returns the name of the currently visible child of @self.
646 ///
647 /// Returns [`None`] if there is no visible child.
648 ///
649 /// # Returns
650 ///
651 /// the name of the visible child
652 /// of the [`Stack`][crate::Stack]
653 #[doc(alias = "gtk_stack_get_visible_child_name")]
654 #[doc(alias = "get_visible_child_name")]
655 #[doc(alias = "visible-child-name")]
656 pub fn visible_child_name(&self) -> Option<glib::GString> {
657 unsafe { from_glib_none(ffi::gtk_stack_get_visible_child_name(self.to_glib_none().0)) }
658 }
659
660 /// Removes a child widget from @self.
661 /// ## `child`
662 /// the child to remove
663 #[doc(alias = "gtk_stack_remove")]
664 pub fn remove(&self, child: &impl IsA<Widget>) {
665 unsafe {
666 ffi::gtk_stack_remove(self.to_glib_none().0, child.as_ref().to_glib_none().0);
667 }
668 }
669
670 /// Sets the [`Stack`][crate::Stack] to be horizontally homogeneous or not.
671 ///
672 /// If it is homogeneous, the [`Stack`][crate::Stack] will request the same
673 /// width for all its children. If it isn't, the stack
674 /// may change width when a different child becomes visible.
675 /// ## `hhomogeneous`
676 /// [`true`] to make @self horizontally homogeneous
677 #[doc(alias = "gtk_stack_set_hhomogeneous")]
678 #[doc(alias = "hhomogeneous")]
679 pub fn set_hhomogeneous(&self, hhomogeneous: bool) {
680 unsafe {
681 ffi::gtk_stack_set_hhomogeneous(self.to_glib_none().0, hhomogeneous.into_glib());
682 }
683 }
684
685 /// Sets whether or not @self will interpolate its size when
686 /// changing the visible child.
687 ///
688 /// If the [`interpolate-size`][struct@crate::Stack#interpolate-size] property is set
689 /// to [`true`], @self will interpolate its size between the current
690 /// one and the one it'll take after changing the visible child,
691 /// according to the set transition duration.
692 /// ## `interpolate_size`
693 /// the new value
694 #[doc(alias = "gtk_stack_set_interpolate_size")]
695 #[doc(alias = "interpolate-size")]
696 pub fn set_interpolate_size(&self, interpolate_size: bool) {
697 unsafe {
698 ffi::gtk_stack_set_interpolate_size(
699 self.to_glib_none().0,
700 interpolate_size.into_glib(),
701 );
702 }
703 }
704
705 /// Sets the duration that transitions between pages in @self
706 /// will take.
707 /// ## `duration`
708 /// the new duration, in milliseconds
709 #[doc(alias = "gtk_stack_set_transition_duration")]
710 #[doc(alias = "transition-duration")]
711 pub fn set_transition_duration(&self, duration: u32) {
712 unsafe {
713 ffi::gtk_stack_set_transition_duration(self.to_glib_none().0, duration);
714 }
715 }
716
717 /// Sets the type of animation that will be used for
718 /// transitions between pages in @self.
719 ///
720 /// Available types include various kinds of fades and slides.
721 ///
722 /// The transition type can be changed without problems
723 /// at runtime, so it is possible to change the animation
724 /// based on the page that is about to become current.
725 /// ## `transition`
726 /// the new transition type
727 #[doc(alias = "gtk_stack_set_transition_type")]
728 #[doc(alias = "transition-type")]
729 pub fn set_transition_type(&self, transition: StackTransitionType) {
730 unsafe {
731 ffi::gtk_stack_set_transition_type(self.to_glib_none().0, transition.into_glib());
732 }
733 }
734
735 /// Sets the [`Stack`][crate::Stack] to be vertically homogeneous or not.
736 ///
737 /// If it is homogeneous, the [`Stack`][crate::Stack] will request the same
738 /// height for all its children. If it isn't, the stack
739 /// may change height when a different child becomes visible.
740 /// ## `vhomogeneous`
741 /// [`true`] to make @self vertically homogeneous
742 #[doc(alias = "gtk_stack_set_vhomogeneous")]
743 #[doc(alias = "vhomogeneous")]
744 pub fn set_vhomogeneous(&self, vhomogeneous: bool) {
745 unsafe {
746 ffi::gtk_stack_set_vhomogeneous(self.to_glib_none().0, vhomogeneous.into_glib());
747 }
748 }
749
750 /// Makes @child the visible child of @self.
751 ///
752 /// If @child is different from the currently visible child,
753 /// the transition between the two will be animated with the
754 /// current transition type of @self.
755 ///
756 /// Note that the @child widget has to be visible itself
757 /// (see [`WidgetExt::show()`][crate::prelude::WidgetExt::show()]) in order to become the visible
758 /// child of @self.
759 /// ## `child`
760 /// a child of @self
761 #[doc(alias = "gtk_stack_set_visible_child")]
762 #[doc(alias = "visible-child")]
763 pub fn set_visible_child(&self, child: &impl IsA<Widget>) {
764 unsafe {
765 ffi::gtk_stack_set_visible_child(
766 self.to_glib_none().0,
767 child.as_ref().to_glib_none().0,
768 );
769 }
770 }
771
772 /// Makes the child with the given name visible.
773 ///
774 /// Note that the child widget has to be visible itself
775 /// (see [`WidgetExt::show()`][crate::prelude::WidgetExt::show()]) in order to become the visible
776 /// child of @self.
777 /// ## `name`
778 /// the name of the child to make visible
779 /// ## `transition`
780 /// the transition type to use
781 #[doc(alias = "gtk_stack_set_visible_child_full")]
782 pub fn set_visible_child_full(&self, name: &str, transition: StackTransitionType) {
783 unsafe {
784 ffi::gtk_stack_set_visible_child_full(
785 self.to_glib_none().0,
786 name.to_glib_none().0,
787 transition.into_glib(),
788 );
789 }
790 }
791
792 /// Makes the child with the given name visible.
793 ///
794 /// If @child is different from the currently visible child,
795 /// the transition between the two will be animated with the
796 /// current transition type of @self.
797 ///
798 /// Note that the child widget has to be visible itself
799 /// (see [`WidgetExt::show()`][crate::prelude::WidgetExt::show()]) in order to become the visible
800 /// child of @self.
801 /// ## `name`
802 /// the name of the child to make visible
803 #[doc(alias = "gtk_stack_set_visible_child_name")]
804 #[doc(alias = "visible-child-name")]
805 pub fn set_visible_child_name(&self, name: &str) {
806 unsafe {
807 ffi::gtk_stack_set_visible_child_name(self.to_glib_none().0, name.to_glib_none().0);
808 }
809 }
810
811 #[doc(alias = "hhomogeneous")]
812 pub fn connect_hhomogeneous_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
813 unsafe extern "C" fn notify_hhomogeneous_trampoline<F: Fn(&Stack) + 'static>(
814 this: *mut ffi::GtkStack,
815 _param_spec: glib::ffi::gpointer,
816 f: glib::ffi::gpointer,
817 ) {
818 unsafe {
819 let f: &F = &*(f as *const F);
820 f(&from_glib_borrow(this))
821 }
822 }
823 unsafe {
824 let f: Box_<F> = Box_::new(f);
825 connect_raw(
826 self.as_ptr() as *mut _,
827 c"notify::hhomogeneous".as_ptr(),
828 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
829 notify_hhomogeneous_trampoline::<F> as *const (),
830 )),
831 Box_::into_raw(f),
832 )
833 }
834 }
835
836 #[doc(alias = "interpolate-size")]
837 pub fn connect_interpolate_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
838 unsafe extern "C" fn notify_interpolate_size_trampoline<F: Fn(&Stack) + 'static>(
839 this: *mut ffi::GtkStack,
840 _param_spec: glib::ffi::gpointer,
841 f: glib::ffi::gpointer,
842 ) {
843 unsafe {
844 let f: &F = &*(f as *const F);
845 f(&from_glib_borrow(this))
846 }
847 }
848 unsafe {
849 let f: Box_<F> = Box_::new(f);
850 connect_raw(
851 self.as_ptr() as *mut _,
852 c"notify::interpolate-size".as_ptr(),
853 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
854 notify_interpolate_size_trampoline::<F> as *const (),
855 )),
856 Box_::into_raw(f),
857 )
858 }
859 }
860
861 #[doc(alias = "pages")]
862 pub fn connect_pages_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
863 unsafe extern "C" fn notify_pages_trampoline<F: Fn(&Stack) + 'static>(
864 this: *mut ffi::GtkStack,
865 _param_spec: glib::ffi::gpointer,
866 f: glib::ffi::gpointer,
867 ) {
868 unsafe {
869 let f: &F = &*(f as *const F);
870 f(&from_glib_borrow(this))
871 }
872 }
873 unsafe {
874 let f: Box_<F> = Box_::new(f);
875 connect_raw(
876 self.as_ptr() as *mut _,
877 c"notify::pages".as_ptr(),
878 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
879 notify_pages_trampoline::<F> as *const (),
880 )),
881 Box_::into_raw(f),
882 )
883 }
884 }
885
886 #[doc(alias = "transition-duration")]
887 pub fn connect_transition_duration_notify<F: Fn(&Self) + 'static>(
888 &self,
889 f: F,
890 ) -> SignalHandlerId {
891 unsafe extern "C" fn notify_transition_duration_trampoline<F: Fn(&Stack) + 'static>(
892 this: *mut ffi::GtkStack,
893 _param_spec: glib::ffi::gpointer,
894 f: glib::ffi::gpointer,
895 ) {
896 unsafe {
897 let f: &F = &*(f as *const F);
898 f(&from_glib_borrow(this))
899 }
900 }
901 unsafe {
902 let f: Box_<F> = Box_::new(f);
903 connect_raw(
904 self.as_ptr() as *mut _,
905 c"notify::transition-duration".as_ptr(),
906 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
907 notify_transition_duration_trampoline::<F> as *const (),
908 )),
909 Box_::into_raw(f),
910 )
911 }
912 }
913
914 #[doc(alias = "transition-running")]
915 pub fn connect_transition_running_notify<F: Fn(&Self) + 'static>(
916 &self,
917 f: F,
918 ) -> SignalHandlerId {
919 unsafe extern "C" fn notify_transition_running_trampoline<F: Fn(&Stack) + 'static>(
920 this: *mut ffi::GtkStack,
921 _param_spec: glib::ffi::gpointer,
922 f: glib::ffi::gpointer,
923 ) {
924 unsafe {
925 let f: &F = &*(f as *const F);
926 f(&from_glib_borrow(this))
927 }
928 }
929 unsafe {
930 let f: Box_<F> = Box_::new(f);
931 connect_raw(
932 self.as_ptr() as *mut _,
933 c"notify::transition-running".as_ptr(),
934 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
935 notify_transition_running_trampoline::<F> as *const (),
936 )),
937 Box_::into_raw(f),
938 )
939 }
940 }
941
942 #[doc(alias = "transition-type")]
943 pub fn connect_transition_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
944 unsafe extern "C" fn notify_transition_type_trampoline<F: Fn(&Stack) + 'static>(
945 this: *mut ffi::GtkStack,
946 _param_spec: glib::ffi::gpointer,
947 f: glib::ffi::gpointer,
948 ) {
949 unsafe {
950 let f: &F = &*(f as *const F);
951 f(&from_glib_borrow(this))
952 }
953 }
954 unsafe {
955 let f: Box_<F> = Box_::new(f);
956 connect_raw(
957 self.as_ptr() as *mut _,
958 c"notify::transition-type".as_ptr(),
959 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
960 notify_transition_type_trampoline::<F> as *const (),
961 )),
962 Box_::into_raw(f),
963 )
964 }
965 }
966
967 #[doc(alias = "vhomogeneous")]
968 pub fn connect_vhomogeneous_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
969 unsafe extern "C" fn notify_vhomogeneous_trampoline<F: Fn(&Stack) + 'static>(
970 this: *mut ffi::GtkStack,
971 _param_spec: glib::ffi::gpointer,
972 f: glib::ffi::gpointer,
973 ) {
974 unsafe {
975 let f: &F = &*(f as *const F);
976 f(&from_glib_borrow(this))
977 }
978 }
979 unsafe {
980 let f: Box_<F> = Box_::new(f);
981 connect_raw(
982 self.as_ptr() as *mut _,
983 c"notify::vhomogeneous".as_ptr(),
984 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
985 notify_vhomogeneous_trampoline::<F> as *const (),
986 )),
987 Box_::into_raw(f),
988 )
989 }
990 }
991
992 #[doc(alias = "visible-child")]
993 pub fn connect_visible_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
994 unsafe extern "C" fn notify_visible_child_trampoline<F: Fn(&Stack) + 'static>(
995 this: *mut ffi::GtkStack,
996 _param_spec: glib::ffi::gpointer,
997 f: glib::ffi::gpointer,
998 ) {
999 unsafe {
1000 let f: &F = &*(f as *const F);
1001 f(&from_glib_borrow(this))
1002 }
1003 }
1004 unsafe {
1005 let f: Box_<F> = Box_::new(f);
1006 connect_raw(
1007 self.as_ptr() as *mut _,
1008 c"notify::visible-child".as_ptr(),
1009 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1010 notify_visible_child_trampoline::<F> as *const (),
1011 )),
1012 Box_::into_raw(f),
1013 )
1014 }
1015 }
1016
1017 #[doc(alias = "visible-child-name")]
1018 pub fn connect_visible_child_name_notify<F: Fn(&Self) + 'static>(
1019 &self,
1020 f: F,
1021 ) -> SignalHandlerId {
1022 unsafe extern "C" fn notify_visible_child_name_trampoline<F: Fn(&Stack) + 'static>(
1023 this: *mut ffi::GtkStack,
1024 _param_spec: glib::ffi::gpointer,
1025 f: glib::ffi::gpointer,
1026 ) {
1027 unsafe {
1028 let f: &F = &*(f as *const F);
1029 f(&from_glib_borrow(this))
1030 }
1031 }
1032 unsafe {
1033 let f: Box_<F> = Box_::new(f);
1034 connect_raw(
1035 self.as_ptr() as *mut _,
1036 c"notify::visible-child-name".as_ptr(),
1037 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1038 notify_visible_child_name_trampoline::<F> as *const (),
1039 )),
1040 Box_::into_raw(f),
1041 )
1042 }
1043 }
1044}
1045
1046impl Default for Stack {
1047 fn default() -> Self {
1048 Self::new()
1049 }
1050}
1051
1052// rustdoc-stripper-ignore-next
1053/// A [builder-pattern] type to construct [`Stack`] objects.
1054///
1055/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1056#[must_use = "The builder must be built to be used"]
1057pub struct StackBuilder {
1058 builder: glib::object::ObjectBuilder<'static, Stack>,
1059}
1060
1061impl StackBuilder {
1062 fn new() -> Self {
1063 Self {
1064 builder: glib::object::Object::builder(),
1065 }
1066 }
1067
1068 /// [`true`] if the stack allocates the same width for all children.
1069 pub fn hhomogeneous(self, hhomogeneous: bool) -> Self {
1070 Self {
1071 builder: self.builder.property("hhomogeneous", hhomogeneous),
1072 }
1073 }
1074
1075 /// Whether or not the size should smoothly change during the transition.
1076 pub fn interpolate_size(self, interpolate_size: bool) -> Self {
1077 Self {
1078 builder: self.builder.property("interpolate-size", interpolate_size),
1079 }
1080 }
1081
1082 /// The animation duration, in milliseconds.
1083 pub fn transition_duration(self, transition_duration: u32) -> Self {
1084 Self {
1085 builder: self
1086 .builder
1087 .property("transition-duration", transition_duration),
1088 }
1089 }
1090
1091 /// The type of animation used to transition.
1092 pub fn transition_type(self, transition_type: StackTransitionType) -> Self {
1093 Self {
1094 builder: self.builder.property("transition-type", transition_type),
1095 }
1096 }
1097
1098 /// [`true`] if the stack allocates the same height for all children.
1099 pub fn vhomogeneous(self, vhomogeneous: bool) -> Self {
1100 Self {
1101 builder: self.builder.property("vhomogeneous", vhomogeneous),
1102 }
1103 }
1104
1105 /// The widget currently visible in the stack.
1106 pub fn visible_child(self, visible_child: &impl IsA<Widget>) -> Self {
1107 Self {
1108 builder: self
1109 .builder
1110 .property("visible-child", visible_child.clone().upcast()),
1111 }
1112 }
1113
1114 /// The name of the widget currently visible in the stack.
1115 pub fn visible_child_name(self, visible_child_name: impl Into<glib::GString>) -> Self {
1116 Self {
1117 builder: self
1118 .builder
1119 .property("visible-child-name", visible_child_name.into()),
1120 }
1121 }
1122
1123 /// Whether the widget or any of its descendents can accept
1124 /// the input focus.
1125 ///
1126 /// This property is meant to be set by widget implementations,
1127 /// typically in their instance init function.
1128 pub fn can_focus(self, can_focus: bool) -> Self {
1129 Self {
1130 builder: self.builder.property("can-focus", can_focus),
1131 }
1132 }
1133
1134 /// Whether the widget can receive pointer events.
1135 pub fn can_target(self, can_target: bool) -> Self {
1136 Self {
1137 builder: self.builder.property("can-target", can_target),
1138 }
1139 }
1140
1141 /// A list of css classes applied to this widget.
1142 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1143 Self {
1144 builder: self.builder.property("css-classes", css_classes.into()),
1145 }
1146 }
1147
1148 /// The name of this widget in the CSS tree.
1149 ///
1150 /// This property is meant to be set by widget implementations,
1151 /// typically in their instance init function.
1152 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1153 Self {
1154 builder: self.builder.property("css-name", css_name.into()),
1155 }
1156 }
1157
1158 /// The cursor used by @widget.
1159 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1160 Self {
1161 builder: self.builder.property("cursor", cursor.clone()),
1162 }
1163 }
1164
1165 /// Whether the widget should grab focus when it is clicked with the mouse.
1166 ///
1167 /// This property is only relevant for widgets that can take focus.
1168 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1169 Self {
1170 builder: self.builder.property("focus-on-click", focus_on_click),
1171 }
1172 }
1173
1174 /// Whether this widget itself will accept the input focus.
1175 pub fn focusable(self, focusable: bool) -> Self {
1176 Self {
1177 builder: self.builder.property("focusable", focusable),
1178 }
1179 }
1180
1181 /// How to distribute horizontal space if widget gets extra space.
1182 pub fn halign(self, halign: Align) -> Self {
1183 Self {
1184 builder: self.builder.property("halign", halign),
1185 }
1186 }
1187
1188 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1189 /// signal on @widget.
1190 ///
1191 /// A true value indicates that @widget can have a tooltip, in this case
1192 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1193 /// determine whether it will provide a tooltip or not.
1194 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1195 Self {
1196 builder: self.builder.property("has-tooltip", has_tooltip),
1197 }
1198 }
1199
1200 /// Overrides for height request of the widget.
1201 ///
1202 /// If this is -1, the natural request will be used.
1203 pub fn height_request(self, height_request: i32) -> Self {
1204 Self {
1205 builder: self.builder.property("height-request", height_request),
1206 }
1207 }
1208
1209 /// Whether to expand horizontally.
1210 pub fn hexpand(self, hexpand: bool) -> Self {
1211 Self {
1212 builder: self.builder.property("hexpand", hexpand),
1213 }
1214 }
1215
1216 /// Whether to use the `hexpand` property.
1217 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1218 Self {
1219 builder: self.builder.property("hexpand-set", hexpand_set),
1220 }
1221 }
1222
1223 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1224 /// the preferred size of the widget, and allocate its children.
1225 ///
1226 /// This property is meant to be set by widget implementations,
1227 /// typically in their instance init function.
1228 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1229 Self {
1230 builder: self
1231 .builder
1232 .property("layout-manager", layout_manager.clone().upcast()),
1233 }
1234 }
1235
1236 /// Makes this widget act like a modal dialog, with respect to
1237 /// event delivery.
1238 ///
1239 /// Global event controllers will not handle events with targets
1240 /// inside the widget, unless they are set up to ignore propagation
1241 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1242 #[cfg(feature = "v4_18")]
1243 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1244 pub fn limit_events(self, limit_events: bool) -> Self {
1245 Self {
1246 builder: self.builder.property("limit-events", limit_events),
1247 }
1248 }
1249
1250 /// Margin on bottom side of widget.
1251 ///
1252 /// This property adds margin outside of the widget's normal size
1253 /// request, the margin will be added in addition to the size from
1254 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1255 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1256 Self {
1257 builder: self.builder.property("margin-bottom", margin_bottom),
1258 }
1259 }
1260
1261 /// Margin on end of widget, horizontally.
1262 ///
1263 /// This property supports left-to-right and right-to-left text
1264 /// directions.
1265 ///
1266 /// This property adds margin outside of the widget's normal size
1267 /// request, the margin will be added in addition to the size from
1268 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1269 pub fn margin_end(self, margin_end: i32) -> Self {
1270 Self {
1271 builder: self.builder.property("margin-end", margin_end),
1272 }
1273 }
1274
1275 /// Margin on start of widget, horizontally.
1276 ///
1277 /// This property supports left-to-right and right-to-left text
1278 /// directions.
1279 ///
1280 /// This property adds margin outside of the widget's normal size
1281 /// request, the margin will be added in addition to the size from
1282 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1283 pub fn margin_start(self, margin_start: i32) -> Self {
1284 Self {
1285 builder: self.builder.property("margin-start", margin_start),
1286 }
1287 }
1288
1289 /// Margin on top side of widget.
1290 ///
1291 /// This property adds margin outside of the widget's normal size
1292 /// request, the margin will be added in addition to the size from
1293 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1294 pub fn margin_top(self, margin_top: i32) -> Self {
1295 Self {
1296 builder: self.builder.property("margin-top", margin_top),
1297 }
1298 }
1299
1300 /// The name of the widget.
1301 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1302 Self {
1303 builder: self.builder.property("name", name.into()),
1304 }
1305 }
1306
1307 /// The requested opacity of the widget.
1308 pub fn opacity(self, opacity: f64) -> Self {
1309 Self {
1310 builder: self.builder.property("opacity", opacity),
1311 }
1312 }
1313
1314 /// How content outside the widget's content area is treated.
1315 ///
1316 /// This property is meant to be set by widget implementations,
1317 /// typically in their instance init function.
1318 pub fn overflow(self, overflow: Overflow) -> Self {
1319 Self {
1320 builder: self.builder.property("overflow", overflow),
1321 }
1322 }
1323
1324 /// Whether the widget will receive the default action when it is focused.
1325 pub fn receives_default(self, receives_default: bool) -> Self {
1326 Self {
1327 builder: self.builder.property("receives-default", receives_default),
1328 }
1329 }
1330
1331 /// Whether the widget responds to input.
1332 pub fn sensitive(self, sensitive: bool) -> Self {
1333 Self {
1334 builder: self.builder.property("sensitive", sensitive),
1335 }
1336 }
1337
1338 /// Sets the text of tooltip to be the given string, which is marked up
1339 /// with Pango markup.
1340 ///
1341 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1342 ///
1343 /// This is a convenience property which will take care of getting the
1344 /// tooltip shown if the given string is not `NULL`:
1345 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1346 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1347 /// the default signal handler.
1348 ///
1349 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1350 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1351 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1352 Self {
1353 builder: self
1354 .builder
1355 .property("tooltip-markup", tooltip_markup.into()),
1356 }
1357 }
1358
1359 /// Sets the text of tooltip to be the given string.
1360 ///
1361 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1362 ///
1363 /// This is a convenience property which will take care of getting the
1364 /// tooltip shown if the given string is not `NULL`:
1365 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1366 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1367 /// the default signal handler.
1368 ///
1369 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1370 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1371 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1372 Self {
1373 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1374 }
1375 }
1376
1377 /// How to distribute vertical space if widget gets extra space.
1378 pub fn valign(self, valign: Align) -> Self {
1379 Self {
1380 builder: self.builder.property("valign", valign),
1381 }
1382 }
1383
1384 /// Whether to expand vertically.
1385 pub fn vexpand(self, vexpand: bool) -> Self {
1386 Self {
1387 builder: self.builder.property("vexpand", vexpand),
1388 }
1389 }
1390
1391 /// Whether to use the `vexpand` property.
1392 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1393 Self {
1394 builder: self.builder.property("vexpand-set", vexpand_set),
1395 }
1396 }
1397
1398 /// Whether the widget is visible.
1399 pub fn visible(self, visible: bool) -> Self {
1400 Self {
1401 builder: self.builder.property("visible", visible),
1402 }
1403 }
1404
1405 /// Overrides for width request of the widget.
1406 ///
1407 /// If this is -1, the natural request will be used.
1408 pub fn width_request(self, width_request: i32) -> Self {
1409 Self {
1410 builder: self.builder.property("width-request", width_request),
1411 }
1412 }
1413
1414 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1415 ///
1416 /// The accessible role cannot be changed once set.
1417 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1418 Self {
1419 builder: self.builder.property("accessible-role", accessible_role),
1420 }
1421 }
1422
1423 // rustdoc-stripper-ignore-next
1424 /// Build the [`Stack`].
1425 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1426 pub fn build(self) -> Stack {
1427 assert_initialized_main_thread!();
1428 self.builder.build()
1429 }
1430}