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