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