gtk4/auto/stack_switcher.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, Orientable,
7 Orientation, Overflow, Stack, 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 a row of buttons to switch between [`Stack`][crate::Stack] pages.
18 ///
19 /// <picture>
20 /// <source srcset="stackswitcher-dark.png" media="(prefers-color-scheme: dark)">
21 /// <img alt="An example GtkStackSwitcher" src="stackswitcher.png">
22 /// </picture>
23 ///
24 /// It acts as a controller for the associated [`Stack`][crate::Stack].
25 ///
26 /// All the content for the buttons comes from the properties of the stacks
27 /// [`StackPage`][crate::StackPage] objects; the button visibility in a [`StackSwitcher`][crate::StackSwitcher]
28 /// widget is controlled by the visibility of the child in the [`Stack`][crate::Stack].
29 ///
30 /// It is possible to associate multiple [`StackSwitcher`][crate::StackSwitcher] widgets
31 /// with the same [`Stack`][crate::Stack] widget.
32 ///
33 /// # CSS nodes
34 ///
35 /// [`StackSwitcher`][crate::StackSwitcher] has a single CSS node named stackswitcher and
36 /// style class .stack-switcher.
37 ///
38 /// When circumstances require it, [`StackSwitcher`][crate::StackSwitcher] adds the
39 /// .needs-attention style class to the widgets representing the
40 /// stack pages.
41 ///
42 /// # Accessibility
43 ///
44 /// [`StackSwitcher`][crate::StackSwitcher] uses the [enum@Gtk.AccessibleRole.tab_list] role
45 /// and uses the [enum@Gtk.AccessibleRole.tab] role for its buttons.
46 ///
47 /// # Orientable
48 ///
49 /// Since GTK 4.4, [`StackSwitcher`][crate::StackSwitcher] implements [`Orientable`][crate::Orientable] allowing
50 /// the stack switcher to be made vertical with
51 /// `gtk_orientable_set_orientation()`.
52 ///
53 /// ## Properties
54 ///
55 ///
56 /// #### `stack`
57 /// The stack.
58 ///
59 /// Readable | Writeable | Construct
60 /// <details><summary><h4>Widget</h4></summary>
61 ///
62 ///
63 /// #### `can-focus`
64 /// Whether the widget or any of its descendents can accept
65 /// the input focus.
66 ///
67 /// This property is meant to be set by widget implementations,
68 /// typically in their instance init function.
69 ///
70 /// Readable | Writeable
71 ///
72 ///
73 /// #### `can-target`
74 /// Whether the widget can receive pointer events.
75 ///
76 /// Readable | Writeable
77 ///
78 ///
79 /// #### `css-classes`
80 /// A list of css classes applied to this widget.
81 ///
82 /// Readable | Writeable
83 ///
84 ///
85 /// #### `css-name`
86 /// The name of this widget in the CSS tree.
87 ///
88 /// This property is meant to be set by widget implementations,
89 /// typically in their instance init function.
90 ///
91 /// Readable | Writeable | Construct Only
92 ///
93 ///
94 /// #### `cursor`
95 /// The cursor used by @widget.
96 ///
97 /// Readable | Writeable
98 ///
99 ///
100 /// #### `focus-on-click`
101 /// Whether the widget should grab focus when it is clicked with the mouse.
102 ///
103 /// This property is only relevant for widgets that can take focus.
104 ///
105 /// Readable | Writeable
106 ///
107 ///
108 /// #### `focusable`
109 /// Whether this widget itself will accept the input focus.
110 ///
111 /// Readable | Writeable
112 ///
113 ///
114 /// #### `halign`
115 /// How to distribute horizontal space if widget gets extra space.
116 ///
117 /// Readable | Writeable
118 ///
119 ///
120 /// #### `has-default`
121 /// Whether the widget is the default widget.
122 ///
123 /// Readable
124 ///
125 ///
126 /// #### `has-focus`
127 /// Whether the widget has the input focus.
128 ///
129 /// Readable
130 ///
131 ///
132 /// #### `has-tooltip`
133 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
134 /// signal on @widget.
135 ///
136 /// A true value indicates that @widget can have a tooltip, in this case
137 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
138 /// determine whether it will provide a tooltip or not.
139 ///
140 /// Readable | Writeable
141 ///
142 ///
143 /// #### `height-request`
144 /// Overrides for height request of the widget.
145 ///
146 /// If this is -1, the natural request will be used.
147 ///
148 /// Readable | Writeable
149 ///
150 ///
151 /// #### `hexpand`
152 /// Whether to expand horizontally.
153 ///
154 /// Readable | Writeable
155 ///
156 ///
157 /// #### `hexpand-set`
158 /// Whether to use the `hexpand` property.
159 ///
160 /// Readable | Writeable
161 ///
162 ///
163 /// #### `layout-manager`
164 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
165 /// the preferred size of the widget, and allocate its children.
166 ///
167 /// This property is meant to be set by widget implementations,
168 /// typically in their instance init function.
169 ///
170 /// Readable | Writeable
171 ///
172 ///
173 /// #### `limit-events`
174 /// Makes this widget act like a modal dialog, with respect to
175 /// event delivery.
176 ///
177 /// Global event controllers will not handle events with targets
178 /// inside the widget, unless they are set up to ignore propagation
179 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
180 ///
181 /// Readable | Writeable
182 ///
183 ///
184 /// #### `margin-bottom`
185 /// Margin on bottom side of widget.
186 ///
187 /// This property adds margin outside of the widget's normal size
188 /// request, the margin will be added in addition to the size from
189 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
190 ///
191 /// Readable | Writeable
192 ///
193 ///
194 /// #### `margin-end`
195 /// Margin on end of widget, horizontally.
196 ///
197 /// This property supports left-to-right and right-to-left text
198 /// directions.
199 ///
200 /// This property adds margin outside of the widget's normal size
201 /// request, the margin will be added in addition to the size from
202 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
203 ///
204 /// Readable | Writeable
205 ///
206 ///
207 /// #### `margin-start`
208 /// Margin on start of widget, horizontally.
209 ///
210 /// This property supports left-to-right and right-to-left text
211 /// directions.
212 ///
213 /// This property adds margin outside of the widget's normal size
214 /// request, the margin will be added in addition to the size from
215 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
216 ///
217 /// Readable | Writeable
218 ///
219 ///
220 /// #### `margin-top`
221 /// Margin on top side of widget.
222 ///
223 /// This property adds margin outside of the widget's normal size
224 /// request, the margin will be added in addition to the size from
225 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
226 ///
227 /// Readable | Writeable
228 ///
229 ///
230 /// #### `name`
231 /// The name of the widget.
232 ///
233 /// Readable | Writeable
234 ///
235 ///
236 /// #### `opacity`
237 /// The requested opacity of the widget.
238 ///
239 /// Readable | Writeable
240 ///
241 ///
242 /// #### `overflow`
243 /// How content outside the widget's content area is treated.
244 ///
245 /// This property is meant to be set by widget implementations,
246 /// typically in their instance init function.
247 ///
248 /// Readable | Writeable
249 ///
250 ///
251 /// #### `parent`
252 /// The parent widget of this widget.
253 ///
254 /// Readable
255 ///
256 ///
257 /// #### `receives-default`
258 /// Whether the widget will receive the default action when it is focused.
259 ///
260 /// Readable | Writeable
261 ///
262 ///
263 /// #### `root`
264 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
265 ///
266 /// This will be `NULL` if the widget is not contained in a root widget.
267 ///
268 /// Readable
269 ///
270 ///
271 /// #### `scale-factor`
272 /// The scale factor of the widget.
273 ///
274 /// Readable
275 ///
276 ///
277 /// #### `sensitive`
278 /// Whether the widget responds to input.
279 ///
280 /// Readable | Writeable
281 ///
282 ///
283 /// #### `tooltip-markup`
284 /// Sets the text of tooltip to be the given string, which is marked up
285 /// with Pango markup.
286 ///
287 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
288 ///
289 /// This is a convenience property which will take care of getting the
290 /// tooltip shown if the given string is not `NULL`:
291 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
292 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
293 /// the default signal handler.
294 ///
295 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
296 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
297 ///
298 /// Readable | Writeable
299 ///
300 ///
301 /// #### `tooltip-text`
302 /// Sets the text of tooltip to be the given string.
303 ///
304 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
305 ///
306 /// This is a convenience property which will take care of getting the
307 /// tooltip shown if the given string is not `NULL`:
308 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
309 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
310 /// the default signal handler.
311 ///
312 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
313 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
314 ///
315 /// Readable | Writeable
316 ///
317 ///
318 /// #### `valign`
319 /// How to distribute vertical space if widget gets extra space.
320 ///
321 /// Readable | Writeable
322 ///
323 ///
324 /// #### `vexpand`
325 /// Whether to expand vertically.
326 ///
327 /// Readable | Writeable
328 ///
329 ///
330 /// #### `vexpand-set`
331 /// Whether to use the `vexpand` property.
332 ///
333 /// Readable | Writeable
334 ///
335 ///
336 /// #### `visible`
337 /// Whether the widget is visible.
338 ///
339 /// Readable | Writeable
340 ///
341 ///
342 /// #### `width-request`
343 /// Overrides for width request of the widget.
344 ///
345 /// If this is -1, the natural request will be used.
346 ///
347 /// Readable | Writeable
348 /// </details>
349 /// <details><summary><h4>Accessible</h4></summary>
350 ///
351 ///
352 /// #### `accessible-role`
353 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
354 ///
355 /// The accessible role cannot be changed once set.
356 ///
357 /// Readable | Writeable
358 /// </details>
359 /// <details><summary><h4>Orientable</h4></summary>
360 ///
361 ///
362 /// #### `orientation`
363 /// The orientation of the orientable.
364 ///
365 /// Readable | Writeable
366 /// </details>
367 ///
368 /// # Implements
369 ///
370 /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
371 #[doc(alias = "GtkStackSwitcher")]
372 pub struct StackSwitcher(Object<ffi::GtkStackSwitcher>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable;
373
374 match fn {
375 type_ => || ffi::gtk_stack_switcher_get_type(),
376 }
377}
378
379impl StackSwitcher {
380 /// Create a new [`StackSwitcher`][crate::StackSwitcher].
381 ///
382 /// # Returns
383 ///
384 /// a new [`StackSwitcher`][crate::StackSwitcher].
385 #[doc(alias = "gtk_stack_switcher_new")]
386 pub fn new() -> StackSwitcher {
387 assert_initialized_main_thread!();
388 unsafe { Widget::from_glib_none(ffi::gtk_stack_switcher_new()).unsafe_cast() }
389 }
390
391 // rustdoc-stripper-ignore-next
392 /// Creates a new builder-pattern struct instance to construct [`StackSwitcher`] objects.
393 ///
394 /// This method returns an instance of [`StackSwitcherBuilder`](crate::builders::StackSwitcherBuilder) which can be used to create [`StackSwitcher`] objects.
395 pub fn builder() -> StackSwitcherBuilder {
396 StackSwitcherBuilder::new()
397 }
398
399 /// Retrieves the stack.
400 ///
401 /// # Returns
402 ///
403 /// the stack
404 #[doc(alias = "gtk_stack_switcher_get_stack")]
405 #[doc(alias = "get_stack")]
406 pub fn stack(&self) -> Option<Stack> {
407 unsafe { from_glib_none(ffi::gtk_stack_switcher_get_stack(self.to_glib_none().0)) }
408 }
409
410 /// Sets the stack to control.
411 /// ## `stack`
412 /// a [`Stack`][crate::Stack]
413 #[doc(alias = "gtk_stack_switcher_set_stack")]
414 #[doc(alias = "stack")]
415 pub fn set_stack(&self, stack: Option<&Stack>) {
416 unsafe {
417 ffi::gtk_stack_switcher_set_stack(self.to_glib_none().0, stack.to_glib_none().0);
418 }
419 }
420
421 #[doc(alias = "stack")]
422 pub fn connect_stack_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
423 unsafe extern "C" fn notify_stack_trampoline<F: Fn(&StackSwitcher) + 'static>(
424 this: *mut ffi::GtkStackSwitcher,
425 _param_spec: glib::ffi::gpointer,
426 f: glib::ffi::gpointer,
427 ) {
428 unsafe {
429 let f: &F = &*(f as *const F);
430 f(&from_glib_borrow(this))
431 }
432 }
433 unsafe {
434 let f: Box_<F> = Box_::new(f);
435 connect_raw(
436 self.as_ptr() as *mut _,
437 c"notify::stack".as_ptr() as *const _,
438 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
439 notify_stack_trampoline::<F> as *const (),
440 )),
441 Box_::into_raw(f),
442 )
443 }
444 }
445}
446
447impl Default for StackSwitcher {
448 fn default() -> Self {
449 Self::new()
450 }
451}
452
453// rustdoc-stripper-ignore-next
454/// A [builder-pattern] type to construct [`StackSwitcher`] objects.
455///
456/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
457#[must_use = "The builder must be built to be used"]
458pub struct StackSwitcherBuilder {
459 builder: glib::object::ObjectBuilder<'static, StackSwitcher>,
460}
461
462impl StackSwitcherBuilder {
463 fn new() -> Self {
464 Self {
465 builder: glib::object::Object::builder(),
466 }
467 }
468
469 /// The stack.
470 pub fn stack(self, stack: &Stack) -> Self {
471 Self {
472 builder: self.builder.property("stack", stack.clone()),
473 }
474 }
475
476 /// Whether the widget or any of its descendents can accept
477 /// the input focus.
478 ///
479 /// This property is meant to be set by widget implementations,
480 /// typically in their instance init function.
481 pub fn can_focus(self, can_focus: bool) -> Self {
482 Self {
483 builder: self.builder.property("can-focus", can_focus),
484 }
485 }
486
487 /// Whether the widget can receive pointer events.
488 pub fn can_target(self, can_target: bool) -> Self {
489 Self {
490 builder: self.builder.property("can-target", can_target),
491 }
492 }
493
494 /// A list of css classes applied to this widget.
495 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
496 Self {
497 builder: self.builder.property("css-classes", css_classes.into()),
498 }
499 }
500
501 /// The name of this widget in the CSS tree.
502 ///
503 /// This property is meant to be set by widget implementations,
504 /// typically in their instance init function.
505 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
506 Self {
507 builder: self.builder.property("css-name", css_name.into()),
508 }
509 }
510
511 /// The cursor used by @widget.
512 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
513 Self {
514 builder: self.builder.property("cursor", cursor.clone()),
515 }
516 }
517
518 /// Whether the widget should grab focus when it is clicked with the mouse.
519 ///
520 /// This property is only relevant for widgets that can take focus.
521 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
522 Self {
523 builder: self.builder.property("focus-on-click", focus_on_click),
524 }
525 }
526
527 /// Whether this widget itself will accept the input focus.
528 pub fn focusable(self, focusable: bool) -> Self {
529 Self {
530 builder: self.builder.property("focusable", focusable),
531 }
532 }
533
534 /// How to distribute horizontal space if widget gets extra space.
535 pub fn halign(self, halign: Align) -> Self {
536 Self {
537 builder: self.builder.property("halign", halign),
538 }
539 }
540
541 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
542 /// signal on @widget.
543 ///
544 /// A true value indicates that @widget can have a tooltip, in this case
545 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
546 /// determine whether it will provide a tooltip or not.
547 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
548 Self {
549 builder: self.builder.property("has-tooltip", has_tooltip),
550 }
551 }
552
553 /// Overrides for height request of the widget.
554 ///
555 /// If this is -1, the natural request will be used.
556 pub fn height_request(self, height_request: i32) -> Self {
557 Self {
558 builder: self.builder.property("height-request", height_request),
559 }
560 }
561
562 /// Whether to expand horizontally.
563 pub fn hexpand(self, hexpand: bool) -> Self {
564 Self {
565 builder: self.builder.property("hexpand", hexpand),
566 }
567 }
568
569 /// Whether to use the `hexpand` property.
570 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
571 Self {
572 builder: self.builder.property("hexpand-set", hexpand_set),
573 }
574 }
575
576 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
577 /// the preferred size of the widget, and allocate its children.
578 ///
579 /// This property is meant to be set by widget implementations,
580 /// typically in their instance init function.
581 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
582 Self {
583 builder: self
584 .builder
585 .property("layout-manager", layout_manager.clone().upcast()),
586 }
587 }
588
589 /// Makes this widget act like a modal dialog, with respect to
590 /// event delivery.
591 ///
592 /// Global event controllers will not handle events with targets
593 /// inside the widget, unless they are set up to ignore propagation
594 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
595 #[cfg(feature = "v4_18")]
596 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
597 pub fn limit_events(self, limit_events: bool) -> Self {
598 Self {
599 builder: self.builder.property("limit-events", limit_events),
600 }
601 }
602
603 /// Margin on bottom side of widget.
604 ///
605 /// This property adds margin outside of the widget's normal size
606 /// request, the margin will be added in addition to the size from
607 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
608 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
609 Self {
610 builder: self.builder.property("margin-bottom", margin_bottom),
611 }
612 }
613
614 /// Margin on end of widget, horizontally.
615 ///
616 /// This property supports left-to-right and right-to-left text
617 /// directions.
618 ///
619 /// This property adds margin outside of the widget's normal size
620 /// request, the margin will be added in addition to the size from
621 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
622 pub fn margin_end(self, margin_end: i32) -> Self {
623 Self {
624 builder: self.builder.property("margin-end", margin_end),
625 }
626 }
627
628 /// Margin on start of widget, horizontally.
629 ///
630 /// This property supports left-to-right and right-to-left text
631 /// directions.
632 ///
633 /// This property adds margin outside of the widget's normal size
634 /// request, the margin will be added in addition to the size from
635 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
636 pub fn margin_start(self, margin_start: i32) -> Self {
637 Self {
638 builder: self.builder.property("margin-start", margin_start),
639 }
640 }
641
642 /// Margin on top side of widget.
643 ///
644 /// This property adds margin outside of the widget's normal size
645 /// request, the margin will be added in addition to the size from
646 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
647 pub fn margin_top(self, margin_top: i32) -> Self {
648 Self {
649 builder: self.builder.property("margin-top", margin_top),
650 }
651 }
652
653 /// The name of the widget.
654 pub fn name(self, name: impl Into<glib::GString>) -> Self {
655 Self {
656 builder: self.builder.property("name", name.into()),
657 }
658 }
659
660 /// The requested opacity of the widget.
661 pub fn opacity(self, opacity: f64) -> Self {
662 Self {
663 builder: self.builder.property("opacity", opacity),
664 }
665 }
666
667 /// How content outside the widget's content area is treated.
668 ///
669 /// This property is meant to be set by widget implementations,
670 /// typically in their instance init function.
671 pub fn overflow(self, overflow: Overflow) -> Self {
672 Self {
673 builder: self.builder.property("overflow", overflow),
674 }
675 }
676
677 /// Whether the widget will receive the default action when it is focused.
678 pub fn receives_default(self, receives_default: bool) -> Self {
679 Self {
680 builder: self.builder.property("receives-default", receives_default),
681 }
682 }
683
684 /// Whether the widget responds to input.
685 pub fn sensitive(self, sensitive: bool) -> Self {
686 Self {
687 builder: self.builder.property("sensitive", sensitive),
688 }
689 }
690
691 /// Sets the text of tooltip to be the given string, which is marked up
692 /// with Pango markup.
693 ///
694 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
695 ///
696 /// This is a convenience property which will take care of getting the
697 /// tooltip shown if the given string is not `NULL`:
698 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
699 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
700 /// the default signal handler.
701 ///
702 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
703 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
704 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
705 Self {
706 builder: self
707 .builder
708 .property("tooltip-markup", tooltip_markup.into()),
709 }
710 }
711
712 /// Sets the text of tooltip to be the given string.
713 ///
714 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
715 ///
716 /// This is a convenience property which will take care of getting the
717 /// tooltip shown if the given string is not `NULL`:
718 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
719 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
720 /// the default signal handler.
721 ///
722 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
723 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
724 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
725 Self {
726 builder: self.builder.property("tooltip-text", tooltip_text.into()),
727 }
728 }
729
730 /// How to distribute vertical space if widget gets extra space.
731 pub fn valign(self, valign: Align) -> Self {
732 Self {
733 builder: self.builder.property("valign", valign),
734 }
735 }
736
737 /// Whether to expand vertically.
738 pub fn vexpand(self, vexpand: bool) -> Self {
739 Self {
740 builder: self.builder.property("vexpand", vexpand),
741 }
742 }
743
744 /// Whether to use the `vexpand` property.
745 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
746 Self {
747 builder: self.builder.property("vexpand-set", vexpand_set),
748 }
749 }
750
751 /// Whether the widget is visible.
752 pub fn visible(self, visible: bool) -> Self {
753 Self {
754 builder: self.builder.property("visible", visible),
755 }
756 }
757
758 /// Overrides for width request of the widget.
759 ///
760 /// If this is -1, the natural request will be used.
761 pub fn width_request(self, width_request: i32) -> Self {
762 Self {
763 builder: self.builder.property("width-request", width_request),
764 }
765 }
766
767 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
768 ///
769 /// The accessible role cannot be changed once set.
770 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
771 Self {
772 builder: self.builder.property("accessible-role", accessible_role),
773 }
774 }
775
776 /// The orientation of the orientable.
777 pub fn orientation(self, orientation: Orientation) -> Self {
778 Self {
779 builder: self.builder.property("orientation", orientation),
780 }
781 }
782
783 // rustdoc-stripper-ignore-next
784 /// Build the [`StackSwitcher`].
785 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
786 pub fn build(self) -> StackSwitcher {
787 assert_initialized_main_thread!();
788 self.builder.build()
789 }
790}