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