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::{ffi, ViewStack};
8use glib::{
9    prelude::*,
10    signal::{connect_raw, SignalHandlerId},
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    /// `ADW_CENTERING_POLICY_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            let f: &F = &*(f as *const F);
665            f(&from_glib_borrow(this))
666        }
667        unsafe {
668            let f: Box_<F> = Box_::new(f);
669            connect_raw(
670                self.as_ptr() as *mut _,
671                c"notify::stack".as_ptr() as *const _,
672                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
673                    notify_stack_trampoline::<F> as *const (),
674                )),
675                Box_::into_raw(f),
676            )
677        }
678    }
679
680    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
681    #[doc(alias = "subtitle")]
682    pub fn connect_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
683        unsafe extern "C" fn notify_subtitle_trampoline<F: Fn(&ViewSwitcherTitle) + 'static>(
684            this: *mut ffi::AdwViewSwitcherTitle,
685            _param_spec: glib::ffi::gpointer,
686            f: glib::ffi::gpointer,
687        ) {
688            let f: &F = &*(f as *const F);
689            f(&from_glib_borrow(this))
690        }
691        unsafe {
692            let f: Box_<F> = Box_::new(f);
693            connect_raw(
694                self.as_ptr() as *mut _,
695                c"notify::subtitle".as_ptr() as *const _,
696                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
697                    notify_subtitle_trampoline::<F> as *const (),
698                )),
699                Box_::into_raw(f),
700            )
701        }
702    }
703
704    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
705    #[doc(alias = "title")]
706    pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
707        unsafe extern "C" fn notify_title_trampoline<F: Fn(&ViewSwitcherTitle) + 'static>(
708            this: *mut ffi::AdwViewSwitcherTitle,
709            _param_spec: glib::ffi::gpointer,
710            f: glib::ffi::gpointer,
711        ) {
712            let f: &F = &*(f as *const F);
713            f(&from_glib_borrow(this))
714        }
715        unsafe {
716            let f: Box_<F> = Box_::new(f);
717            connect_raw(
718                self.as_ptr() as *mut _,
719                c"notify::title".as_ptr() as *const _,
720                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
721                    notify_title_trampoline::<F> as *const (),
722                )),
723                Box_::into_raw(f),
724            )
725        }
726    }
727
728    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
729    #[doc(alias = "title-visible")]
730    pub fn connect_title_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
731        unsafe extern "C" fn notify_title_visible_trampoline<
732            F: Fn(&ViewSwitcherTitle) + 'static,
733        >(
734            this: *mut ffi::AdwViewSwitcherTitle,
735            _param_spec: glib::ffi::gpointer,
736            f: glib::ffi::gpointer,
737        ) {
738            let f: &F = &*(f as *const F);
739            f(&from_glib_borrow(this))
740        }
741        unsafe {
742            let f: Box_<F> = Box_::new(f);
743            connect_raw(
744                self.as_ptr() as *mut _,
745                c"notify::title-visible".as_ptr() as *const _,
746                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
747                    notify_title_visible_trampoline::<F> as *const (),
748                )),
749                Box_::into_raw(f),
750            )
751        }
752    }
753
754    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
755    #[doc(alias = "view-switcher-enabled")]
756    pub fn connect_view_switcher_enabled_notify<F: Fn(&Self) + 'static>(
757        &self,
758        f: F,
759    ) -> SignalHandlerId {
760        unsafe extern "C" fn notify_view_switcher_enabled_trampoline<
761            F: Fn(&ViewSwitcherTitle) + 'static,
762        >(
763            this: *mut ffi::AdwViewSwitcherTitle,
764            _param_spec: glib::ffi::gpointer,
765            f: glib::ffi::gpointer,
766        ) {
767            let f: &F = &*(f as *const F);
768            f(&from_glib_borrow(this))
769        }
770        unsafe {
771            let f: Box_<F> = Box_::new(f);
772            connect_raw(
773                self.as_ptr() as *mut _,
774                c"notify::view-switcher-enabled".as_ptr() as *const _,
775                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
776                    notify_view_switcher_enabled_trampoline::<F> as *const (),
777                )),
778                Box_::into_raw(f),
779            )
780        }
781    }
782}
783
784impl Default for ViewSwitcherTitle {
785    fn default() -> Self {
786        Self::new()
787    }
788}
789
790// rustdoc-stripper-ignore-next
791/// A [builder-pattern] type to construct [`ViewSwitcherTitle`] objects.
792///
793/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
794#[must_use = "The builder must be built to be used"]
795pub struct ViewSwitcherTitleBuilder {
796    builder: glib::object::ObjectBuilder<'static, ViewSwitcherTitle>,
797}
798
799impl ViewSwitcherTitleBuilder {
800    fn new() -> Self {
801        Self {
802            builder: glib::object::Object::builder(),
803        }
804    }
805
806    /// The stack the view switcher controls.
807    /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
808    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
809    pub fn stack(self, stack: &ViewStack) -> Self {
810        Self {
811            builder: self.builder.property("stack", stack.clone()),
812        }
813    }
814
815    /// The subtitle to display.
816    ///
817    /// The subtitle should give the user additional details.
818    /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
819    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
820    pub fn subtitle(self, subtitle: impl Into<glib::GString>) -> Self {
821        Self {
822            builder: self.builder.property("subtitle", subtitle.into()),
823        }
824    }
825
826    /// The title to display.
827    ///
828    /// The title typically identifies the current view or content item, and
829    /// generally does not use the application name.
830    /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
831    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
832    pub fn title(self, title: impl Into<glib::GString>) -> Self {
833        Self {
834            builder: self.builder.property("title", title.into()),
835        }
836    }
837
838    /// Whether the view switcher is enabled.
839    ///
840    /// If it is disabled, the title will be displayed instead. This allows to
841    /// programmatically hide the view switcher even if it fits in the available
842    /// space.
843    ///
844    /// This can be used e.g. to ensure the view switcher is hidden below a certain
845    /// window width, or any other constraint you find suitable.
846    /// See [the migration guide](migrating-to-breakpoints.html#replace-adwviewswitchertitle)
847    #[cfg_attr(feature = "v1_4", deprecated = "Since 1.4")]
848    pub fn view_switcher_enabled(self, view_switcher_enabled: bool) -> Self {
849        Self {
850            builder: self
851                .builder
852                .property("view-switcher-enabled", view_switcher_enabled),
853        }
854    }
855
856    /// Whether the widget or any of its descendents can accept
857    /// the input focus.
858    ///
859    /// This property is meant to be set by widget implementations,
860    /// typically in their instance init function.
861    pub fn can_focus(self, can_focus: bool) -> Self {
862        Self {
863            builder: self.builder.property("can-focus", can_focus),
864        }
865    }
866
867    /// Whether the widget can receive pointer events.
868    pub fn can_target(self, can_target: bool) -> Self {
869        Self {
870            builder: self.builder.property("can-target", can_target),
871        }
872    }
873
874    /// A list of css classes applied to this widget.
875    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
876        Self {
877            builder: self.builder.property("css-classes", css_classes.into()),
878        }
879    }
880
881    /// The name of this widget in the CSS tree.
882    ///
883    /// This property is meant to be set by widget implementations,
884    /// typically in their instance init function.
885    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
886        Self {
887            builder: self.builder.property("css-name", css_name.into()),
888        }
889    }
890
891    /// The cursor used by @widget.
892    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
893        Self {
894            builder: self.builder.property("cursor", cursor.clone()),
895        }
896    }
897
898    /// Whether the widget should grab focus when it is clicked with the mouse.
899    ///
900    /// This property is only relevant for widgets that can take focus.
901    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
902        Self {
903            builder: self.builder.property("focus-on-click", focus_on_click),
904        }
905    }
906
907    /// Whether this widget itself will accept the input focus.
908    pub fn focusable(self, focusable: bool) -> Self {
909        Self {
910            builder: self.builder.property("focusable", focusable),
911        }
912    }
913
914    /// How to distribute horizontal space if widget gets extra space.
915    pub fn halign(self, halign: gtk::Align) -> Self {
916        Self {
917            builder: self.builder.property("halign", halign),
918        }
919    }
920
921    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
922    /// signal on @widget.
923    ///
924    /// A true value indicates that @widget can have a tooltip, in this case
925    /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
926    /// determine whether it will provide a tooltip or not.
927    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
928        Self {
929            builder: self.builder.property("has-tooltip", has_tooltip),
930        }
931    }
932
933    /// Overrides for height request of the widget.
934    ///
935    /// If this is -1, the natural request will be used.
936    pub fn height_request(self, height_request: i32) -> Self {
937        Self {
938            builder: self.builder.property("height-request", height_request),
939        }
940    }
941
942    /// Whether to expand horizontally.
943    pub fn hexpand(self, hexpand: bool) -> Self {
944        Self {
945            builder: self.builder.property("hexpand", hexpand),
946        }
947    }
948
949    /// Whether to use the `hexpand` property.
950    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
951        Self {
952            builder: self.builder.property("hexpand-set", hexpand_set),
953        }
954    }
955
956    /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
957    /// the preferred size of the widget, and allocate its children.
958    ///
959    /// This property is meant to be set by widget implementations,
960    /// typically in their instance init function.
961    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
962        Self {
963            builder: self
964                .builder
965                .property("layout-manager", layout_manager.clone().upcast()),
966        }
967    }
968
969    /// Makes this widget act like a modal dialog, with respect to
970    /// event delivery.
971    ///
972    /// Global event controllers will not handle events with targets
973    /// inside the widget, unless they are set up to ignore propagation
974    /// limits. See `Gtk::EventController::set_propagation_limit()`.
975    #[cfg(feature = "gtk_v4_18")]
976    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
977    pub fn limit_events(self, limit_events: bool) -> Self {
978        Self {
979            builder: self.builder.property("limit-events", limit_events),
980        }
981    }
982
983    /// Margin on bottom side of widget.
984    ///
985    /// This property adds margin outside of the widget's normal size
986    /// request, the margin will be added in addition to the size from
987    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
988    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
989        Self {
990            builder: self.builder.property("margin-bottom", margin_bottom),
991        }
992    }
993
994    /// Margin on end of widget, horizontally.
995    ///
996    /// This property supports left-to-right and right-to-left text
997    /// directions.
998    ///
999    /// This property adds margin outside of the widget's normal size
1000    /// request, the margin will be added in addition to the size from
1001    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
1002    pub fn margin_end(self, margin_end: i32) -> Self {
1003        Self {
1004            builder: self.builder.property("margin-end", margin_end),
1005        }
1006    }
1007
1008    /// Margin on start of widget, horizontally.
1009    ///
1010    /// This property supports left-to-right and right-to-left text
1011    /// directions.
1012    ///
1013    /// This property adds margin outside of the widget's normal size
1014    /// request, the margin will be added in addition to the size from
1015    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
1016    pub fn margin_start(self, margin_start: i32) -> Self {
1017        Self {
1018            builder: self.builder.property("margin-start", margin_start),
1019        }
1020    }
1021
1022    /// Margin on top side of widget.
1023    ///
1024    /// This property adds margin outside of the widget's normal size
1025    /// request, the margin will be added in addition to the size from
1026    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
1027    pub fn margin_top(self, margin_top: i32) -> Self {
1028        Self {
1029            builder: self.builder.property("margin-top", margin_top),
1030        }
1031    }
1032
1033    /// The name of the widget.
1034    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1035        Self {
1036            builder: self.builder.property("name", name.into()),
1037        }
1038    }
1039
1040    /// The requested opacity of the widget.
1041    pub fn opacity(self, opacity: f64) -> Self {
1042        Self {
1043            builder: self.builder.property("opacity", opacity),
1044        }
1045    }
1046
1047    /// How content outside the widget's content area is treated.
1048    ///
1049    /// This property is meant to be set by widget implementations,
1050    /// typically in their instance init function.
1051    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
1052        Self {
1053            builder: self.builder.property("overflow", overflow),
1054        }
1055    }
1056
1057    /// Whether the widget will receive the default action when it is focused.
1058    pub fn receives_default(self, receives_default: bool) -> Self {
1059        Self {
1060            builder: self.builder.property("receives-default", receives_default),
1061        }
1062    }
1063
1064    /// Whether the widget responds to input.
1065    pub fn sensitive(self, sensitive: bool) -> Self {
1066        Self {
1067            builder: self.builder.property("sensitive", sensitive),
1068        }
1069    }
1070
1071    /// Sets the text of tooltip to be the given string, which is marked up
1072    /// with Pango markup.
1073    ///
1074    /// Also see `Gtk::Tooltip::set_markup()`.
1075    ///
1076    /// This is a convenience property which will take care of getting the
1077    /// tooltip shown if the given string is not `NULL`:
1078    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
1079    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
1080    /// the default signal handler.
1081    ///
1082    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
1083    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
1084    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1085        Self {
1086            builder: self
1087                .builder
1088                .property("tooltip-markup", tooltip_markup.into()),
1089        }
1090    }
1091
1092    /// Sets the text of tooltip to be the given string.
1093    ///
1094    /// Also see `Gtk::Tooltip::set_text()`.
1095    ///
1096    /// This is a convenience property which will take care of getting the
1097    /// tooltip shown if the given string is not `NULL`:
1098    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
1099    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
1100    /// the default signal handler.
1101    ///
1102    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
1103    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
1104    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1105        Self {
1106            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1107        }
1108    }
1109
1110    /// How to distribute vertical space if widget gets extra space.
1111    pub fn valign(self, valign: gtk::Align) -> Self {
1112        Self {
1113            builder: self.builder.property("valign", valign),
1114        }
1115    }
1116
1117    /// Whether to expand vertically.
1118    pub fn vexpand(self, vexpand: bool) -> Self {
1119        Self {
1120            builder: self.builder.property("vexpand", vexpand),
1121        }
1122    }
1123
1124    /// Whether to use the `vexpand` property.
1125    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1126        Self {
1127            builder: self.builder.property("vexpand-set", vexpand_set),
1128        }
1129    }
1130
1131    /// Whether the widget is visible.
1132    pub fn visible(self, visible: bool) -> Self {
1133        Self {
1134            builder: self.builder.property("visible", visible),
1135        }
1136    }
1137
1138    /// Overrides for width request of the widget.
1139    ///
1140    /// If this is -1, the natural request will be used.
1141    pub fn width_request(self, width_request: i32) -> Self {
1142        Self {
1143            builder: self.builder.property("width-request", width_request),
1144        }
1145    }
1146
1147    /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
1148    ///
1149    /// The accessible role cannot be changed once set.
1150    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
1151        Self {
1152            builder: self.builder.property("accessible-role", accessible_role),
1153        }
1154    }
1155
1156    // rustdoc-stripper-ignore-next
1157    /// Build the [`ViewSwitcherTitle`].
1158    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1159    pub fn build(self) -> ViewSwitcherTitle {
1160        assert_initialized_main_thread!();
1161        self.builder.build()
1162    }
1163}