Re: [gtkmm] Tooltips with gtkmm-2.3

On Friday 09 April 2004 17:00, Murray Cumming wrote:
> On Fri, 2004-04-09 at 15:19, Chris Vine wrote:
> > To follow up on my own post and to help any others with this problem, I
> > have found two ways of getting tooltips to work with Gtk::Toolbar:
> >
> > The hack, which uses the Gtk::Tooltips object provided by Gtk::Toolbar -
> >   Gtk::Toolbar* toolbar_p = manage(new Gtk::Toolbar);
> >   toolbar_p->set_tooltips(true);
> >   Gtk::Tooltips* tooltips_p = Glib::wrap(tool_bar.gobj()->tooltips,
> > false); Gtk::ToolButton* button_p = manage(new Gtk::ToolButton(image));
> > button_p->set_tooltip(*tooltips_p, "Tooltips text");
> Yes, I noticed this before:
> I will add a Gtk::Toolbar::get_tooltips_object() accessor. Thanks for
> reminding me. I guess that solves the problem.

The thing that slightly troubles me is that this means accessing a private 
member of struct _GtkToolbar, which you are not really supposed to do.  On 
the other hand, GTK+ has deprecated gtk_toolbar_append_item, presumably 
expecting new code to use gtk_toolbar_insert which seems to be the only 
relevant function left undeprecated (perhaps its a documentation error?), but 
it has provided no accessor function for the tooltips object which is needed 
to use gtk_tool_item_set_tooltip(), which is the only other way of setting a 
tooltip.  It seems a clear error in the GTK+ API.

I think the better course is just to wrap gtk_toolbar_append_item.  Although 
it is said to be deprecated, it is in fact the only function which can 
sensibly be used.

There are also confusingly different ways of setting a tooltip.  Translated 
from GTK+-speak into gtkmm-speak, assuming a Gtk::Tooltips object "tooltips", 
a Gtk::Button object "button" has its tooltip set with:

 tooltips.set_tip(button, "Tooltip text");

Whereas a Gtk::ToolButton object "button" with a Gtk::Tooltips object 
"tooltips" has its tooltip set with:

 button.set_tooltip(tooltips, "Tooltip text");

(With a Gtk::ToolButton object the Gtk::Button approach will not work - a 
Gtk::ToolButton is not derived from Gtk::Button and they have unrelated 
member functions.)

There is nothing gtkmm can do about this, it follows from the GTK+ API, which 
seems to have got lost somewhere down the line.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]