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 ///
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 | Writable | 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 | Writable
71 ///
72 ///
73 /// #### `can-target`
74 /// Whether the widget can receive pointer events.
75 ///
76 /// Readable | Writable
77 ///
78 ///
79 /// #### `css-classes`
80 /// A list of css classes applied to this widget.
81 ///
82 /// Readable | Writable
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 | Writable | Construct Only
92 ///
93 ///
94 /// #### `cursor`
95 /// The cursor used by @widget.
96 ///
97 /// Readable | Writable
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 | Writable
106 ///
107 ///
108 /// #### `focusable`
109 /// Whether this widget itself will accept the input focus.
110 ///
111 /// Readable | Writable
112 ///
113 ///
114 /// #### `halign`
115 /// How to distribute horizontal space if widget gets extra space.
116 ///
117 /// Readable | Writable
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 | Writable
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 | Writable
149 ///
150 ///
151 /// #### `hexpand`
152 /// Whether to expand horizontally.
153 ///
154 /// Readable | Writable
155 ///
156 ///
157 /// #### `hexpand-set`
158 /// Whether to use the `hexpand` property.
159 ///
160 /// Readable | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
228 ///
229 ///
230 /// #### `name`
231 /// The name of the widget.
232 ///
233 /// Readable | Writable
234 ///
235 ///
236 /// #### `opacity`
237 /// The requested opacity of the widget.
238 ///
239 /// Readable | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
316 ///
317 ///
318 /// #### `valign`
319 /// How to distribute vertical space if widget gets extra space.
320 ///
321 /// Readable | Writable
322 ///
323 ///
324 /// #### `vexpand`
325 /// Whether to expand vertically.
326 ///
327 /// Readable | Writable
328 ///
329 ///
330 /// #### `vexpand-set`
331 /// Whether to use the `vexpand` property.
332 ///
333 /// Readable | Writable
334 ///
335 ///
336 /// #### `visible`
337 /// Whether the widget is visible.
338 ///
339 /// Readable | Writable
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 | Writable
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 | Writable
358 /// </details>
359 /// <details><summary><h4>Orientable</h4></summary>
360 ///
361 ///
362 /// #### `orientation`
363 /// The orientation of the orientable.
364 ///
365 /// Readable | Writable
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
379#[cfg(not(feature = "v4_10"))]
380glib::wrapper! {
381 #[doc(alias = "GtkStackSwitcher")]
382 pub struct StackSwitcher(Object<ffi::GtkStackSwitcher>) @extends Widget, @implements Buildable, ConstraintTarget, Orientable;
383
384 match fn {
385 type_ => || ffi::gtk_stack_switcher_get_type(),
386 }
387}
388
389impl StackSwitcher {
390 /// Create a new [`StackSwitcher`][crate::StackSwitcher].
391 ///
392 /// # Returns
393 ///
394 /// a new [`StackSwitcher`][crate::StackSwitcher].
395 #[doc(alias = "gtk_stack_switcher_new")]
396 pub fn new() -> StackSwitcher {
397 assert_initialized_main_thread!();
398 unsafe { Widget::from_glib_none(ffi::gtk_stack_switcher_new()).unsafe_cast() }
399 }
400
401 // rustdoc-stripper-ignore-next
402 /// Creates a new builder-pattern struct instance to construct [`StackSwitcher`] objects.
403 ///
404 /// This method returns an instance of [`StackSwitcherBuilder`](crate::builders::StackSwitcherBuilder) which can be used to create [`StackSwitcher`] objects.
405 pub fn builder() -> StackSwitcherBuilder {
406 StackSwitcherBuilder::new()
407 }
408
409 /// Retrieves the stack.
410 ///
411 /// # Returns
412 ///
413 /// the stack
414 #[doc(alias = "gtk_stack_switcher_get_stack")]
415 #[doc(alias = "get_stack")]
416 pub fn stack(&self) -> Option<Stack> {
417 unsafe { from_glib_none(ffi::gtk_stack_switcher_get_stack(self.to_glib_none().0)) }
418 }
419
420 /// Sets the stack to control.
421 /// ## `stack`
422 /// a [`Stack`][crate::Stack]
423 #[doc(alias = "gtk_stack_switcher_set_stack")]
424 #[doc(alias = "stack")]
425 pub fn set_stack(&self, stack: Option<&Stack>) {
426 unsafe {
427 ffi::gtk_stack_switcher_set_stack(self.to_glib_none().0, stack.to_glib_none().0);
428 }
429 }
430
431 #[doc(alias = "stack")]
432 pub fn connect_stack_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
433 unsafe extern "C" fn notify_stack_trampoline<F: Fn(&StackSwitcher) + 'static>(
434 this: *mut ffi::GtkStackSwitcher,
435 _param_spec: glib::ffi::gpointer,
436 f: glib::ffi::gpointer,
437 ) {
438 unsafe {
439 let f: &F = &*(f as *const F);
440 f(&from_glib_borrow(this))
441 }
442 }
443 unsafe {
444 let f: Box_<F> = Box_::new(f);
445 connect_raw(
446 self.as_ptr() as *mut _,
447 c"notify::stack".as_ptr(),
448 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
449 notify_stack_trampoline::<F> as *const (),
450 )),
451 Box_::into_raw(f),
452 )
453 }
454 }
455}
456
457impl Default for StackSwitcher {
458 fn default() -> Self {
459 Self::new()
460 }
461}
462
463// rustdoc-stripper-ignore-next
464/// A [builder-pattern] type to construct [`StackSwitcher`] objects.
465///
466/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
467#[must_use = "The builder must be built to be used"]
468pub struct StackSwitcherBuilder {
469 builder: glib::object::ObjectBuilder<'static, StackSwitcher>,
470}
471
472impl StackSwitcherBuilder {
473 fn new() -> Self {
474 Self {
475 builder: glib::object::Object::builder(),
476 }
477 }
478
479 /// The stack.
480 pub fn stack(self, stack: &Stack) -> Self {
481 Self {
482 builder: self.builder.property("stack", stack.clone()),
483 }
484 }
485
486 /// Whether the widget or any of its descendents can accept
487 /// the input focus.
488 ///
489 /// This property is meant to be set by widget implementations,
490 /// typically in their instance init function.
491 pub fn can_focus(self, can_focus: bool) -> Self {
492 Self {
493 builder: self.builder.property("can-focus", can_focus),
494 }
495 }
496
497 /// Whether the widget can receive pointer events.
498 pub fn can_target(self, can_target: bool) -> Self {
499 Self {
500 builder: self.builder.property("can-target", can_target),
501 }
502 }
503
504 /// A list of css classes applied to this widget.
505 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
506 Self {
507 builder: self.builder.property("css-classes", css_classes.into()),
508 }
509 }
510
511 /// The name of this widget in the CSS tree.
512 ///
513 /// This property is meant to be set by widget implementations,
514 /// typically in their instance init function.
515 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
516 Self {
517 builder: self.builder.property("css-name", css_name.into()),
518 }
519 }
520
521 /// The cursor used by @widget.
522 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
523 Self {
524 builder: self.builder.property("cursor", cursor.clone()),
525 }
526 }
527
528 /// Whether the widget should grab focus when it is clicked with the mouse.
529 ///
530 /// This property is only relevant for widgets that can take focus.
531 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
532 Self {
533 builder: self.builder.property("focus-on-click", focus_on_click),
534 }
535 }
536
537 /// Whether this widget itself will accept the input focus.
538 pub fn focusable(self, focusable: bool) -> Self {
539 Self {
540 builder: self.builder.property("focusable", focusable),
541 }
542 }
543
544 /// How to distribute horizontal space if widget gets extra space.
545 pub fn halign(self, halign: Align) -> Self {
546 Self {
547 builder: self.builder.property("halign", halign),
548 }
549 }
550
551 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
552 /// signal on @widget.
553 ///
554 /// A true value indicates that @widget can have a tooltip, in this case
555 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
556 /// determine whether it will provide a tooltip or not.
557 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
558 Self {
559 builder: self.builder.property("has-tooltip", has_tooltip),
560 }
561 }
562
563 /// Overrides for height request of the widget.
564 ///
565 /// If this is -1, the natural request will be used.
566 pub fn height_request(self, height_request: i32) -> Self {
567 Self {
568 builder: self.builder.property("height-request", height_request),
569 }
570 }
571
572 /// Whether to expand horizontally.
573 pub fn hexpand(self, hexpand: bool) -> Self {
574 Self {
575 builder: self.builder.property("hexpand", hexpand),
576 }
577 }
578
579 /// Whether to use the `hexpand` property.
580 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
581 Self {
582 builder: self.builder.property("hexpand-set", hexpand_set),
583 }
584 }
585
586 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
587 /// the preferred size of the widget, and allocate its children.
588 ///
589 /// This property is meant to be set by widget implementations,
590 /// typically in their instance init function.
591 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
592 Self {
593 builder: self
594 .builder
595 .property("layout-manager", layout_manager.clone().upcast()),
596 }
597 }
598
599 /// Makes this widget act like a modal dialog, with respect to
600 /// event delivery.
601 ///
602 /// Global event controllers will not handle events with targets
603 /// inside the widget, unless they are set up to ignore propagation
604 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
605 #[cfg(feature = "v4_18")]
606 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
607 pub fn limit_events(self, limit_events: bool) -> Self {
608 Self {
609 builder: self.builder.property("limit-events", limit_events),
610 }
611 }
612
613 /// Margin on bottom side of widget.
614 ///
615 /// This property adds margin outside of the widget's normal size
616 /// request, the margin will be added in addition to the size from
617 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
618 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
619 Self {
620 builder: self.builder.property("margin-bottom", margin_bottom),
621 }
622 }
623
624 /// Margin on end of widget, horizontally.
625 ///
626 /// This property supports left-to-right and right-to-left text
627 /// directions.
628 ///
629 /// This property adds margin outside of the widget's normal size
630 /// request, the margin will be added in addition to the size from
631 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
632 pub fn margin_end(self, margin_end: i32) -> Self {
633 Self {
634 builder: self.builder.property("margin-end", margin_end),
635 }
636 }
637
638 /// Margin on start of widget, horizontally.
639 ///
640 /// This property supports left-to-right and right-to-left text
641 /// directions.
642 ///
643 /// This property adds margin outside of the widget's normal size
644 /// request, the margin will be added in addition to the size from
645 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
646 pub fn margin_start(self, margin_start: i32) -> Self {
647 Self {
648 builder: self.builder.property("margin-start", margin_start),
649 }
650 }
651
652 /// Margin on top side of widget.
653 ///
654 /// This property adds margin outside of the widget's normal size
655 /// request, the margin will be added in addition to the size from
656 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
657 pub fn margin_top(self, margin_top: i32) -> Self {
658 Self {
659 builder: self.builder.property("margin-top", margin_top),
660 }
661 }
662
663 /// The name of the widget.
664 pub fn name(self, name: impl Into<glib::GString>) -> Self {
665 Self {
666 builder: self.builder.property("name", name.into()),
667 }
668 }
669
670 /// The requested opacity of the widget.
671 pub fn opacity(self, opacity: f64) -> Self {
672 Self {
673 builder: self.builder.property("opacity", opacity),
674 }
675 }
676
677 /// How content outside the widget's content area is treated.
678 ///
679 /// This property is meant to be set by widget implementations,
680 /// typically in their instance init function.
681 pub fn overflow(self, overflow: Overflow) -> Self {
682 Self {
683 builder: self.builder.property("overflow", overflow),
684 }
685 }
686
687 /// Whether the widget will receive the default action when it is focused.
688 pub fn receives_default(self, receives_default: bool) -> Self {
689 Self {
690 builder: self.builder.property("receives-default", receives_default),
691 }
692 }
693
694 /// Whether the widget responds to input.
695 pub fn sensitive(self, sensitive: bool) -> Self {
696 Self {
697 builder: self.builder.property("sensitive", sensitive),
698 }
699 }
700
701 /// Sets the text of tooltip to be the given string, which is marked up
702 /// with Pango markup.
703 ///
704 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
705 ///
706 /// This is a convenience property which will take care of getting the
707 /// tooltip shown if the given string is not `NULL`:
708 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
709 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
710 /// the default signal handler.
711 ///
712 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
713 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
714 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
715 Self {
716 builder: self
717 .builder
718 .property("tooltip-markup", tooltip_markup.into()),
719 }
720 }
721
722 /// Sets the text of tooltip to be the given string.
723 ///
724 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
725 ///
726 /// This is a convenience property which will take care of getting the
727 /// tooltip shown if the given string is not `NULL`:
728 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
729 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
730 /// the default signal handler.
731 ///
732 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
733 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
734 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
735 Self {
736 builder: self.builder.property("tooltip-text", tooltip_text.into()),
737 }
738 }
739
740 /// How to distribute vertical space if widget gets extra space.
741 pub fn valign(self, valign: Align) -> Self {
742 Self {
743 builder: self.builder.property("valign", valign),
744 }
745 }
746
747 /// Whether to expand vertically.
748 pub fn vexpand(self, vexpand: bool) -> Self {
749 Self {
750 builder: self.builder.property("vexpand", vexpand),
751 }
752 }
753
754 /// Whether to use the `vexpand` property.
755 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
756 Self {
757 builder: self.builder.property("vexpand-set", vexpand_set),
758 }
759 }
760
761 /// Whether the widget is visible.
762 pub fn visible(self, visible: bool) -> Self {
763 Self {
764 builder: self.builder.property("visible", visible),
765 }
766 }
767
768 /// Overrides for width request of the widget.
769 ///
770 /// If this is -1, the natural request will be used.
771 pub fn width_request(self, width_request: i32) -> Self {
772 Self {
773 builder: self.builder.property("width-request", width_request),
774 }
775 }
776
777 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
778 ///
779 /// The accessible role cannot be changed once set.
780 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
781 Self {
782 builder: self.builder.property("accessible-role", accessible_role),
783 }
784 }
785
786 /// The orientation of the orientable.
787 pub fn orientation(self, orientation: Orientation) -> Self {
788 Self {
789 builder: self.builder.property("orientation", orientation),
790 }
791 }
792
793 // rustdoc-stripper-ignore-next
794 /// Build the [`StackSwitcher`].
795 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
796 pub fn build(self) -> StackSwitcher {
797 assert_initialized_main_thread!();
798 self.builder.build()
799 }
800}