Re: [gtkmm] Tooltips on Toolbuttons



On Saturday 02 October 2004 18:18, Chris Vine wrote:
> On Friday 01 October 2004 07:56, Daniel J. Lauk wrote:
> > As the signatures of set_tip are
> > <code>
> > Gtk::Tooltips::set_tip(Widget& widget, const Glib::ustring& tip_text)
> > Gtk::Tooltips::set_tip(Widget& widget, const Glib::ustring& tip_text,
> > const Glib::ustring& tip_private)
> > </code>
> > you can set a tip for any widget not just a tool button, right?
> >
> > So I want to have tool tips on a lot of things other than tool buttons
> > (text boxes, regular buttons, tree view...) and this is why I call this
> > function instead.
> >
> >
> > Still I have the problem, that none of the tool tips ever shows up, so
> > maybe my approach is wrong.
>
> That is how you do it, so you must have done something else wrong.  This
> will work so as to provide a tooltip for any widget (that is, anything
> derived from Gtk::Widget), such as a Gtk::Button object.
>
> If the things you are dealing with are buttons in a toolbar, a Gtk::Toolbar
> object has it's own in-built tooltips object which you can use to save you
> having to construct your own (in gtkmm-2.4 you can access it with
> Gtk::Toolbar::get_tooltips_object()), although there is nothing to stop you
> constructing your own additional Gtk::Tooltips object and using that
> instead. In gtkmm-2.4 the API for setting a tooltip for a button in the
> toolbar is rather curiously duplicative.  You can either use the
> Gtk::Tooltips::set_tip() method you refer to above on the Gtk::ToolButton
> object (which incidentally is not derived from Gtk::Button but is derived
> from Gtk::ToolItem), or you can use the separate method which
> Gtk::ToolButton inherits from Gtk::ToolItem, namely
> Gtk::ToolItem::set_tooltip(Gtk::Tooltips&, Glib::ustring&, Glib::ustring&).
> Both do the same thing, and in either case you would use
> Gtk::Toolbar::get_tooltips_object() to get the Gtk::Tooltips object.
>
> In gtkmm-2.0/2.2, there is no Gtk::ToolButton class, and you insert
> standard Gtk::Button objects in the toolbar.  You can set the tooltip for
> the button using Gtk::Tooltips::set_tip(), but there is no accessor
> function for the built-in tooltips object contained by the toolbar object. 
> You either have to (i) access the raw GTK+ GtkTooltips object maintained by
> the GtkToolbar struct via Gtk::Toolbar::gobj()->tooltips (this is OK, the
> tooltips member of the _GtkToolbar struct is a public member), (ii)
> construct your own Gtk::Tooltips object and use that, or more likely (iii)
> you will use the Gtk::Toolbar_Helpers::ToolList member functions which
> enable you to set the tooltip text for the button when inserting it in the
> toolbar.
>
> I prefer the gtkmm-2.0/2.2 API using Gtk::Toolbar_Helpers::ToolList, but
> this is not available in gtkmm-2.4, hence the need to mess about in the way
> described above.

Incidentally, if you are using the in-built Gtk::Tooltips object contained by 
the Gtk::Toolbar object, you need to call Gtk::Toolbar::set_tooltips(bool), 
by passing "true" to that method.  It occurs to me that the reason why your 
tooltips don't work is because you did not do that.

Chris.



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