Description
A toolbar is created with a call to gtk_toolbar_new().
A toolbar can contain instances of a subclass of GtkToolItem. To add
a GtkToolItem to the a toolbar, use gtk_toolbar_insert(). To remove
an item from the toolbar use gtk_container_remove(). To add a button
to the toolbar, add an instance of GtkToolButton.
Toolbar items can be visually grouped by adding instances of
GtkSeparatorToolItem to the toolbar. If the GtkToolbar child property
“expand” is TRUE and the property “draw” is set to
FALSE, the effect is to force all following items to the end of the toolbar.
By default, a toolbar can be shrunk, upon which it will add an arrow button
to show an overflow menu offering access to any GtkToolItem child that has
a proxy menu item. To disable this and request enough size for all children,
call gtk_toolbar_set_show_arrow() to set “show-arrow” to FALSE.
Creating a context menu for the toolbar can be done by connecting to
the “popup-context-menu” signal.
CSS nodes
GtkToolbar has a single CSS node with name toolbar.
Functions
gtk_toolbar_new ()
GtkWidget *
gtk_toolbar_new (void);
Creates a new toolbar.
Returns
the newly-created toolbar.
gtk_toolbar_insert ()
void
gtk_toolbar_insert (GtkToolbar *toolbar,
GtkToolItem *item,
gint pos);
Insert a GtkToolItem into the toolbar at position pos
. If pos
is
0 the item is prepended to the start of the toolbar. If pos
is
negative, the item is appended to the end of the toolbar.
Since: 2.4
gtk_toolbar_get_item_index ()
gint
gtk_toolbar_get_item_index (GtkToolbar *toolbar,
GtkToolItem *item);
Returns the position of item
on the toolbar, starting from 0.
It is an error if item
is not a child of the toolbar.
Returns
the position of item on the toolbar.
Since: 2.4
gtk_toolbar_get_n_items ()
gint
gtk_toolbar_get_n_items (GtkToolbar *toolbar);
Returns the number of items on the toolbar.
Returns
the number of items on the toolbar
Since: 2.4
gtk_toolbar_get_nth_item ()
GtkToolItem *
gtk_toolbar_get_nth_item (GtkToolbar *toolbar,
gint n);
Returns the n
'th item on toolbar
, or NULL if the
toolbar does not contain an n
'th item.
Returns
The n
'th GtkToolItem on toolbar
,
or NULL if there isn’t an n
'th item.
[nullable][transfer none]
Since: 2.4
gtk_toolbar_get_drop_index ()
gint
gtk_toolbar_get_drop_index (GtkToolbar *toolbar,
gint x,
gint y);
Returns the position corresponding to the indicated point on
toolbar
. This is useful when dragging items to the toolbar:
this function returns the position a new item should be
inserted.
x
and y
are in toolbar
coordinates.
Returns
The position corresponding to the point (x
, y
) on the toolbar.
Since: 2.4
gtk_toolbar_set_drop_highlight_item ()
void
gtk_toolbar_set_drop_highlight_item (GtkToolbar *toolbar,
GtkToolItem *tool_item,
gint index_);
Highlights toolbar
to give an idea of what it would look like
if item
was added to toolbar
at the position indicated by index_
.
If item
is NULL, highlighting is turned off. In that case index_
is ignored.
The tool_item
passed to this function must not be part of any widget
hierarchy. When an item is set as drop highlight item it can not
added to any widget hierarchy or used as highlight item for another
toolbar.
Since: 2.4
gtk_toolbar_set_show_arrow ()
void
gtk_toolbar_set_show_arrow (GtkToolbar *toolbar,
gboolean show_arrow);
Sets whether to show an overflow menu when toolbar
isn’t allocated enough
size to show all of its items. If TRUE, items which can’t fit in toolbar
,
and which have a proxy menu item set by gtk_tool_item_set_proxy_menu_item()
or “create-menu-proxy”, will be available in an overflow menu,
which can be opened by an added arrow button. If FALSE, toolbar
will
request enough size to fit all of its child items without any overflow.
Since: 2.4
gtk_toolbar_unset_icon_size ()
void
gtk_toolbar_unset_icon_size (GtkToolbar *toolbar);
Unsets toolbar icon size set with gtk_toolbar_set_icon_size(), so that
user preferences will be used to determine the icon size.
gtk_toolbar_get_relief_style ()
GtkReliefStyle
gtk_toolbar_get_relief_style (GtkToolbar *toolbar);
Returns the relief style of buttons on toolbar
. See
gtk_button_set_relief().
Returns
The relief style of buttons on toolbar
.
Since: 2.4
gtk_toolbar_set_style ()
void
gtk_toolbar_set_style (GtkToolbar *toolbar,
GtkToolbarStyle style);
Alters the view of toolbar
to display either icons only, text only, or both.
gtk_toolbar_set_icon_size ()
void
gtk_toolbar_set_icon_size (GtkToolbar *toolbar,
GtkIconSize icon_size);
This function sets the size of stock icons in the toolbar. You
can call it both before you add the icons and after they’ve been
added. The size you set will override user preferences for the default
icon size.
This should only be used for special-purpose toolbars, normal
application toolbars should respect the user preferences for the
size of icons.
gtk_toolbar_unset_style ()
void
gtk_toolbar_unset_style (GtkToolbar *toolbar);
Unsets a toolbar style set with gtk_toolbar_set_style(), so that
user preferences will be used to determine the toolbar style.
Property Details
The “icon-size” property
“icon-size” GtkIconSize
The size of the icons in a toolbar is normally determined by
the toolbar-icon-size setting. When this property is set, it
overrides the setting.
This should only be used for special-purpose toolbars, normal
application toolbars should respect the user preferences for the
size of icons.
Owner: GtkToolbar
Flags: Read / Write
Default value: GTK_ICON_SIZE_LARGE_TOOLBAR
Since: 2.10
The “icon-size-set” property
“icon-size-set” gboolean
Is TRUE if the icon-size property has been set.
Owner: GtkToolbar
Flags: Read / Write
Default value: FALSE
Since: 2.10
The “show-arrow” property
“show-arrow” gboolean
If an arrow should be shown if the toolbar doesn't fit.
Owner: GtkToolbar
Flags: Read / Write
Default value: TRUE
The “toolbar-style” property
“toolbar-style” GtkToolbarStyle
How to draw the toolbar.
Owner: GtkToolbar
Flags: Read / Write
Default value: GTK_TOOLBAR_BOTH_HORIZ
Style Property Details
The “button-relief” style property
“button-relief” GtkReliefStyle
Type of bevel around toolbar buttons.
Owner: GtkToolbar
Flags: Read
Default value: GTK_RELIEF_NONE
The “internal-padding” style property
“internal-padding” gint
Amount of border space between the toolbar shadow and the buttons.
GtkToolbar:internal-padding has been deprecated since version 3.6 and should not be used in newly-written code.
Use the standard padding CSS property
(through objects like GtkStyleContext and GtkCssProvider); the value
of this style property is ignored.
Owner: GtkToolbar
Flags: Read
Allowed values: >= 0
Default value: 0
The “max-child-expand” style property
“max-child-expand” gint
Maximum amount of space an expandable item will be given.
Owner: GtkToolbar
Flags: Read
Allowed values: >= 0
Default value: 2147483647
The “shadow-type” style property
“shadow-type” GtkShadowType
Style of bevel around the toolbar.
GtkToolbar:shadow-type has been deprecated since version 3.6 and should not be used in newly-written code.
Use the standard border CSS property
(through objects like GtkStyleContext and GtkCssProvider); the value
of this style property is ignored.
Owner: GtkToolbar
Flags: Read
Default value: GTK_SHADOW_OUT
The “space-size” style property
“space-size” gint
Size of toolbar spacers.
GtkToolbar:space-size has been deprecated since version 3.20 and should not be used in newly-written code.
Use the standard margin/padding CSS properties on the
separator elements; the value of this style property is ignored.
Owner: GtkToolbar
Flags: Read
Allowed values: >= 0
Default value: 12
The “space-style” style property
“space-style” GtkToolbarSpaceStyle
Style of toolbar spacers.
GtkToolbar:space-style has been deprecated since version 3.20 and should not be used in newly-written code.
Use CSS properties on the separator elements to style
toolbar spacers; the value of this style property is ignored.
Owner: GtkToolbar
Flags: Read
Default value: GTK_TOOLBAR_SPACE_LINE
Signal Details
The “focus-home-or-end” signal
gboolean
user_function (GtkToolbar *toolbar,
gboolean focus_home,
gpointer user_data)
A keybinding signal used internally by GTK+. This signal can't
be used in application code
Returns
TRUE if the signal was handled, FALSE if not
Flags: Action
The “popup-context-menu” signal
gboolean
user_function (GtkToolbar *toolbar,
gint x,
gint y,
gint button,
gpointer user_data)
Emitted when the user right-clicks the toolbar or uses the
keybinding to display a popup menu.
Application developers should handle this signal if they want
to display a context menu on the toolbar. The context-menu should
appear at the coordinates given by x
and y
. The mouse button
number is given by the button
parameter. If the menu was popped
up using the keybaord, button
is -1.
Returns
return TRUE if the signal was handled, FALSE if not
Flags: Run Last