Icon visibility in GtkEntry

Is there a way to set visibility of the primary or secondary icon in Gtk.Entry to false? I was hoping to write an entry where the icon and tooltip shows up when invalid. But with the docs I read, the furthest I can do is to unset the icon (with the tooltip still visible).

However when using the interactive debugger, setting the icon visibility to false solves all of this. Is there a way to do this in code?

Cheers,
ltlnx

Please explain what you’re trying to achieve here.

Refer XY problem - Wikipedia.

1 Like

Sorry, I thought my question is clear enough. To address the X-Y problem: There seems to be no way to set the visible of an icon inside of a Gtk.Entry to false. Is there?

For the Y in case the first post lacks in clarity: I’m attempting to make a GtkEntry where a warning icon pops up in case of invalid data. When the icon is clicked, a popup will show to instruct how to amend the input. When the input is correct however, the icon can only be unset but not hidden, so the tooltip of the icon still shows when hovering over the blank space that the unset icon left behind.

As specified in the documentation for the following methods:

If icon / icon_name / paintable is NULL, no icon will be shown in the specified position.

So, you can set the icon and tooltip accordingly in your validation code.

Thanks! I tried that, but it crashes and throws the error

unhandled exception (type std::exception) in signal handler:
what: basic_string: construction from null is not valid

Is this expected or should I file a bug report?

Huh, set_icon_from_gicon worked with this method, but set_icon_from_icon_name crashes. Probably a bug then. Again thanks for your help.

Probably a bug then.

Not a bug. If you’re using Gtkmm, you can use the following to unset GtkEntry icon

Gtk::Entry::unset_icon (IconPosition)

Refer: gtkmm: Gtk::Entry Class Reference

1 Like