libadwaita/auto/view_switcher_title.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#![allow(deprecated)]
6
7use crate::{ViewStack, ffi};
8use glib::{
9 prelude::*,
10 signal::{SignalHandlerId, connect_raw},
11 translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16 /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
17 /// A view switcher title.
18 ///
19 /// <picture>
20 /// <source srcset="view-switcher-title-dark.png" media="(prefers-color-scheme: dark)">
21 /// <img src="view-switcher-title.png" alt="view-switcher-title">
22 /// </picture>
23 ///
24 /// A widget letting you switch between multiple views contained by a
25 /// [`ViewStack`][crate::ViewStack] via an [`ViewSwitcher`][crate::ViewSwitcher].
26 ///
27 /// It is designed to be used as the title widget of a [`HeaderBar`][crate::HeaderBar], and
28 /// will display the window's title when the window is too narrow to fit the view
29 /// switcher e.g. on mobile phones, or if there are less than two views.
30 ///
31 /// In order to center the title in narrow windows, the header bar should have
32 /// [`centering-policy`][struct@crate::HeaderBar#centering-policy] set to
33 /// [enum@Adw.CenteringPolicy.strict].
34 ///
35 /// [`ViewSwitcherTitle`][crate::ViewSwitcherTitle] is intended to be used together with
36 /// [`ViewSwitcherBar`][crate::ViewSwitcherBar].
37 ///
38 /// A common use case is to bind the [`reveal`][struct@crate::ViewSwitcherBar#reveal] property
39 /// to [`title-visible`][struct@crate::ViewSwitcherTitle#title-visible] to automatically reveal the
40 /// view switcher bar when the title label is displayed in place of the view
41 /// switcher, as follows:
42 ///
43 /// ```xml
44 /// <object class="AdwWindow">
45 /// <property name="content">
46 /// <object class="AdwToolbarView">
47 /// <child type="top">
48 /// <object class="AdwHeaderBar">
49 /// <property name="centering-policy">strict</property>
50 /// <property name="title-widget">
51 /// <object class="AdwViewSwitcherTitle" id="title">
52 /// <property name="stack">stack</property>
53 /// </object>
54 /// </property>
55 /// </object>
56 /// </child>
57 /// <property name="content">
58 /// <object class="AdwViewStack" id="stack"/>
59 /// </property>
60 /// <child type="bottom">
61 /// <object class="AdwViewSwitcherBar">
62 /// <property name="stack">stack</property>
63 /// <binding name="reveal">
64 /// <lookup name="title-visible">title</lookup>
65 /// </binding>
66 /// </object>
67 /// </child>
68 /// </object>
69 /// </property>
70 /// </object>
71 /// ```
72 ///
73 /// ## CSS nodes
74 ///
75 /// [`ViewSwitcherTitle`][crate::ViewSwitcherTitle] has a single CSS node with name `viewswitchertitle`.
76 ///
77 /// ## Properties
78 ///
79 ///
80 /// #### `stack`
81 /// The stack the view switcher controls.
82 ///
83 /// Readable | Writeable
84 ///
85 ///
86 /// #### `subtitle`
87 /// The subtitle to display.
88 ///
89 /// The subtitle should give the user additional details.
90 ///
91 /// Readable | Writeable
92 ///
93 ///
94 /// #### `title`
95 /// The title to display.
96 ///
97 /// The title typically identifies the current view or content item, and
98 /// generally does not use the application name.
99 ///
100 /// Readable | Writeable
101 ///
102 ///
103 /// #### `title-visible`
104 /// Whether the title is currently visible.
105 ///
106 /// If the title is visible, it means the view switcher is hidden an it may be
107 /// wanted to show an alternative switcher, e.g. a [`ViewSwitcherBar`][crate::ViewSwitcherBar].
108 ///
109 /// Readable
110 ///
111 ///
112 /// #### `view-switcher-enabled`
113 /// Whether the view switcher is enabled.
114 ///
115 /// If it is disabled, the title will be displayed instead. This allows to
116 /// programmatically hide the view switcher even if it fits in the available
117 /// space.
118 ///
119 /// This can be used e.g. to ensure the view switcher is hidden below a certain
120 /// window width, or any other constraint you find suitable.
121 ///
122 /// Readable | Writeable
123 /// <details><summary><h4>Widget</h4></summary>
124 ///
125 ///
126 /// #### `can-focus`
127 /// Whether the widget or any of its descendents can accept
128 /// the input focus.
129 ///
130 /// This property is meant to be set by widget implementations,
131 /// typically in their instance init function.
132 ///
133 /// Readable | Writeable
134 ///
135 ///
136 /// #### `can-target`
137 /// Whether the widget can receive pointer events.
138 ///
139 /// Readable | Writeable
140 ///
141 ///
142 /// #### `css-classes`
143 /// A list of css classes applied to this widget.
144 ///
145 /// Readable | Writeable
146 ///
147 ///
148 /// #### `css-name`
149 /// The name of this widget in the CSS tree.
150 ///
151 /// This property is meant to be set by widget implementations,
152 /// typically in their instance init function.
153 ///
154 /// Readable | Writeable | Construct Only
155 ///
156 ///
157 /// #### `cursor`
158 /// The cursor used by @widget.
159 ///
160 /// Readable | Writeable
161 ///
162 ///
163 /// #### `focus-on-click`
164 /// Whether the widget should grab focus when it is clicked with the mouse.
165 ///
166 /// This property is only relevant for widgets that can take focus.
167 ///
168 /// Readable | Writeable
169 ///
170 ///
171 /// #### `focusable`
172 /// Whether this widget itself will accept the input focus.
173 ///
174 /// Readable | Writeable
175 ///
176 ///
177 /// #### `halign`
178 /// How to distribute horizontal space if widget gets extra space.
179 ///
180 /// Readable | Writeable
181 ///
182 ///
183 /// #### `has-default`
184 /// Whether the widget is the default widget.
185 ///
186 /// Readable
187 ///
188 ///
189 /// #### `has-focus`
190 /// Whether the widget has the input focus.
191 ///
192 /// Readable
193 ///
194 ///
195 /// #### `has-tooltip`
196 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
197 /// signal on @widget.
198 ///
199 /// A true value indicates that @widget can have a tooltip, in this case
200 /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
201 /// determine whether it will provide a tooltip or not.
202 ///
203 /// Readable | Writeable
204 ///
205 ///
206 /// #### `height-request`
207 /// Overrides for height request of the widget.
208 ///
209 /// If this is -1, the natural request will be used.
210 ///
211 /// Readable | Writeable
212 ///
213 ///
214 /// #### `hexpand`
215 /// Whether to expand horizontally.
216 ///
217 /// Readable | Writeable
218 ///
219 ///
220 /// #### `hexpand-set`
221 /// Whether to use the `hexpand` property.
222 ///
223 /// Readable | Writeable
224 ///
225 ///
226 /// #### `layout-manager`
227 /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
228 /// the preferred size of the widget, and allocate its children.
229 ///
230 /// This property is meant to be set by widget implementations,
231 /// typically in their instance init function.
232 ///
233 /// Readable | Writeable
234 ///
235 ///
236 /// #### `limit-events`
237 /// Makes this widget act like a modal dialog, with respect to
238 /// event delivery.
239 ///
240 /// Global event controllers will not handle events with targets
241 /// inside the widget, unless they are set up to ignore propagation
242 /// limits. See `Gtk::EventController::set_propagation_limit()`.
243 ///
244 /// Readable | Writeable
245 ///
246 ///
247 /// #### `margin-bottom`
248 /// Margin on bottom side of widget.
249 ///
250 /// This property adds margin outside of the widget's normal size
251 /// request, the margin will be added in addition to the size from
252 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
253 ///
254 /// Readable | Writeable
255 ///
256 ///
257 /// #### `margin-end`
258 /// Margin on end of widget, horizontally.
259 ///
260 /// This property supports left-to-right and right-to-left text
261 /// directions.
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 /// #### `margin-start`
271 /// Margin on start of widget, horizontally.
272 ///
273 /// This property supports left-to-right and right-to-left text
274 /// directions.
275 ///
276 /// This property adds margin outside of the widget's normal size
277 /// request, the margin will be added in addition to the size from
278 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
279 ///
280 /// Readable | Writeable
281 ///
282 ///
283 /// #### `margin-top`
284 /// Margin on top side of widget.
285 ///
286 /// This property adds margin outside of the widget's normal size
287 /// request, the margin will be added in addition to the size from
288 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
289 ///
290 /// Readable | Writeable
291 ///
292 ///
293 /// #### `name`
294 /// The name of the widget.
295 ///
296 /// Readable | Writeable
297 ///
298 ///
299 /// #### `opacity`
300 /// The requested opacity of the widget.
301 ///
302 /// Readable | Writeable
303 ///
304 ///
305 /// #### `overflow`
306 /// How content outside the widget's content area is treated.
307 ///
308 /// This property is meant to be set by widget implementations,
309 /// typically in their instance init function.
310 ///
311 /// Readable | Writeable
312 ///
313 ///
314 /// #### `parent`
315 /// The parent widget of this widget.
316 ///
317 /// Readable
318 ///
319 ///
320 /// #### `receives-default`
321 /// Whether the widget will receive the default action when it is focused.
322 ///
323 /// Readable | Writeable
324 ///
325 ///
326 /// #### `root`
327 /// The [`gtk::Root`][crate::gtk::Root] widget of the widget tree containing this widget.
328 ///
329 /// This will be `NULL` if the widget is not contained in a root widget.
330 ///
331 /// Readable
332 ///
333 ///
334 /// #### `scale-factor`
335 /// The scale factor of the widget.
336 ///
337 /// Readable
338 ///
339 ///
340 /// #### `sensitive`
341 /// Whether the widget responds to input.
342 ///
343 /// Readable | Writeable
344 ///
345 ///
346 /// #### `tooltip-markup`
347 /// Sets the text of tooltip to be the given string, which is marked up
348 /// with Pango markup.
349 ///
350 /// Also see `Gtk::Tooltip::set_markup()`.
351 ///
352 /// This is a convenience property which will take care of getting the
353 /// tooltip shown if the given string is not `NULL`:
354 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
355 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
356 /// the default signal handler.
357 ///
358 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
359 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
360 ///
361 /// Readable | Writeable
362 ///
363 ///
364 /// #### `tooltip-text`
365 /// Sets the text of tooltip to be the given string.
366 ///
367 /// Also see `Gtk::Tooltip::set_text()`.
368 ///
369 /// This is a convenience property which will take care of getting the
370 /// tooltip shown if the given string is not `NULL`:
371 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
372 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
373 /// the default signal handler.
374 ///
375 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
376 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
377 ///
378 /// Readable | Writeable
379 ///
380 ///
381 /// #### `valign`
382 /// How to distribute vertical space if widget gets extra space.
383 ///
384 /// Readable | Writeable
385 ///
386 ///
387 /// #### `vexpand`
388 /// Whether to expand vertically.
389 ///
390 /// Readable | Writeable
391 ///
392 ///
393 /// #### `vexpand-set`
394 /// Whether to use the `vexpand` property.
395 ///
396 /// Readable | Writeable
397 ///
398 ///
399 /// #### `visible`
400 /// Whether the widget is visible.
401 ///
402 /// Readable | Writeable
403 ///
404 ///
405 /// #### `width-request`
406 /// Overrides for width request of the widget.
407 ///
408 /// If this is -1, the natural request will be used.
409 ///
410 /// Readable | Writeable
411 /// </details>
412 /// <details><summary><h4>Accessible</h4></summary>
413 ///
414 ///
415 /// #### `accessible-role`
416 /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
417 ///
418 /// The accessible role cannot be changed once set.
419 ///
420 /// Readable | Writeable
421 /// </details>
422 ///
423 /// # Implements
424 ///
425 /// [`trait@gtk::prelude::WidgetExt`], [`trait@glib::ObjectExt`], [`trait@gtk::prelude::AccessibleExt`], [`trait@gtk::prelude::BuildableExt`], [`trait@gtk::prelude::ConstraintTargetExt`]
426 #[doc(alias = "AdwViewSwitcherTitle")]
427 pub struct ViewSwitcherTitle(Object<ffi::AdwViewSwitcherTitle, ffi::AdwViewSwitcherTitleClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
428
429 match fn {
430 type_ => || ffi::adw_view_switcher_title_get_type(),
431 }
432}
433
434impl ViewSwitcherTitle {
435 /// Creates a new [`ViewSwitcherTitle`][crate::ViewSwitcherTitle].
436 ///
437 /// # Deprecated since 1.4
438 ///
439 /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
440 ///
441 /// # Returns
442 ///
443 /// the newly created [`ViewSwitcherTitle`][crate::ViewSwitcherTitle]
444 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
445 #[allow(deprecated)]
446 #[doc(alias = "adw_view_switcher_title_new")]
447 pub fn new() -> ViewSwitcherTitle {
448 assert_initialized_main_thread!();
449 unsafe { gtk::Widget::from_glib_none(ffi::adw_view_switcher_title_new()).unsafe_cast() }
450 }
451
452 // rustdoc-stripper-ignore-next
453 /// Creates a new builder-pattern struct instance to construct [`ViewSwitcherTitle`] objects.
454 ///
455 /// This method returns an instance of [`ViewSwitcherTitleBuilder`](crate::builders::ViewSwitcherTitleBuilder) which can be used to create [`ViewSwitcherTitle`] objects.
456 pub fn builder() -> ViewSwitcherTitleBuilder {
457 ViewSwitcherTitleBuilder::new()
458 }
459
460 /// Gets the stack controlled by @self.
461 ///
462 /// # Deprecated since 1.4
463 ///
464 /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
465 ///
466 /// # Returns
467 ///
468 /// the stack
469 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
470 #[allow(deprecated)]
471 #[doc(alias = "adw_view_switcher_title_get_stack")]
472 #[doc(alias = "get_stack")]
473 pub fn stack(&self) -> Option<ViewStack> {
474 unsafe {
475 from_glib_none(ffi::adw_view_switcher_title_get_stack(
476 self.to_glib_none().0,
477 ))
478 }
479 }
480
481 /// Gets the subtitle of @self.
482 ///
483 /// # Deprecated since 1.4
484 ///
485 /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
486 ///
487 /// # Returns
488 ///
489 /// the subtitle
490 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
491 #[allow(deprecated)]
492 #[doc(alias = "adw_view_switcher_title_get_subtitle")]
493 #[doc(alias = "get_subtitle")]
494 pub fn subtitle(&self) -> glib::GString {
495 unsafe {
496 from_glib_none(ffi::adw_view_switcher_title_get_subtitle(
497 self.to_glib_none().0,
498 ))
499 }
500 }
501
502 /// Gets the title of @self.
503 ///
504 /// # Deprecated since 1.4
505 ///
506 /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
507 ///
508 /// # Returns
509 ///
510 /// the title
511 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
512 #[allow(deprecated)]
513 #[doc(alias = "adw_view_switcher_title_get_title")]
514 #[doc(alias = "get_title")]
515 pub fn title(&self) -> glib::GString {
516 unsafe {
517 from_glib_none(ffi::adw_view_switcher_title_get_title(
518 self.to_glib_none().0,
519 ))
520 }
521 }
522
523 /// Gets whether the title of @self is currently visible.
524 ///
525 /// If the title is visible, it means the view switcher is hidden an it may be
526 /// wanted to show an alternative switcher, e.g. a [`ViewSwitcherBar`][crate::ViewSwitcherBar].
527 ///
528 /// # Deprecated since 1.4
529 ///
530 /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
531 ///
532 /// # Returns
533 ///
534 /// whether the title of @self is currently visible
535 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
536 #[allow(deprecated)]
537 #[doc(alias = "adw_view_switcher_title_get_title_visible")]
538 #[doc(alias = "get_title_visible")]
539 #[doc(alias = "title-visible")]
540 pub fn is_title_visible(&self) -> bool {
541 unsafe {
542 from_glib(ffi::adw_view_switcher_title_get_title_visible(
543 self.to_glib_none().0,
544 ))
545 }
546 }
547
548 /// Gets whether @self's view switcher is enabled.
549 ///
550 /// # Deprecated since 1.4
551 ///
552 /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
553 ///
554 /// # Returns
555 ///
556 /// whether the view switcher is enabled
557 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
558 #[allow(deprecated)]
559 #[doc(alias = "adw_view_switcher_title_get_view_switcher_enabled")]
560 #[doc(alias = "get_view_switcher_enabled")]
561 #[doc(alias = "view-switcher-enabled")]
562 pub fn is_view_switcher_enabled(&self) -> bool {
563 unsafe {
564 from_glib(ffi::adw_view_switcher_title_get_view_switcher_enabled(
565 self.to_glib_none().0,
566 ))
567 }
568 }
569
570 /// Sets the stack controlled by @self.
571 ///
572 /// # Deprecated since 1.4
573 ///
574 /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
575 /// ## `stack`
576 /// a stack
577 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
578 #[allow(deprecated)]
579 #[doc(alias = "adw_view_switcher_title_set_stack")]
580 #[doc(alias = "stack")]
581 pub fn set_stack(&self, stack: Option<&ViewStack>) {
582 unsafe {
583 ffi::adw_view_switcher_title_set_stack(self.to_glib_none().0, stack.to_glib_none().0);
584 }
585 }
586
587 /// Sets the subtitle of @self.
588 ///
589 /// The subtitle should give the user additional details.
590 ///
591 /// # Deprecated since 1.4
592 ///
593 /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
594 /// ## `subtitle`
595 /// a subtitle
596 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
597 #[allow(deprecated)]
598 #[doc(alias = "adw_view_switcher_title_set_subtitle")]
599 #[doc(alias = "subtitle")]
600 pub fn set_subtitle(&self, subtitle: &str) {
601 unsafe {
602 ffi::adw_view_switcher_title_set_subtitle(
603 self.to_glib_none().0,
604 subtitle.to_glib_none().0,
605 );
606 }
607 }
608
609 /// Sets the title of @self.
610 ///
611 /// The title typically identifies the current view or content item, and
612 /// generally does not use the application name.
613 ///
614 /// # Deprecated since 1.4
615 ///
616 /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
617 /// ## `title`
618 /// a title
619 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
620 #[allow(deprecated)]
621 #[doc(alias = "adw_view_switcher_title_set_title")]
622 #[doc(alias = "title")]
623 pub fn set_title(&self, title: &str) {
624 unsafe {
625 ffi::adw_view_switcher_title_set_title(self.to_glib_none().0, title.to_glib_none().0);
626 }
627 }
628
629 /// Sets whether @self's view switcher is enabled.
630 ///
631 /// If it is disabled, the title will be displayed instead. This allows to
632 /// programmatically hide the view switcher even if it fits in the available
633 /// space.
634 ///
635 /// This can be used e.g. to ensure the view switcher is hidden below a certain
636 /// window width, or any other constraint you find suitable.
637 ///
638 /// # Deprecated since 1.4
639 ///
640 /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
641 /// ## `enabled`
642 /// whether the view switcher is enabled
643 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
644 #[allow(deprecated)]
645 #[doc(alias = "adw_view_switcher_title_set_view_switcher_enabled")]
646 #[doc(alias = "view-switcher-enabled")]
647 pub fn set_view_switcher_enabled(&self, enabled: bool) {
648 unsafe {
649 ffi::adw_view_switcher_title_set_view_switcher_enabled(
650 self.to_glib_none().0,
651 enabled.into_glib(),
652 );
653 }
654 }
655
656 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
657 #[doc(alias = "stack")]
658 pub fn connect_stack_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
659 unsafe extern "C" fn notify_stack_trampoline<F: Fn(&ViewSwitcherTitle) + 'static>(
660 this: *mut ffi::AdwViewSwitcherTitle,
661 _param_spec: glib::ffi::gpointer,
662 f: glib::ffi::gpointer,
663 ) {
664 unsafe {
665 let f: &F = &*(f as *const F);
666 f(&from_glib_borrow(this))
667 }
668 }
669 unsafe {
670 let f: Box_<F> = Box_::new(f);
671 connect_raw(
672 self.as_ptr() as *mut _,
673 c"notify::stack".as_ptr(),
674 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
675 notify_stack_trampoline::<F> as *const (),
676 )),
677 Box_::into_raw(f),
678 )
679 }
680 }
681
682 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
683 #[doc(alias = "subtitle")]
684 pub fn connect_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
685 unsafe extern "C" fn notify_subtitle_trampoline<F: Fn(&ViewSwitcherTitle) + 'static>(
686 this: *mut ffi::AdwViewSwitcherTitle,
687 _param_spec: glib::ffi::gpointer,
688 f: glib::ffi::gpointer,
689 ) {
690 unsafe {
691 let f: &F = &*(f as *const F);
692 f(&from_glib_borrow(this))
693 }
694 }
695 unsafe {
696 let f: Box_<F> = Box_::new(f);
697 connect_raw(
698 self.as_ptr() as *mut _,
699 c"notify::subtitle".as_ptr(),
700 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
701 notify_subtitle_trampoline::<F> as *const (),
702 )),
703 Box_::into_raw(f),
704 )
705 }
706 }
707
708 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
709 #[doc(alias = "title")]
710 pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
711 unsafe extern "C" fn notify_title_trampoline<F: Fn(&ViewSwitcherTitle) + 'static>(
712 this: *mut ffi::AdwViewSwitcherTitle,
713 _param_spec: glib::ffi::gpointer,
714 f: glib::ffi::gpointer,
715 ) {
716 unsafe {
717 let f: &F = &*(f as *const F);
718 f(&from_glib_borrow(this))
719 }
720 }
721 unsafe {
722 let f: Box_<F> = Box_::new(f);
723 connect_raw(
724 self.as_ptr() as *mut _,
725 c"notify::title".as_ptr(),
726 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
727 notify_title_trampoline::<F> as *const (),
728 )),
729 Box_::into_raw(f),
730 )
731 }
732 }
733
734 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
735 #[doc(alias = "title-visible")]
736 pub fn connect_title_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
737 unsafe extern "C" fn notify_title_visible_trampoline<
738 F: Fn(&ViewSwitcherTitle) + 'static,
739 >(
740 this: *mut ffi::AdwViewSwitcherTitle,
741 _param_spec: glib::ffi::gpointer,
742 f: glib::ffi::gpointer,
743 ) {
744 unsafe {
745 let f: &F = &*(f as *const F);
746 f(&from_glib_borrow(this))
747 }
748 }
749 unsafe {
750 let f: Box_<F> = Box_::new(f);
751 connect_raw(
752 self.as_ptr() as *mut _,
753 c"notify::title-visible".as_ptr(),
754 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
755 notify_title_visible_trampoline::<F> as *const (),
756 )),
757 Box_::into_raw(f),
758 )
759 }
760 }
761
762 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
763 #[doc(alias = "view-switcher-enabled")]
764 pub fn connect_view_switcher_enabled_notify<F: Fn(&Self) + 'static>(
765 &self,
766 f: F,
767 ) -> SignalHandlerId {
768 unsafe extern "C" fn notify_view_switcher_enabled_trampoline<
769 F: Fn(&ViewSwitcherTitle) + 'static,
770 >(
771 this: *mut ffi::AdwViewSwitcherTitle,
772 _param_spec: glib::ffi::gpointer,
773 f: glib::ffi::gpointer,
774 ) {
775 unsafe {
776 let f: &F = &*(f as *const F);
777 f(&from_glib_borrow(this))
778 }
779 }
780 unsafe {
781 let f: Box_<F> = Box_::new(f);
782 connect_raw(
783 self.as_ptr() as *mut _,
784 c"notify::view-switcher-enabled".as_ptr(),
785 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
786 notify_view_switcher_enabled_trampoline::<F> as *const (),
787 )),
788 Box_::into_raw(f),
789 )
790 }
791 }
792}
793
794impl Default for ViewSwitcherTitle {
795 fn default() -> Self {
796 Self::new()
797 }
798}
799
800// rustdoc-stripper-ignore-next
801/// A [builder-pattern] type to construct [`ViewSwitcherTitle`] objects.
802///
803/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
804#[must_use = "The builder must be built to be used"]
805pub struct ViewSwitcherTitleBuilder {
806 builder: glib::object::ObjectBuilder<'static, ViewSwitcherTitle>,
807}
808
809impl ViewSwitcherTitleBuilder {
810 fn new() -> Self {
811 Self {
812 builder: glib::object::Object::builder(),
813 }
814 }
815
816 /// The stack the view switcher controls.
817 /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
818 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
819 pub fn stack(self, stack: &ViewStack) -> Self {
820 Self {
821 builder: self.builder.property("stack", stack.clone()),
822 }
823 }
824
825 /// The subtitle to display.
826 ///
827 /// The subtitle should give the user additional details.
828 /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
829 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
830 pub fn subtitle(self, subtitle: impl Into<glib::GString>) -> Self {
831 Self {
832 builder: self.builder.property("subtitle", subtitle.into()),
833 }
834 }
835
836 /// The title to display.
837 ///
838 /// The title typically identifies the current view or content item, and
839 /// generally does not use the application name.
840 /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
841 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
842 pub fn title(self, title: impl Into<glib::GString>) -> Self {
843 Self {
844 builder: self.builder.property("title", title.into()),
845 }
846 }
847
848 /// Whether the view switcher is enabled.
849 ///
850 /// If it is disabled, the title will be displayed instead. This allows to
851 /// programmatically hide the view switcher even if it fits in the available
852 /// space.
853 ///
854 /// This can be used e.g. to ensure the view switcher is hidden below a certain
855 /// window width, or any other constraint you find suitable.
856 /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
857 #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
858 pub fn view_switcher_enabled(self, view_switcher_enabled: bool) -> Self {
859 Self {
860 builder: self
861 .builder
862 .property("view-switcher-enabled", view_switcher_enabled),
863 }
864 }
865
866 /// Whether the widget or any of its descendents can accept
867 /// the input focus.
868 ///
869 /// This property is meant to be set by widget implementations,
870 /// typically in their instance init function.
871 pub fn can_focus(self, can_focus: bool) -> Self {
872 Self {
873 builder: self.builder.property("can-focus", can_focus),
874 }
875 }
876
877 /// Whether the widget can receive pointer events.
878 pub fn can_target(self, can_target: bool) -> Self {
879 Self {
880 builder: self.builder.property("can-target", can_target),
881 }
882 }
883
884 /// A list of css classes applied to this widget.
885 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
886 Self {
887 builder: self.builder.property("css-classes", css_classes.into()),
888 }
889 }
890
891 /// The name of this widget in the CSS tree.
892 ///
893 /// This property is meant to be set by widget implementations,
894 /// typically in their instance init function.
895 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
896 Self {
897 builder: self.builder.property("css-name", css_name.into()),
898 }
899 }
900
901 /// The cursor used by @widget.
902 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
903 Self {
904 builder: self.builder.property("cursor", cursor.clone()),
905 }
906 }
907
908 /// Whether the widget should grab focus when it is clicked with the mouse.
909 ///
910 /// This property is only relevant for widgets that can take focus.
911 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
912 Self {
913 builder: self.builder.property("focus-on-click", focus_on_click),
914 }
915 }
916
917 /// Whether this widget itself will accept the input focus.
918 pub fn focusable(self, focusable: bool) -> Self {
919 Self {
920 builder: self.builder.property("focusable", focusable),
921 }
922 }
923
924 /// How to distribute horizontal space if widget gets extra space.
925 pub fn halign(self, halign: gtk::Align) -> Self {
926 Self {
927 builder: self.builder.property("halign", halign),
928 }
929 }
930
931 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
932 /// signal on @widget.
933 ///
934 /// A true value indicates that @widget can have a tooltip, in this case
935 /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
936 /// determine whether it will provide a tooltip or not.
937 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
938 Self {
939 builder: self.builder.property("has-tooltip", has_tooltip),
940 }
941 }
942
943 /// Overrides for height request of the widget.
944 ///
945 /// If this is -1, the natural request will be used.
946 pub fn height_request(self, height_request: i32) -> Self {
947 Self {
948 builder: self.builder.property("height-request", height_request),
949 }
950 }
951
952 /// Whether to expand horizontally.
953 pub fn hexpand(self, hexpand: bool) -> Self {
954 Self {
955 builder: self.builder.property("hexpand", hexpand),
956 }
957 }
958
959 /// Whether to use the `hexpand` property.
960 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
961 Self {
962 builder: self.builder.property("hexpand-set", hexpand_set),
963 }
964 }
965
966 /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
967 /// the preferred size of the widget, and allocate its children.
968 ///
969 /// This property is meant to be set by widget implementations,
970 /// typically in their instance init function.
971 pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
972 Self {
973 builder: self
974 .builder
975 .property("layout-manager", layout_manager.clone().upcast()),
976 }
977 }
978
979 /// Makes this widget act like a modal dialog, with respect to
980 /// event delivery.
981 ///
982 /// Global event controllers will not handle events with targets
983 /// inside the widget, unless they are set up to ignore propagation
984 /// limits. See `Gtk::EventController::set_propagation_limit()`.
985 #[cfg(feature = "gtk_v4_18")]
986 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
987 pub fn limit_events(self, limit_events: bool) -> Self {
988 Self {
989 builder: self.builder.property("limit-events", limit_events),
990 }
991 }
992
993 /// Margin on bottom side of widget.
994 ///
995 /// This property adds margin outside of the widget's normal size
996 /// request, the margin will be added in addition to the size from
997 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
998 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
999 Self {
1000 builder: self.builder.property("margin-bottom", margin_bottom),
1001 }
1002 }
1003
1004 /// Margin on end of widget, horizontally.
1005 ///
1006 /// This property supports left-to-right and right-to-left text
1007 /// directions.
1008 ///
1009 /// This property adds margin outside of the widget's normal size
1010 /// request, the margin will be added in addition to the size from
1011 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
1012 pub fn margin_end(self, margin_end: i32) -> Self {
1013 Self {
1014 builder: self.builder.property("margin-end", margin_end),
1015 }
1016 }
1017
1018 /// Margin on start of widget, horizontally.
1019 ///
1020 /// This property supports left-to-right and right-to-left text
1021 /// directions.
1022 ///
1023 /// This property adds margin outside of the widget's normal size
1024 /// request, the margin will be added in addition to the size from
1025 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
1026 pub fn margin_start(self, margin_start: i32) -> Self {
1027 Self {
1028 builder: self.builder.property("margin-start", margin_start),
1029 }
1030 }
1031
1032 /// Margin on top side of widget.
1033 ///
1034 /// This property adds margin outside of the widget's normal size
1035 /// request, the margin will be added in addition to the size from
1036 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
1037 pub fn margin_top(self, margin_top: i32) -> Self {
1038 Self {
1039 builder: self.builder.property("margin-top", margin_top),
1040 }
1041 }
1042
1043 /// The name of the widget.
1044 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1045 Self {
1046 builder: self.builder.property("name", name.into()),
1047 }
1048 }
1049
1050 /// The requested opacity of the widget.
1051 pub fn opacity(self, opacity: f64) -> Self {
1052 Self {
1053 builder: self.builder.property("opacity", opacity),
1054 }
1055 }
1056
1057 /// How content outside the widget's content area is treated.
1058 ///
1059 /// This property is meant to be set by widget implementations,
1060 /// typically in their instance init function.
1061 pub fn overflow(self, overflow: gtk::Overflow) -> Self {
1062 Self {
1063 builder: self.builder.property("overflow", overflow),
1064 }
1065 }
1066
1067 /// Whether the widget will receive the default action when it is focused.
1068 pub fn receives_default(self, receives_default: bool) -> Self {
1069 Self {
1070 builder: self.builder.property("receives-default", receives_default),
1071 }
1072 }
1073
1074 /// Whether the widget responds to input.
1075 pub fn sensitive(self, sensitive: bool) -> Self {
1076 Self {
1077 builder: self.builder.property("sensitive", sensitive),
1078 }
1079 }
1080
1081 /// Sets the text of tooltip to be the given string, which is marked up
1082 /// with Pango markup.
1083 ///
1084 /// Also see `Gtk::Tooltip::set_markup()`.
1085 ///
1086 /// This is a convenience property which will take care of getting the
1087 /// tooltip shown if the given string is not `NULL`:
1088 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
1089 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
1090 /// the default signal handler.
1091 ///
1092 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
1093 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
1094 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1095 Self {
1096 builder: self
1097 .builder
1098 .property("tooltip-markup", tooltip_markup.into()),
1099 }
1100 }
1101
1102 /// Sets the text of tooltip to be the given string.
1103 ///
1104 /// Also see `Gtk::Tooltip::set_text()`.
1105 ///
1106 /// This is a convenience property which will take care of getting the
1107 /// tooltip shown if the given string is not `NULL`:
1108 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
1109 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
1110 /// the default signal handler.
1111 ///
1112 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
1113 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
1114 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1115 Self {
1116 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1117 }
1118 }
1119
1120 /// How to distribute vertical space if widget gets extra space.
1121 pub fn valign(self, valign: gtk::Align) -> Self {
1122 Self {
1123 builder: self.builder.property("valign", valign),
1124 }
1125 }
1126
1127 /// Whether to expand vertically.
1128 pub fn vexpand(self, vexpand: bool) -> Self {
1129 Self {
1130 builder: self.builder.property("vexpand", vexpand),
1131 }
1132 }
1133
1134 /// Whether to use the `vexpand` property.
1135 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1136 Self {
1137 builder: self.builder.property("vexpand-set", vexpand_set),
1138 }
1139 }
1140
1141 /// Whether the widget is visible.
1142 pub fn visible(self, visible: bool) -> Self {
1143 Self {
1144 builder: self.builder.property("visible", visible),
1145 }
1146 }
1147
1148 /// Overrides for width request of the widget.
1149 ///
1150 /// If this is -1, the natural request will be used.
1151 pub fn width_request(self, width_request: i32) -> Self {
1152 Self {
1153 builder: self.builder.property("width-request", width_request),
1154 }
1155 }
1156
1157 /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
1158 ///
1159 /// The accessible role cannot be changed once set.
1160 pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
1161 Self {
1162 builder: self.builder.property("accessible-role", accessible_role),
1163 }
1164 }
1165
1166 // rustdoc-stripper-ignore-next
1167 /// Build the [`ViewSwitcherTitle`].
1168 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1169 pub fn build(self) -> ViewSwitcherTitle {
1170 assert_initialized_main_thread!();
1171 self.builder.build()
1172 }
1173}