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 ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Orientable,
7 Orientation, Overflow, Stack, Widget,
8};
9use glib::{
10 prelude::*,
11 signal::{connect_raw, SignalHandlerId},
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 let f: &F = &*(f as *const F);
429 f(&from_glib_borrow(this))
430 }
431 unsafe {
432 let f: Box_<F> = Box_::new(f);
433 connect_raw(
434 self.as_ptr() as *mut _,
435 c"notify::stack".as_ptr() as *const _,
436 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
437 notify_stack_trampoline::<F> as *const (),
438 )),
439 Box_::into_raw(f),
440 )
441 }
442 }
443}
444
445impl Default for StackSwitcher {
446 fn default() -> Self {
447 Self::new()
448 }
449}
450
451// rustdoc-stripper-ignore-next
452/// A [builder-pattern] type to construct [`StackSwitcher`] objects.
453///
454/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
455#[must_use = "The builder must be built to be used"]
456pub struct StackSwitcherBuilder {
457 builder: glib::object::ObjectBuilder<'static, StackSwitcher>,
458}
459
460impl StackSwitcherBuilder {
461 fn new() -> Self {
462 Self {
463 builder: glib::object::Object::builder(),
464 }
465 }
466
467 /// The stack.
468 pub fn stack(self, stack: &Stack) -> Self {
469 Self {
470 builder: self.builder.property("stack", stack.clone()),
471 }
472 }
473
474 /// Whether the widget or any of its descendents can accept
475 /// the input focus.
476 ///
477 /// This property is meant to be set by widget implementations,
478 /// typically in their instance init function.
479 pub fn can_focus(self, can_focus: bool) -> Self {
480 Self {
481 builder: self.builder.property("can-focus", can_focus),
482 }
483 }
484
485 /// Whether the widget can receive pointer events.
486 pub fn can_target(self, can_target: bool) -> Self {
487 Self {
488 builder: self.builder.property("can-target", can_target),
489 }
490 }
491
492 /// A list of css classes applied to this widget.
493 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
494 Self {
495 builder: self.builder.property("css-classes", css_classes.into()),
496 }
497 }
498
499 /// The name of this widget in the CSS tree.
500 ///
501 /// This property is meant to be set by widget implementations,
502 /// typically in their instance init function.
503 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
504 Self {
505 builder: self.builder.property("css-name", css_name.into()),
506 }
507 }
508
509 /// The cursor used by @widget.
510 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
511 Self {
512 builder: self.builder.property("cursor", cursor.clone()),
513 }
514 }
515
516 /// Whether the widget should grab focus when it is clicked with the mouse.
517 ///
518 /// This property is only relevant for widgets that can take focus.
519 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
520 Self {
521 builder: self.builder.property("focus-on-click", focus_on_click),
522 }
523 }
524
525 /// Whether this widget itself will accept the input focus.
526 pub fn focusable(self, focusable: bool) -> Self {
527 Self {
528 builder: self.builder.property("focusable", focusable),
529 }
530 }
531
532 /// How to distribute horizontal space if widget gets extra space.
533 pub fn halign(self, halign: Align) -> Self {
534 Self {
535 builder: self.builder.property("halign", halign),
536 }
537 }
538
539 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
540 /// signal on @widget.
541 ///
542 /// A true value indicates that @widget can have a tooltip, in this case
543 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
544 /// determine whether it will provide a tooltip or not.
545 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
546 Self {
547 builder: self.builder.property("has-tooltip", has_tooltip),
548 }
549 }
550
551 /// Overrides for height request of the widget.
552 ///
553 /// If this is -1, the natural request will be used.
554 pub fn height_request(self, height_request: i32) -> Self {
555 Self {
556 builder: self.builder.property("height-request", height_request),
557 }
558 }
559
560 /// Whether to expand horizontally.
561 pub fn hexpand(self, hexpand: bool) -> Self {
562 Self {
563 builder: self.builder.property("hexpand", hexpand),
564 }
565 }
566
567 /// Whether to use the `hexpand` property.
568 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
569 Self {
570 builder: self.builder.property("hexpand-set", hexpand_set),
571 }
572 }
573
574 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
575 /// the preferred size of the widget, and allocate its children.
576 ///
577 /// This property is meant to be set by widget implementations,
578 /// typically in their instance init function.
579 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
580 Self {
581 builder: self
582 .builder
583 .property("layout-manager", layout_manager.clone().upcast()),
584 }
585 }
586
587 /// Makes this widget act like a modal dialog, with respect to
588 /// event delivery.
589 ///
590 /// Global event controllers will not handle events with targets
591 /// inside the widget, unless they are set up to ignore propagation
592 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
593 #[cfg(feature = "v4_18")]
594 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
595 pub fn limit_events(self, limit_events: bool) -> Self {
596 Self {
597 builder: self.builder.property("limit-events", limit_events),
598 }
599 }
600
601 /// Margin on bottom side of widget.
602 ///
603 /// This property adds margin outside of the widget's normal size
604 /// request, the margin will be added in addition to the size from
605 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
606 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
607 Self {
608 builder: self.builder.property("margin-bottom", margin_bottom),
609 }
610 }
611
612 /// Margin on end of widget, horizontally.
613 ///
614 /// This property supports left-to-right and right-to-left text
615 /// directions.
616 ///
617 /// This property adds margin outside of the widget's normal size
618 /// request, the margin will be added in addition to the size from
619 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
620 pub fn margin_end(self, margin_end: i32) -> Self {
621 Self {
622 builder: self.builder.property("margin-end", margin_end),
623 }
624 }
625
626 /// Margin on start of widget, horizontally.
627 ///
628 /// This property supports left-to-right and right-to-left text
629 /// directions.
630 ///
631 /// This property adds margin outside of the widget's normal size
632 /// request, the margin will be added in addition to the size from
633 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
634 pub fn margin_start(self, margin_start: i32) -> Self {
635 Self {
636 builder: self.builder.property("margin-start", margin_start),
637 }
638 }
639
640 /// Margin on top side of widget.
641 ///
642 /// This property adds margin outside of the widget's normal size
643 /// request, the margin will be added in addition to the size from
644 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
645 pub fn margin_top(self, margin_top: i32) -> Self {
646 Self {
647 builder: self.builder.property("margin-top", margin_top),
648 }
649 }
650
651 /// The name of the widget.
652 pub fn name(self, name: impl Into<glib::GString>) -> Self {
653 Self {
654 builder: self.builder.property("name", name.into()),
655 }
656 }
657
658 /// The requested opacity of the widget.
659 pub fn opacity(self, opacity: f64) -> Self {
660 Self {
661 builder: self.builder.property("opacity", opacity),
662 }
663 }
664
665 /// How content outside the widget's content area is treated.
666 ///
667 /// This property is meant to be set by widget implementations,
668 /// typically in their instance init function.
669 pub fn overflow(self, overflow: Overflow) -> Self {
670 Self {
671 builder: self.builder.property("overflow", overflow),
672 }
673 }
674
675 /// Whether the widget will receive the default action when it is focused.
676 pub fn receives_default(self, receives_default: bool) -> Self {
677 Self {
678 builder: self.builder.property("receives-default", receives_default),
679 }
680 }
681
682 /// Whether the widget responds to input.
683 pub fn sensitive(self, sensitive: bool) -> Self {
684 Self {
685 builder: self.builder.property("sensitive", sensitive),
686 }
687 }
688
689 /// Sets the text of tooltip to be the given string, which is marked up
690 /// with Pango markup.
691 ///
692 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
693 ///
694 /// This is a convenience property which will take care of getting the
695 /// tooltip shown if the given string is not `NULL`:
696 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
697 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
698 /// the default signal handler.
699 ///
700 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
701 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
702 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
703 Self {
704 builder: self
705 .builder
706 .property("tooltip-markup", tooltip_markup.into()),
707 }
708 }
709
710 /// Sets the text of tooltip to be the given string.
711 ///
712 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
713 ///
714 /// This is a convenience property which will take care of getting the
715 /// tooltip shown if the given string is not `NULL`:
716 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
717 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
718 /// the default signal handler.
719 ///
720 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
721 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
722 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
723 Self {
724 builder: self.builder.property("tooltip-text", tooltip_text.into()),
725 }
726 }
727
728 /// How to distribute vertical space if widget gets extra space.
729 pub fn valign(self, valign: Align) -> Self {
730 Self {
731 builder: self.builder.property("valign", valign),
732 }
733 }
734
735 /// Whether to expand vertically.
736 pub fn vexpand(self, vexpand: bool) -> Self {
737 Self {
738 builder: self.builder.property("vexpand", vexpand),
739 }
740 }
741
742 /// Whether to use the `vexpand` property.
743 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
744 Self {
745 builder: self.builder.property("vexpand-set", vexpand_set),
746 }
747 }
748
749 /// Whether the widget is visible.
750 pub fn visible(self, visible: bool) -> Self {
751 Self {
752 builder: self.builder.property("visible", visible),
753 }
754 }
755
756 /// Overrides for width request of the widget.
757 ///
758 /// If this is -1, the natural request will be used.
759 pub fn width_request(self, width_request: i32) -> Self {
760 Self {
761 builder: self.builder.property("width-request", width_request),
762 }
763 }
764
765 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
766 ///
767 /// The accessible role cannot be changed once set.
768 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
769 Self {
770 builder: self.builder.property("accessible-role", accessible_role),
771 }
772 }
773
774 /// The orientation of the orientable.
775 pub fn orientation(self, orientation: Orientation) -> Self {
776 Self {
777 builder: self.builder.property("orientation", orientation),
778 }
779 }
780
781 // rustdoc-stripper-ignore-next
782 /// Build the [`StackSwitcher`].
783 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
784 pub fn build(self) -> StackSwitcher {
785 assert_initialized_main_thread!();
786 self.builder.build()
787 }
788}