Description
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.
The GtkStack widget was added in GTK+ 3.10.
CSS nodes
GtkStack has a single CSS node named stack.
Functions
gtk_stack_add_named ()
void
gtk_stack_add_named (GtkStack *stack,
GtkWidget *child,
const gchar *name);
Adds a child to stack
.
The child is identified by the name
.
Since: 3.10
gtk_stack_add_titled ()
void
gtk_stack_add_titled (GtkStack *stack,
GtkWidget *child,
const gchar *name,
const gchar *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.
Since: 3.10
gtk_stack_get_child_by_name ()
GtkWidget *
gtk_stack_get_child_by_name (GtkStack *stack,
const gchar *name);
Finds the child of the GtkStack with the name given as
the argument. Returns NULL if there is no child with this
name.
Returns
the requested child of the GtkStack.
[transfer none][nullable]
Since: 3.12
gtk_stack_set_visible_child ()
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
.
Since: 3.10
gtk_stack_get_visible_child ()
GtkWidget *
gtk_stack_get_visible_child (GtkStack *stack);
Gets the currently visible child of stack
, or NULL if
there are no visible children.
Returns
the visible child of the GtkStack.
[transfer none][nullable]
Since: 3.10
gtk_stack_set_visible_child_name ()
void
gtk_stack_set_visible_child_name (GtkStack *stack,
const gchar *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
.
Since: 3.10
gtk_stack_get_visible_child_name ()
const gchar *
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.
Returns
the name of the visible child of the GtkStack.
[transfer none][nullable]
Since: 3.10
gtk_stack_set_visible_child_full ()
void
gtk_stack_set_visible_child_full (GtkStack *stack,
const gchar *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
.
Since: 3.10
gtk_stack_set_homogeneous ()
void
gtk_stack_set_homogeneous (GtkStack *stack,
gboolean homogeneous);
Sets the GtkStack to be homogeneous or not. If it
is homogeneous, the GtkStack will request the same
size for all its children. If it isn't, the stack
may change size when a different child becomes visible.
Since 3.16, homogeneity can be controlled separately
for horizontal and vertical size, with the
“hhomogeneous” and “vhomogeneous”.
Since: 3.10
gtk_stack_set_hhomogeneous ()
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.
Since: 3.16
gtk_stack_set_vhomogeneous ()
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.
Since: 3.16
gtk_stack_set_transition_duration ()
void
gtk_stack_set_transition_duration (GtkStack *stack,
guint duration);
Sets the duration that transitions between pages in stack
will take.
Since: 3.10
gtk_stack_get_transition_duration ()
guint
gtk_stack_get_transition_duration (GtkStack *stack);
Returns the amount of time (in milliseconds) that
transitions between pages in stack
will take.
Returns
the transition duration
Since: 3.10
gtk_stack_set_transition_type ()
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.
Since: 3.10
gtk_stack_get_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
.
Returns
the current transition type of stack
Since: 3.10
gtk_stack_get_transition_running ()
gboolean
gtk_stack_get_transition_running (GtkStack *stack);
Returns whether the stack
is currently in a transition from one page to
another.
Returns
TRUE if the transition is currently running, FALSE otherwise.
Since: 3.12
gtk_stack_get_interpolate_size ()
gboolean
gtk_stack_get_interpolate_size (GtkStack *stack);
Returns wether the GtkStack is set up to interpolate between
the sizes of children on page switch.
Returns
TRUE if child sizes are interpolated
Since: 3.18
gtk_stack_set_interpolate_size ()
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.
Since: 3.18
Property Details
The “hhomogeneous” property
“hhomogeneous” gboolean
TRUE if the stack allocates the same width for all children.
Owner: GtkStack
Flags: Read / Write
Default value: TRUE
Since: 3.16
The “homogeneous” property
“homogeneous” gboolean
Homogeneous sizing.
Owner: GtkStack
Flags: Read / Write
Default value: TRUE
The “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
The “transition-duration” property
“transition-duration” guint
The animation duration, in milliseconds.
Owner: GtkStack
Flags: Read / Write
Default value: 200
The “transition-running” property
“transition-running” gboolean
Whether or not the transition is currently running.
Owner: GtkStack
Flags: Read
Default value: FALSE
The “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
The “vhomogeneous” property
“vhomogeneous” gboolean
TRUE if the stack allocates the same height for all children.
Owner: GtkStack
Flags: Read / Write
Default value: TRUE
Since: 3.16
The “visible-child” property
“visible-child” GtkWidget *
The widget currently visible in the stack.
Owner: GtkStack
Flags: Read / Write
The “visible-child-name” property
“visible-child-name” gchar *
The name of the widget currently visible in the stack.
Owner: GtkStack
Flags: Read / Write
Default value: NULL