<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Migrating from GtkTooltips to GtkTooltip: GTK+ 2 Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="GTK+ 2 Reference Manual">
<link rel="up" href="migrating.html" title="Part IV. Migrating from Previous Versions of GTK+">
<link rel="prev" href="gtk-migrating-GtkBuilder.html" title="Migrating from libglade to GtkBuilder">
<link rel="next" href="gtk-migrating-entry-icons.html" title="Migrating from SexyIconEntry to GtkEntry">
<meta name="generator" content="GTK-Doc V1.26.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="migrating.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="gtk-migrating-GtkBuilder.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="gtk-migrating-entry-icons.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="chapter">
<div class="titlepage"><div><div><h2 class="title">
<a name="gtk-migrating-tooltips"></a>Migrating from GtkTooltips to GtkTooltip</h2></div></div></div>
<p>
GTK+ 2.12 brings a completely new tooltip implementation which
allows many things that were not possible with the old
<a class="link" href="GtkTooltips.html" title="GtkTooltips"><span class="type">GtkTooltips</span></a> interface. The new possibilities are explained
in more detail in the section about <a class="link" href="GtkTooltip.html" title="GtkTooltip"><span class="type">GtkTooltip</span></a>.
</p>
<p>
A number of complications of the old API have been removed:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p>
Tooltips can not be grouped anymore. The old tooltips
API allowed this by using multiple <a class="link" href="GtkTooltips.html" title="GtkTooltips"><span class="type">GtkTooltips</span></a> objects.
We believe that the timeout behaviour of the new tooltips
implementation is better and makes it unnecessary to use
grouping as a way to overcome shortcomings of the
fast-tooltips mode.
</p></li>
<li class="listitem"><p>
Timeouts can not be set individually anymore. Instead
there are settings <a class="link" href="GtkSettings.html#GtkSettings--gtk-tooltip-timeout" title="The “gtk-tooltip-timeout” property"><span class="type">“gtk-tooltip-timeout”</span></a>,
<a class="link" href="GtkSettings.html#GtkSettings--gtk-tooltip-browse-timeout" title="The “gtk-tooltip-browse-timeout” property"><span class="type">“gtk-tooltip-browse-timeout”</span></a> and
<a class="link" href="GtkSettings.html#GtkSettings--gtk-tooltip-browse-mode-timeout" title="The “gtk-tooltip-browse-mode-timeout” property"><span class="type">“gtk-tooltip-browse-mode-timeout”</span></a> to influence
the behaviour of tooltips globally.
</p></li>
</ul></div>
<p>
</p>
<p>
Here is an example of setting a tooltip on a widget with the old API:
</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1
2</pre></td>
<td class="listing_code"><pre class="programlisting">GtkTooltips <span class="gtkdoc opt">*</span>tooltips <span class="gtkdoc opt">=</span> <span class="function"><a href="GtkTooltips.html#gtk-tooltips-new">gtk_tooltips_new</a></span> <span class="gtkdoc opt">();</span>
<span class="function"><a href="GtkTooltips.html#gtk-tooltips-set-tip">gtk_tooltips_set_tip</a></span> <span class="gtkdoc opt">(</span>tooltips<span class="gtkdoc opt">,</span> widget<span class="gtkdoc opt">,</span> <span class="string">"Some tips"</span><span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span></pre></td>
</tr>
</tbody>
</table>
</div>
<p>
</p>
<p>
Using the new tooltips API, it is no longer necessary to create
an object:
</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="function"><a href="GtkWidget.html#gtk-widget-set-tooltip-text">gtk_widget_set_tooltip_text</a></span> <span class="gtkdoc opt">(</span>widget<span class="gtkdoc opt">,</span> <span class="string">"Some tips"</span><span class="gtkdoc opt">);</span></pre></td>
</tr>
</tbody>
</table>
</div>
<p>
</p>
<p>
Similarly, setting a tooltip on a <a class="link" href="GtkToolItem.html" title="GtkToolItem"><span class="type">GtkToolItem</span></a> gets
simplified from
</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="function"><a href="GtkToolItem.html#gtk-tool-item-set-tooltip">gtk_tool_item_set_tooltip</a></span> <span class="gtkdoc opt">(</span>toolitem<span class="gtkdoc opt">,</span> toolbar<span class="gtkdoc opt">-></span>tooltips<span class="gtkdoc opt">,</span> <span class="string">"tool tip"</span><span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span></pre></td>
</tr>
</tbody>
</table>
</div>
<p>
to
</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="function"><a href="GtkToolItem.html#gtk-tool-item-set-tooltip-text">gtk_tool_item_set_tooltip_text</a></span> <span class="gtkdoc opt">(</span>toolitem<span class="gtkdoc opt">,</span> text<span class="gtkdoc opt">);</span></pre></td>
</tr>
</tbody>
</table>
</div>
<p>
</p>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.26.1</div>
</body>
</html>