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