#include <gtk/gtk.h>

static void
on_icon_press (GtkEntry             *entry,
               GtkEntryIconPosition  icon_pos,
               GdkEvent             *event,
               gpointer              user_data)
{
  static gboolean warn = FALSE;

  gtk_entry_set_icon_tooltip_text (entry, icon_pos, warn ? "a warning" : NULL);
  gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_PRIMARY,
                                     warn ? "dialog-warning-symbolic" : "object-select-symbolic");

  warn = !warn;
}

int
main (int argc, char **argv)
{
  gtk_init (&argc, &argv);

  GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  GtkWidget *entry = gtk_entry_new ();
  gtk_entry_set_icon_from_icon_name ((GtkEntry *)entry, GTK_ENTRY_ICON_PRIMARY,
                                     "dialog-question-symbolic");
  gtk_widget_set_tooltip_text (entry, "overall tooltip");
  g_signal_connect (entry, "icon-press", (GCallback) on_icon_press, NULL);
  gtk_container_add ((GtkContainer *)window, entry);
  gtk_widget_show_all (window);

  gtk_main ();
}
