Next: , Previous: GtkTearoffMenuItem, Up: Top


65 GtkToolbar

Create bars of buttons and other widgets

65.1 Overview

A toolbar is created with a call to gtk-toolbar-new.

A toolbar can contain instances of a subclass of <gtk-tool-item>. To add a <gtk-tool-item> 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 <gtk-tool-button>.

Toolbar items can be visually grouped by adding instances of <gtk-separator-tool-item> to the toolbar. If a <gtk-separator-tool-item> has the "expand" property set to #t and the "draw" property set to #f the effect is to force all following items to the end of the toolbar.

Creating a context menu for the toolbar can be done by connecting to the <gtk-toolbar::popup-context-menu> signal.

65.2 Usage

— Class: <gtk-toolbar>

Derives from <gtk-container>.

This class defines the following slots:

orientation
The orientation of the toolbar
toolbar-style
How to draw the toolbar
show-arrow
If an arrow should be shown if the toolbar doesn't fit
tooltips
If the tooltips of the toolbar should be active or not
icon-size
Size of icons in this toolbar
icon-size-set
Whether the icon-size property has been set
— Signal on <gtk-toolbar>: orientation-changed (arg0 <gtk-orientation>)

Emitted when the orientation of the toolbar changes.

— Signal on <gtk-toolbar>: style-changed (arg0 <gtk-toolbar-style>)

Emitted when the style of the toolbar changes.

— Signal on <gtk-toolbar>: popup-context-menu (arg0 <gint>) (arg1 <gint>) (arg2 <gint>) ⇒ <gboolean>

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.

— Signal on <gtk-toolbar>: focus-home-or-end (arg0 <gboolean>) ⇒ <gboolean>

A keybinding signal used internally by GTK+. This signal can't be used in application code

— Function: gtk-toolbar-new ⇒  (ret <gtk-widget>)

Creates a new toolbar.

ret
the newly-created toolbar.
— Function: gtk-toolbar-insert (self <gtk-toolbar>) (item <gtk-tool-item>) (pos int)
— Method: insert

Insert a <gtk-tool-item> 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.

toolbar
a <gtk-toolbar>
item
a <gtk-tool-item>
pos
the position of the new item

Since 2.4

— Function: gtk-toolbar-get-item-index (self <gtk-toolbar>) (item <gtk-tool-item>) ⇒  (ret int)
— Method: get-item-index

Returns the position of item on the toolbar, starting from 0. It is an error if item is not a child of the toolbar.

toolbar
a <gtk-toolbar>
item
a <gtk-tool-item> that is a child of toolbar
ret
the position of item on the toolbar.

Since 2.4

— Function: gtk-toolbar-get-n-items (self <gtk-toolbar>) ⇒  (ret int)
— Method: get-n-items

Returns the number of items on the toolbar.

toolbar
a <gtk-toolbar>
ret
the number of items on the toolbar

Since 2.4

— Function: gtk-toolbar-get-nth-item (self <gtk-toolbar>) (int) ⇒  (ret <gtk-tool-item>)
— Method: get-nth-item

Returns the n'th item on toolbar, or ‘#f’ if the toolbar does not contain an n'th item.

toolbar
a <gtk-toolbar>
n
A position on the toolbar
ret
The n'th <gtk-tool-item> on toolbar, or ‘#f’ if there isn't an n'th item.

Since 2.4

— Function: gtk-toolbar-get-drop-index (self <gtk-toolbar>) (int) (int) ⇒  (ret int)
— Method: get-drop-index

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.

toolbar
a <gtk-toolbar>
x
x coordinate of a point on the toolbar
y
y coordinate of a point on the toolbar
ret
The position corresponding to the point (x, y) on the toolbar.

Since 2.4

— Function: gtk-toolbar-set-drop-highlight-item (self <gtk-toolbar>) (tool_item <gtk-tool-item>) (index_ int)
— Method: set-drop-highlight-item

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 ‘#f’, 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.

toolbar
a <gtk-toolbar>
tool-item
a <gtk-tool-item>, or ‘#f’ to turn of highlighting
index
a position on toolbar

Since 2.4

— Function: gtk-toolbar-set-show-arrow (self <gtk-toolbar>) (show_arrow bool)
— Method: set-show-arrow

Sets whether to show an overflow menu when toolbar doesn't have room for all items on it. If ‘#t’, items that there are not room are available through an overflow menu.

toolbar
a <gtk-toolbar>
show-arrow
Whether to show an overflow menu

Since 2.4

— Function: gtk-toolbar-set-orientation (self <gtk-toolbar>) (orientation <gtk-orientation>)
— Method: set-orientation

Sets whether a toolbar should appear horizontally or vertically.

toolbar
a <gtk-toolbar>.
orientation
a new <gtk-orientation>.
— Function: gtk-toolbar-set-tooltips (self <gtk-toolbar>) (enable bool)
— Method: set-tooltips

Sets if the tooltips of a toolbar should be active or not.

toolbar
a <gtk-toolbar>.
enable
set to ‘#f’ to disable the tooltips, or ‘#t’ to enable them.
— Function: gtk-toolbar-get-show-arrow (self <gtk-toolbar>) ⇒  (ret bool)
— Method: get-show-arrow

Returns whether the toolbar has an overflow menu. See gtk-toolbar-set-show-arrow.

toolbar
a <gtk-toolbar>
ret
#t’ if the toolbar has an overflow menu.

Since 2.4

— Function: gtk-toolbar-get-orientation (self <gtk-toolbar>) ⇒  (ret <gtk-orientation>)
— Method: get-orientation

Retrieves the current orientation of the toolbar. See gtk-toolbar-set-orientation.

toolbar
a <gtk-toolbar>
ret
the orientation
— Function: gtk-toolbar-get-style (self <gtk-toolbar>) ⇒  (ret <gtk-toolbar-style>)
— Method: get-style

Retrieves whether the toolbar has text, icons, or both . See gtk-toolbar-set-style.

toolbar
a <gtk-toolbar>
ret
the current style of toolbar
— Function: gtk-toolbar-get-icon-size (self <gtk-toolbar>) ⇒  (ret <gtk-icon-size>)
— Method: get-icon-size

Retrieves the icon size for the toolbar. See gtk-toolbar-set-icon-size.

toolbar
a <gtk-toolbar>
ret
the current icon size for the icons on the toolbar.
— Function: gtk-toolbar-get-tooltips (self <gtk-toolbar>) ⇒  (ret bool)
— Method: get-tooltips

Retrieves whether tooltips are enabled. See gtk-toolbar-set-tooltips.

toolbar
a <gtk-toolbar>
ret
#t’ if tooltips are enabled
— Function: gtk-toolbar-get-relief-style (self <gtk-toolbar>) ⇒  (ret <gtk-relief-style>)
— Method: get-relief-style

Returns the relief style of buttons on toolbar. See gtk-button-set-relief.

toolbar
a <gtk-toolbar>
ret
The relief style of buttons on toolbar.

Since 2.4

— Function: gtk-toolbar-set-style (self <gtk-toolbar>) (style <gtk-toolbar-style>)
— Method: set-style

Alters the view of toolbar to display either icons only, text only, or both.

toolbar
a <gtk-toolbar>.
style
the new style for toolbar.
— Function: gtk-toolbar-unset-style (self <gtk-toolbar>)
— Method: unset-style

Unsets a toolbar style set with gtk-toolbar-set-style, so that user preferences will be used to determine the toolbar style.

toolbar
a <gtk-toolbar>