Add tips to your widgets.
Basic tooltips can be realized simply by using the functions
gtk-widget-tooltip-text or
gtk-widget-tooltip-markup
without any explicit tooltip object.
When you need a tooltip with a little more fancy contents, like adding an
image, or you want the tooltip to have different contents per
gtk-tree-view row or cell, you will have to do a little more work:
- Set the has-tooltip property 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. The signal will be emitted when
a tooltip is supposed to be shown. One of the arguments passed to the signal handler is a gtk-tooltip object. This is the object that we
are about to display as a tooltip, and can be manipulated in your callback function using functions like the gtk-tooltip-set-icon function.
There are functions for setting the markup of the tooltip, setting an
image from a stock icon, or even putting in a 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
gtk-window
which will be used as tooltip window. This works as follows:
- Set the has-tooltip property and connect to the
"query-tooltip" signal as before.
- Use the function gtk-widget-tooltip-window to set a gtk-window created by you as tooltip window.
-
In the "query-tooltip" callback you can access your window using the function gtk-widget-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.