GNOME Bugzilla – Bug 347637
Tooltips on toolbar broken
Last modified: 2011-02-04 16:10:42 UTC
The tooltips on the toolbar are broken with GTK 2.10. Maybe a GTK bug, filing here now so we don't forget about it.
Definitely a gtk+ problem, since I cannot reproduce this on epiphany 2.14 using gtk+ 2.8 but can when using same version with gtk 2.10. Re-assigning. This could have broken with either bug 300982 or bug 312173... Also I noticed that gtk_action_sync_tooltip is wrong: is takes the tooltip text from its private data instead of getting the property (which can be overridden in a derived class!) if (GTK_IS_TOOL_ITEM (proxy) && GTK_IS_TOOLBAR (parent)) gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (proxy), GTK_TOOLBAR (parent)->tooltips, action->private_data->tooltip, NULL);
I don't see whats wrong with using private data there. If a derived class overrides the property, it better store it to the same place.
How can a derived class store the tooltip in the same place ? It doesn't have access to the GtkAction's private_data (or am I missing something ?)
( Epiphany's bookmarks action overrides the "tooltip" property, in order to save memory (the tooltip is the location) and we really don't want to store the same potentially long string a 2nd time as tooltip. The problem that the tooltips don't work anymore is unrelated to this (since it also concerns normal toolitems), it was just something I noticed when I looked at potential sources of the problem. )
Crispin, you can "chain up the setter" by calling g_object_set (object, "BaseClass::propname", value, NULL) Christian, can you give a testcase of nonworking tooltips on toolitems ? It seems to work fine with testactions and testmerge
Chaining up will store the string in extra memory, which I don't want to do... (it's rarely used [only on tooltips on toolbar, and on statusbar on demand]) I don't have a testcase yet, but Epiphany creates a toolitem from an action, inserts into the toolbar and then calls notify on ::tooltip to get the tooltip to actually appear; while in testmerge the UI manager handles the entire toolbar...
As a workaround for your notify problem, you can simply replace g_object_notify (action, "tooltip") by g_object_get (action, "tooltip", &tooltip, NULL); g_object_set (action, "tooltip", tooltip, NULL); g_free (tooltip); For your duplicate tooltip storage problem, have you verified that it actually works to make gtk_action_sync_tooltip use g_object_get (action, "tooltip", &tooltip, NULL) instead of action->private_data->tooltip ? I'm not 100% sure if overriding the property plays nicely with g_object_get. I'm willing to do that change if you confirm that it works.
Hi, To make tooltips work on the toolbar, I had to specify the (supposedly) private tooltips of the GtkToolbar. So: /* code start */ GtkToolbar *my_toolbar = gtk_toolbar_new(); gtk_toolbar_set_tooltips( my_toolbar, TRUE ); /* ... */ GtkToolItem *item = gtk_tool_button_new_from_stock( GTK_STOC_HELP ); gtk_tool_item_set_tooltip( item, my_toolbar->tooltips, "Tip", "Private" ); /* code end */ If GtkToolbar should really have only private members, then there should be a gtk_toolbar_get_tooltips(), so you can do gtk_tool_item_set_tooltip( item, gtk_toolbar_get_tooltips( my_menubar ), "Tip", "Private" ); The current API is a bit chaotic, compared to the deprecated API. Previously, tooltips were enabled/disabled and set using gtk_toolbar methods. Now they are set with a gtk_tool_item method, in combination with data (or a future method) from gtk_toolbar. That is a bit much flipping back-and-forth in the documentation and it may take a while before a user figures out how to make tooltips on tool items work. Actually, specifying the GtkToolTips at all seems a lot of unnecessary typing, as it rarely seems useful to have several groups of tooltips for a menubar, or even all menubars in an application. If gtk_tool_item_set_tooltip() is called after gtk_toolbar_insert, it could figure out the tooltips group by itself. Alternatively, gtk_toolbar_insert() could take tooltips much like the deprecated functions do, or there could be a variant like gtk_toolbar_insert_with_tooltip(). Another alternative is to have all toolbar items in an application share the same tooltips group, so it need not be specified. Or am I supposed to define a GtkTooltips of my own and use that instead of the one in GtkToolbar? If that is the case, then gtk_toolbar_set_tooltips() should have been deprecated. Anyway, I am confused by the current API and unsure how one is supposed to code in an undeprecated way. Best regards, Bastiaan Veelo. (using 2.10.6)
*** Bug 387686 has been marked as a duplicate of this bug. ***
(FYI: Note that the toolbar will use the new tooltips API from 2.11.6 and higher).
I changed the epiphany toolbar implementation to use the new tooltips API, which fixes this problem. I think the cause was the work-around that bug 455482 will remove, so I'm closing this bug.