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