Top |
Functions
Properties
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 |
Implemented Interfaces
GtkStackPage implements GtkAccessible.
GtkStack implements GtkAccessible, GtkBuildable and GtkConstraintTarget.
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.
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()
.
GtkStack as GtkBuildable
To set child-specific properties in a .ui file, create GtkStackPage objects explicitly, and set the child widget as a property on it:
1 2 3 4 5 6 7 8 9 10 11 12 |
<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> |
Accessibility
GtkStack uses the GTK_ACCESSIBLE_ROLE_TAB_PANEL for the stack pages, which are the accessible parent objects of the child widgets.
Functions
gtk_stack_page_get_visible ()
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.
gtk_stack_page_set_visible ()
void gtk_stack_page_set_visible (GtkStackPage *self
,gboolean visible
);
Sets the new value of the “visible” property
to visible
.
gtk_stack_page_get_title ()
const char *
gtk_stack_page_get_title (GtkStackPage *self
);
Returns the current value of the “title” property.
Returns
The value of the “title” property.
See gtk_stack_page_set_title()
for details on how to set a new value.
[nullable]
gtk_stack_page_set_title ()
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()
gtk_stack_page_get_name ()
const char *
gtk_stack_page_get_name (GtkStackPage *self
);
Returns the current value of the “name” property.
Returns
The value of the “name” property.
See gtk_stack_page_set_name()
for details on how to set a new value.
[nullable]
gtk_stack_page_set_name ()
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()
gtk_stack_page_get_needs_attention ()
gboolean
gtk_stack_page_get_needs_attention (GtkStackPage *self
);
Returns the current value of the “needs-attention” property.
Returns
The value of the “needs-attention” property.
See gtk_stack_page_set_needs_attention()
for details on how to set a new value.
gtk_stack_page_set_needs_attention ()
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()
gtk_stack_page_get_use_underline ()
gboolean
gtk_stack_page_get_use_underline (GtkStackPage *self
);
Returns the current value of the “use-underline” property.
Returns
The value of the “use-underline” property.
See gtk_stack_page_set_use_underline()
for details on how to set a new value.
gtk_stack_page_set_use_underline ()
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()
gtk_stack_page_get_icon_name ()
const char *
gtk_stack_page_get_icon_name (GtkStackPage *self
);
Returns the current value of the “icon-name” property.
Returns
The value of the “icon-name” property.
See gtk_stack_page_set_icon_name()
for details on how to set a new value.
[nullable]
gtk_stack_page_set_icon_name ()
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()
gtk_stack_page_get_child ()
GtkWidget *
gtk_stack_page_get_child (GtkStackPage *self
);
Returns the stack child to which self
belongs.
gtk_stack_add_child ()
GtkStackPage * gtk_stack_add_child (GtkStack *stack
,GtkWidget *child
);
Adds a child to stack
.
gtk_stack_add_named ()
GtkStackPage * gtk_stack_add_named (GtkStack *stack
,GtkWidget *child
,const char *name
);
Adds a child to stack
.
The child is identified by the name
.
gtk_stack_add_titled ()
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.
Parameters
stack |
a GtkStack |
|
child |
the widget to add |
|
name |
the name for |
[nullable] |
title |
a human-readable title for |
gtk_stack_remove ()
void gtk_stack_remove (GtkStack *stack
,GtkWidget *child
);
Removes a child widget from stack
.
gtk_stack_get_child_by_name ()
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.
gtk_stack_get_page ()
GtkStackPage * gtk_stack_get_page (GtkStack *stack
,GtkWidget *child
);
Returns the GtkStackPage object for child
.
gtk_stack_get_pages ()
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.
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
.
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.
gtk_stack_set_visible_child_name ()
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
.
gtk_stack_get_visible_child_name ()
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.
gtk_stack_set_visible_child_full ()
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
.
Parameters
stack |
a GtkStack |
|
name |
the name of the child to make visible |
|
transition |
the transition type to use |
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.
gtk_stack_get_hhomogeneous ()
gboolean
gtk_stack_get_hhomogeneous (GtkStack *stack
);
Gets whether stack
is horizontally homogeneous.
See gtk_stack_set_hhomogeneous()
.
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.
gtk_stack_get_vhomogeneous ()
gboolean
gtk_stack_get_vhomogeneous (GtkStack *stack
);
Gets whether stack
is vertically homogeneous.
See gtk_stack_set_vhomogeneous()
.
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.
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.
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.
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
.
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.
gtk_stack_get_interpolate_size ()
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.
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.
Types and Values
enum GtkStackTransitionType
These enumeration values describe the possible transitions between pages in a GtkStack widget.
New values may be added to this enumeration over time.
Members
No transition |
||
A cross-fade |
||
Slide from left to right |
||
Slide from right to left |
||
Slide from bottom up |
||
Slide from top down |
||
Slide from left or right according to the children order |
||
Slide from top down or bottom up according to the order |
||
Cover the old page by sliding up |
||
Cover the old page by sliding down |
||
Cover the old page by sliding to the left |
||
Cover the old page by sliding to the right |
||
Uncover the new page by sliding up |
||
Uncover the new page by sliding down |
||
Uncover the new page by sliding to the left |
||
Uncover the new page by sliding to the right |
||
Cover the old page sliding up or uncover the new page sliding down, according to order |
||
Cover the old page sliding down or uncover the new page sliding up, according to order |
||
Cover the old page sliding left or uncover the new page sliding right, according to order |
||
Cover the old page sliding right or uncover the new page sliding left, according to order |
||
Pretend the pages are sides of a cube and rotate that cube to the left |
||
Pretend the pages are sides of a cube and rotate that cube to the right |
||
Pretend the pages are sides of a cube and rotate that cube to the left or right according to the children order |
Property Details
The “child”
property
“child” GtkWidget *
The child of the page.
Owner: GtkStackPage
Flags: Read / Write / Construct Only
The “icon-name”
property
“icon-name” char *
The icon name of the child page.
Owner: GtkStackPage
Flags: Read / Write
Default value: NULL
The “name”
property
“name” char *
The name of the child page.
Owner: GtkStackPage
Flags: Read / Write / Construct Only
Default value: NULL
The “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
The “title”
property
“title” char *
The title of the child page.
Owner: GtkStackPage
Flags: Read / Write
Default value: NULL
The “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
The “visible”
property
“visible” gboolean
Whether this page is visible.
Owner: GtkStackPage
Flags: Read / Write
Default value: TRUE
The “hhomogeneous”
property
“hhomogeneous” gboolean
TRUE
if the stack allocates the same width for all children.
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 “pages”
property
“pages” GtkSelectionModel *
A selection model with the stacks pages.
Owner: GtkStack
Flags: Read
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
The “visible-child”
property
“visible-child” GtkWidget *
The widget currently visible in the stack.
Owner: GtkStack
Flags: Read / Write