After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 541296 - Failing to remove a tooltip with GTKMM-2.12
Failing to remove a tooltip with GTKMM-2.12
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: general
2.12.x
Other Linux
: Normal minor
: ---
Assigned To: Jonathon Jongsma
gtkmm-forge
Depends on: 541399
Blocks:
 
 
Reported: 2008-07-02 19:15 UTC by Markus Schwab
Modified: 2011-07-20 10:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
provide unset_*() methods for tooltip-related functionality (3.92 KB, patch)
2008-07-02 20:30 UTC, Jonathon Jongsma
none Details | Review

Description Markus Schwab 2008-07-02 19:15:56 UTC
Using GTKMM 2.12.7/GTK-2.12.9 I can set/change a tool-tip for a widget with Gtk::Widget::set_tooltip_text ("Text").

What fails is removing the tool-tip. Both set_tooltip_text (Glib::ustring ()) and set_tooltip_text ("") only remove its text, but not the tool-tip itself (i.e. hoovering the mouse over the widget in question displays a small, empty (yellow) window).

When I call the respective GTK-function gtk_widget_set_tooltip_text (widget.gobj (), NULL) this works as expected (i.e. no tool-tip window is displayed).

Of course I can't call Gtk::Widget::set_tooltip_text (NULL) as this causes an exception (in Glib::ustring).

As a side-note: The deprecated Gtk::Tooltips::unset_tip also does not work (but did work, probably up to GTKMM 2.12)

Another side-note: The same problem might occur with Gtk::Widget::set_tooltip_window (), though I didn't check that.

Workarounds: Use the aforementioned gtk_widget_set_tooltip_text.
Comment 1 Jonathon Jongsma 2008-07-02 19:28:22 UTC
what about Gtk::Widget::set_has_tooltip(false)?  Does this do what you want?
Comment 2 Murray Cumming 2008-07-02 20:19:59 UTC
I guess we should check for "" and use NULL in that case in our implementation. A patch would be welcome.

Or you could patch GTK+, which should really check for this itself.
Comment 3 Jonathon Jongsma 2008-07-02 20:30:54 UTC
Created attachment 113881 [details] [review]
provide unset_*() methods for tooltip-related functionality

actually, I think we should probably provide unset_ methods for these things rather than checking for an empty string since the same issue will be true of the other properties of the tooltip (e.g. Tooltip::set_custom_widget(), set_icon(), etc).  In all of these cases, passing a NULL parameter, will disable that UI element.  So we may as well provide the same interface for the text one as well.  Here's a patch that does this.  What do you think?
Comment 4 Markus Schwab 2008-07-03 04:56:20 UTC
To answer comment #1: Gtk::Widget::set_has_tooltip(false) does work (i.e. remove the tooltip-widget)!

Thanks for the (incredible) fast reply!
Comment 5 Murray Cumming 2008-07-03 06:17:14 UTC
Yeah, the unsets probably make it even more explicit, though I still think that GTK+ just shouldn't ever show an empty tooltip.
Comment 6 Jonathon Jongsma 2008-07-03 12:57:34 UTC
well, we could provide the unset_ methods *and* check for an empty string in set_text(). But that would mean that you could set an empty string in GTK+ and not in gtkmm.  And even though it's strange to have an empty tooltip, I guess I'd rather not disallow something that can be accomplished in GTK+ unless I know for certain why they allow it.
Comment 7 Murray Cumming 2008-07-03 15:32:33 UTC
I created a patch for GTK+ in bug #541399.
Comment 8 Jonathon Jongsma 2008-07-11 10:50:54 UTC
Murray, what about the patch that I attached here?  It seems that it's still good API to add, even if the fix to GTK+ fixed the immediate issue.
Comment 9 Murray Cumming 2008-07-26 14:19:53 UTC
What would be unclear about set*("") or set*(Glib::ustring())?

It seems like we'd have to add a lot of unset*() methods here.
Comment 10 Murray Cumming 2009-04-26 22:44:11 UTC
Jonathon, do you have an opinion?
Comment 11 Murray Cumming 2011-02-21 12:11:55 UTC
Jonathon?
Comment 12 Murray Cumming 2011-07-20 10:17:59 UTC
The unset methods don't seem particularly useful.(In reply to comment #3)
> Created an attachment (id=113881) [details] [review]
> provide unset_*() methods for tooltip-related functionality

I have applied the Tooltip::unset_*() part of this, though not the unset_tip_area() because the C documentation does not say that it can be NULL or what that would mean:
http://git.gnome.org/browse/gtkmm/commit/?id=654b19a38cb820b5d18aa5d10256b162813bdf50

This is particularly useful for unsetting the icon, so it makes sense there, but I'm not sure if it's really useful for methods that can take "", now that the C implementation has been fixed to handle "" like NULL.