GtkStack — A stacking container
GtkWidget * | child | Read / Write / Construct Only |
char * | icon-name | Read / Write |
char * | name | Read / Write / Construct Only |
gboolean | needs-attention | Read / Write |
char * | title | Read / Write |
gboolean | use-underline | Read / Write |
gboolean | visible | Read / Write |
gboolean | hhomogeneous | Read / Write |
gboolean | interpolate-size | Read / Write |
GtkSelectionModel * | pages | Read |
guint | transition-duration | Read / Write |
gboolean | transition-running | Read |
GtkStackTransitionType | transition-type | Read / Write |
gboolean | vhomogeneous | Read / Write |
GtkWidget * | visible-child | Read / Write |
char * | visible-child-name | Read / Write |
GObject ├── GInitiallyUnowned │ ╰── GtkWidget │ ╰── GtkStack ╰── GtkStackPage
GtkStackPage implements GtkAccessible.
GtkStack implements GtkAccessible, GtkBuildable and GtkConstraintTarget.
#include <gtk/gtk.h>
The GtkStack widget is a container which only shows one of its children at a time. In contrast to GtkNotebook, GtkStack does not provide a means for users to change the visible child. Instead, the GtkStackSwitcher widget can be used with GtkStack to provide this functionality.
Transitions between pages can be animated as slides or fades. This can be controlled with gtk_stack_set_transition_type()
. These animations respect the “gtk-enable-animations” setting.
GtkStack maintains a GtkStackPage object for each added child, which holds additional per-child properties. You obtain the GtkStackPage for a child with gtk_stack_get_page()
.
To set child-specific properties in a .ui file, create GtkStackPage objects explicitly, and set the child widget as a property on it:
<object class="GtkStack" id="stack"> <child> <object class="GtkStackPage"> <property name="name">page1</property> <property name="title">In the beginning…</property> <property name="child"> <object class="GtkLabel"> <property name="label">It was dark</property> </object> </property> </object> </child>
GtkStack has a single CSS node named stack.
GtkStack uses the GTK_ACCESSIBLE_ROLE_TAB_PANEL for the stack pages, which are the accessible parent objects of the child widgets.
gboolean
gtk_stack_page_get_visible (GtkStackPage *self
);
Returns whether page
is visible in its GtkStack. This is independent from the “visible” value of its GtkWidget.
self |
TRUE
if page
is visible
void gtk_stack_page_set_visible (GtkStackPage *self
,gboolean visible
);
Sets the new value of the “visible” property to visible
.
self | ||
visible | The new property value |
const char *
gtk_stack_page_get_title (GtkStackPage *self
);
Returns the current value of the “title” property.
self |
The value of the “title” property. See gtk_stack_page_set_title()
for details on how to set a new value.
[nullable]
void gtk_stack_page_set_title (GtkStackPage *self
,const char *setting
);
Sets the new value of the “title” property. See also gtk_stack_page_get_title()
self | ||
setting | the new value to set. | [transfer none] |
const char *
gtk_stack_page_get_name (GtkStackPage *self
);
Returns the current value of the “name” property.
self |
The value of the “name” property. See gtk_stack_page_set_name()
for details on how to set a new value.
[nullable]
void gtk_stack_page_set_name (GtkStackPage *self
,const char *setting
);
Sets the new value of the “name” property. See also gtk_stack_page_get_name()
self | ||
setting | the new value to set. | [transfer none] |
gboolean
gtk_stack_page_get_needs_attention (GtkStackPage *self
);
Returns the current value of the “needs-attention” property.
self |
The value of the “needs-attention” property. See gtk_stack_page_set_needs_attention()
for details on how to set a new value.
void gtk_stack_page_set_needs_attention (GtkStackPage *self
,gboolean setting
);
Sets the new value of the “needs-attention” property. See also gtk_stack_page_get_needs_attention()
self | ||
setting | the new value to set |
gboolean
gtk_stack_page_get_use_underline (GtkStackPage *self
);
Returns the current value of the “use-underline” property.
self |
The value of the “use-underline” property. See gtk_stack_page_set_use_underline()
for details on how to set a new value.
void gtk_stack_page_set_use_underline (GtkStackPage *self
,gboolean setting
);
Sets the new value of the “use-underline” property. See also gtk_stack_page_get_use_underline()
self | ||
setting | the new value to set |
const char *
gtk_stack_page_get_icon_name (GtkStackPage *self
);
Returns the current value of the “icon-name” property.
self |
The value of the “icon-name” property. See gtk_stack_page_set_icon_name()
for details on how to set a new value.
[nullable]
void gtk_stack_page_set_icon_name (GtkStackPage *self
,const char *setting
);
Sets the new value of the “icon-name” property. See also gtk_stack_page_get_icon_name()
self | ||
setting | the new value to set. | [transfer none] |
GtkWidget *
gtk_stack_page_get_child (GtkStackPage *self
);
Returns the stack child to which self
belongs.
self |
the child to which self
belongs.
[transfer none]
GtkWidget *
gtk_stack_new (void
);
Creates a new GtkStack container.
a new GtkStack
GtkStackPage * gtk_stack_add_child (GtkStack *stack
,GtkWidget *child
);
Adds a child to stack
.
stack | a GtkStack | |
child | the widget to add |
GtkStackPage * gtk_stack_add_named (GtkStack *stack
,GtkWidget *child
,const char *name
);
Adds a child to stack
. The child is identified by the name
.
stack | a GtkStack | |
child | the widget to add | |
name | the name for | [nullable] |
GtkStackPage * gtk_stack_add_titled (GtkStack *stack
,GtkWidget *child
,const char *name
,const char *title
);
Adds a child to stack
. The child is identified by the name
. The title
will be used by GtkStackSwitcher to represent child
in a tab bar, so it should be short.
stack | a GtkStack | |
child | the widget to add | |
name | the name for | [nullable] |
title | a human-readable title for |
void gtk_stack_remove (GtkStack *stack
,GtkWidget *child
);
Removes a child widget from stack
.
stack | a GtkStack | |
child | the child to remove |
GtkWidget * gtk_stack_get_child_by_name (GtkStack *stack
,const char *name
);
Finds the child of the GtkStack with the name given as the argument. Returns NULL
if there is no child with this name.
stack | a GtkStack | |
name | the name of the child to find |
GtkStackPage * gtk_stack_get_page (GtkStack *stack
,GtkWidget *child
);
Returns the GtkStackPage object for child
.
stack | a GtkStack | |
child | a child of |
GtkSelectionModel *
gtk_stack_get_pages (GtkStack *stack
);
Returns a GListModel that contains the pages of the stack, and can be used to keep an up-to-date view. The model also implements GtkSelectionModel and can be used to track and modify the visible page.
stack | a GtkStack |
void gtk_stack_set_visible_child (GtkStack *stack
,GtkWidget *child
);
Makes child
the visible child of stack
.
If child
is different from the currently visible child, the transition between the two will be animated with the current transition type of stack
.
Note that the child
widget has to be visible itself (see gtk_widget_show()
) in order to become the visible child of stack
.
stack | a GtkStack | |
child | a child of |
GtkWidget *
gtk_stack_get_visible_child (GtkStack *stack
);
Gets the currently visible child of stack
, or NULL
if there are no visible children.
stack | a GtkStack |
void gtk_stack_set_visible_child_name (GtkStack *stack
,const char *name
);
Makes the child with the given name visible.
If child
is different from the currently visible child, the transition between the two will be animated with the current transition type of stack
.
Note that the child widget has to be visible itself (see gtk_widget_show()
) in order to become the visible child of stack
.
stack | a GtkStack | |
name | the name of the child to make visible |
const char *
gtk_stack_get_visible_child_name (GtkStack *stack
);
Returns the name of the currently visible child of stack
, or NULL
if there is no visible child.
stack | a GtkStack |
void gtk_stack_set_visible_child_full (GtkStack *stack
,const char *name
,GtkStackTransitionType transition
);
Makes the child with the given name visible.
Note that the child widget has to be visible itself (see gtk_widget_show()
) in order to become the visible child of stack
.
stack | a GtkStack | |
name | the name of the child to make visible | |
transition | the transition type to use |
void gtk_stack_set_hhomogeneous (GtkStack *stack
,gboolean hhomogeneous
);
Sets the GtkStack to be horizontally homogeneous or not. If it is homogeneous, the GtkStack will request the same width for all its children. If it isn't, the stack may change width when a different child becomes visible.
stack | a GtkStack | |
hhomogeneous |
|
gboolean
gtk_stack_get_hhomogeneous (GtkStack *stack
);
Gets whether stack
is horizontally homogeneous. See gtk_stack_set_hhomogeneous()
.
stack | a GtkStack |
whether stack
is horizontally homogeneous.
void gtk_stack_set_vhomogeneous (GtkStack *stack
,gboolean vhomogeneous
);
Sets the GtkStack to be vertically homogeneous or not. If it is homogeneous, the GtkStack will request the same height for all its children. If it isn't, the stack may change height when a different child becomes visible.
stack | a GtkStack | |
vhomogeneous |
|
gboolean
gtk_stack_get_vhomogeneous (GtkStack *stack
);
Gets whether stack
is vertically homogeneous. See gtk_stack_set_vhomogeneous()
.
stack | a GtkStack |
whether stack
is vertically homogeneous.
void gtk_stack_set_transition_duration (GtkStack *stack
,guint duration
);
Sets the duration that transitions between pages in stack
will take.
stack | a GtkStack | |
duration | the new duration, in milliseconds |
guint
gtk_stack_get_transition_duration (GtkStack *stack
);
Returns the amount of time (in milliseconds) that transitions between pages in stack
will take.
stack | a GtkStack |
the transition duration
void gtk_stack_set_transition_type (GtkStack *stack
,GtkStackTransitionType transition
);
Sets the type of animation that will be used for transitions between pages in stack
. Available types include various kinds of fades and slides.
The transition type can be changed without problems at runtime, so it is possible to change the animation based on the page that is about to become current.
stack | a GtkStack | |
transition | the new transition type |
GtkStackTransitionType
gtk_stack_get_transition_type (GtkStack *stack
);
Gets the type of animation that will be used for transitions between pages in stack
.
stack | a GtkStack |
the current transition type of stack
gboolean
gtk_stack_get_transition_running (GtkStack *stack
);
Returns whether the stack
is currently in a transition from one page to another.
stack | a GtkStack |
TRUE
if the transition is currently running, FALSE
otherwise.
gboolean
gtk_stack_get_interpolate_size (GtkStack *stack
);
Returns whether the GtkStack is set up to interpolate between the sizes of children on page switch.
stack | A GtkStack |
TRUE
if child sizes are interpolated
void gtk_stack_set_interpolate_size (GtkStack *stack
,gboolean interpolate_size
);
Sets whether or not stack
will interpolate its size when changing the visible child. If the “interpolate-size” property is set to TRUE
, stack
will interpolate its size between the current one and the one it'll take after changing the visible child, according to the set transition duration.
stack | A GtkStack | |
interpolate_size | the new value |
typedef struct _GtkStackPage GtkStackPage;
typedef struct _GtkStack GtkStack;
These enumeration values describe the possible transitions between pages in a GtkStack widget.
New values may be added to this enumeration over time.
GTK_STACK_TRANSITION_TYPE_NONE | No transition | |
GTK_STACK_TRANSITION_TYPE_CROSSFADE | A cross-fade | |
GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT | Slide from left to right | |
GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT | Slide from right to left | |
GTK_STACK_TRANSITION_TYPE_SLIDE_UP | Slide from bottom up | |
GTK_STACK_TRANSITION_TYPE_SLIDE_DOWN | Slide from top down | |
GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT | Slide from left or right according to the children order | |
GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN | Slide from top down or bottom up according to the order | |
GTK_STACK_TRANSITION_TYPE_OVER_UP | Cover the old page by sliding up | |
GTK_STACK_TRANSITION_TYPE_OVER_DOWN | Cover the old page by sliding down | |
GTK_STACK_TRANSITION_TYPE_OVER_LEFT | Cover the old page by sliding to the left | |
GTK_STACK_TRANSITION_TYPE_OVER_RIGHT | Cover the old page by sliding to the right | |
GTK_STACK_TRANSITION_TYPE_UNDER_UP | Uncover the new page by sliding up | |
GTK_STACK_TRANSITION_TYPE_UNDER_DOWN | Uncover the new page by sliding down | |
GTK_STACK_TRANSITION_TYPE_UNDER_LEFT | Uncover the new page by sliding to the left | |
GTK_STACK_TRANSITION_TYPE_UNDER_RIGHT | Uncover the new page by sliding to the right | |
GTK_STACK_TRANSITION_TYPE_OVER_UP_DOWN | Cover the old page sliding up or uncover the new page sliding down, according to order | |
GTK_STACK_TRANSITION_TYPE_OVER_DOWN_UP | Cover the old page sliding down or uncover the new page sliding up, according to order | |
GTK_STACK_TRANSITION_TYPE_OVER_LEFT_RIGHT | Cover the old page sliding left or uncover the new page sliding right, according to order | |
GTK_STACK_TRANSITION_TYPE_OVER_RIGHT_LEFT | Cover the old page sliding right or uncover the new page sliding left, according to order | |
GTK_STACK_TRANSITION_TYPE_ROTATE_LEFT | Pretend the pages are sides of a cube and rotate that cube to the left | |
GTK_STACK_TRANSITION_TYPE_ROTATE_RIGHT | Pretend the pages are sides of a cube and rotate that cube to the right | |
GTK_STACK_TRANSITION_TYPE_ROTATE_LEFT_RIGHT | Pretend the pages are sides of a cube and rotate that cube to the left or right according to the children order |
“child”
property“child” GtkWidget *
The child of the page.
Owner: GtkStackPage
Flags: Read / Write / Construct Only
“icon-name”
property“icon-name” char *
The icon name of the child page.
Owner: GtkStackPage
Flags: Read / Write
Default value: NULL
“name”
property“name” char *
The name of the child page.
Owner: GtkStackPage
Flags: Read / Write / Construct Only
Default value: NULL
“needs-attention”
property“needs-attention” gboolean
Sets a flag specifying whether the page requires the user attention. This is used by the GtkStackSwitcher to change the appearance of the corresponding button when a page needs attention and it is not the current one.
Owner: GtkStackPage
Flags: Read / Write
Default value: FALSE
“title”
property“title” char *
The title of the child page.
Owner: GtkStackPage
Flags: Read / Write
Default value: NULL
“use-underline”
property“use-underline” gboolean
If set, an underline in the title indicates the next character should be used for the mnemonic accelerator key.
Owner: GtkStackPage
Flags: Read / Write
Default value: FALSE
“visible”
property“visible” gboolean
Whether this page is visible.
Owner: GtkStackPage
Flags: Read / Write
Default value: TRUE
“hhomogeneous”
property“hhomogeneous” gboolean
TRUE
if the stack allocates the same width for all children.
Owner: GtkStack
Flags: Read / Write
Default value: TRUE
“interpolate-size”
property“interpolate-size” gboolean
Whether or not the size should smoothly change when changing between differently sized children.
Owner: GtkStack
Flags: Read / Write
Default value: FALSE
“pages”
property“pages” GtkSelectionModel *
A selection model with the stacks pages.
Owner: GtkStack
Flags: Read
“transition-duration”
property“transition-duration” guint
The animation duration, in milliseconds.
Owner: GtkStack
Flags: Read / Write
Default value: 200
“transition-running”
property“transition-running” gboolean
Whether or not the transition is currently running.
Owner: GtkStack
Flags: Read
Default value: FALSE
“transition-type”
property“transition-type” GtkStackTransitionType
The type of animation used to transition.
Owner: GtkStack
Flags: Read / Write
Default value: GTK_STACK_TRANSITION_TYPE_NONE
“vhomogeneous”
property“vhomogeneous” gboolean
TRUE
if the stack allocates the same height for all children.
Owner: GtkStack
Flags: Read / Write
Default value: TRUE
“visible-child”
property“visible-child” GtkWidget *
The widget currently visible in the stack.
Owner: GtkStack
Flags: Read / Write
“visible-child-name”
property“visible-child-name” char *
The name of the widget currently visible in the stack.
Owner: GtkStack
Flags: Read / Write
Default value: NULL
© 2005–2020 The GNOME Project
Licensed under the GNU Lesser General Public License version 2.1 or later.
https://developer.gnome.org/gtk4/4.0/GtkStack.html