Top | ![]() |
![]() |
![]() |
![]() |
GtkWidget * | child | Read / Write / Construct Only |
GIcon * | icon | Read / Write |
gboolean | indicator-activatable | Read / Write |
GIcon * | indicator-icon | Read / Write |
gboolean | loading | Read / Write |
gboolean | needs-attention | Read / Write |
HdyTabPage * | parent | Read / Write / Construct Only |
gboolean | pinned | Read |
gboolean | selected | Read |
char * | title | Read / Write |
char * | tooltip | Read / Write |
GIcon * | default-icon | Read / Write |
gboolean | is-transferring-page | Read |
GMenuModel * | menu-model | Read / Write |
int | n-pages | Read |
int | n-pinned-pages | Read |
HdyTabPage * | selected-page | Read / Write |
GtkWidget * | shortcut-widget | Read / Write |
GObject ├── GInitiallyUnowned │ ╰── GtkWidget │ ╰── GtkContainer │ ╰── GtkBin │ ╰── HdyTabView ╰── HdyTabPage
HdyTabView 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 HdyTabBar.
HdyTabView maintains a HdyTabPage object for each page,which holds
additional per-page properties. You can obtain the HdyTabPage for a page
with hdy_tab_view_get_page()
, and as return value for hdy_tab_view_append()
and other functions for adding children.
HdyTabView 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, or adding children via GtkBuilder.
HdyTabView has a main CSS node with the name tabview.
It contains the subnode overlay, which contains subnodes stack and widget. The stack subnode contains the added pages.
tabview ╰── overlay ├── stack │ ╰── [ Children ] ╰── widget
GtkWidget *
hdy_tab_page_get_child (HdyTabPage *self
);
Gets the child of self
.
Since: 1.2
HdyTabPage *
hdy_tab_page_get_parent (HdyTabPage *self
);
Gets the parent page of self
, or NULL
if the self
does not have a parent.
See hdy_tab_view_add_page()
and hdy_tab_view_close_page()
.
Since: 1.2
gboolean
hdy_tab_page_get_selected (HdyTabPage *self
);
Gets whether self
is selected. See hdy_tab_view_set_selected_page()
.
Since: 1.2
gboolean
hdy_tab_page_get_pinned (HdyTabPage *self
);
Gets whether self
is pinned. See hdy_tab_view_set_page_pinned()
.
Since: 1.2
const gchar *
hdy_tab_page_get_title (HdyTabPage *self
);
Gets the title of self
, see hdy_tab_page_set_title()
.
Since: 1.2
void hdy_tab_page_set_title (HdyTabPage *self
,const gchar *title
);
Sets the title of self
.
HdyTabBar will display it in the center of the tab representing self
unless it's pinned, and will use it as a tooltip unless “tooltip”
is set.
Since: 1.2
const gchar *
hdy_tab_page_get_tooltip (HdyTabPage *self
);
Gets the tooltip of self
, see hdy_tab_page_set_tooltip()
.
Since: 1.2
void hdy_tab_page_set_tooltip (HdyTabPage *self
,const gchar *tooltip
);
Sets the tooltip of self
, marked up with the Pango text markup language.
If not set, HdyTabBar will use “title” as a tooltip instead.
Since: 1.2
GIcon *
hdy_tab_page_get_icon (HdyTabPage *self
);
Gets the icon of self
, see hdy_tab_page_set_icon()
.
Since: 1.2
void hdy_tab_page_set_icon (HdyTabPage *self
,GIcon *icon
);
Sets the icon of self
, displayed next to the title.
HdyTabBar will not show the icon if “loading” is set to TRUE
,
or if self
is pinned and “indicator-icon” is set.
Since: 1.2
gboolean
hdy_tab_page_get_loading (HdyTabPage *self
);
Gets whether self
is loading, see hdy_tab_page_set_loading()
.
Since: 1.2
void hdy_tab_page_set_loading (HdyTabPage *self
,gboolean loading
);
Sets wether self
is loading.
If set to TRUE
, HdyTabBar will display a spinner in place of icon.
If self
is pinned and “indicator-icon” is set, the loading status
will not be visible.
Since: 1.2
GIcon *
hdy_tab_page_get_indicator_icon (HdyTabPage *self
);
Gets the indicator icon of self
, see hdy_tab_page_set_indicator_icon()
.
Since: 1.2
void hdy_tab_page_set_indicator_icon (HdyTabPage *self
,GIcon *indicator_icon
);
Sets the indicator icon of self
.
A common use case is an audio or camera indicator in a web browser.
HdyTabPage will show it at the beginning of the tab, alongside icon representing “icon” or loading spinner.
If the page is pinned, the indicator will be shown instead of icon or spinner.
If “indicator-activatable” is set to TRUE
, indicator icon
can act as a button.
Since: 1.2
gboolean
hdy_tab_page_get_indicator_activatable
(HdyTabPage *self
);
Gets whether the indicator of self
is activatable, see
hdy_tab_page_set_indicator_activatable()
.
Since: 1.2
void hdy_tab_page_set_indicator_activatable (HdyTabPage *self
,gboolean activatable
);
sets whether the indicator of self
is activatable.
If set to TRUE
, “indicator-activated” will be emitted when
the indicator is clicked.
If “indicator-icon” is not set, does nothing.
Since: 1.2
gboolean
hdy_tab_page_get_needs_attention (HdyTabPage *self
);
Gets whether self
needs attention, see hdy_tab_page_set_needs_attention()
.
Since: 1.2
void hdy_tab_page_set_needs_attention (HdyTabPage *self
,gboolean needs_attention
);
Sets whether self
needs attention.
HdyTabBar will display a glow under the tab representing self
if set to
TRUE
. If the tab is not visible, the corresponding edge of the tab bar will
be highlighted.
Since: 1.2
HdyTabView *
hdy_tab_view_new (void
);
Creates a new HdyTabView widget.
Since: 1.2
gint
hdy_tab_view_get_n_pages (HdyTabView *self
);
Gets the number of pages in self
.
Since: 1.2
gint
hdy_tab_view_get_n_pinned_pages (HdyTabView *self
);
Gets the number of pinned pages in self
.
See hdy_tab_view_set_page_pinned()
.
Since: 1.2
gboolean
hdy_tab_view_get_is_transferring_page (HdyTabView *self
);
Whether a page is being transferred.
Gets the value of “is-transferring-page” property.
Since: 1.2
HdyTabPage *
hdy_tab_view_get_selected_page (HdyTabView *self
);
Gets the currently selected page in self
.
Since: 1.2
void hdy_tab_view_set_selected_page (HdyTabView *self
,HdyTabPage *selected_page
);
Sets the currently selected page in self
.
Since: 1.2
gboolean
hdy_tab_view_select_previous_page (HdyTabView *self
);
Selects the page before the currently selected page.
If the first page was already selected, this function does nothing.
Since: 1.2
gboolean
hdy_tab_view_select_next_page (HdyTabView *self
);
Selects the page after the currently selected page.
If the last page was already selected, this function does nothing.
Since: 1.2
GIcon *
hdy_tab_view_get_default_icon (HdyTabView *self
);
Gets default icon of self
, see hdy_tab_view_set_default_icon()
.
Since: 1.2
void hdy_tab_view_set_default_icon (HdyTabView *self
,GIcon *default_icon
);
Sets default page icon for self
.
If a page doesn't provide its own icon via “icon”, default icon may be used instead for contexts where having an icon is necessary.
HdyTabBar 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, 'hdy-tab-icon-missing-symbolic' icon is used.
Since: 1.2
GMenuModel *
hdy_tab_view_get_menu_model (HdyTabView *self
);
Gets the tab context menu model for self
, see hdy_tab_view_set_menu_model()
.
Since: 1.2
void hdy_tab_view_set_menu_model (HdyTabView *self
,GMenuModel *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 “setup-menu” signal to set up the menu actions for the particular tab.
Since: 1.2
GtkWidget *
hdy_tab_view_get_shortcut_widget (HdyTabView *self
);
Gets the shortcut widget for self
, see hdy_tab_view_set_shortcut_widget()
.
Since: 1.2
void hdy_tab_view_set_shortcut_widget (HdyTabView *self
,GtkWidget *widget
);
Sets the shortcut widget for self
.
Registers the following shortcuts on widget
:
Ctrl+Page Up - switch to the previous page
Ctrl+Page Down - switch to the next page
Ctrl+Home - switch to the first page
Ctrl+End - switch to the last page
Ctrl+Shift+Page Up - move the current page backward
Ctrl+Shift+Page Down - move the current page forward
Ctrl+Shift+Home - move the current page at the start
Ctrl+Shift+End - move the current page at the end
Ctrl+Tab - switch to the next page, with looping
Ctrl+Shift+Tab - switch to the previous page, with looping
Alt+1-9 - switch to pages 1-9
Alt+0 - switch to page 10
These shortcuts are always available on self
, this function is useful if
they should be available globally.
Since: 1.2
void hdy_tab_view_set_page_pinned (HdyTabView *self
,HdyTabPage *page
,gboolean pinned
);
Pins or unpins page
.
Pinned pages are guaranteed to be placed before all non-pinned pages; at any
given moment the first “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.
HdyTabBar 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:
Pinned pages cannot be closed by default, see “close-page” for how to override that behavior.
Since: 1.2
HdyTabPage * hdy_tab_view_get_page (HdyTabView *self
,GtkWidget *child
);
Gets the HdyTabPage object representing child
.
Since: 1.2
HdyTabPage * hdy_tab_view_get_nth_page (HdyTabView *self
,gint position
);
Gets the HdyTabPage representing the child at position
.
Since: 1.2
gint hdy_tab_view_get_page_position (HdyTabView *self
,HdyTabPage *page
);
Finds the position of page
in self
, starting from 0.
Since: 1.2
HdyTabPage * hdy_tab_view_add_page (HdyTabView *self
,GtkWidget *child
,HdyTabPage *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
hdy_tab_view_close_page()
).
If parent
is NULL
, this function is equivalent to hdy_tab_view_append()
.
Since: 1.2
HdyTabPage * hdy_tab_view_insert (HdyTabView *self
,GtkWidget *child
,gint 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
hdy_tab_view_insert_pinned()
should be used instead.
Since: 1.2
HdyTabPage * hdy_tab_view_prepend (HdyTabView *self
,GtkWidget *child
);
Inserts child
as the first non-pinned page.
Since: 1.2
HdyTabPage * hdy_tab_view_append (HdyTabView *self
,GtkWidget *child
);
Inserts child
as the last non-pinned page.
Since: 1.2
HdyTabPage * hdy_tab_view_insert_pinned (HdyTabView *self
,GtkWidget *child
,gint 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 hdy_tab_view_insert()
should be used instead.
Since: 1.2
HdyTabPage * hdy_tab_view_prepend_pinned (HdyTabView *self
,GtkWidget *child
);
Inserts child
as the first pinned page.
Since: 1.2
HdyTabPage * hdy_tab_view_append_pinned (HdyTabView *self
,GtkWidget *child
);
Inserts child
as the last pinned page.
Since: 1.2
void hdy_tab_view_close_page (HdyTabView *self
,HdyTabPage *page
);
Requests to close page
.
Calling this function will result in “close-page” signal being
emitted for page
. Closing the page can then be confirmed or denied via
hdy_tab_view_close_page_finish()
.
If the page is waiting for a hdy_tab_view_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 “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.
Since: 1.2
void hdy_tab_view_close_page_finish (HdyTabView *self
,HdyTabPage *page
,gboolean confirm
);
Completes a hdy_tab_view_close_page()
call for page
.
If confirm
is TRUE
, page
will be closed. If it's FALSE
, ite will be
reverted to its previous state and hdy_tab_view_close_page()
can be called
for it again.
This function should not be called unless a custom handler for “close-page” is used.
Since: 1.2
void hdy_tab_view_close_other_pages (HdyTabView *self
,HdyTabPage *page
);
Requests to close all pages other than page
.
Since: 1.2
void hdy_tab_view_close_pages_before (HdyTabView *self
,HdyTabPage *page
);
Requests to close all pages before page
.
Since: 1.2
void hdy_tab_view_close_pages_after (HdyTabView *self
,HdyTabPage *page
);
Requests to close all pages after page
.
Since: 1.2
gboolean hdy_tab_view_reorder_page (HdyTabView *self
,HdyTabPage *page
,gint 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.
Since: 1.2
gboolean hdy_tab_view_reorder_backward (HdyTabView *self
,HdyTabPage *page
);
Reorders page
to before its previous page if possible.
Since: 1.2
gboolean hdy_tab_view_reorder_forward (HdyTabView *self
,HdyTabPage *page
);
Reorders page
to after its next page if possible.
Since: 1.2
gboolean hdy_tab_view_reorder_first (HdyTabView *self
,HdyTabPage *page
);
Reorders page
to the first possible position.
Since: 1.2
gboolean hdy_tab_view_reorder_last (HdyTabView *self
,HdyTabPage *page
);
Reorders page
to the last possible position.
Since: 1.2
void hdy_tab_view_transfer_page (HdyTabView *self
,HdyTabPage *page
,HdyTabView *other_view
,gint 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 |
||
page |
a page of |
|
other_view |
the tab view to transfer the page to |
|
position |
the position to insert the page at, starting at 0 |
Since: 1.2
GListModel *
hdy_tab_view_get_pages (HdyTabView *self
);
Returns a GListModel containing the pages of self
. This model can be used
to keep an up to date view of the pages.
Since: 1.2
“child”
property“child” GtkWidget *
The child of the page.
Owner: HdyTabPage
Flags: Read / Write / Construct Only
Since: 1.2
“icon”
property“icon” GIcon *
The icon of the page, displayed next to the title.
HdyTabBar will not show the icon if “loading” is set to TRUE
,
or if the page is pinned and “indicator-icon” is set.
Owner: HdyTabPage
Flags: Read / Write
Since: 1.2
“indicator-activatable”
property“indicator-activatable” gboolean
Whether the indicator icon is activatable.
If set to TRUE
, “indicator-activated” will be emitted when
the indicator icon is clicked.
If “indicator-icon” is not set, does nothing.
Owner: HdyTabPage
Flags: Read / Write
Default value: FALSE
Since: 1.2
“indicator-icon”
property“indicator-icon” GIcon *
An indicator icon for the page.
A common use case is an audio or camera indicator in a web browser.
HdyTabPage will show it at the beginning of the tab, alongside icon representing “icon” or loading spinner.
If the page is pinned, the indicator will be shown instead of icon or spinner.
If “indicator-activatable” is set to TRUE
, the indicator icon
can act as a button.
Owner: HdyTabPage
Flags: Read / Write
Since: 1.2
“loading”
property“loading” gboolean
Whether the page is loading.
If set to TRUE
, HdyTabBar will display a spinner in place of icon.
If the page is pinned and “indicator-icon” is set, the loading status will not be visible.
Owner: HdyTabPage
Flags: Read / Write
Default value: FALSE
Since: 1.2
“needs-attention”
property“needs-attention” gboolean
Whether the page needs attention.
HdyTabBar will display a glow under the tab representing the page if set
to TRUE
. If the tab is not visible, the corresponding edge of the tab bar
will be highlighted.
Owner: HdyTabPage
Flags: Read / Write
Default value: FALSE
Since: 1.2
“parent”
property“parent” HdyTabPage *
The parent page of the page.
See hdy_tab_view_add_page()
and hdy_tab_view_close_page()
.
Owner: HdyTabPage
Flags: Read / Write / Construct Only
Since: 1.2
“pinned”
property“pinned” gboolean
Whether the page is pinned. See hdy_tab_view_set_page_pinned()
.
Owner: HdyTabPage
Flags: Read
Default value: FALSE
Since: 1.2
“selected”
property“selected” gboolean
Whether the page is selected.
Owner: HdyTabPage
Flags: Read
Default value: FALSE
Since: 1.2
“title”
property “title” char *
The title of the page.
HdyTabBar will display it in the center of the tab unless it's pinned, and will use it as a tooltip unless “tooltip” is set.
Owner: HdyTabPage
Flags: Read / Write
Default value: NULL
Since: 1.2
“tooltip”
property “tooltip” char *
The tooltip of the page, marked up with the Pango text markup language.
If not set, HdyTabBar will use “title” as a tooltip instead.
Owner: HdyTabPage
Flags: Read / Write
Default value: NULL
Since: 1.2
“default-icon”
property“default-icon” GIcon *
Default page icon.
If a page doesn't provide its own icon via “icon”, default icon may be used instead for contexts where having an icon is necessary.
HdyTabBar 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.
Owner: HdyTabView
Flags: Read / Write
Since: 1.2
“is-transferring-page”
property“is-transferring-page” gboolean
Whether a page is being transferred.
This property will be set to TRUE
when a drag-n-drop tab transfer starts
on any HdyTabView, 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.
Owner: HdyTabView
Flags: Read
Default value: FALSE
Since: 1.2
“menu-model”
property“menu-model” GMenuModel *
Tab context menu model.
When a context menu is shown for a tab, it will be constructed from the provided menu model. Use “setup-menu” signal to set up the menu actions for the particular tab.
Owner: HdyTabView
Flags: Read / Write
Since: 1.2
“n-pages”
property “n-pages” int
The number of pages in the tab view.
Owner: HdyTabView
Flags: Read
Allowed values: >= 0
Default value: 0
Since: 1.2
“n-pinned-pages”
property “n-pinned-pages” int
The number of pinned pages in the tab view.
See hdy_tab_view_set_page_pinned()
.
Owner: HdyTabView
Flags: Read
Allowed values: >= 0
Default value: 0
Since: 1.2
“selected-page”
property“selected-page” HdyTabPage *
The currently selected page.
Owner: HdyTabView
Flags: Read / Write
Since: 1.2
“shortcut-widget”
property“shortcut-widget” GtkWidget *
Tab shortcut widget, has the following shortcuts:
Ctrl+Page Up - switch to the previous page
Ctrl+Page Down - switch to the next page
Ctrl+Home - switch to the first page
Ctrl+End - switch to the last page
Ctrl+Shift+Page Up - move the current page backward
Ctrl+Shift+Page Down - move the current page forward
Ctrl+Shift+Home - move the current page at the start
Ctrl+Shift+End - move the current page at the end
Ctrl+Tab - switch to the next page, with looping
Ctrl+Shift+Tab - switch to the previous page, with looping
Alt+1-9 - switch to pages 1-9
Alt+0 - switch to page 10
These shortcuts are always available on self
, this property is useful if
they should be available globally.
Owner: HdyTabView
Flags: Read / Write
Since: 1.2
“close-page”
signalgboolean user_function (HdyTabView *self, HdyTabPage *page, gpointer user_data)
This signal is emitted after hdy_tab_view_close_page()
has been called for
page
.
The handler is expected to call hdy_tab_view_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:
1 2 3 4 5 6 7 8 9 |
static gboolean close_page_cb (HdyTabView *view, HdyTabPage *page, gpointer user_data) { hdy_tab_view_close_page_finish (view, page, !hdy_tab_page_get_pinned (page)); return GDK_EVENT_STOP; } |
The hdy_tab_view_close_page_finish()
doesn't have to happen during 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.
Flags: Run Last
Since: 1.2
“create-window”
signalHdyTabView* user_function (HdyTabView *self, gpointer user_data)
This signal is emitted when a tab is dropped onto desktop and should be transferred into a new window.
The signal handler is expected to create a new window, position it as needed and return its HdyTabView that the page will be transferred into.
Flags: Run Last
Since: 1.2
“indicator-activated”
signalvoid user_function (HdyTabView *self, HdyTabPage *page, gpointer user_data)
This signal is emitted after the indicator icon on page
has been activated.
See “indicator-icon” and “indicator-activatable”.
Flags: Run Last
Since: 1.2
“page-attached”
signalvoid user_function (HdyTabView *self, HdyTabPage *page, int position, gpointer user_data)
This signal is 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 |
||
page |
a page of |
|
position |
the position of the page, starting from 0 |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
Since: 1.2
“page-detached”
signalvoid user_function (HdyTabView *self, HdyTabPage *page, int position, gpointer user_data)
This signal is 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
hdy_tab_view_close_page_finish()
calls.
self |
||
page |
a page of |
|
position |
the position of the removed page, starting from 0 |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
Since: 1.2
“page-reordered”
signalvoid user_function (HdyTabView *self, HdyTabPage *page, int position, gpointer user_data)
This signal is emitted after page
has been reordered to position
.
self |
||
page |
a page of |
|
position |
the position |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
Since: 1.2
“setup-menu”
signalvoid user_function (HdyTabView *self, HdyTabPage *page, gpointer user_data)
This signal is emitted before a context menu is opened for page
, and after
it's closed, in the latter case the 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 |
||
page |
a page of |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
Since: 1.2