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