# MenuButton

Marta Maria Casetti
mmcasetti@gmail.com 2012
Add tips to your widgets

# Tooltip

A toolbar with a tooltip (with an image) for a button.

# Code used to generate this example

# Useful methods for a Tooltip widget

`set_tooltip_text(text)` and `set_tooltip_markup(text)` can be used to add a tooltip of plain text (or text in the Pango Markup Language) to a widget.

For more complex tooltips, for instance for a tooltip with an image:

Set the `"has-tooltip"` property of the widget to `True`; this will make GTK+ monitor the widget for motion and related events which are needed to determine when and where to show a tooltip.

Connect to the `"query-tooltip"` signal. This signal will be emitted when a tooltip is supposed to be shown. One of the arguments passed to the signal handler is a GtkTooltip object. This is the object that we are about to display as a tooltip, and can be manipulated in your callback using functions like `set_icon()`. There are functions for setting the tooltip's markup (`set_markup(text)`), setting an image from a stock icon (`set_icon_from_stock(stock_id, size)`), or even putting in a custom widget (`set_custom(widget)`).

Return `True` from your query-tooltip handler. This causes the tooltip to be show. If you return `False`, it will not be shown.

In the probably rare case where you want to have even more control over the tooltip that is about to be shown, you can set your own GtkWindow which will be used as tooltip window. This works as follows:

Set `"has-tooltip"` and connect to `"query-tooltip"` as before.

Use `set_tooltip_window()` on the widget to set a GtkWindow created by you as tooltip window.

In the `"query-tooltip"` callback you can access your window using `get_tooltip_window()` and manipulate as you wish. The semantics of the return value are exactly as before, return `True` to show the window, `False` to not show it.

# API References

Dans cet exemple, les éléments suivants sont utilisés :

GtkTooltip

GtkToolbar

GtkWidget

Stock Items