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