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