Skip to main content

libadwaita/auto/
navigation_view.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::{NavigationPage, Swipeable, ffi};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{SignalHandlerId, connect_raw},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    /// A page-based navigation container.
17    ///
18    /// <picture>
19    ///   <source srcset="navigation-view-dark.png" media="(prefers-color-scheme: dark)">
20    ///   <img src="navigation-view.png" alt="navigation-view">
21    /// </picture>
22    ///
23    /// [`NavigationView`][crate::NavigationView] presents one child at a time, similar to
24    /// [`gtk::Stack`][crate::gtk::Stack].
25    ///
26    /// [`NavigationView`][crate::NavigationView] can only contain [`NavigationPage`][crate::NavigationPage] children.
27    ///
28    /// It maintains a navigation stack that can be controlled with
29    /// [`push()`][Self::push()] and [`pop()`][Self::pop()]. The whole
30    /// navigation stack can also be replaced using [`replace()`][Self::replace()].
31    ///
32    /// [`NavigationView`][crate::NavigationView] allows to manage pages statically or dynamically.
33    ///
34    /// Static pages can be added using the [`add()`][Self::add()] method. The
35    /// [`NavigationView`][crate::NavigationView] will keep a reference to these pages, but they aren't
36    /// accessible to the user until [`push()`][Self::push()] is called (except
37    /// for the first page, which is pushed automatically). Use the
38    /// [`remove()`][Self::remove()] method to remove them. This is useful for
39    /// applications that have a small number of unique pages and just need
40    /// navigation between them.
41    ///
42    /// Dynamic pages are automatically destroyed once they are popped off the
43    /// navigation stack. To add a page like this, push it using the
44    /// [`push()`][Self::push()] method without calling
45    /// [`add()`][Self::add()] first.
46    ///
47    /// ## Tags
48    ///
49    /// Static pages, as well as any pages in the navigation stack, can be accessed
50    /// by their [`tag`][struct@crate::NavigationPage#tag]. For example,
51    /// [`push_by_tag()`][Self::push_by_tag()] can be used to push a static page that's
52    /// not in the navigation stack without having to keep a reference to it manually.
53    ///
54    /// ## Header Bar Integration
55    ///
56    /// When used inside [`NavigationView`][crate::NavigationView], [`HeaderBar`][crate::HeaderBar] will automatically
57    /// display a back button that can be used to go back to the previous page when
58    /// possible. The button also has a context menu, allowing to pop multiple pages
59    /// at once, potentially across multiple navigation views.
60    ///
61    /// Set [`show-back-button`][struct@crate::HeaderBar#show-back-button] to `FALSE` to disable this behavior
62    /// in rare scenarios where it's unwanted.
63    ///
64    /// [`HeaderBar`][crate::HeaderBar] will also display the title of the [`NavigationPage`][crate::NavigationPage] it's
65    /// placed into, so most applications shouldn't need to customize it at all.
66    ///
67    /// ## Shortcuts and Gestures
68    ///
69    /// [`NavigationView`][crate::NavigationView] supports the following shortcuts for going to the
70    /// previous page:
71    ///
72    /// - <kbd>Escape</kbd> (unless [`pop-on-escape`][struct@crate::NavigationView#pop-on-escape] is set to
73    ///   `FALSE`)
74    /// - <kbd>Alt</kbd>+<kbd>←</kbd>
75    /// - Back mouse button
76    ///
77    /// Additionally, it supports interactive gestures:
78    ///
79    /// - One-finger swipe towards the right on touchscreens
80    /// - Scrolling towards the right on touchpads (usually two-finger swipe)
81    ///
82    /// These gestures have transitions enabled regardless of the
83    /// [`animate-transitions`][struct@crate::NavigationView#animate-transitions] value.
84    ///
85    /// Applications can also enable shortcuts for pushing another page onto the
86    /// navigation stack via connecting to the [`get-next-page`][struct@crate::NavigationView#get-next-page]
87    /// signal, in that case the following shortcuts are supported:
88    ///
89    /// - <kbd>Alt</kbd>+<kbd>→</kbd>
90    /// - Forward mouse button
91    /// - Swipe/scrolling towards the left
92    ///
93    /// For right-to-left locales, the gestures and shortcuts are reversed.
94    ///
95    /// [`can-pop`][struct@crate::NavigationPage#can-pop] can be used to disable them, along with the
96    /// header bar back buttons.
97    ///
98    /// ## Actions
99    ///
100    /// [`NavigationView`][crate::NavigationView] defines actions for controlling the navigation stack.
101    /// actions for controlling the navigation stack:
102    ///
103    /// - `navigation.push` takes a string parameter specifying the tag of the page to
104    /// push, and is equivalent to calling [`push_by_tag()`][Self::push_by_tag()].
105    ///
106    /// - `navigation.pop` doesn't take any parameters and pops the current page from
107    /// the navigation stack, equivalent to calling [`pop()`][Self::pop()].
108    ///
109    /// ## [`NavigationView`][crate::NavigationView] as [`gtk::Buildable`][crate::gtk::Buildable]
110    ///
111    /// [`NavigationView`][crate::NavigationView] allows to add pages as children, equivalent to using the
112    /// [`add()`][Self::add()] method.
113    ///
114    /// Example of an [`NavigationView`][crate::NavigationView] UI definition:
115    ///
116    /// ```xml
117    /// <object class="AdwNavigationView">
118    ///   <child>
119    ///     <object class="AdwNavigationPage">
120    ///       <property name="title" translatable="yes">Page 1</property>
121    ///       <property name="child">
122    ///         <object class="AdwToolbarView">
123    ///           <child type="top">
124    ///             <object class="AdwHeaderBar"/>
125    ///           </child>
126    ///           <property name="content">
127    ///             <object class="GtkButton">
128    ///               <property name="label" translatable="yes">Open Page 2</property>
129    ///               <property name="halign">center</property>
130    ///               <property name="valign">center</property>
131    ///               <property name="action-name">navigation.push</property>
132    ///               <property name="action-target">'page-2'</property>
133    ///               <style>
134    ///                 <class name="pill"/>
135    ///                </style>
136    ///             </object>
137    ///           </property>
138    ///         </object>
139    ///       </property>
140    ///     </object>
141    ///   </child>
142    ///   <child>
143    ///     <object class="AdwNavigationPage">
144    ///       <property name="title" translatable="yes">Page 2</property>
145    ///       <property name="tag">page-2</property>
146    ///       <property name="child">
147    ///         <object class="AdwToolbarView">
148    ///           <child type="top">
149    ///             <object class="AdwHeaderBar"/>
150    ///           </child>
151    ///           <property name="content">
152    ///             <!-- ... -->
153    ///           </property>
154    ///         </object>
155    ///       </property>
156    ///     </object>
157    ///   </child>
158    /// </object>
159    /// ```
160    ///
161    /// <picture>
162    ///   <source srcset="navigation-view-example-dark.png" media="(prefers-color-scheme: dark)">
163    ///   <img src="navigation-view-example.png" alt="navigation-view-example">
164    /// </picture>
165    ///
166    /// ## CSS nodes
167    ///
168    /// [`NavigationView`][crate::NavigationView] has a single CSS node with the name `navigation-view`.
169    ///
170    /// ## Accessibility
171    ///
172    /// [`NavigationView`][crate::NavigationView] uses the [enum@Gtk.AccessibleRole.group] role.
173    ///
174    /// ## Properties
175    ///
176    ///
177    /// #### `animate-transitions`
178    ///  Whether to animate page transitions.
179    ///
180    /// Gesture-based transitions are always animated.
181    ///
182    /// Readable | Writeable
183    ///
184    ///
185    /// #### `hhomogeneous`
186    ///  Whether the view is horizontally homogeneous.
187    ///
188    /// If the view is horizontally homogeneous, it allocates the same width for
189    /// all pages.
190    ///
191    /// If it's not, the page may change width when a different page becomes
192    /// visible.
193    ///
194    /// Readable | Writeable
195    ///
196    ///
197    /// #### `navigation-stack`
198    ///  A list model that contains the pages in navigation stack.
199    ///
200    /// The pages are sorted from root page to visible page.
201    ///
202    /// This can be used to keep an up-to-date view.
203    ///
204    /// Readable
205    ///
206    ///
207    /// #### `pop-on-escape`
208    ///  Whether pressing Escape pops the current page.
209    ///
210    /// Applications using [`NavigationView`][crate::NavigationView] to implement a browser may want to
211    /// disable it.
212    ///
213    /// Readable | Writeable
214    ///
215    ///
216    /// #### `vhomogeneous`
217    ///  Whether the view is vertically homogeneous.
218    ///
219    /// If the view is vertically homogeneous, it allocates the same height for
220    /// all pages.
221    ///
222    /// If it's not, the view may change height when a different page becomes
223    /// visible.
224    ///
225    /// Readable | Writeable
226    ///
227    ///
228    /// #### `visible-page`
229    ///  The currently visible page.
230    ///
231    /// Readable
232    ///
233    ///
234    /// #### `visible-page-tag`
235    ///  The tag of the currently visible page.
236    ///
237    /// Readable
238    /// <details><summary><h4>Widget</h4></summary>
239    ///
240    ///
241    /// #### `can-focus`
242    ///  Whether the widget or any of its descendents can accept
243    /// the input focus.
244    ///
245    /// This property is meant to be set by widget implementations,
246    /// typically in their instance init function.
247    ///
248    /// Readable | Writeable
249    ///
250    ///
251    /// #### `can-target`
252    ///  Whether the widget can receive pointer events.
253    ///
254    /// Readable | Writeable
255    ///
256    ///
257    /// #### `css-classes`
258    ///  A list of css classes applied to this widget.
259    ///
260    /// Readable | Writeable
261    ///
262    ///
263    /// #### `css-name`
264    ///  The name of this widget in the CSS tree.
265    ///
266    /// This property is meant to be set by widget implementations,
267    /// typically in their instance init function.
268    ///
269    /// Readable | Writeable | Construct Only
270    ///
271    ///
272    /// #### `cursor`
273    ///  The cursor used by @widget.
274    ///
275    /// Readable | Writeable
276    ///
277    ///
278    /// #### `focus-on-click`
279    ///  Whether the widget should grab focus when it is clicked with the mouse.
280    ///
281    /// This property is only relevant for widgets that can take focus.
282    ///
283    /// Readable | Writeable
284    ///
285    ///
286    /// #### `focusable`
287    ///  Whether this widget itself will accept the input focus.
288    ///
289    /// Readable | Writeable
290    ///
291    ///
292    /// #### `halign`
293    ///  How to distribute horizontal space if widget gets extra space.
294    ///
295    /// Readable | Writeable
296    ///
297    ///
298    /// #### `has-default`
299    ///  Whether the widget is the default widget.
300    ///
301    /// Readable
302    ///
303    ///
304    /// #### `has-focus`
305    ///  Whether the widget has the input focus.
306    ///
307    /// Readable
308    ///
309    ///
310    /// #### `has-tooltip`
311    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
312    /// signal on @widget.
313    ///
314    /// A true value indicates that @widget can have a tooltip, in this case
315    /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
316    /// determine whether it will provide a tooltip or not.
317    ///
318    /// Readable | Writeable
319    ///
320    ///
321    /// #### `height-request`
322    ///  Overrides for height request of the widget.
323    ///
324    /// If this is -1, the natural request will be used.
325    ///
326    /// Readable | Writeable
327    ///
328    ///
329    /// #### `hexpand`
330    ///  Whether to expand horizontally.
331    ///
332    /// Readable | Writeable
333    ///
334    ///
335    /// #### `hexpand-set`
336    ///  Whether to use the `hexpand` property.
337    ///
338    /// Readable | Writeable
339    ///
340    ///
341    /// #### `layout-manager`
342    ///  The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
343    /// the preferred size of the widget, and allocate its children.
344    ///
345    /// This property is meant to be set by widget implementations,
346    /// typically in their instance init function.
347    ///
348    /// Readable | Writeable
349    ///
350    ///
351    /// #### `limit-events`
352    ///  Makes this widget act like a modal dialog, with respect to
353    /// event delivery.
354    ///
355    /// Global event controllers will not handle events with targets
356    /// inside the widget, unless they are set up to ignore propagation
357    /// limits. See `Gtk::EventController::set_propagation_limit()`.
358    ///
359    /// Readable | Writeable
360    ///
361    ///
362    /// #### `margin-bottom`
363    ///  Margin on bottom side of widget.
364    ///
365    /// This property adds margin outside of the widget's normal size
366    /// request, the margin will be added in addition to the size from
367    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
368    ///
369    /// Readable | Writeable
370    ///
371    ///
372    /// #### `margin-end`
373    ///  Margin on end of widget, horizontally.
374    ///
375    /// This property supports left-to-right and right-to-left text
376    /// directions.
377    ///
378    /// This property adds margin outside of the widget's normal size
379    /// request, the margin will be added in addition to the size from
380    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
381    ///
382    /// Readable | Writeable
383    ///
384    ///
385    /// #### `margin-start`
386    ///  Margin on start of widget, horizontally.
387    ///
388    /// This property supports left-to-right and right-to-left text
389    /// directions.
390    ///
391    /// This property adds margin outside of the widget's normal size
392    /// request, the margin will be added in addition to the size from
393    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
394    ///
395    /// Readable | Writeable
396    ///
397    ///
398    /// #### `margin-top`
399    ///  Margin on top side of widget.
400    ///
401    /// This property adds margin outside of the widget's normal size
402    /// request, the margin will be added in addition to the size from
403    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
404    ///
405    /// Readable | Writeable
406    ///
407    ///
408    /// #### `name`
409    ///  The name of the widget.
410    ///
411    /// Readable | Writeable
412    ///
413    ///
414    /// #### `opacity`
415    ///  The requested opacity of the widget.
416    ///
417    /// Readable | Writeable
418    ///
419    ///
420    /// #### `overflow`
421    ///  How content outside the widget's content area is treated.
422    ///
423    /// This property is meant to be set by widget implementations,
424    /// typically in their instance init function.
425    ///
426    /// Readable | Writeable
427    ///
428    ///
429    /// #### `parent`
430    ///  The parent widget of this widget.
431    ///
432    /// Readable
433    ///
434    ///
435    /// #### `receives-default`
436    ///  Whether the widget will receive the default action when it is focused.
437    ///
438    /// Readable | Writeable
439    ///
440    ///
441    /// #### `root`
442    ///  The [`gtk::Root`][crate::gtk::Root] widget of the widget tree containing this widget.
443    ///
444    /// This will be `NULL` if the widget is not contained in a root widget.
445    ///
446    /// Readable
447    ///
448    ///
449    /// #### `scale-factor`
450    ///  The scale factor of the widget.
451    ///
452    /// Readable
453    ///
454    ///
455    /// #### `sensitive`
456    ///  Whether the widget responds to input.
457    ///
458    /// Readable | Writeable
459    ///
460    ///
461    /// #### `tooltip-markup`
462    ///  Sets the text of tooltip to be the given string, which is marked up
463    /// with Pango markup.
464    ///
465    /// Also see `Gtk::Tooltip::set_markup()`.
466    ///
467    /// This is a convenience property which will take care of getting the
468    /// tooltip shown if the given string is not `NULL`:
469    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
470    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
471    /// the default signal handler.
472    ///
473    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
474    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
475    ///
476    /// Readable | Writeable
477    ///
478    ///
479    /// #### `tooltip-text`
480    ///  Sets the text of tooltip to be the given string.
481    ///
482    /// Also see `Gtk::Tooltip::set_text()`.
483    ///
484    /// This is a convenience property which will take care of getting the
485    /// tooltip shown if the given string is not `NULL`:
486    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
487    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
488    /// the default signal handler.
489    ///
490    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
491    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
492    ///
493    /// Readable | Writeable
494    ///
495    ///
496    /// #### `valign`
497    ///  How to distribute vertical space if widget gets extra space.
498    ///
499    /// Readable | Writeable
500    ///
501    ///
502    /// #### `vexpand`
503    ///  Whether to expand vertically.
504    ///
505    /// Readable | Writeable
506    ///
507    ///
508    /// #### `vexpand-set`
509    ///  Whether to use the `vexpand` property.
510    ///
511    /// Readable | Writeable
512    ///
513    ///
514    /// #### `visible`
515    ///  Whether the widget is visible.
516    ///
517    /// Readable | Writeable
518    ///
519    ///
520    /// #### `width-request`
521    ///  Overrides for width request of the widget.
522    ///
523    /// If this is -1, the natural request will be used.
524    ///
525    /// Readable | Writeable
526    /// </details>
527    /// <details><summary><h4>Accessible</h4></summary>
528    ///
529    ///
530    /// #### `accessible-role`
531    ///  The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
532    ///
533    /// The accessible role cannot be changed once set.
534    ///
535    /// Readable | Writeable
536    /// </details>
537    ///
538    /// ## Signals
539    ///
540    ///
541    /// #### `get-next-page`
542    ///  Emitted when a push shortcut or a gesture is triggered.
543    ///
544    /// To support the push shortcuts and gestures, the application is expected to
545    /// return the page to push in the handler.
546    ///
547    /// This signal can be emitted multiple times for the gestures, for example
548    /// when the gesture is cancelled by the user. As such, the application must
549    /// not make any irreversible changes in the handler, such as removing the page
550    /// from a forward stack.
551    ///
552    /// Instead, it should be done in the [`pushed`][struct@crate::NavigationView#pushed] handler.
553    ///
554    ///
555    ///
556    ///
557    /// #### `popped`
558    ///  Emitted after @page has been popped from the navigation stack.
559    ///
560    /// See [`NavigationView::pop()`][crate::NavigationView::pop()].
561    ///
562    /// When using [`NavigationView::pop_to_page()`][crate::NavigationView::pop_to_page()] or
563    /// [`NavigationView::pop_to_tag()`][crate::NavigationView::pop_to_tag()], this signal is emitted for each of the
564    /// popped pages.
565    ///
566    ///
567    ///
568    ///
569    /// #### `pushed`
570    ///  Emitted after a page has been pushed to the navigation stack.
571    ///
572    /// See [`NavigationView::push()`][crate::NavigationView::push()].
573    ///
574    ///
575    ///
576    ///
577    /// #### `replaced`
578    ///  Emitted after the navigation stack has been replaced.
579    ///
580    /// See [`NavigationView::replace()`][crate::NavigationView::replace()].
581    ///
582    ///
583    /// <details><summary><h4>Widget</h4></summary>
584    ///
585    ///
586    /// #### `destroy`
587    ///  Signals that all holders of a reference to the widget should release
588    /// the reference that they hold.
589    ///
590    /// May result in finalization of the widget if all references are released.
591    ///
592    /// This signal is not suitable for saving widget state.
593    ///
594    ///
595    ///
596    ///
597    /// #### `direction-changed`
598    ///  Emitted when the text direction of a widget changes.
599    ///
600    ///
601    ///
602    ///
603    /// #### `hide`
604    ///  Emitted when @widget is hidden.
605    ///
606    ///
607    ///
608    ///
609    /// #### `keynav-failed`
610    ///  Emitted if keyboard navigation fails.
611    ///
612    /// See [`WidgetExtManual::keynav_failed()`][crate::gtk::prelude::WidgetExtManual::keynav_failed()] for details.
613    ///
614    ///
615    ///
616    ///
617    /// #### `map`
618    ///  Emitted when @widget is going to be mapped.
619    ///
620    /// A widget is mapped when the widget is visible (which is controlled with
621    /// [`visible`][struct@crate::gtk::Widget#visible]) and all its parents up to the toplevel widget
622    /// are also visible.
623    ///
624    /// The `::map` signal can be used to determine whether a widget will be drawn,
625    /// for instance it can resume an animation that was stopped during the
626    /// emission of [`unmap`][struct@crate::gtk::Widget#unmap].
627    ///
628    ///
629    ///
630    ///
631    /// #### `mnemonic-activate`
632    ///  Emitted when a widget is activated via a mnemonic.
633    ///
634    /// The default handler for this signal activates @widget if @group_cycling
635    /// is false, or just makes @widget grab focus if @group_cycling is true.
636    ///
637    ///
638    ///
639    ///
640    /// #### `move-focus`
641    ///  Emitted when the focus is moved.
642    ///
643    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
644    ///
645    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
646    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
647    ///
648    /// Action
649    ///
650    ///
651    /// #### `query-tooltip`
652    ///  Emitted when the widget’s tooltip is about to be shown.
653    ///
654    /// This happens when the [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] property
655    /// is true and the hover timeout has expired with the cursor hovering
656    /// above @widget; or emitted when @widget got focus in keyboard mode.
657    ///
658    /// Using the given coordinates, the signal handler should determine
659    /// whether a tooltip should be shown for @widget. If this is the case
660    /// true should be returned, false otherwise. Note that if @keyboard_mode
661    /// is true, the values of @x and @y are undefined and should not be used.
662    ///
663    /// The signal handler is free to manipulate @tooltip with the therefore
664    /// destined function calls.
665    ///
666    ///
667    ///
668    ///
669    /// #### `realize`
670    ///  Emitted when @widget is associated with a `GdkSurface`.
671    ///
672    /// This means that [`WidgetExtManual::realize()`][crate::gtk::prelude::WidgetExtManual::realize()] has been called
673    /// or the widget has been mapped (that is, it is going to be drawn).
674    ///
675    ///
676    ///
677    ///
678    /// #### `show`
679    ///  Emitted when @widget is shown.
680    ///
681    ///
682    ///
683    ///
684    /// #### `state-flags-changed`
685    ///  Emitted when the widget state changes.
686    ///
687    /// See [`WidgetExtManual::state_flags()`][crate::gtk::prelude::WidgetExtManual::state_flags()].
688    ///
689    ///
690    ///
691    ///
692    /// #### `unmap`
693    ///  Emitted when @widget is going to be unmapped.
694    ///
695    /// A widget is unmapped when either it or any of its parents up to the
696    /// toplevel widget have been set as hidden.
697    ///
698    /// As `::unmap` indicates that a widget will not be shown any longer,
699    /// it can be used to, for example, stop an animation on the widget.
700    ///
701    ///
702    ///
703    ///
704    /// #### `unrealize`
705    ///  Emitted when the `GdkSurface` associated with @widget is destroyed.
706    ///
707    /// This means that [`WidgetExtManual::unrealize()`][crate::gtk::prelude::WidgetExtManual::unrealize()] has been called
708    /// or the widget has been unmapped (that is, it is going to be hidden).
709    ///
710    ///
711    /// </details>
712    ///
713    /// # Implements
714    ///
715    /// [`trait@gtk::prelude::WidgetExt`], [`trait@glib::ObjectExt`], [`trait@gtk::prelude::AccessibleExt`], [`trait@gtk::prelude::BuildableExt`], [`trait@gtk::prelude::ConstraintTargetExt`], [`SwipeableExt`][trait@crate::prelude::SwipeableExt]
716    #[doc(alias = "AdwNavigationView")]
717    pub struct NavigationView(Object<ffi::AdwNavigationView, ffi::AdwNavigationViewClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, Swipeable;
718
719    match fn {
720        type_ => || ffi::adw_navigation_view_get_type(),
721    }
722}
723
724impl NavigationView {
725    /// Creates a new [`NavigationView`][crate::NavigationView].
726    ///
727    /// # Returns
728    ///
729    /// the new created [`NavigationView`][crate::NavigationView]
730    #[doc(alias = "adw_navigation_view_new")]
731    pub fn new() -> NavigationView {
732        assert_initialized_main_thread!();
733        unsafe { gtk::Widget::from_glib_none(ffi::adw_navigation_view_new()).unsafe_cast() }
734    }
735
736    // rustdoc-stripper-ignore-next
737    /// Creates a new builder-pattern struct instance to construct [`NavigationView`] objects.
738    ///
739    /// This method returns an instance of [`NavigationViewBuilder`](crate::builders::NavigationViewBuilder) which can be used to create [`NavigationView`] objects.
740    pub fn builder() -> NavigationViewBuilder {
741        NavigationViewBuilder::new()
742    }
743
744    /// Permanently adds @page to @self.
745    ///
746    /// Any page that has been added will stay in @self even after being popped from
747    /// the navigation stack.
748    ///
749    /// Adding a page while no page is visible will automatically push it to the
750    /// navigation stack.
751    ///
752    /// See [`remove()`][Self::remove()].
753    /// ## `page`
754    /// the page to add
755    #[doc(alias = "adw_navigation_view_add")]
756    pub fn add(&self, page: &impl IsA<NavigationPage>) {
757        unsafe {
758            ffi::adw_navigation_view_add(self.to_glib_none().0, page.as_ref().to_glib_none().0);
759        }
760    }
761
762    /// Finds a page in @self by its tag.
763    ///
764    /// See [`tag`][struct@crate::NavigationPage#tag].
765    /// ## `tag`
766    /// a page tag
767    ///
768    /// # Returns
769    ///
770    /// the page with the given tag
771    #[doc(alias = "adw_navigation_view_find_page")]
772    pub fn find_page(&self, tag: &str) -> Option<NavigationPage> {
773        unsafe {
774            from_glib_none(ffi::adw_navigation_view_find_page(
775                self.to_glib_none().0,
776                tag.to_glib_none().0,
777            ))
778        }
779    }
780
781    /// Gets whether @self animates page transitions.
782    ///
783    /// # Returns
784    ///
785    /// whether to animate page transitions
786    #[doc(alias = "adw_navigation_view_get_animate_transitions")]
787    #[doc(alias = "get_animate_transitions")]
788    #[doc(alias = "animate-transitions")]
789    pub fn is_animate_transitions(&self) -> bool {
790        unsafe {
791            from_glib(ffi::adw_navigation_view_get_animate_transitions(
792                self.to_glib_none().0,
793            ))
794        }
795    }
796
797    /// Gets whether @self is horizontally homogeneous.
798    ///
799    /// # Returns
800    ///
801    /// whether @self is horizontally homogeneous
802    #[cfg(feature = "v1_7")]
803    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
804    #[doc(alias = "adw_navigation_view_get_hhomogeneous")]
805    #[doc(alias = "get_hhomogeneous")]
806    #[doc(alias = "hhomogeneous")]
807    pub fn is_hhomogeneous(&self) -> bool {
808        unsafe {
809            from_glib(ffi::adw_navigation_view_get_hhomogeneous(
810                self.to_glib_none().0,
811            ))
812        }
813    }
814
815    /// Returns a [`gio::ListModel`][crate::gio::ListModel] that contains the pages in navigation stack.
816    ///
817    /// The pages are sorted from root page to visible page.
818    ///
819    /// This can be used to keep an up-to-date view.
820    ///
821    /// # Returns
822    ///
823    /// a list model for the navigation stack
824    #[doc(alias = "adw_navigation_view_get_navigation_stack")]
825    #[doc(alias = "get_navigation_stack")]
826    #[doc(alias = "navigation-stack")]
827    pub fn navigation_stack(&self) -> gio::ListModel {
828        unsafe {
829            from_glib_full(ffi::adw_navigation_view_get_navigation_stack(
830                self.to_glib_none().0,
831            ))
832        }
833    }
834
835    /// Gets whether pressing Escape pops the current page on @self.
836    ///
837    /// # Returns
838    ///
839    /// whether to pop the current page
840    #[doc(alias = "adw_navigation_view_get_pop_on_escape")]
841    #[doc(alias = "get_pop_on_escape")]
842    #[doc(alias = "pop-on-escape")]
843    pub fn is_pop_on_escape(&self) -> bool {
844        unsafe {
845            from_glib(ffi::adw_navigation_view_get_pop_on_escape(
846                self.to_glib_none().0,
847            ))
848        }
849    }
850
851    /// Gets the previous page for @page.
852    ///
853    /// If @page is in the navigation stack, returns the page popping @page will
854    /// reveal.
855    ///
856    /// If @page is the root page or is not in the navigation stack, returns `NULL`.
857    /// ## `page`
858    /// a page in @self
859    ///
860    /// # Returns
861    ///
862    /// the previous page
863    #[doc(alias = "adw_navigation_view_get_previous_page")]
864    #[doc(alias = "get_previous_page")]
865    pub fn previous_page(&self, page: &impl IsA<NavigationPage>) -> Option<NavigationPage> {
866        unsafe {
867            from_glib_none(ffi::adw_navigation_view_get_previous_page(
868                self.to_glib_none().0,
869                page.as_ref().to_glib_none().0,
870            ))
871        }
872    }
873
874    /// Gets whether @self is vertically homogeneous.
875    ///
876    /// # Returns
877    ///
878    /// whether @self is vertically homogeneous
879    #[cfg(feature = "v1_7")]
880    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
881    #[doc(alias = "adw_navigation_view_get_vhomogeneous")]
882    #[doc(alias = "get_vhomogeneous")]
883    #[doc(alias = "vhomogeneous")]
884    pub fn is_vhomogeneous(&self) -> bool {
885        unsafe {
886            from_glib(ffi::adw_navigation_view_get_vhomogeneous(
887                self.to_glib_none().0,
888            ))
889        }
890    }
891
892    /// Gets the currently visible page in @self.
893    ///
894    /// # Returns
895    ///
896    /// the currently visible page
897    #[doc(alias = "adw_navigation_view_get_visible_page")]
898    #[doc(alias = "get_visible_page")]
899    #[doc(alias = "visible-page")]
900    pub fn visible_page(&self) -> Option<NavigationPage> {
901        unsafe {
902            from_glib_none(ffi::adw_navigation_view_get_visible_page(
903                self.to_glib_none().0,
904            ))
905        }
906    }
907
908    /// Gets the tag of the currently visible page in @self.
909    ///
910    /// # Returns
911    ///
912    /// the tag of the currently visible page
913    #[cfg(feature = "v1_7")]
914    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
915    #[doc(alias = "adw_navigation_view_get_visible_page_tag")]
916    #[doc(alias = "get_visible_page_tag")]
917    #[doc(alias = "visible-page-tag")]
918    pub fn visible_page_tag(&self) -> Option<glib::GString> {
919        unsafe {
920            from_glib_none(ffi::adw_navigation_view_get_visible_page_tag(
921                self.to_glib_none().0,
922            ))
923        }
924    }
925
926    /// Pops the visible page from the navigation stack.
927    ///
928    /// Does nothing if the navigation stack contains less than two pages.
929    ///
930    /// If [`add()`][Self::add()] hasn't been called, the page is automatically
931    /// removed.
932    ///
933    /// [`popped`][struct@crate::NavigationView#popped] will be emitted for the current visible page.
934    ///
935    /// See [`pop_to_page()`][Self::pop_to_page()] and
936    /// [`pop_to_tag()`][Self::pop_to_tag()].
937    ///
938    /// # Returns
939    ///
940    /// `TRUE` if a page has been popped
941    #[doc(alias = "adw_navigation_view_pop")]
942    pub fn pop(&self) -> bool {
943        unsafe { from_glib(ffi::adw_navigation_view_pop(self.to_glib_none().0)) }
944    }
945
946    /// Pops pages from the navigation stack until @page is visible.
947    ///
948    /// @page must be in the navigation stack.
949    ///
950    /// If [`add()`][Self::add()] hasn't been called for any of the popped pages,
951    /// they are automatically removed.
952    ///
953    /// [`popped`][struct@crate::NavigationView#popped] will be be emitted for each of the popped
954    /// pages.
955    ///
956    /// See [`pop()`][Self::pop()] and [`pop_to_tag()`][Self::pop_to_tag()].
957    /// ## `page`
958    /// the page to pop to
959    ///
960    /// # Returns
961    ///
962    /// `TRUE` if any pages have been popped
963    #[doc(alias = "adw_navigation_view_pop_to_page")]
964    pub fn pop_to_page(&self, page: &impl IsA<NavigationPage>) -> bool {
965        unsafe {
966            from_glib(ffi::adw_navigation_view_pop_to_page(
967                self.to_glib_none().0,
968                page.as_ref().to_glib_none().0,
969            ))
970        }
971    }
972
973    /// Pops pages from the navigation stack until page with the tag @tag is visible.
974    ///
975    /// The page must be in the navigation stack.
976    ///
977    /// If [`add()`][Self::add()] hasn't been called for any of the popped pages,
978    /// they are automatically removed.
979    ///
980    /// [`popped`][struct@crate::NavigationView#popped] will be emitted for each of the popped pages.
981    ///
982    /// See [`pop_to_page()`][Self::pop_to_page()] and [`tag`][struct@crate::NavigationPage#tag].
983    /// ## `tag`
984    /// a page tag
985    ///
986    /// # Returns
987    ///
988    /// `TRUE` if any pages have been popped
989    #[doc(alias = "adw_navigation_view_pop_to_tag")]
990    pub fn pop_to_tag(&self, tag: &str) -> bool {
991        unsafe {
992            from_glib(ffi::adw_navigation_view_pop_to_tag(
993                self.to_glib_none().0,
994                tag.to_glib_none().0,
995            ))
996        }
997    }
998
999    /// Pushes @page onto the navigation stack.
1000    ///
1001    /// If [`add()`][Self::add()] hasn't been called, the page is automatically
1002    /// removed once it's popped.
1003    ///
1004    /// [`pushed`][struct@crate::NavigationView#pushed] will be emitted for @page.
1005    ///
1006    /// See [`push_by_tag()`][Self::push_by_tag()].
1007    /// ## `page`
1008    /// the page to push
1009    #[doc(alias = "adw_navigation_view_push")]
1010    pub fn push(&self, page: &impl IsA<NavigationPage>) {
1011        unsafe {
1012            ffi::adw_navigation_view_push(self.to_glib_none().0, page.as_ref().to_glib_none().0);
1013        }
1014    }
1015
1016    /// Pushes the page with the tag @tag onto the navigation stack.
1017    ///
1018    /// If [`add()`][Self::add()] hasn't been called, the page is automatically
1019    /// removed once it's popped.
1020    ///
1021    /// [`pushed`][struct@crate::NavigationView#pushed] will be emitted for the page.
1022    ///
1023    /// See [`push()`][Self::push()] and [`tag`][struct@crate::NavigationPage#tag].
1024    /// ## `tag`
1025    /// the page tag
1026    #[doc(alias = "adw_navigation_view_push_by_tag")]
1027    pub fn push_by_tag(&self, tag: &str) {
1028        unsafe {
1029            ffi::adw_navigation_view_push_by_tag(self.to_glib_none().0, tag.to_glib_none().0);
1030        }
1031    }
1032
1033    /// Removes @page from @self.
1034    ///
1035    /// If @page is currently in the navigation stack, it will be removed once it's
1036    /// popped. Otherwise, it's removed immediately.
1037    ///
1038    /// See [`add()`][Self::add()].
1039    /// ## `page`
1040    /// the page to remove
1041    #[doc(alias = "adw_navigation_view_remove")]
1042    pub fn remove(&self, page: &impl IsA<NavigationPage>) {
1043        unsafe {
1044            ffi::adw_navigation_view_remove(self.to_glib_none().0, page.as_ref().to_glib_none().0);
1045        }
1046    }
1047
1048    /// Replaces the current navigation stack with @pages.
1049    ///
1050    /// The last page becomes the visible page.
1051    ///
1052    /// Replacing the navigation stack has no animation.
1053    ///
1054    /// If [`add()`][Self::add()] hasn't been called for any pages that are no
1055    /// longer in the navigation stack, they are automatically removed.
1056    ///
1057    /// @n_pages can be 0, in that case no page will be visible after calling this
1058    /// method. This can be useful for removing all pages from @self.
1059    ///
1060    /// The [`replaced`][struct@crate::NavigationView#replaced] signal will be emitted.
1061    ///
1062    /// See [`replace_with_tags()`][Self::replace_with_tags()].
1063    /// ## `pages`
1064    /// the new navigation stack
1065    #[doc(alias = "adw_navigation_view_replace")]
1066    pub fn replace(&self, pages: &[NavigationPage]) {
1067        let n_pages = pages.len() as _;
1068        unsafe {
1069            ffi::adw_navigation_view_replace(
1070                self.to_glib_none().0,
1071                pages.to_glib_none().0,
1072                n_pages,
1073            );
1074        }
1075    }
1076
1077    /// Replaces the current navigation stack with pages with the tags @tags.
1078    ///
1079    /// The last page becomes the visible page.
1080    ///
1081    /// Replacing the navigation stack has no animation.
1082    ///
1083    /// If [`add()`][Self::add()] hasn't been called for any pages that are no
1084    /// longer in the navigation stack, they are automatically removed.
1085    ///
1086    /// @n_tags can be 0, in that case no page will be visible after calling this
1087    /// method. This can be useful for removing all pages from @self.
1088    ///
1089    /// The [`replaced`][struct@crate::NavigationView#replaced] signal will be emitted.
1090    ///
1091    /// See [`replace()`][Self::replace()] and [`tag`][struct@crate::NavigationPage#tag].
1092    /// ## `tags`
1093    /// tags of the pages in the
1094    ///   navigation stack
1095    #[doc(alias = "adw_navigation_view_replace_with_tags")]
1096    pub fn replace_with_tags(&self, tags: &[&str]) {
1097        let n_tags = tags.len() as _;
1098        unsafe {
1099            ffi::adw_navigation_view_replace_with_tags(
1100                self.to_glib_none().0,
1101                tags.to_glib_none().0,
1102                n_tags,
1103            );
1104        }
1105    }
1106
1107    /// Sets whether @self should animate page transitions.
1108    ///
1109    /// Gesture-based transitions are always animated.
1110    /// ## `animate_transitions`
1111    /// whether to animate page transitions
1112    #[doc(alias = "adw_navigation_view_set_animate_transitions")]
1113    #[doc(alias = "animate-transitions")]
1114    pub fn set_animate_transitions(&self, animate_transitions: bool) {
1115        unsafe {
1116            ffi::adw_navigation_view_set_animate_transitions(
1117                self.to_glib_none().0,
1118                animate_transitions.into_glib(),
1119            );
1120        }
1121    }
1122
1123    /// Sets @self to be horizontally homogeneous or not.
1124    ///
1125    /// If the view is horizontally homogeneous, it allocates the same width for
1126    /// all pages.
1127    ///
1128    /// If it's not, the view may change width when a different page becomes visible.
1129    /// ## `hhomogeneous`
1130    /// whether to make @self horizontally homogeneous
1131    #[cfg(feature = "v1_7")]
1132    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
1133    #[doc(alias = "adw_navigation_view_set_hhomogeneous")]
1134    #[doc(alias = "hhomogeneous")]
1135    pub fn set_hhomogeneous(&self, hhomogeneous: bool) {
1136        unsafe {
1137            ffi::adw_navigation_view_set_hhomogeneous(
1138                self.to_glib_none().0,
1139                hhomogeneous.into_glib(),
1140            );
1141        }
1142    }
1143
1144    /// Sets whether pressing Escape pops the current page on @self.
1145    ///
1146    /// Applications using [`NavigationView`][crate::NavigationView] to implement a browser may want to
1147    /// disable it.
1148    /// ## `pop_on_escape`
1149    /// whether to pop the current page when pressing Escape
1150    #[doc(alias = "adw_navigation_view_set_pop_on_escape")]
1151    #[doc(alias = "pop-on-escape")]
1152    pub fn set_pop_on_escape(&self, pop_on_escape: bool) {
1153        unsafe {
1154            ffi::adw_navigation_view_set_pop_on_escape(
1155                self.to_glib_none().0,
1156                pop_on_escape.into_glib(),
1157            );
1158        }
1159    }
1160
1161    /// Sets @self to be vertically homogeneous or not.
1162    ///
1163    /// If the view is vertically homogeneous, it allocates the same height for
1164    /// all pages.
1165    ///
1166    /// If it's not, the view may change height when a different page becomes
1167    /// visible.
1168    /// ## `vhomogeneous`
1169    /// whether to make @self vertically homogeneous
1170    #[cfg(feature = "v1_7")]
1171    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
1172    #[doc(alias = "adw_navigation_view_set_vhomogeneous")]
1173    #[doc(alias = "vhomogeneous")]
1174    pub fn set_vhomogeneous(&self, vhomogeneous: bool) {
1175        unsafe {
1176            ffi::adw_navigation_view_set_vhomogeneous(
1177                self.to_glib_none().0,
1178                vhomogeneous.into_glib(),
1179            );
1180        }
1181    }
1182
1183    /// Emitted when a push shortcut or a gesture is triggered.
1184    ///
1185    /// To support the push shortcuts and gestures, the application is expected to
1186    /// return the page to push in the handler.
1187    ///
1188    /// This signal can be emitted multiple times for the gestures, for example
1189    /// when the gesture is cancelled by the user. As such, the application must
1190    /// not make any irreversible changes in the handler, such as removing the page
1191    /// from a forward stack.
1192    ///
1193    /// Instead, it should be done in the [`pushed`][struct@crate::NavigationView#pushed] handler.
1194    ///
1195    /// # Returns
1196    ///
1197    /// the page to push
1198    #[cfg(feature = "v1_4")]
1199    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
1200    #[doc(alias = "get-next-page")]
1201    pub fn connect_get_next_page<F: Fn(&Self) -> Option<NavigationPage> + 'static>(
1202        &self,
1203        f: F,
1204    ) -> SignalHandlerId {
1205        unsafe extern "C" fn get_next_page_trampoline<
1206            F: Fn(&NavigationView) -> Option<NavigationPage> + 'static,
1207        >(
1208            this: *mut ffi::AdwNavigationView,
1209            f: glib::ffi::gpointer,
1210        ) -> *mut ffi::AdwNavigationPage {
1211            unsafe {
1212                let f: &F = &*(f as *const F);
1213                f(&from_glib_borrow(this)).to_glib_full()
1214            }
1215        }
1216        unsafe {
1217            let f: Box_<F> = Box_::new(f);
1218            connect_raw(
1219                self.as_ptr() as *mut _,
1220                c"get-next-page".as_ptr(),
1221                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1222                    get_next_page_trampoline::<F> as *const (),
1223                )),
1224                Box_::into_raw(f),
1225            )
1226        }
1227    }
1228
1229    /// Emitted after @page has been popped from the navigation stack.
1230    ///
1231    /// See [`pop()`][Self::pop()].
1232    ///
1233    /// When using [`pop_to_page()`][Self::pop_to_page()] or
1234    /// [`pop_to_tag()`][Self::pop_to_tag()], this signal is emitted for each of the
1235    /// popped pages.
1236    /// ## `page`
1237    /// the popped page
1238    #[cfg(feature = "v1_4")]
1239    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
1240    #[doc(alias = "popped")]
1241    pub fn connect_popped<F: Fn(&Self, &NavigationPage) + 'static>(&self, f: F) -> SignalHandlerId {
1242        unsafe extern "C" fn popped_trampoline<
1243            F: Fn(&NavigationView, &NavigationPage) + 'static,
1244        >(
1245            this: *mut ffi::AdwNavigationView,
1246            page: *mut ffi::AdwNavigationPage,
1247            f: glib::ffi::gpointer,
1248        ) {
1249            unsafe {
1250                let f: &F = &*(f as *const F);
1251                f(&from_glib_borrow(this), &from_glib_borrow(page))
1252            }
1253        }
1254        unsafe {
1255            let f: Box_<F> = Box_::new(f);
1256            connect_raw(
1257                self.as_ptr() as *mut _,
1258                c"popped".as_ptr(),
1259                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1260                    popped_trampoline::<F> as *const (),
1261                )),
1262                Box_::into_raw(f),
1263            )
1264        }
1265    }
1266
1267    /// Emitted after a page has been pushed to the navigation stack.
1268    ///
1269    /// See [`push()`][Self::push()].
1270    #[cfg(feature = "v1_4")]
1271    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
1272    #[doc(alias = "pushed")]
1273    pub fn connect_pushed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1274        unsafe extern "C" fn pushed_trampoline<F: Fn(&NavigationView) + 'static>(
1275            this: *mut ffi::AdwNavigationView,
1276            f: glib::ffi::gpointer,
1277        ) {
1278            unsafe {
1279                let f: &F = &*(f as *const F);
1280                f(&from_glib_borrow(this))
1281            }
1282        }
1283        unsafe {
1284            let f: Box_<F> = Box_::new(f);
1285            connect_raw(
1286                self.as_ptr() as *mut _,
1287                c"pushed".as_ptr(),
1288                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1289                    pushed_trampoline::<F> as *const (),
1290                )),
1291                Box_::into_raw(f),
1292            )
1293        }
1294    }
1295
1296    /// Emitted after the navigation stack has been replaced.
1297    ///
1298    /// See [`replace()`][Self::replace()].
1299    #[cfg(feature = "v1_4")]
1300    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
1301    #[doc(alias = "replaced")]
1302    pub fn connect_replaced<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1303        unsafe extern "C" fn replaced_trampoline<F: Fn(&NavigationView) + 'static>(
1304            this: *mut ffi::AdwNavigationView,
1305            f: glib::ffi::gpointer,
1306        ) {
1307            unsafe {
1308                let f: &F = &*(f as *const F);
1309                f(&from_glib_borrow(this))
1310            }
1311        }
1312        unsafe {
1313            let f: Box_<F> = Box_::new(f);
1314            connect_raw(
1315                self.as_ptr() as *mut _,
1316                c"replaced".as_ptr(),
1317                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1318                    replaced_trampoline::<F> as *const (),
1319                )),
1320                Box_::into_raw(f),
1321            )
1322        }
1323    }
1324
1325    #[cfg(feature = "v1_4")]
1326    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
1327    #[doc(alias = "animate-transitions")]
1328    pub fn connect_animate_transitions_notify<F: Fn(&Self) + 'static>(
1329        &self,
1330        f: F,
1331    ) -> SignalHandlerId {
1332        unsafe extern "C" fn notify_animate_transitions_trampoline<
1333            F: Fn(&NavigationView) + 'static,
1334        >(
1335            this: *mut ffi::AdwNavigationView,
1336            _param_spec: glib::ffi::gpointer,
1337            f: glib::ffi::gpointer,
1338        ) {
1339            unsafe {
1340                let f: &F = &*(f as *const F);
1341                f(&from_glib_borrow(this))
1342            }
1343        }
1344        unsafe {
1345            let f: Box_<F> = Box_::new(f);
1346            connect_raw(
1347                self.as_ptr() as *mut _,
1348                c"notify::animate-transitions".as_ptr(),
1349                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1350                    notify_animate_transitions_trampoline::<F> as *const (),
1351                )),
1352                Box_::into_raw(f),
1353            )
1354        }
1355    }
1356
1357    #[cfg(feature = "v1_7")]
1358    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
1359    #[doc(alias = "hhomogeneous")]
1360    pub fn connect_hhomogeneous_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1361        unsafe extern "C" fn notify_hhomogeneous_trampoline<F: Fn(&NavigationView) + 'static>(
1362            this: *mut ffi::AdwNavigationView,
1363            _param_spec: glib::ffi::gpointer,
1364            f: glib::ffi::gpointer,
1365        ) {
1366            unsafe {
1367                let f: &F = &*(f as *const F);
1368                f(&from_glib_borrow(this))
1369            }
1370        }
1371        unsafe {
1372            let f: Box_<F> = Box_::new(f);
1373            connect_raw(
1374                self.as_ptr() as *mut _,
1375                c"notify::hhomogeneous".as_ptr(),
1376                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1377                    notify_hhomogeneous_trampoline::<F> as *const (),
1378                )),
1379                Box_::into_raw(f),
1380            )
1381        }
1382    }
1383
1384    #[cfg(feature = "v1_4")]
1385    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
1386    #[doc(alias = "navigation-stack")]
1387    pub fn connect_navigation_stack_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1388        unsafe extern "C" fn notify_navigation_stack_trampoline<
1389            F: Fn(&NavigationView) + 'static,
1390        >(
1391            this: *mut ffi::AdwNavigationView,
1392            _param_spec: glib::ffi::gpointer,
1393            f: glib::ffi::gpointer,
1394        ) {
1395            unsafe {
1396                let f: &F = &*(f as *const F);
1397                f(&from_glib_borrow(this))
1398            }
1399        }
1400        unsafe {
1401            let f: Box_<F> = Box_::new(f);
1402            connect_raw(
1403                self.as_ptr() as *mut _,
1404                c"notify::navigation-stack".as_ptr(),
1405                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1406                    notify_navigation_stack_trampoline::<F> as *const (),
1407                )),
1408                Box_::into_raw(f),
1409            )
1410        }
1411    }
1412
1413    #[cfg(feature = "v1_4")]
1414    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
1415    #[doc(alias = "pop-on-escape")]
1416    pub fn connect_pop_on_escape_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1417        unsafe extern "C" fn notify_pop_on_escape_trampoline<F: Fn(&NavigationView) + 'static>(
1418            this: *mut ffi::AdwNavigationView,
1419            _param_spec: glib::ffi::gpointer,
1420            f: glib::ffi::gpointer,
1421        ) {
1422            unsafe {
1423                let f: &F = &*(f as *const F);
1424                f(&from_glib_borrow(this))
1425            }
1426        }
1427        unsafe {
1428            let f: Box_<F> = Box_::new(f);
1429            connect_raw(
1430                self.as_ptr() as *mut _,
1431                c"notify::pop-on-escape".as_ptr(),
1432                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1433                    notify_pop_on_escape_trampoline::<F> as *const (),
1434                )),
1435                Box_::into_raw(f),
1436            )
1437        }
1438    }
1439
1440    #[cfg(feature = "v1_7")]
1441    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
1442    #[doc(alias = "vhomogeneous")]
1443    pub fn connect_vhomogeneous_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1444        unsafe extern "C" fn notify_vhomogeneous_trampoline<F: Fn(&NavigationView) + 'static>(
1445            this: *mut ffi::AdwNavigationView,
1446            _param_spec: glib::ffi::gpointer,
1447            f: glib::ffi::gpointer,
1448        ) {
1449            unsafe {
1450                let f: &F = &*(f as *const F);
1451                f(&from_glib_borrow(this))
1452            }
1453        }
1454        unsafe {
1455            let f: Box_<F> = Box_::new(f);
1456            connect_raw(
1457                self.as_ptr() as *mut _,
1458                c"notify::vhomogeneous".as_ptr(),
1459                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1460                    notify_vhomogeneous_trampoline::<F> as *const (),
1461                )),
1462                Box_::into_raw(f),
1463            )
1464        }
1465    }
1466
1467    #[cfg(feature = "v1_4")]
1468    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
1469    #[doc(alias = "visible-page")]
1470    pub fn connect_visible_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1471        unsafe extern "C" fn notify_visible_page_trampoline<F: Fn(&NavigationView) + 'static>(
1472            this: *mut ffi::AdwNavigationView,
1473            _param_spec: glib::ffi::gpointer,
1474            f: glib::ffi::gpointer,
1475        ) {
1476            unsafe {
1477                let f: &F = &*(f as *const F);
1478                f(&from_glib_borrow(this))
1479            }
1480        }
1481        unsafe {
1482            let f: Box_<F> = Box_::new(f);
1483            connect_raw(
1484                self.as_ptr() as *mut _,
1485                c"notify::visible-page".as_ptr(),
1486                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1487                    notify_visible_page_trampoline::<F> as *const (),
1488                )),
1489                Box_::into_raw(f),
1490            )
1491        }
1492    }
1493
1494    #[cfg(feature = "v1_7")]
1495    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
1496    #[doc(alias = "visible-page-tag")]
1497    pub fn connect_visible_page_tag_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1498        unsafe extern "C" fn notify_visible_page_tag_trampoline<
1499            F: Fn(&NavigationView) + 'static,
1500        >(
1501            this: *mut ffi::AdwNavigationView,
1502            _param_spec: glib::ffi::gpointer,
1503            f: glib::ffi::gpointer,
1504        ) {
1505            unsafe {
1506                let f: &F = &*(f as *const F);
1507                f(&from_glib_borrow(this))
1508            }
1509        }
1510        unsafe {
1511            let f: Box_<F> = Box_::new(f);
1512            connect_raw(
1513                self.as_ptr() as *mut _,
1514                c"notify::visible-page-tag".as_ptr(),
1515                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1516                    notify_visible_page_tag_trampoline::<F> as *const (),
1517                )),
1518                Box_::into_raw(f),
1519            )
1520        }
1521    }
1522}
1523
1524#[cfg(feature = "v1_4")]
1525#[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
1526impl Default for NavigationView {
1527    fn default() -> Self {
1528        Self::new()
1529    }
1530}
1531
1532// rustdoc-stripper-ignore-next
1533/// A [builder-pattern] type to construct [`NavigationView`] objects.
1534///
1535/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1536#[must_use = "The builder must be built to be used"]
1537pub struct NavigationViewBuilder {
1538    builder: glib::object::ObjectBuilder<'static, NavigationView>,
1539}
1540
1541impl NavigationViewBuilder {
1542    fn new() -> Self {
1543        Self {
1544            builder: glib::object::Object::builder(),
1545        }
1546    }
1547
1548    /// Whether to animate page transitions.
1549    ///
1550    /// Gesture-based transitions are always animated.
1551    #[cfg(feature = "v1_4")]
1552    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
1553    pub fn animate_transitions(self, animate_transitions: bool) -> Self {
1554        Self {
1555            builder: self
1556                .builder
1557                .property("animate-transitions", animate_transitions),
1558        }
1559    }
1560
1561    /// Whether the view is horizontally homogeneous.
1562    ///
1563    /// If the view is horizontally homogeneous, it allocates the same width for
1564    /// all pages.
1565    ///
1566    /// If it's not, the page may change width when a different page becomes
1567    /// visible.
1568    #[cfg(feature = "v1_7")]
1569    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
1570    pub fn hhomogeneous(self, hhomogeneous: bool) -> Self {
1571        Self {
1572            builder: self.builder.property("hhomogeneous", hhomogeneous),
1573        }
1574    }
1575
1576    /// Whether pressing Escape pops the current page.
1577    ///
1578    /// Applications using [`NavigationView`][crate::NavigationView] to implement a browser may want to
1579    /// disable it.
1580    #[cfg(feature = "v1_4")]
1581    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
1582    pub fn pop_on_escape(self, pop_on_escape: bool) -> Self {
1583        Self {
1584            builder: self.builder.property("pop-on-escape", pop_on_escape),
1585        }
1586    }
1587
1588    /// Whether the view is vertically homogeneous.
1589    ///
1590    /// If the view is vertically homogeneous, it allocates the same height for
1591    /// all pages.
1592    ///
1593    /// If it's not, the view may change height when a different page becomes
1594    /// visible.
1595    #[cfg(feature = "v1_7")]
1596    #[cfg_attr(docsrs, doc(cfg(feature = "v1_7")))]
1597    pub fn vhomogeneous(self, vhomogeneous: bool) -> Self {
1598        Self {
1599            builder: self.builder.property("vhomogeneous", vhomogeneous),
1600        }
1601    }
1602
1603    /// Whether the widget or any of its descendents can accept
1604    /// the input focus.
1605    ///
1606    /// This property is meant to be set by widget implementations,
1607    /// typically in their instance init function.
1608    pub fn can_focus(self, can_focus: bool) -> Self {
1609        Self {
1610            builder: self.builder.property("can-focus", can_focus),
1611        }
1612    }
1613
1614    /// Whether the widget can receive pointer events.
1615    pub fn can_target(self, can_target: bool) -> Self {
1616        Self {
1617            builder: self.builder.property("can-target", can_target),
1618        }
1619    }
1620
1621    /// A list of css classes applied to this widget.
1622    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1623        Self {
1624            builder: self.builder.property("css-classes", css_classes.into()),
1625        }
1626    }
1627
1628    /// The name of this widget in the CSS tree.
1629    ///
1630    /// This property is meant to be set by widget implementations,
1631    /// typically in their instance init function.
1632    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1633        Self {
1634            builder: self.builder.property("css-name", css_name.into()),
1635        }
1636    }
1637
1638    /// The cursor used by @widget.
1639    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1640        Self {
1641            builder: self.builder.property("cursor", cursor.clone()),
1642        }
1643    }
1644
1645    /// Whether the widget should grab focus when it is clicked with the mouse.
1646    ///
1647    /// This property is only relevant for widgets that can take focus.
1648    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1649        Self {
1650            builder: self.builder.property("focus-on-click", focus_on_click),
1651        }
1652    }
1653
1654    /// Whether this widget itself will accept the input focus.
1655    pub fn focusable(self, focusable: bool) -> Self {
1656        Self {
1657            builder: self.builder.property("focusable", focusable),
1658        }
1659    }
1660
1661    /// How to distribute horizontal space if widget gets extra space.
1662    pub fn halign(self, halign: gtk::Align) -> Self {
1663        Self {
1664            builder: self.builder.property("halign", halign),
1665        }
1666    }
1667
1668    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
1669    /// signal on @widget.
1670    ///
1671    /// A true value indicates that @widget can have a tooltip, in this case
1672    /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
1673    /// determine whether it will provide a tooltip or not.
1674    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1675        Self {
1676            builder: self.builder.property("has-tooltip", has_tooltip),
1677        }
1678    }
1679
1680    /// Overrides for height request of the widget.
1681    ///
1682    /// If this is -1, the natural request will be used.
1683    pub fn height_request(self, height_request: i32) -> Self {
1684        Self {
1685            builder: self.builder.property("height-request", height_request),
1686        }
1687    }
1688
1689    /// Whether to expand horizontally.
1690    pub fn hexpand(self, hexpand: bool) -> Self {
1691        Self {
1692            builder: self.builder.property("hexpand", hexpand),
1693        }
1694    }
1695
1696    /// Whether to use the `hexpand` property.
1697    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1698        Self {
1699            builder: self.builder.property("hexpand-set", hexpand_set),
1700        }
1701    }
1702
1703    /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
1704    /// the preferred size of the widget, and allocate its children.
1705    ///
1706    /// This property is meant to be set by widget implementations,
1707    /// typically in their instance init function.
1708    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
1709        Self {
1710            builder: self
1711                .builder
1712                .property("layout-manager", layout_manager.clone().upcast()),
1713        }
1714    }
1715
1716    /// Makes this widget act like a modal dialog, with respect to
1717    /// event delivery.
1718    ///
1719    /// Global event controllers will not handle events with targets
1720    /// inside the widget, unless they are set up to ignore propagation
1721    /// limits. See `Gtk::EventController::set_propagation_limit()`.
1722    #[cfg(feature = "gtk_v4_18")]
1723    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
1724    pub fn limit_events(self, limit_events: bool) -> Self {
1725        Self {
1726            builder: self.builder.property("limit-events", limit_events),
1727        }
1728    }
1729
1730    /// Margin on bottom side of widget.
1731    ///
1732    /// This property adds margin outside of the widget's normal size
1733    /// request, the margin will be added in addition to the size from
1734    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
1735    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1736        Self {
1737            builder: self.builder.property("margin-bottom", margin_bottom),
1738        }
1739    }
1740
1741    /// Margin on end of widget, horizontally.
1742    ///
1743    /// This property supports left-to-right and right-to-left text
1744    /// directions.
1745    ///
1746    /// This property adds margin outside of the widget's normal size
1747    /// request, the margin will be added in addition to the size from
1748    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
1749    pub fn margin_end(self, margin_end: i32) -> Self {
1750        Self {
1751            builder: self.builder.property("margin-end", margin_end),
1752        }
1753    }
1754
1755    /// Margin on start of widget, horizontally.
1756    ///
1757    /// This property supports left-to-right and right-to-left text
1758    /// directions.
1759    ///
1760    /// This property adds margin outside of the widget's normal size
1761    /// request, the margin will be added in addition to the size from
1762    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
1763    pub fn margin_start(self, margin_start: i32) -> Self {
1764        Self {
1765            builder: self.builder.property("margin-start", margin_start),
1766        }
1767    }
1768
1769    /// Margin on top side of widget.
1770    ///
1771    /// This property adds margin outside of the widget's normal size
1772    /// request, the margin will be added in addition to the size from
1773    /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
1774    pub fn margin_top(self, margin_top: i32) -> Self {
1775        Self {
1776            builder: self.builder.property("margin-top", margin_top),
1777        }
1778    }
1779
1780    /// The name of the widget.
1781    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1782        Self {
1783            builder: self.builder.property("name", name.into()),
1784        }
1785    }
1786
1787    /// The requested opacity of the widget.
1788    pub fn opacity(self, opacity: f64) -> Self {
1789        Self {
1790            builder: self.builder.property("opacity", opacity),
1791        }
1792    }
1793
1794    /// How content outside the widget's content area is treated.
1795    ///
1796    /// This property is meant to be set by widget implementations,
1797    /// typically in their instance init function.
1798    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
1799        Self {
1800            builder: self.builder.property("overflow", overflow),
1801        }
1802    }
1803
1804    /// Whether the widget will receive the default action when it is focused.
1805    pub fn receives_default(self, receives_default: bool) -> Self {
1806        Self {
1807            builder: self.builder.property("receives-default", receives_default),
1808        }
1809    }
1810
1811    /// Whether the widget responds to input.
1812    pub fn sensitive(self, sensitive: bool) -> Self {
1813        Self {
1814            builder: self.builder.property("sensitive", sensitive),
1815        }
1816    }
1817
1818    /// Sets the text of tooltip to be the given string, which is marked up
1819    /// with Pango markup.
1820    ///
1821    /// Also see `Gtk::Tooltip::set_markup()`.
1822    ///
1823    /// This is a convenience property which will take care of getting the
1824    /// tooltip shown if the given string is not `NULL`:
1825    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
1826    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
1827    /// the default signal handler.
1828    ///
1829    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
1830    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
1831    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1832        Self {
1833            builder: self
1834                .builder
1835                .property("tooltip-markup", tooltip_markup.into()),
1836        }
1837    }
1838
1839    /// Sets the text of tooltip to be the given string.
1840    ///
1841    /// Also see `Gtk::Tooltip::set_text()`.
1842    ///
1843    /// This is a convenience property which will take care of getting the
1844    /// tooltip shown if the given string is not `NULL`:
1845    /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
1846    /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
1847    /// the default signal handler.
1848    ///
1849    /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
1850    /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
1851    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1852        Self {
1853            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1854        }
1855    }
1856
1857    /// How to distribute vertical space if widget gets extra space.
1858    pub fn valign(self, valign: gtk::Align) -> Self {
1859        Self {
1860            builder: self.builder.property("valign", valign),
1861        }
1862    }
1863
1864    /// Whether to expand vertically.
1865    pub fn vexpand(self, vexpand: bool) -> Self {
1866        Self {
1867            builder: self.builder.property("vexpand", vexpand),
1868        }
1869    }
1870
1871    /// Whether to use the `vexpand` property.
1872    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1873        Self {
1874            builder: self.builder.property("vexpand-set", vexpand_set),
1875        }
1876    }
1877
1878    /// Whether the widget is visible.
1879    pub fn visible(self, visible: bool) -> Self {
1880        Self {
1881            builder: self.builder.property("visible", visible),
1882        }
1883    }
1884
1885    /// Overrides for width request of the widget.
1886    ///
1887    /// If this is -1, the natural request will be used.
1888    pub fn width_request(self, width_request: i32) -> Self {
1889        Self {
1890            builder: self.builder.property("width-request", width_request),
1891        }
1892    }
1893
1894    /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
1895    ///
1896    /// The accessible role cannot be changed once set.
1897    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
1898        Self {
1899            builder: self.builder.property("accessible-role", accessible_role),
1900        }
1901    }
1902
1903    // rustdoc-stripper-ignore-next
1904    /// Build the [`NavigationView`].
1905    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1906    pub fn build(self) -> NavigationView {
1907        assert_initialized_main_thread!();
1908        self.builder.build()
1909    }
1910}