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