Re: [gtkmm] Tooltips with gtkmm-2.3



On Friday 09 April 2004 01:41, Chris Vine wrote:
> I have been trying out gtkmm-2.3.7, but I cannot work out how to get
> tooltips to show with Gtk::ToolButton objects placed in a Gtk::Toolbar. 
> The GTK+ equivalent GtkToolbar has a gtk_toolbar_append_item() function
> which has (as the third parameter) the tooltip text to be shown, but
> Gtk::Toolbar::append() does not appear to have anything equivalent to this.
>
> As a hack I have also tried indirectly to get at a Gtk::Tooltips object by
> wrapping the output of Gtk::Toolbar::gobj->tooltips, and then calling
> Gtk::Tooltips::set_tip() on the individual toolbar buttons, but whilst this
> compiles it does not actually show any tips (even after calling
> Gtk::Toolbar::set_tooltips(true).
>
> Am I missing something?

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");

Or the more kosher version which duplicates an unnecessary Gtk::Tooltips 
object -
  Gtk::Toolbar* toolbar_p = manage(new Gtk::Toolbar);
  Gtk::Tooltips* tooltips_p = manage(new Gtk::Tooltips);
  Gtk::ToolButton* button_p = manage(new Gtk::ToolButton(image));
  button_p->set_tooltip(*tooltips_p, "Tooltips text");
  tooltips_p->enable();

This seems to be a GTK+ rather than a gtkmm problem: C does not provide a 
proper access function for the GtkTooltips* member of struct _GtkToolbar.

Chris.



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