Adw.TabView¶
- Subclasses:
None
Methods¶
- Inherited:
Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1)
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9)
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
|||
r |
|||
r/w/en |
|||
r |
|||
r |
|||
r |
|||
r/w/en |
|||
r/w/en |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted after [method`TabView`.close_page] has been called for page. |
|
Emitted when a tab should be transferred into a new window. |
|
Emitted after the indicator icon on page has been activated. |
|
Emitted when a page has been created or transferred to self. |
|
Emitted when a page has been removed or transferred to another view. |
|
Emitted after page has been reordered to position. |
|
Emitted when a context menu is opened or closed for page. |
Fields¶
- Inherited:
Class Details¶
- class Adw.TabView(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
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 [class`TabBar`], [class`TabOverview`] and [class`TabButton`].AdwTabView
maintains a [class`TabPage`] object for each page, which holds additional per-page properties. You can obtain theAdwTabPage
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`:py:data::shortcuts<Adw.TabView.props.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 nametabview
.- Accessibility
AdwTabView
uses theGTK_ACCESSIBLE_ROLE_TAB_PANEL
for the tab pages which are the accessible parent objects of the child widgets.- classmethod new()¶
- Returns:
the newly created
AdwTabView
- Return type:
Creates a new
AdwTabView
.
- add_page(child, parent)¶
- Parameters:
child (
Gtk.Widget
) – a widget to addparent (
Adw.TabPage
orNone
) – a parent page for child
- Returns:
the page object representing child
- Return type:
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].
- add_shortcuts(shortcuts)¶
- Parameters:
shortcuts (
Adw.TabViewShortcuts
) – the shortcuts to add
Adds shortcuts for self.
See [property`TabView`:py:data::shortcuts<Adw.TabView.props.shortcuts>] for details.
New in version 1.2.
- append(child)¶
- Parameters:
child (
Gtk.Widget
) – a widget to add- Returns:
the page object representing child
- Return type:
Inserts child as the last non-pinned page.
- append_pinned(child)¶
- Parameters:
child (
Gtk.Widget
) – a widget to add- Returns:
the page object representing child
- Return type:
Inserts child as the last pinned page.
- close_other_pages(page)¶
- Parameters:
page (
Adw.TabPage
) – a page of self
Requests to close all pages other than page.
- close_page(page)¶
- Parameters:
page (
Adw.TabPage
) – a page of self
Requests to close page.
Calling this function will result in the [signal`TabView`:py:func:::close-page<Adw.TabView.signals.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`:py:func:::close-page<Adw.TabView.signals.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`:py:data::parent<Adw.TabView.props.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.
- close_page_finish(page, confirm)¶
- Parameters:
page (
Adw.TabPage
) – a page of selfconfirm (
bool
) – whether to confirm or deny closing page
Completes a [method`TabView`.close_page] call for page.
If confirm is
TRUE
, page will be closed. If it’sFALSE
, 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`:py:func:::close-page<Adw.TabView.signals.close_page>] is used.
- close_pages_after(page)¶
- Parameters:
page (
Adw.TabPage
) – a page of self
Requests to close all pages after page.
- close_pages_before(page)¶
- Parameters:
page (
Adw.TabPage
) – a page of self
Requests to close all pages before page.
- get_default_icon()¶
- Returns:
the default icon of self.
- Return type:
Gets the default icon of self.
- get_is_transferring_page()¶
- Returns:
whether a page is being transferred
- Return type:
Whether a page is being transferred.
The corresponding property will be set to
TRUE
when a drag-n-drop tab transfer starts on anyAdwTabView
, and toFALSE
after it ends.During the transfer, children cannot receive pointer input and a tab can be safely dropped on the tab view.
- Returns:
the tab context menu model for self
- Return type:
Gets the tab context menu model for self.
- get_n_pages()¶
- Returns:
the number of pages in self
- Return type:
Gets the number of pages in self.
- get_n_pinned_pages()¶
- Returns:
the number of pinned pages in self
- Return type:
Gets the number of pinned pages in self.
See [method`TabView`.set_page_pinned].
- get_nth_page(position)¶
- Parameters:
position (
int
) – the index of the page in self, starting from 0- Returns:
the page object at position
- Return type:
Gets the [class`TabPage`] representing the child at position.
- get_page(child)¶
- Parameters:
child (
Gtk.Widget
) – a child in self- Returns:
the page object for child
- Return type:
Gets the [class`TabPage`] object representing child.
- get_page_position(page)¶
- Parameters:
page (
Adw.TabPage
) – a page of self- Returns:
the position of page in self
- Return type:
Finds the position of page in self, starting from 0.
- get_pages()¶
- Returns:
a
GtkSelectionModel
for the pages of self- Return type:
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.
- get_selected_page()¶
- Returns:
the selected page
- Return type:
Adw.TabPage
orNone
Gets the currently selected page in self.
- get_shortcuts()¶
- Returns:
the shortcut mask
- Return type:
Gets the enabled shortcuts for self.
New in version 1.2.
- insert(child, position)¶
- Parameters:
child (
Gtk.Widget
) – a widget to addposition (
int
) – the position to add child at, starting from 0
- Returns:
the page object representing child
- Return type:
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.
- insert_pinned(child, position)¶
- Parameters:
child (
Gtk.Widget
) – a widget to addposition (
int
) – the position to add child at, starting from 0
- Returns:
the page object representing child
- Return type:
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.
- invalidate_thumbnails()¶
Invalidates thumbnails for all pages in self.
This is a convenience method, equivalent to calling [method`TabPage`.invalidate_thumbnail] on each page.
New in version 1.3.
- prepend(child)¶
- Parameters:
child (
Gtk.Widget
) – a widget to add- Returns:
the page object representing child
- Return type:
Inserts child as the first non-pinned page.
- prepend_pinned(child)¶
- Parameters:
child (
Gtk.Widget
) – a widget to add- Returns:
the page object representing child
- Return type:
Inserts child as the first pinned page.
- remove_shortcuts(shortcuts)¶
- Parameters:
shortcuts (
Adw.TabViewShortcuts
) – the shortcuts to reomve
Removes shortcuts from self.
See [property`TabView`:py:data::shortcuts<Adw.TabView.props.shortcuts>] for details.
New in version 1.2.
- reorder_backward(page)¶
- Parameters:
page (
Adw.TabPage
) – a page of self- Returns:
whether page was moved
- Return type:
Reorders page to before its previous page if possible.
- reorder_first(page)¶
- Parameters:
page (
Adw.TabPage
) – a page of self- Returns:
whether page was moved
- Return type:
Reorders page to the first possible position.
- reorder_forward(page)¶
- Parameters:
page (
Adw.TabPage
) – a page of self- Returns:
whether page was moved
- Return type:
Reorders page to after its next page if possible.
- reorder_last(page)¶
- Parameters:
page (
Adw.TabPage
) – a page of self- Returns:
whether page was moved
- Return type:
Reorders page to the last possible position.
- reorder_page(page, position)¶
- Parameters:
page (
Adw.TabPage
) – a page of selfposition (
int
) – the position to insert the page at, starting at 0
- Returns:
whether page was moved
- Return type:
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.
- select_next_page()¶
- Returns:
whether the selected page was changed
- Return type:
Selects the page after the currently selected page.
If the last page was already selected, this function does nothing.
- select_previous_page()¶
- Returns:
whether the selected page was changed
- Return type:
Selects the page before the currently selected page.
If the first page was already selected, this function does nothing.
- set_default_icon(default_icon)¶
- Parameters:
default_icon (
Gio.Icon
) – the default icon
Sets the default page icon for self.
If a page doesn’t provide its own icon via [property`TabPage`:py:data::icon<Adw.TabView.props.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.
[class`TabOverview`] will use default icon for pages with missing thumbnails.
By default, the
adw-tab-icon-missing-symbolic
icon is used.
- Parameters:
menu_model (
Gio.MenuModel
orNone
) – a 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`:py:func:::setup-menu<Adw.TabView.signals.setup_menu>] signal to set up the menu actions for the particular tab.
- set_page_pinned(page, pinned)¶
- Parameters:
page (
Adw.TabPage
) – a page of selfpinned (
bool
) – whether page should be 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`:py:data::n-pinned-pages<Adw.TabView.props.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:
[property`TabPage`:py:data::indicator-icon<Adw.TabView.props.indicator_icon>]
A spinner if [property`TabPage`:py:data::loading<Adw.TabView.props.loading>] is
TRUE
[property`TabPage`:py:data::icon<Adw.TabView.props.icon>]
[property`TabView`:py:data::default-icon<Adw.TabView.props.default_icon>]
[class`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 [signal`TabView`:py:func:::close-page<Adw.TabView.signals.close_page>] for how to override that behavior.
Changes the value of the [property`TabPage`:py:data::pinned<Adw.TabView.props.pinned>] property.
- set_selected_page(selected_page)¶
- Parameters:
selected_page (
Adw.TabPage
) – a page in self
Sets the currently selected page in self.
- set_shortcuts(shortcuts)¶
- Parameters:
shortcuts (
Adw.TabViewShortcuts
) – the new 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.
New in version 1.2.
- transfer_page(page, other_view, position)¶
- Parameters:
page (
Adw.TabPage
) – a page of selfother_view (
Adw.TabView
) – the tab view to transfer the page toposition (
int
) – the position to insert the page at, starting at 0
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.
Signal Details¶
- Adw.TabView.signals.close_page(tab_view, page)¶
- Signal Name:
close-page
- Flags:
- Parameters:
tab_view (
Adw.TabView
) – The object which received the signalpage (
Adw.TabPage
) – a page of self
- Returns:
whether propagation should be stopped
- Return type:
Emitted after [method`TabView`.close_page] has been called for page.
The handler is expected to call [method`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:
```c static
bool
close_page_cb (Adw.TabView
*view,Adw.TabPage
*page,object
user_data) {Adw.TabView.close_page_finish
(view, page, !:obj:Adw.TabPage.get_pinned (page));return
Gdk.EVENT_STOP
; } ```The [method`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 orGDK_EVENT_CONTINUE
to invoke the default handler.
- Adw.TabView.signals.create_window(tab_view)¶
- Signal Name:
create-window
- Flags:
- Parameters:
tab_view (
Adw.TabView
) – The object which received the signal- Returns:
the
AdwTabView
from the new window- Return type:
Adw.TabView
orNone
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.
- Adw.TabView.signals.indicator_activated(tab_view, page)¶
- Signal Name:
indicator-activated
- Flags:
- Parameters:
tab_view (
Adw.TabView
) – The object which received the signalpage (
Adw.TabPage
) – a page of self
Emitted after the indicator icon on page has been activated.
See [property`TabPage`:py:data::indicator-icon<Adw.TabView.props.indicator_icon>] and [property`TabPage`:py:data::indicator-activatable<Adw.TabView.props.indicator_activatable>].
- Adw.TabView.signals.page_attached(tab_view, page, position)¶
- Signal Name:
page-attached
- Flags:
- Parameters:
tab_view (
Adw.TabView
) – The object which received the signalpage (
Adw.TabPage
) – a page of selfposition (
int
) – the position of the page, starting from 0
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.
- Adw.TabView.signals.page_detached(tab_view, page, position)¶
- Signal Name:
page-detached
- Flags:
- Parameters:
tab_view (
Adw.TabView
) – The object which received the signalpage (
Adw.TabPage
) – a page of selfposition (
int
) – the position of the removed page, starting from 0
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 [signal`TabView`:py:func:::page-attached<Adw.TabView.signals.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 [method`TabView`.close_page_finish] calls.
- Adw.TabView.signals.page_reordered(tab_view, page, position)¶
- Signal Name:
page-reordered
- Flags:
- Parameters:
tab_view (
Adw.TabView
) – The object which received the signalpage (
Adw.TabPage
) – a page of selfposition (
int
) – the position page was moved to, starting at 0
Emitted after page has been reordered to position.
- Signal Name:
setup-menu
- Flags:
- Parameters:
tab_view (
Adw.TabView
) – The object which received the signalpage (
Adw.TabPage
orNone
) – a page of self
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.
Property Details¶
- Adw.TabView.props.default_icon¶
- Name:
default-icon
- Type:
- Default Value:
- Flags:
Default page icon.
If a page doesn’t provide its own icon via [property`TabPage`:py:data::icon<Adw.TabView.props.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.
[class`TabOverview`] will use default icon for pages with missing thumbnails.
By default, the
adw-tab-icon-missing-symbolic
icon is used.
- Adw.TabView.props.is_transferring_page¶
-
Whether a page is being transferred.
This property will be set to
TRUE
when a drag-n-drop tab transfer starts on anyAdwTabView
, and toFALSE
after it ends.During the transfer, children cannot receive pointer input and a tab can be safely dropped on the tab view.
- Name:
menu-model
- Type:
- Default Value:
- Flags:
Tab context menu model.
When a context menu is shown for a tab, it will be constructed from the provided menu model. Use the [signal`TabView`:py:func:::setup-menu<Adw.TabView.signals.setup_menu>] signal to set up the menu actions for the particular tab.
- Adw.TabView.props.n_pages¶
-
The number of pages in the tab view.
- Adw.TabView.props.n_pinned_pages¶
-
The number of pinned pages in the tab view.
See [method`TabView`.set_page_pinned].
- Adw.TabView.props.pages¶
- Name:
pages
- Type:
- Default Value:
- Flags:
A selection model with the tab view’s pages.
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.
- Adw.TabView.props.selected_page¶
- Name:
selected-page
- Type:
- Default Value:
- Flags:
The currently selected page.
- Adw.TabView.props.shortcuts¶
- Name:
shortcuts
- Type:
- Default Value:
Adw.TabViewShortcuts.CONTROL_TAB
|Adw.TabViewShortcuts.CONTROL_SHIFT_TAB
|Adw.TabViewShortcuts.CONTROL_PAGE_UP
|Adw.TabViewShortcuts.CONTROL_PAGE_DOWN
|Adw.TabViewShortcuts.CONTROL_HOME
|Adw.TabViewShortcuts.CONTROL_END
|Adw.TabViewShortcuts.CONTROL_SHIFT_PAGE_UP
|Adw.TabViewShortcuts.CONTROL_SHIFT_PAGE_DOWN
|Adw.TabViewShortcuts.CONTROL_SHIFT_HOME
|Adw.TabViewShortcuts.CONTROL_SHIFT_END
|Adw.TabViewShortcuts.ALT_DIGITS
|Adw.TabViewShortcuts.ALT_ZERO
|Adw.TabViewShortcuts.ALL_SHORTCUTS
- Flags:
The enabled shortcuts.
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.
New in version 1.2.