1.65 <AdwTabView>

Class: <AdwTabView>

It derives from <GtkWidget>.

A dynamic tabbed container.

<AdwTabView> is a container which shows one child at a time. While it provides keyboard shortcuts for switching between pages, it does not provide a visible tab switcher and relies on external widgets for that, such as TabBar, TabOverview and TabButton.

<AdwTabView> maintains a TabPage object for each page, which holds additional per-page properties. You can obtain the <AdwTabPage> for a page with TabView.get_page, and as the return value for TabView.append and other functions for adding children.

<AdwTabView> only aims to be useful for dynamic tabs in multi-window document-based applications, such as web browsers, file managers, text editors or terminals. It does not aim to replace <GtkNotebook> for use cases such as tabbed dialogs.

As such, it does not support disabling page reordering or detaching.

<AdwTabView> adds a number of global page switching and reordering shortcuts. The TabView:shortcuts property can be used to manage them.

See TabViewShortcuts for the list of the available shortcuts. All of the shortcuts are enabled by default.

TabView.add_shortcuts and TabView.remove_shortcuts can be used to manage shortcuts in a convenient way, for example:

adw_tab_view_remove_shortcuts (view, ADW_TAB_VIEW_SHORTCUT_CONTROL_HOME |
                                     ADW_TAB_VIEW_SHORTCUT_CONTROL_END);

CSS nodes

<AdwTabView> has a main CSS node with the name tabview.

Accessibility

<AdwTabView> uses the Gtk.AccessibleRole.tab-panel role for the tab pages which are the accessible parent objects of the child widgets.

Properties

Property: tab-view:default-icon self

Default page icon.

If a page doesn’t provide its own icon via TabPage:icon, a default icon may be used instead for contexts where having an icon is necessary.

TabBar will use default icon for pinned tabs in case the page is not loading, doesn’t have an icon and an indicator. Default icon is never used for tabs that aren’t pinned.

TabOverview will use default icon for pages with missing thumbnails.

By default, the adw-tab-icon-missing-symbolic icon is used.

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

Set it with (set! (tab-view:default-icon self) value).

Property: tab-view:is-transferring-page self

Whether a page is being transferred.

This property will be set to TRUE when a drag-n-drop tab transfer starts on any <AdwTabView>, and to FALSE after it ends.

During the transfer, children cannot receive pointer input and a tab can be safely dropped on the tab view.

Its value is a boolean.

It is read only.

Property: tab-view:menu-model self

Tab context menu model.

When a context menu is shown for a tab, it will be constructed from the provided menu model. Use the "setup-menu" signal to set up the menu actions for the particular tab.

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

Set it with (set! (tab-view:menu-model self) value).

Property: tab-view:n-pages self

The number of pages in the tab view.

Its value is a 32-bit integer.

It is read only.

Property: tab-view:n-pinned-pages self

The number of pinned pages in the tab view.

See TabView.set_page_pinned.

Its value is a 32-bit integer.

It is read only.

Property: tab-view:pages self

A list model with the tab view’s pages.

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

The model implements <GtkSectionModel>, with one section for pinned pages and one for the rest of the pages.

It also implements <GtkSelectionModel> and can be used to track and change the selected page.

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

It is read only.

Property: tab-view:selected-page self

The currently selected page.

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

Set it with (set! (tab-view:selected-page self) value).

Property: tab-view:shortcuts self

The enabled shortcuts.

See TabViewShortcuts for the list of the available shortcuts. All of the shortcuts are enabled by default.

TabView.add_shortcuts and TabView.remove_shortcuts provide a convenient way to manage individual shortcuts.

Its value is a <AdwTabViewShortcuts> (or, to set it, a list of its symbols, or one of them).

Set it with (set! (tab-view:shortcuts self) value).

Procedures

Method: tab-view:add-page self child [parent] ⇒ %return
Method: add-page self child [parent] ⇒ %return

Adds child to self with parent as the parent.

This function can be used to automatically position new pages, and to select the correct page when this page is closed while being selected (see TabView.close_page).

If parent is NULL, this function is equivalent to TabView.append.

self

Passed: a <AdwTabView>.

a tab view

child

Passed: a <GtkWidget>.

a widget to add

parent

Passed, or left out: a <AdwTabPage>, or #f.

a parent page for child

%return

Returned: a <AdwTabPage>.

the page object representing child

Method: tab-view:add-shortcuts self shortcuts
Method: add-shortcuts self shortcuts

Adds shortcuts for self.

See TabView:shortcuts for details.

self

Passed: a <AdwTabView>.

a tab view

shortcuts

Passed: a <AdwTabViewShortcuts>, or a list of its symbols, or one of them.

the shortcuts to add

Method: tab-view:append self child ⇒ %return
Method: append self child ⇒ %return

Inserts child as the last non-pinned page.

self

Passed: a <AdwTabView>.

a tab view

child

Passed: a <GtkWidget>.

a widget to add

%return

Returned: a <AdwTabPage>.

the page object representing child

Method: tab-view:append-pinned self child ⇒ %return
Method: append-pinned self child ⇒ %return

Inserts child as the last pinned page.

self

Passed: a <AdwTabView>.

a tab view

child

Passed: a <GtkWidget>.

a widget to add

%return

Returned: a <AdwTabPage>.

the page object representing child

Method: tab-view:close-other-pages self page
Method: close-other-pages self page

Requests to close all pages other than page.

self

Passed: a <AdwTabView>.

a tab view

page

Passed: a <AdwTabPage>.

a page of self

Method: tab-view:close-page self page
Method: close-page self page

Requests to close page.

Calling this function will result in the "close-page" signal being emitted for page. Closing the page can then be confirmed or denied via TabView.close_page_finish.

If the page is waiting for a TabView.close_page_finish call, this function will do nothing.

The default handler for "close-page" will immediately confirm closing the page if it’s non-pinned, or reject it if it’s pinned. This behavior can be changed by registering your own handler for that signal.

If page was selected, another page will be selected instead:

If the TabPage:parent value is NULL, the next page will be selected when possible, or if the page was already last, the previous page will be selected instead.

If it’s not NULL, the previous page will be selected if it’s a descendant (possibly indirect) of the parent. If both the previous page and the parent are pinned, the parent will be selected instead.

self

Passed: a <AdwTabView>.

a tab view

page

Passed: a <AdwTabPage>.

a page of self

Method: tab-view:close-page-finish self page confirm
Method: close-page-finish self page confirm

Completes a TabView.close_page call for page.

If confirm is TRUE, page will be closed. If it’s FALSE, it will be reverted to its previous state and TabView.close_page can be called for it again.

This function should not be called unless a custom handler for "close-page" is used.

self

Passed: a <AdwTabView>.

a tab view

page

Passed: a <AdwTabPage>.

a page of self

confirm

Passed: a boolean.

whether to confirm or deny closing page

Method: tab-view:close-pages-after self page
Method: close-pages-after self page

Requests to close all pages after page.

self

Passed: a <AdwTabView>.

a tab view

page

Passed: a <AdwTabPage>.

a page of self

Method: tab-view:close-pages-before self page
Method: close-pages-before self page

Requests to close all pages before page.

self

Passed: a <AdwTabView>.

a tab view

page

Passed: a <AdwTabPage>.

a page of self

Method: tab-view:get-default-icon self ⇒ %return
Method: get-default-icon self ⇒ %return

Gets the default icon of self.

self

Passed: a <AdwTabView>.

a tab view

%return

Returned: a <GIcon>.

the default icon of self.

Method: tab-view:get-is-transferring-page? self ⇒ %return
Method: get-is-transferring-page? self ⇒ %return

Whether a page is being transferred.

The corresponding property will be set to TRUE when a drag-n-drop tab transfer starts on any <AdwTabView>, and to FALSE after it ends.

During the transfer, children cannot receive pointer input and a tab can be safely dropped on the tab view.

self

Passed: a <AdwTabView>.

a tab view

%return

Returned: a boolean.

whether a page is being transferred

Method: tab-view:get-menu-model self ⇒ %return
Method: get-menu-model self ⇒ %return

Gets the tab context menu model for self.

self

Passed: a <AdwTabView>.

a tab view

%return

Returned: a <GMenuModel>, or #f.

the tab context menu model for self

Method: tab-view:get-n-pages self ⇒ %return
Method: get-n-pages self ⇒ %return

Gets the number of pages in self.

self

Passed: a <AdwTabView>.

a tab view

%return

Returned: a 32-bit integer.

the number of pages in self

Method: tab-view:get-n-pinned-pages self ⇒ %return
Method: get-n-pinned-pages self ⇒ %return

Gets the number of pinned pages in self.

See TabView.set_page_pinned.

self

Passed: a <AdwTabView>.

a tab view

%return

Returned: a 32-bit integer.

the number of pinned pages in self

Method: tab-view:get-nth-page self position ⇒ %return
Method: get-nth-page self position ⇒ %return

Gets the TabPage representing the child at position.

self

Passed: a <AdwTabView>.

a tab view

position

Passed: a 32-bit integer.

the index of the page in self, starting from 0

%return

Returned: a <AdwTabPage>.

the page object at position

Method: tab-view:get-page self child ⇒ %return
Method: get-page self child ⇒ %return

Gets the TabPage object representing child.

self

Passed: a <AdwTabView>.

a tab view

child

Passed: a <GtkWidget>.

a child in self

%return

Returned: a <AdwTabPage>.

the page object for child

Method: tab-view:get-page-position self page ⇒ %return
Method: get-page-position self page ⇒ %return

Finds the position of page in self, starting from 0.

self

Passed: a <AdwTabView>.

a tab view

page

Passed: a <AdwTabPage>.

a page of self

%return

Returned: a 32-bit integer.

the position of page in self

Method: tab-view:get-pages self ⇒ %return
Method: get-pages self ⇒ %return

Returns a <GListModel> that contains the pages of self.

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

The model implements <GtkSectionModel>, with one section for pinned pages and one for the rest of the pages.

It also implements <GtkSelectionModel> and can be used to track and change the selected page.

self

Passed: a <AdwTabView>.

a tab view

%return

Returned: a <GtkSelectionModel>.

a <GtkSelectionModel> for the pages of self

Method: tab-view:get-selected-page self ⇒ %return
Method: get-selected-page self ⇒ %return

Gets the currently selected page in self.

self

Passed: a <AdwTabView>.

a tab view

%return

Returned: a <AdwTabPage>, or #f.

the selected page

Method: tab-view:get-shortcuts self ⇒ %return
Method: get-shortcuts self ⇒ %return

Gets the enabled shortcuts for self.

self

Passed: a <AdwTabView>.

a tab view

%return

Returned: a <AdwTabViewShortcuts>.

the shortcut mask

Method: tab-view:insert self child position ⇒ %return
Method: insert self child position ⇒ %return

Inserts a non-pinned page at position.

It’s an error to try to insert a page before a pinned page, in that case TabView.insert_pinned should be used instead.

self

Passed: a <AdwTabView>.

a tab view

child

Passed: a <GtkWidget>.

a widget to add

position

Passed: a 32-bit integer.

the position to add child at, starting from 0

%return

Returned: a <AdwTabPage>.

the page object representing child

Method: tab-view:insert-pinned self child position ⇒ %return
Method: insert-pinned self child position ⇒ %return

Inserts a pinned page at position.

It’s an error to try to insert a pinned page after a non-pinned page, in that case TabView.insert should be used instead.

self

Passed: a <AdwTabView>.

a tab view

child

Passed: a <GtkWidget>.

a widget to add

position

Passed: a 32-bit integer.

the position to add child at, starting from 0

%return

Returned: a <AdwTabPage>.

the page object representing child

Method: tab-view:invalidate-thumbnails self
Method: invalidate-thumbnails self

Invalidates thumbnails for all pages in self.

This is a convenience method, equivalent to calling TabPage.invalidate_thumbnail on each page.

self

Passed: a <AdwTabView>.

a tab view

Procedure: tab-view:new ⇒ %return

Creates a new <AdwTabView>.

%return

Returned: a <AdwTabView>.

the newly created <AdwTabView>

Method: tab-view:prepend self child ⇒ %return
Method: prepend self child ⇒ %return

Inserts child as the first non-pinned page.

self

Passed: a <AdwTabView>.

a tab view

child

Passed: a <GtkWidget>.

a widget to add

%return

Returned: a <AdwTabPage>.

the page object representing child

Method: tab-view:prepend-pinned self child ⇒ %return
Method: prepend-pinned self child ⇒ %return

Inserts child as the first pinned page.

self

Passed: a <AdwTabView>.

a tab view

child

Passed: a <GtkWidget>.

a widget to add

%return

Returned: a <AdwTabPage>.

the page object representing child

Method: tab-view:remove-shortcuts self shortcuts
Method: remove-shortcuts self shortcuts

Removes shortcuts from self.

See TabView:shortcuts for details.

self

Passed: a <AdwTabView>.

a tab view

shortcuts

Passed: a <AdwTabViewShortcuts>, or a list of its symbols, or one of them.

the shortcuts to remove

Method: tab-view:reorder-backward? self page ⇒ %return
Method: reorder-backward? self page ⇒ %return

Reorders page to before its previous page if possible.

self

Passed: a <AdwTabView>.

a tab view

page

Passed: a <AdwTabPage>.

a page of self

%return

Returned: a boolean.

whether page was moved

Method: tab-view:reorder-first? self page ⇒ %return
Method: reorder-first? self page ⇒ %return

Reorders page to the first possible position.

self

Passed: a <AdwTabView>.

a tab view

page

Passed: a <AdwTabPage>.

a page of self

%return

Returned: a boolean.

whether page was moved

Method: tab-view:reorder-forward? self page ⇒ %return
Method: reorder-forward? self page ⇒ %return

Reorders page to after its next page if possible.

self

Passed: a <AdwTabView>.

a tab view

page

Passed: a <AdwTabPage>.

a page of self

%return

Returned: a boolean.

whether page was moved

Method: tab-view:reorder-last? self page ⇒ %return
Method: reorder-last? self page ⇒ %return

Reorders page to the last possible position.

self

Passed: a <AdwTabView>.

a tab view

page

Passed: a <AdwTabPage>.

a page of self

%return

Returned: a boolean.

whether page was moved

Method: tab-view:reorder-page? self page position ⇒ %return
Method: reorder-page? self page position ⇒ %return

Reorders page to position.

It’s a programmer error to try to reorder a pinned page after a non-pinned one, or a non-pinned page before a pinned one.

self

Passed: a <AdwTabView>.

a tab view

page

Passed: a <AdwTabPage>.

a page of self

position

Passed: a 32-bit integer.

the position to insert the page at, starting at 0

%return

Returned: a boolean.

whether page was moved

Method: tab-view:select-next-page? self ⇒ %return
Method: select-next-page? self ⇒ %return

Selects the page after the currently selected page.

If the last page was already selected, this function does nothing.

self

Passed: a <AdwTabView>.

a tab view

%return

Returned: a boolean.

whether the selected page was changed

Method: tab-view:select-previous-page? self ⇒ %return
Method: select-previous-page? self ⇒ %return

Selects the page before the currently selected page.

If the first page was already selected, this function does nothing.

self

Passed: a <AdwTabView>.

a tab view

%return

Returned: a boolean.

whether the selected page was changed

Method: tab-view:set-default-icon self default-icon
Method: set-default-icon self default-icon

Sets the default page icon for self.

If a page doesn’t provide its own icon via TabPage:icon, a default icon may be used instead for contexts where having an icon is necessary.

TabBar will use default icon for pinned tabs in case the page is not loading, doesn’t have an icon and an indicator. Default icon is never used for tabs that aren’t pinned.

TabOverview will use default icon for pages with missing thumbnails.

By default, the adw-tab-icon-missing-symbolic icon is used.

self

Passed: a <AdwTabView>.

a tab view

default-icon

Passed: a <GIcon>.

the default icon

Method: tab-view:set-menu-model self [menu-model]
Method: set-menu-model self [menu-model]

Sets the tab context menu model for self.

When a context menu is shown for a tab, it will be constructed from the provided menu model. Use the "setup-menu" signal to set up the menu actions for the particular tab.

self

Passed: a <AdwTabView>.

a tab view

menu-model

Passed, or left out: a <GMenuModel>, or #f.

a menu model

Method: tab-view:set-page-pinned self page pinned
Method: set-page-pinned self page pinned

Pins or unpins page.

Pinned pages are guaranteed to be placed before all non-pinned pages; at any given moment the first TabView:n-pinned-pages pages in self are guaranteed to be pinned.

When a page is pinned or unpinned, it’s automatically reordered: pinning a page moves it after other pinned pages; unpinning a page moves it before other non-pinned pages.

Pinned pages can still be reordered between each other.

TabBar will display pinned pages in a compact form, never showing the title or close button, and only showing a single icon, selected in the following order:

  1. TabPage:indicator-icon
  2. A spinner if TabPage:loading is TRUE
  3. TabPage:icon
  4. TabView:default-icon

TabOverview will not show a thumbnail for pinned pages, and replace the close button with an unpin button. Unlike <AdwTabBar>, it will still display the page’s title, icon and indicator separately.

Pinned pages cannot be closed by default, see "close-page" for how to override that behavior.

Changes the value of the TabPage:pinned property.

self

Passed: a <AdwTabView>.

a tab view

page

Passed: a <AdwTabPage>.

a page of self

pinned

Passed: a boolean.

whether page should be pinned

Method: tab-view:set-selected-page self selected-page
Method: set-selected-page self selected-page

Sets the currently selected page in self.

self

Passed: a <AdwTabView>.

a tab view

selected-page

Passed: a <AdwTabPage>.

a page in self

Method: tab-view:set-shortcuts self shortcuts
Method: set-shortcuts self shortcuts

Sets the enabled shortcuts for self.

See TabViewShortcuts for the list of the available shortcuts. All of the shortcuts are enabled by default.

TabView.add_shortcuts and TabView.remove_shortcuts provide a convenient way to manage individual shortcuts.

self

Passed: a <AdwTabView>.

a tab view

shortcuts

Passed: a <AdwTabViewShortcuts>, or a list of its symbols, or one of them.

the new shortcuts

Method: tab-view:transfer-page self page other-view position
Method: transfer-page self page other-view position

Transfers page from self to other-view.

The page object will be reused.

It’s a programmer error to try to insert a pinned page after a non-pinned one, or a non-pinned page before a pinned one.

self

Passed: a <AdwTabView>.

a tab view

page

Passed: a <AdwTabPage>.

a page of self

other-view

Passed: a <AdwTabView>.

the tab view to transfer the page to

position

Passed: a 32-bit integer.

the position to insert the page at, starting at 0

Signals

Signal: tab-view:close-page

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

Emitted after TabView.close_page has been called for page.

The handler is expected to call TabView.close_page_finish to confirm or reject the closing.

The default handler will immediately confirm closing for non-pinned pages, or reject it for pinned pages, equivalent to the following example:

static gboolean
close_page_cb (AdwTabView *view,
               AdwTabPage *page,
               gpointer    user_data)
{
  adw_tab_view_close_page_finish (view, page, !adw_tab_page_get_pinned (page));

  return GDK_EVENT_STOP;
}

The TabView.close_page_finish call doesn’t have to happen inside the handler, so can be used to do asynchronous checks before confirming the closing.

A typical reason to connect to this signal is to show a confirmation dialog for closing a tab.

The signal handler should return Gdk.EVENT_STOP to stop propagation or Gdk.EVENT_PROPAGATE to invoke the default handler.

self

Passed: a <AdwTabView>.

page

Passed: a <AdwTabPage>.

a page of self

%return

Returned: a boolean.

whether propagation should be stopped

Signal: tab-view:create-window

Connect a handler with (connect object tab-view:create-window handler). It is called as (handler self) ⇒ %return.

Emitted when a tab should be transferred into a new window.

This can happen after a tab has been dropped on desktop.

The signal handler is expected to create a new window, position it as needed and return its <AdwTabView> that the page will be transferred into.

self

Passed: a <AdwTabView>.

%return

Returned: a <AdwTabView>, or #f.

the <AdwTabView> from the new window

Signal: tab-view:indicator-activated

Connect a handler with (connect object tab-view:indicator-activated handler). It is called as (handler self page).

Emitted after the indicator icon on page has been activated.

See TabPage:indicator-icon and TabPage:indicator-activatable.

self

Passed: a <AdwTabView>.

page

Passed: a <AdwTabPage>.

a page of self

Signal: tab-view:page-attached

Connect a handler with (connect object tab-view:page-attached handler). It is called as (handler self page position).

Emitted when a page has been created or transferred to self.

A typical reason to connect to this signal would be to connect to page signals for things such as updating window title.

self

Passed: a <AdwTabView>.

page

Passed: a <AdwTabPage>.

a page of self

position

Passed: a 32-bit integer.

the position of the page, starting from 0

Signal: tab-view:page-detached

Connect a handler with (connect object tab-view:page-detached handler). It is called as (handler self page position).

Emitted when a page has been removed or transferred to another view.

A typical reason to connect to this signal would be to disconnect signal handlers connected in the "page-attached" handler.

It is important not to try and destroy the page child in the handler of this function as the child might merely be moved to another window; use child dispose handler for that or do it in sync with your TabView.close_page_finish calls.

self

Passed: a <AdwTabView>.

page

Passed: a <AdwTabPage>.

a page of self

position

Passed: a 32-bit integer.

the position of the removed page, starting from 0

Signal: tab-view:page-reordered

Connect a handler with (connect object tab-view:page-reordered handler). It is called as (handler self page position).

Emitted after page has been reordered to position.

self

Passed: a <AdwTabView>.

page

Passed: a <AdwTabPage>.

a page of self

position

Passed: a 32-bit integer.

the position page was moved to, starting at 0

Signal: tab-view:setup-menu

Connect a handler with (connect object tab-view:setup-menu handler). It is called as (handler self page).

Emitted when a context menu is opened or closed for page.

If the menu has been closed, page will be set to NULL.

It can be used to set up menu actions before showing the menu, for example disable actions not applicable to page.

self

Passed: a <AdwTabView>.

page

Passed: a <AdwTabPage>, or #f.

a page of self