Next: , Previous: GtkSeparatorToolItem, Up: Top


68 GtkToolButton

A GtkToolItem subclass that displays buttons

68.1 Overview

<gtk-tool-button>s are <gtk-tool-items> containing buttons.

Use gtk-tool-button-new to create a new <gtk-tool-button>. Use gtk-tool-button-new-with-stock to create a <gtk-tool-button> containing a stock item.

The label of a <gtk-tool-button> is determined by the properties "label_widget", "label", and "stock_id". If "label_widget" is non-‘#f’, then that widget is used as the label. Otherwise, if "label" is non-‘#f’, that string is used as the label. Otherwise, if "stock_id" is non-‘#f’, the label is determined by the stock item. Otherwise, the button does not have a label.

The icon of a <gtk-tool-button> is determined by the properties "icon_widget" and "stock_id". If "icon_widget" is non-‘#f’, then that widget is used as the icon. Otherwise, if "stock_id" is non-‘#f’, the icon is determined by the stock item. Otherwise, the button does not have a label.

68.2 Usage

— Class: <gtk-tool-button>

Derives from <gtk-tool-item>.

This class defines the following slots:

label
Text to show in the item.
use-underline
If set, an underline in the label property indicates that the next character should be used for the mnemonic accelerator key in the overflow menu
label-widget
Widget to use as the item label
stock-id
The stock icon displayed on the item
icon-name
The name of the themed icon displayed on the item
icon-widget
Icon widget to display in the item
— Signal on <gtk-tool-button>: clicked

This signal is emitted when the tool button is clicked with the mouse or activated with the keyboard.

— Function: gtk-tool-button-new (icon_widget <gtk-widget>) (label mchars) ⇒  (ret <gtk-tool-item>)

Creates a new ‘GtkToolButton’ using icon-widget as icon and label as label.

icon-widget
a widget that will be used as icon widget, or ‘#f
label
a string that will be used as label, or ‘#f
ret
A new <gtk-tool-button>

Since 2.4

— Function: gtk-tool-button-new-from-stock (stock_id mchars) ⇒  (ret <gtk-tool-item>)

Creates a new <gtk-tool-button> containing the image and text from a stock item. Some stock ids have preprocessor macros like <gtk-stock-ok> and <gtk-stock-apply>.

It is an error if stock-id is not a name of a stock item.

stock-id
the name of the stock item
ret
A new <gtk-tool-button>

Since 2.4

— Function: gtk-tool-button-set-label (self <gtk-tool-button>) (label mchars)
— Method: set-label

Sets label as the label used for the tool button. The "label" property only has an effect if not overridden by a non-‘#f’ "label_widget" property. If both the "label_widget" and "label" properties are ‘#f’, the label is determined by the "stock_id" property. If the "stock_id" property is also ‘#f’, button will not have a label.

button
a <gtk-tool-button>
label
a string that will be used as label, or ‘#f’.

Since 2.4

— Function: gtk-tool-button-get-label (self <gtk-tool-button>) ⇒  (ret mchars)
— Method: get-label

Returns the label used by the tool button, or ‘#f’ if the tool button doesn't have a label. or uses a the label from a stock item. The returned string is owned by GTK+, and must not be modified or freed.

button
a <gtk-tool-button>
ret
The label, or ‘#f

Since 2.4

— Function: gtk-tool-button-set-use-underline (self <gtk-tool-button>) (use_underline bool)
— Method: set-use-underline

If set, an underline in the label property indicates that the next character should be used for the mnemonic accelerator key in the overflow menu. For example, if the label property is "_Open" and use-underline is ‘#t’, the label on the tool button will be "Open" and the item on the overflow menu will have an underlined 'O'.

Labels shown on tool buttons never have mnemonics on them; this property only affects the menu item on the overflow menu.

button
a <gtk-tool-button>
use-underline
whether the button label has the form "_Open"

Since 2.4

— Function: gtk-tool-button-get-use-underline (self <gtk-tool-button>) ⇒  (ret bool)
— Method: get-use-underline

Returns whether underscores in the label property are used as mnemonics on menu items on the overflow menu. See gtk-tool-button-set-use-underline.

button
a <gtk-tool-button>
ret
#t’ if underscores in the label property are used as mnemonics on menu items on the overflow menu.

Since 2.4

— Function: gtk-tool-button-set-stock-id (self <gtk-tool-button>) (stock_id mchars)
— Method: set-stock-id

Sets the name of the stock item. See gtk-tool-button-new-from-stock. The stock_id property only has an effect if not overridden by non-‘#f’ "label" and "icon_widget" properties.

button
a <gtk-tool-button>
stock-id
a name of a stock item, or ‘#f

Since 2.4

— Function: gtk-tool-button-get-stock-id (self <gtk-tool-button>) ⇒  (ret mchars)
— Method: get-stock-id

Returns the name of the stock item. See gtk-tool-button-set-stock-id. The returned string is owned by GTK+ and must not be freed or modifed.

button
a <gtk-tool-button>
ret
the name of the stock item for button.

Since 2.4

— Function: gtk-tool-button-set-icon-name (self <gtk-tool-button>) (icon_name mchars)
— Method: set-icon-name

Sets the icon for the tool button from a named themed icon. See the docs for <gtk-icon-theme> for more details. The "icon_name" property only has an effect if not overridden by non-‘#f’ "label", "icon_widget" and "stock_id" properties.

button
a <gtk-tool-button>
icon-name
the name of the themed icon

Since 2.8

— Function: gtk-tool-button-get-icon-name (self <gtk-tool-button>) ⇒  (ret mchars)
— Method: get-icon-name

Returns the name of the themed icon for the tool button, see gtk-tool-button-set-icon-name.

button
a <gtk-tool-button>
ret
the icon name or ‘#f’ if the tool button has no themed icon

Since 2.8

— Function: gtk-tool-button-set-icon-widget (self <gtk-tool-button>) (icon_widget <gtk-widget>)
— Method: set-icon-widget

Sets icon as the widget used as icon on button. If icon-widget is ‘#f’ the icon is determined by the "stock_id" property. If the "stock_id" property is also ‘#f’, button will not have an icon.

button
a <gtk-tool-button>
icon-widget
the widget used as icon, or ‘#f

Since 2.4

— Function: gtk-tool-button-get-icon-widget (self <gtk-tool-button>) ⇒  (ret <gtk-widget>)
— Method: get-icon-widget

Return the widget used as icon widget on button. See gtk-tool-button-set-icon-widget.

button
a <gtk-tool-button>
ret
The widget used as icon on button, or ‘#f’.

Since 2.4

— Function: gtk-tool-button-set-label-widget (self <gtk-tool-button>) (label_widget <gtk-widget>)
— Method: set-label-widget

Sets label-widget as the widget that will be used as the label for button. If label-widget is ‘#f’ the "label" property is used as label. If "label" is also ‘#f’, the label in the stock item determined by the "stock_id" property is used as label. If "stock_id" is also ‘#f’, button does not have a label.

button
a <gtk-tool-button>
label-widget
the widget used as label, or ‘#f

Since 2.4

— Function: gtk-tool-button-get-label-widget (self <gtk-tool-button>) ⇒  (ret <gtk-widget>)
— Method: get-label-widget

Returns the widget used as label on button. See gtk-tool-button-set-label-widget.

button
a <gtk-tool-button>
ret
The widget used as label on button, or ‘#f’.

Since 2.4