GNOME Bugzilla – Bug 458283
wrong tooltip on menutoolbutton
Last modified: 2011-02-04 16:11:04 UTC
Steps to repro: 0) item = gtk_menu_tool_button_new_from_stock (GTK_STOCK_GO_BACK); gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (item), "Go back"); gtk_menu_tool_button_set_arrow_tooltip_text (GTK_MENU_TOOL_BUTTON (item), "Back history"); gtk_widget_set_tooltip_text (GTK_WIDGET (item), "Widget tooltip"); 1) Move mouse to the drop-down arrow 2) Move mouse to the back icon 3) Move mouse directly and very quickly to the drop-down arrow 4) Move mouse slowly back to the back icon so that the button is just highlighted but the mouse pointer still at the extreme border of it (i.e. moving it one pixel to the right un-highlights the back icon button) Results: 1) No tooltip shows up on the drop-down arrow. 2) Tooltip shows up, but it's the one from gtk_widget_set_tooltip_text not the one from gtk_tool_item_set_tooltip_text 3) Tooltip shows up on the drop-down arrow! 4) No tooltip shows up
Created attachment 91976 [details] testcase
Try setting the tooltip after inserting the item into the toolbar. The problem here really is that gtk_tool_item_set_tooltIp() is setting the tooltip on its child. However, during toolbar reconfiguration (which happens when you insert this tool item), a new box is created, and the old one is replaced, and hence the tooltip is lost. Maybe this was one of the reasons for the ::set-tooltip signal? Since the ::set-tooltip handler here is setting the tooltip on the button (which is packed into the hbox), instead of on the hbox ... As a solution here we could move over the tooltip properties from one hbox to the other ... Any opinions here?
IMHO the tooltip should be transferred, yes. We can't expect the programmer to know that the tool item internas are going to be reconstructed in ways that make it lose the tooltip. And not being able to set the tooltip until the item is in a toolbar (and having to re-set it after a toolbar style change) was one of the major flaws of the old API; I'd rather not introduce it into the new API.
Created attachment 93199 [details] [review] transfer possible tooltip to new box This patch transfers a tooltip to the new box (if needed). I don't think this is the most elegant solution. As I argued before, this feels like the reason why set-tooltip was introduced as a virtual function. We really want to have this tooltip on the button here, but gtk_toolitem_set_tooltip() sets it on toolitem->child, which is an hbox in this case. There seems to be a real need to be able to set the toolitem tooltip on something else than toolitem->child. I don't think the problem of not being able to set a tooltip on a toolbar toolitem will ever return, since that required the GtkToolbar to be alive and provide a GtkTooltips structure, AFAIK. And right now, the tooltip is just a property on the object.
Does this also need to handle complex tooltips with query-tooltip ?
I don't think we need to support query-tooltip for menutoolbutton (and anyway if one connected to it, one would presumably connect to it on the menutoolbutton itself not its child, I think).
And for GtkToolItem we only have helper functions for tooltip_text and tooltip_markup to replace gtk_toolitem_set_tooltip() as well.
Committed in r18785.