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