Migrating from SexyIconEntry to GtkEntry

GTK+ 2.16 supports showing icons inside a GtkEntry, similar to SexyIconEntry. Porting from SexyIconEntry to GtkEntry is relatively straightforward. The main difference between the two APIs is that SexyIconEntry uses GtkImage widgets in a somewhat awkward way as storage vehicles for icons, while GtkEntry allows to specify icons via pixbufs, stock ids, icon names or GIcons. So, if your code uses e.g.:

1

you can get rid of the image, and directly write:

1

The signals SexyIconEntry::icon-pressed and SexyIconEntry::icon-released have been renamed to “icon-press” and “icon-release” to avoid problems due to signal name clashes. Also, the signature of the signals has changed from

1

to

1

The new signature has the advantage that the signal handler can use the timestamp of the event, e.g. for passing it to gtk_menu_popup(). When adapting an existing signal handler to the new signature, you should note that the button number is easily available as event->button, as shown in the following example:

1

can be ported as:

1

Another difference is that SexyIconEntry offers manual control of the icon prelighting, via sexy_icon_entry_set_icon_highlight(). GtkEntry prelights automatically when appropriate, depending on whether the icon is activatable and sensitive. You should make sure that your icons are properly marked as activatable or nonactivatable and sensitive or insensitive:

GtkEntry has no direct equivalent of the special-purpose function sexy_icon_entry_add_clear_button(). If you need this functionality, the following code works:

1