Class TabView

All Implemented Interfaces:
PointerInterface

public class TabView extends Widget
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 bar and relies on external widgets for that, such as
[class@TabBar].

`AdwTabView` maintains a [class@TabPage] object for each page, which holds
additional per-page properties. You can obtain the `AdwTabPage` for a page
with [method@TabView.get_page], and as the return value for
[method@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 [class@Gtk.Notebook] 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 [property@TabView:shortcuts] property can be used to manage them.

See [flags@TabViewShortcuts] for the list of the available shortcuts. All of
the shortcuts are enabled by default.

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

```c
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`.

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.TabView.html

  • Field Details

  • Constructor Details

    • TabView

      public TabView(PointerContainer pointer)
    • TabView

      public TabView()
      Creates a new `AdwTabView`.
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • addPage

      public TabPage addPage(@Nonnull Widget child, @Nullable TabPage parent)
      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
      [method@TabView.close_page]).

      If @parent is `NULL`, this function is equivalent to [method@TabView.append].
      Parameters:
      child - a widget to add
      parent - a parent page for @child
      Returns:
      the page object representing @child
    • addShortcuts

      public void addShortcuts(int shortcuts)
      Adds @shortcuts for @self.

      See [property@TabView:shortcuts] for details.
      Parameters:
      shortcuts - the shortcuts to add
    • append

      public TabPage append(@Nonnull Widget child)
      Inserts @child as the last non-pinned page.
      Parameters:
      child - a widget to add
      Returns:
      the page object representing @child
    • appendPinned

      public TabPage appendPinned(@Nonnull Widget child)
      Inserts @child as the last pinned page.
      Parameters:
      child - a widget to add
      Returns:
      the page object representing @child
    • closeOtherPages

      public void closeOtherPages(@Nonnull TabPage page)
      Requests to close all pages other than @page.
      Parameters:
      page - a page of @self
    • closePage

      public void closePage(@Nonnull TabPage page)
      Requests to close @page.

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

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

      The default handler for [signal@TabView::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 [property@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.
      Parameters:
      page - a page of @self
    • closePageFinish

      public void closePageFinish(@Nonnull TabPage page, boolean confirm)
      Completes a [method@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 [method@TabView.close_page] can be called
      for it again.

      This function should not be called unless a custom handler for
      [signal@TabView::close-page] is used.
      Parameters:
      page - a page of @self
      confirm - whether to confirm or deny closing @page
    • closePagesAfter

      public void closePagesAfter(@Nonnull TabPage page)
      Requests to close all pages after @page.
      Parameters:
      page - a page of @self
    • closePagesBefore

      public void closePagesBefore(@Nonnull TabPage page)
      Requests to close all pages before @page.
      Parameters:
      page - a page of @self
    • getDefaultIcon

      public Icon getDefaultIcon()
      Gets the default icon of @self.
      Returns:
      the default icon of @self.
    • getIsTransferringPage

      public boolean getIsTransferringPage()
      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.
      Returns:
      whether a page is being transferred
    • getMenuModel

      public MenuModel getMenuModel()
      Gets the tab context menu model for @self.
      Returns:
      the tab context menu model for @self
    • getNPages

      public int getNPages()
      Gets the number of pages in @self.
      Returns:
      the number of pages in @self
    • getNPinnedPages

      public int getNPinnedPages()
      Gets the number of pinned pages in @self.

      See [method@TabView.set_page_pinned].
      Returns:
      the number of pinned pages in @self
    • getNthPage

      public TabPage getNthPage(int position)
      Gets the [class@TabPage] representing the child at @position.
      Parameters:
      position - the index of the page in @self, starting from 0
      Returns:
      the page object at @position
    • getPage

      public TabPage getPage(@Nonnull Widget child)
      Gets the [class@TabPage] object representing @child.
      Parameters:
      child - a child in @self
      Returns:
      the page object for @child
    • getPagePosition

      public int getPagePosition(@Nonnull TabPage page)
      Finds the position of @page in @self, starting from 0.
      Parameters:
      page - a page of @self
      Returns:
      the position of @page in @self
    • getPages

      public SelectionModel getPages()
      Returns a [iface@Gio.ListModel] that contains the pages of @self.

      This can be used to keep an up-to-date view. The model also implements
      [iface@Gtk.SelectionModel] and can be used to track and change the selected
      page.
      Returns:
      a `GtkSelectionModel` for the pages of @self
    • getSelectedPage

      public TabPage getSelectedPage()
      Gets the currently selected page in @self.
      Returns:
      the selected page
    • getShortcuts

      public int getShortcuts()
      Gets the enabled shortcuts for @self.
      Returns:
      the shortcut mask
    • insert

      public TabPage insert(@Nonnull Widget child, int position)
      Inserts a non-pinned page at @position.

      It's an error to try to insert a page before a pinned page, in that case
      [method@TabView.insert_pinned] should be used instead.
      Parameters:
      child - a widget to add
      position - the position to add @child at, starting from 0
      Returns:
      the page object representing @child
    • insertPinned

      public TabPage insertPinned(@Nonnull Widget child, int position)
      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 [method@TabView.insert] should be used instead.
      Parameters:
      child - a widget to add
      position - the position to add @child at, starting from 0
      Returns:
      the page object representing @child
    • prepend

      public TabPage prepend(@Nonnull Widget child)
      Inserts @child as the first non-pinned page.
      Parameters:
      child - a widget to add
      Returns:
      the page object representing @child
    • prependPinned

      public TabPage prependPinned(@Nonnull Widget child)
      Inserts @child as the first pinned page.
      Parameters:
      child - a widget to add
      Returns:
      the page object representing @child
    • removeShortcuts

      public void removeShortcuts(int shortcuts)
      Removes @shortcuts from @self.

      See [property@TabView:shortcuts] for details.
      Parameters:
      shortcuts - the shortcuts to reomve
    • reorderBackward

      public boolean reorderBackward(@Nonnull TabPage page)
      Reorders @page to before its previous page if possible.
      Parameters:
      page - a page of @self
      Returns:
      whether @page was moved
    • reorderFirst

      public boolean reorderFirst(@Nonnull TabPage page)
      Reorders @page to the first possible position.
      Parameters:
      page - a page of @self
      Returns:
      whether @page was moved
    • reorderForward

      public boolean reorderForward(@Nonnull TabPage page)
      Reorders @page to after its next page if possible.
      Parameters:
      page - a page of @self
      Returns:
      whether @page was moved
    • reorderLast

      public boolean reorderLast(@Nonnull TabPage page)
      Reorders @page to the last possible position.
      Parameters:
      page - a page of @self
      Returns:
      whether @page was moved
    • reorderPage

      public boolean reorderPage(@Nonnull TabPage page, int position)
      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.
      Parameters:
      page - a page of @self
      position - the position to insert the page at, starting at 0
      Returns:
      whether @page was moved
    • selectNextPage

      public boolean selectNextPage()
      Selects the page after the currently selected page.

      If the last page was already selected, this function does nothing.
      Returns:
      whether the selected page was changed
    • selectPreviousPage

      public boolean selectPreviousPage()
      Selects the page before the currently selected page.

      If the first page was already selected, this function does nothing.
      Returns:
      whether the selected page was changed
    • setDefaultIcon

      public void setDefaultIcon(@Nonnull Icon default_icon)
      Sets the default page icon for @self.

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

      [class@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.

      By default, the `adw-tab-icon-missing-symbolic` icon is used.
      Parameters:
      default_icon - the default icon
    • setMenuModel

      public void setMenuModel(@Nullable MenuModel 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 [signal@TabView::setup-menu] signal to set up
      the menu actions for the particular tab.
      Parameters:
      menu_model - a menu model
    • setPagePinned

      public void setPagePinned(@Nonnull TabPage page, boolean pinned)
      Pins or unpins @page.

      Pinned pages are guaranteed to be placed before all non-pinned pages; at any
      given moment the first [property@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.

      [class@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. [property@TabPage:indicator-icon]
      2. A spinner if [property@TabPage:loading] is `TRUE`
      3. [property@TabPage:icon]
      4. [property@TabView:default-icon]

      Pinned pages cannot be closed by default, see [signal@TabView::close-page]
      for how to override that behavior.

      Changes the value of the [property@TabPage:pinned] property.
      Parameters:
      page - a page of @self
      pinned - whether @page should be pinned
    • setSelectedPage

      public void setSelectedPage(@Nonnull TabPage selected_page)
      Sets the currently selected page in @self.
      Parameters:
      selected_page - a page in @self
    • setShortcuts

      public void setShortcuts(int shortcuts)
      Sets the enabled shortcuts for @self.

      See [flags@TabViewShortcuts] for the list of the available shortcuts. All of
      the shortcuts are enabled by default.

      [method@TabView.add_shortcuts] and [method@TabView.remove_shortcuts] provide
      a convenient way to manage individual shortcuts.
      Parameters:
      shortcuts - the new shortcuts
    • transferPage

      public void transferPage(@Nonnull TabPage page, @Nonnull TabView other_view, int 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.
      Parameters:
      page - a page of @self
      other_view - the tab view to transfer the page to
      position - the position to insert the page at, starting at 0
    • onClosePage

      public SignalHandler onClosePage(TabView.OnClosePage signal)
      Connect to signal "close-page".
      See TabView.OnClosePage.onClosePage(ch.bailu.gtk.adw.TabPage) for signal description.
      Field SIGNAL_ON_CLOSE_PAGE contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onCreateWindow

      public SignalHandler onCreateWindow(TabView.OnCreateWindow signal)
      Connect to signal "create-window".
      See TabView.OnCreateWindow.onCreateWindow() for signal description.
      Field SIGNAL_ON_CREATE_WINDOW contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onIndicatorActivated

      public SignalHandler onIndicatorActivated(TabView.OnIndicatorActivated signal)
      Connect to signal "indicator-activated".
      See TabView.OnIndicatorActivated.onIndicatorActivated(ch.bailu.gtk.adw.TabPage) for signal description.
      Field SIGNAL_ON_INDICATOR_ACTIVATED contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onPageAttached

      public SignalHandler onPageAttached(TabView.OnPageAttached signal)
      Connect to signal "page-attached".
      See TabView.OnPageAttached.onPageAttached(ch.bailu.gtk.adw.TabPage, int) for signal description.
      Field SIGNAL_ON_PAGE_ATTACHED contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onPageDetached

      public SignalHandler onPageDetached(TabView.OnPageDetached signal)
      Connect to signal "page-detached".
      See TabView.OnPageDetached.onPageDetached(ch.bailu.gtk.adw.TabPage, int) for signal description.
      Field SIGNAL_ON_PAGE_DETACHED contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onPageReordered

      public SignalHandler onPageReordered(TabView.OnPageReordered signal)
      Connect to signal "page-reordered".
      See TabView.OnPageReordered.onPageReordered(ch.bailu.gtk.adw.TabPage, int) for signal description.
      Field SIGNAL_ON_PAGE_REORDERED contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onSetupMenu

      public SignalHandler onSetupMenu(TabView.OnSetupMenu signal)
      Connect to signal "setup-menu".
      See TabView.OnSetupMenu.onSetupMenu(ch.bailu.gtk.adw.TabPage) for signal description.
      Field SIGNAL_ON_SETUP_MENU contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • asAccessible

      public Accessible asAccessible()
      Implements interface Accessible. Call this to get access to interface functions.
      Overrides:
      asAccessible in class Widget
      Returns:
      Accessible
    • asBuildable

      public Buildable asBuildable()
      Implements interface Buildable. Call this to get access to interface functions.
      Overrides:
      asBuildable in class Widget
      Returns:
      Buildable
    • asConstraintTarget

      public ConstraintTarget asConstraintTarget()
      Implements interface ConstraintTarget. Call this to get access to interface functions.
      Overrides:
      asConstraintTarget in class Widget
      Returns:
      ConstraintTarget
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()