Next: <AdwNoneAnimationTarget>, Previous: <AdwNavigationSplitView>, Up: Classes   [Index]


1.36 <AdwNavigationView> ¶

Class: <AdwNavigationView> ¶

It derives from <GtkWidget>.

A page-based navigation container.

<AdwNavigationView> presents one child at a time, similar to <GtkStack>.

<AdwNavigationView> can only contain NavigationPage children.

It maintains a navigation stack that can be controlled with NavigationView.push and NavigationView.pop. The whole navigation stack can also be replaced using NavigationView.replace.

<AdwNavigationView> allows to manage pages statically or dynamically.

Static pages can be added using the NavigationView.add method. The <AdwNavigationView> will keep a reference to these pages, but they aren’t accessible to the user until NavigationView.push is called (except for the first page, which is pushed automatically). Use the NavigationView.remove method to remove them. This is useful for applications that have a small number of unique pages and just need navigation between them.

Dynamic pages are automatically destroyed once they are popped off the navigation stack. To add a page like this, push it using the NavigationView.push method without calling NavigationView.add first.

Tags ¶

Static pages, as well as any pages in the navigation stack, can be accessed by their NavigationPage:tag. For example, NavigationView.push_by_tag can be used to push a static page that’s not in the navigation stack without having to keep a reference to it manually.

Header Bar Integration ¶

When used inside <AdwNavigationView>, HeaderBar will automatically display a back button that can be used to go back to the previous page when possible. The button also has a context menu, allowing to pop multiple pages at once, potentially across multiple navigation views.

Set HeaderBar:show-back-button to FALSE to disable this behavior in rare scenarios where it’s unwanted.

<AdwHeaderBar> will also display the title of the <AdwNavigationPage> it’s placed into, so most applications shouldn’t need to customize it at all.

Shortcuts and Gestures ¶

<AdwNavigationView> supports the following shortcuts for going to the previous page:

  • Escape (unless NavigationView:pop-on-escape is set to FALSE)
  • Alt+←
  • Back mouse button

Additionally, it supports interactive gestures:

  • One-finger swipe towards the right on touchscreens
  • Scrolling towards the right on touchpads (usually two-finger swipe)

These gestures have transitions enabled regardless of the NavigationView:animate-transitions value.

Applications can also enable shortcuts for pushing another page onto the navigation stack via connecting to the "get-next-page" signal, in that case the following shortcuts are supported:

  • Alt+→
  • Forward mouse button
  • Swipe/scrolling towards the left

For right-to-left locales, the gestures and shortcuts are reversed.

NavigationPage:can-pop can be used to disable them, along with the header bar back buttons.

Actions ¶

<AdwNavigationView> defines actions for controlling the navigation stack. actions for controlling the navigation stack:

  • navigation.push takes a string parameter specifying the tag of the page to push, and is equivalent to calling NavigationView.push_by_tag.
  • navigation.pop doesn’t take any parameters and pops the current page from the navigation stack, equivalent to calling NavigationView.pop.

‘AdwNavigationView‘ as ‘GtkBuildable‘ ¶

<AdwNavigationView> allows to add pages as children, equivalent to using the NavigationView.add method.

Example of an <AdwNavigationView> UI definition:

<object class="AdwNavigationView">
  <child>
    <object class="AdwNavigationPage">
      <property name="title" translatable="yes">Page 1</property>
      <property name="child">
        <object class="AdwToolbarView">
          <child type="top">
            <object class="AdwHeaderBar"/>
          </child>
          <property name="content">
            <object class="GtkButton">
              <property name="label" translatable="yes">Open Page 2</property>
              <property name="halign">center</property>
              <property name="valign">center</property>
              <property name="action-name">navigation.push</property>
              <property name="action-target">'page-2'</property>
              <style>
                <class name="pill"/>
               </style>
            </object>
          </property>
        </object>
      </property>
    </object>
  </child>
  <child>
    <object class="AdwNavigationPage">
      <property name="title" translatable="yes">Page 2</property>
      <property name="tag">page-2</property>
      <property name="child">
        <object class="AdwToolbarView">
          <child type="top">
            <object class="AdwHeaderBar"/>
          </child>
          <property name="content">
            <!-- ... -->
          </property>
        </object>
      </property>
    </object>
  </child>
</object>

CSS nodes ¶

<AdwNavigationView> has a single CSS node with the name navigation-view.

Accessibility ¶

<AdwNavigationView> uses the Gtk.AccessibleRole.group role.

Properties ¶

Property: navigation-view:animate-transitions self ¶

Whether to animate page transitions.

Gesture-based transitions are always animated.

Its value is a boolean.

Set it with (set! (navigation-view:animate-transitions self) value).

Property: navigation-view:hhomogeneous self ¶

Whether the view is horizontally homogeneous.

If the view is horizontally homogeneous, it allocates the same width for all pages.

If it’s not, the page may change width when a different page becomes visible.

Its value is a boolean.

Set it with (set! (navigation-view:hhomogeneous self) value).

Property: navigation-view:navigation-stack self ¶

A list model that contains the pages in navigation stack.

The pages are sorted from root page to visible page.

This can be used to keep an up-to-date view.

Its value is a <GListModel>, or #f.

It is read only.

Property: navigation-view:pop-on-escape self ¶

Whether pressing Escape pops the current page.

Applications using <AdwNavigationView> to implement a browser may want to disable it.

Its value is a boolean.

Set it with (set! (navigation-view:pop-on-escape self) value).

Property: navigation-view:vhomogeneous self ¶

Whether the view is vertically homogeneous.

If the view is vertically homogeneous, it allocates the same height for all pages.

If it’s not, the view may change height when a different page becomes visible.

Its value is a boolean.

Set it with (set! (navigation-view:vhomogeneous self) value).

Property: navigation-view:visible-page self ¶

The currently visible page.

Its value is a <AdwNavigationPage>, or #f.

It is read only.

Property: navigation-view:visible-page-tag self ¶

The tag of the currently visible page.

Its value is a string, or #f.

It is read only.

Procedures ¶

Method: navigation-view:add self page ¶
Method: add self page ¶

Permanently adds page to self.

Any page that has been added will stay in self even after being popped from the navigation stack.

Adding a page while no page is visible will automatically push it to the navigation stack.

See NavigationView.remove.

self

Passed: a <AdwNavigationView>.

a navigation view

page

Passed: a <AdwNavigationPage>.

the page to add

Method: navigation-view:find-page self tag ⇒ %return ¶
Method: find-page self tag ⇒ %return ¶

Finds a page in self by its tag.

See NavigationPage:tag.

self

Passed: a <AdwNavigationView>.

a navigation view

tag

Passed: a string.

a page tag

%return

Returned: a <AdwNavigationPage>, or #f.

the page with the given tag

Method: navigation-view:get-animate-transitions? self ⇒ %return ¶
Method: get-animate-transitions? self ⇒ %return ¶

Gets whether self animates page transitions.

self

Passed: a <AdwNavigationView>.

a navigation view

%return

Returned: a boolean.

whether to animate page transitions

Method: navigation-view:get-hhomogeneous? self ⇒ %return ¶
Method: get-hhomogeneous? self ⇒ %return ¶

Gets whether self is horizontally homogeneous.

self

Passed: a <AdwNavigationView>.

a navigation view

%return

Returned: a boolean.

whether self is horizontally homogeneous

Method: navigation-view:get-navigation-stack self ⇒ %return ¶
Method: get-navigation-stack self ⇒ %return ¶

Returns a <GListModel> that contains the pages in navigation stack.

The pages are sorted from root page to visible page.

This can be used to keep an up-to-date view.

self

Passed: a <AdwNavigationView>.

a navigation view

%return

Returned: a <GListModel>.

a list model for the navigation stack

Method: navigation-view:get-pop-on-escape? self ⇒ %return ¶
Method: get-pop-on-escape? self ⇒ %return ¶

Gets whether pressing Escape pops the current page on self.

self

Passed: a <AdwNavigationView>.

a navigation view

%return

Returned: a boolean.

whether to pop the current page

Method: navigation-view:get-previous-page self page ⇒ %return ¶
Method: get-previous-page self page ⇒ %return ¶

Gets the previous page for page.

If page is in the navigation stack, returns the page popping page will reveal.

If page is the root page or is not in the navigation stack, returns NULL.

self

Passed: a <AdwNavigationView>.

a navigation view

page

Passed: a <AdwNavigationPage>.

a page in self

%return

Returned: a <AdwNavigationPage>, or #f.

the previous page

Method: navigation-view:get-vhomogeneous? self ⇒ %return ¶
Method: get-vhomogeneous? self ⇒ %return ¶

Gets whether self is vertically homogeneous.

self

Passed: a <AdwNavigationView>.

a navigation view

%return

Returned: a boolean.

whether self is vertically homogeneous

Method: navigation-view:get-visible-page self ⇒ %return ¶
Method: get-visible-page self ⇒ %return ¶

Gets the currently visible page in self.

self

Passed: a <AdwNavigationView>.

a navigation view

%return

Returned: a <AdwNavigationPage>, or #f.

the currently visible page

Method: navigation-view:get-visible-page-tag self ⇒ %return ¶
Method: get-visible-page-tag self ⇒ %return ¶

Gets the tag of the currently visible page in self.

self

Passed: a <AdwNavigationView>.

a navigation view

%return

Returned: a string, or #f.

the tag of the currently visible page

Procedure: navigation-view:new ⇒ %return ¶

Creates a new <AdwNavigationView>.

%return

Returned: a <GtkWidget>.

the new created <AdwNavigationView>

Method: navigation-view:pop-to-page? self page ⇒ %return ¶
Method: pop-to-page? self page ⇒ %return ¶

Pops pages from the navigation stack until page is visible.

page must be in the navigation stack.

If NavigationView.add hasn’t been called for any of the popped pages, they are automatically removed.

"popped" will be be emitted for each of the popped pages.

See NavigationView.pop and NavigationView.pop_to_tag.

self

Passed: a <AdwNavigationView>.

a navigation view

page

Passed: a <AdwNavigationPage>.

the page to pop to

%return

Returned: a boolean.

TRUE if any pages have been popped

Method: navigation-view:pop-to-tag? self tag ⇒ %return ¶
Method: pop-to-tag? self tag ⇒ %return ¶

Pops pages from the navigation stack until page with the tag tag is visible.

The page must be in the navigation stack.

If NavigationView.add hasn’t been called for any of the popped pages, they are automatically removed.

"popped" will be emitted for each of the popped pages.

See NavigationView.pop_to_page and NavigationPage:tag.

self

Passed: a <AdwNavigationView>.

a navigation view

tag

Passed: a string.

a page tag

%return

Returned: a boolean.

TRUE if any pages have been popped

Method: navigation-view:pop? self ⇒ %return ¶
Method: pop? self ⇒ %return ¶

Pops the visible page from the navigation stack.

Does nothing if the navigation stack contains less than two pages.

If NavigationView.add hasn’t been called, the page is automatically removed.

"popped" will be emitted for the current visible page.

See NavigationView.pop_to_page and NavigationView.pop_to_tag.

self

Passed: a <AdwNavigationView>.

a navigation view

%return

Returned: a boolean.

TRUE if a page has been popped

Method: navigation-view:push self page ¶
Method: push self page ¶

Pushes page onto the navigation stack.

If NavigationView.add hasn’t been called, the page is automatically removed once it’s popped.

"pushed" will be emitted for page.

See NavigationView.push_by_tag.

self

Passed: a <AdwNavigationView>.

a navigation view

page

Passed: a <AdwNavigationPage>.

the page to push

Method: navigation-view:push-by-tag self tag ¶
Method: push-by-tag self tag ¶

Pushes the page with the tag tag onto the navigation stack.

If NavigationView.add hasn’t been called, the page is automatically removed once it’s popped.

"pushed" will be emitted for the page.

See NavigationView.push and NavigationPage:tag.

self

Passed: a <AdwNavigationView>.

a navigation view

tag

Passed: a string.

the page tag

Method: navigation-view:remove self page ¶
Method: remove self page ¶

Removes page from self.

If page is currently in the navigation stack, it will be removed once it’s popped. Otherwise, it’s removed immediately.

See NavigationView.add.

self

Passed: a <AdwNavigationView>.

a navigation view

page

Passed: a <AdwNavigationPage>.

the page to remove

Method: navigation-view:replace self pages ¶
Method: replace self pages ¶

Replaces the current navigation stack with pages.

The last page becomes the visible page.

Replacing the navigation stack has no animation.

If NavigationView.add hasn’t been called for any pages that are no longer in the navigation stack, they are automatically removed.

n-pages can be 0, in that case no page will be visible after calling this method. This can be useful for removing all pages from self.

The "replaced" signal will be emitted.

See NavigationView.replace_with_tags.

self

Passed: a <AdwNavigationView>.

a navigation view

pages

Passed: a list or vector, each a <AdwNavigationPage>.

the new navigation stack

n-pages

Not passed: guile-gi gives the length of pages.

the number of pages in pages

Method: navigation-view:replace-with-tags self tags ¶
Method: replace-with-tags self tags ¶

Replaces the current navigation stack with pages with the tags tags.

The last page becomes the visible page.

Replacing the navigation stack has no animation.

If NavigationView.add hasn’t been called for any pages that are no longer in the navigation stack, they are automatically removed.

n-tags can be 0, in that case no page will be visible after calling this method. This can be useful for removing all pages from self.

The "replaced" signal will be emitted.

See NavigationView.replace and NavigationPage:tag.

self

Passed: a <AdwNavigationView>.

a navigation view

tags

Passed: a list or vector, each a string.

tags of the pages in the navigation stack

n-tags

Not passed: guile-gi gives the length of tags.

the number of tags

Method: navigation-view:set-animate-transitions self animate-transitions ¶
Method: set-animate-transitions self animate-transitions ¶

Sets whether self should animate page transitions.

Gesture-based transitions are always animated.

self

Passed: a <AdwNavigationView>.

a navigation view

animate-transitions

Passed: a boolean.

whether to animate page transitions

Method: navigation-view:set-hhomogeneous self hhomogeneous ¶
Method: set-hhomogeneous self hhomogeneous ¶

Sets self to be horizontally homogeneous or not.

If the view is horizontally homogeneous, it allocates the same width for all pages.

If it’s not, the view may change width when a different page becomes visible.

self

Passed: a <AdwNavigationView>.

a navigation view

hhomogeneous

Passed: a boolean.

whether to make self horizontally homogeneous

Method: navigation-view:set-pop-on-escape self pop-on-escape ¶
Method: set-pop-on-escape self pop-on-escape ¶

Sets whether pressing Escape pops the current page on self.

Applications using <AdwNavigationView> to implement a browser may want to disable it.

self

Passed: a <AdwNavigationView>.

a navigation view

pop-on-escape

Passed: a boolean.

whether to pop the current page when pressing Escape

Method: navigation-view:set-vhomogeneous self vhomogeneous ¶
Method: set-vhomogeneous self vhomogeneous ¶

Sets self to be vertically homogeneous or not.

If the view is vertically homogeneous, it allocates the same height for all pages.

If it’s not, the view may change height when a different page becomes visible.

self

Passed: a <AdwNavigationView>.

a navigation view

vhomogeneous

Passed: a boolean.

whether to make self vertically homogeneous

Signals ¶

Signal: navigation-view:get-next-page ¶

Connect a handler with (connect object navigation-view:get-next-page handler). It is called as (handler self) ⇒ %return.

Emitted when a push shortcut or a gesture is triggered.

To support the push shortcuts and gestures, the application is expected to return the page to push in the handler.

This signal can be emitted multiple times for the gestures, for example when the gesture is cancelled by the user. As such, the application must not make any irreversible changes in the handler, such as removing the page from a forward stack.

Instead, it should be done in the "pushed" handler.

self

Passed: a <AdwNavigationView>.

%return

Returned: a <AdwNavigationPage>, or #f.

the page to push

Signal: navigation-view:popped ¶

Connect a handler with (connect object navigation-view:popped handler). It is called as (handler self page).

Emitted after page has been popped from the navigation stack.

See NavigationView.pop.

When using NavigationView.pop_to_page or NavigationView.pop_to_tag, this signal is emitted for each of the popped pages.

self

Passed: a <AdwNavigationView>.

page

Passed: a <AdwNavigationPage>.

the popped page

Signal: navigation-view:pushed ¶

Connect a handler with (connect object navigation-view:pushed handler). It is called as (handler self).

Emitted after a page has been pushed to the navigation stack.

See NavigationView.push.

self

Passed: a <AdwNavigationView>.

Signal: navigation-view:replaced ¶

Connect a handler with (connect object navigation-view:replaced handler). It is called as (handler self).

Emitted after the navigation stack has been replaced.

See NavigationView.replace.

self

Passed: a <AdwNavigationView>.


Next: <AdwNoneAnimationTarget>, Previous: <AdwNavigationSplitView>, Up: Classes   [Index]