/*
    Compile with:
    gcc `pkg-config --cflags gtk+-3.0` -o entry entry.c `pkg-config --libs gtk+-3.0`
*/

#include <gtk/gtk.h>

void
on_insert_text (GtkEditable *editable,
                gchar       *new_text,
                gint         new_text_length,
                gpointer     position,
                gpointer     user_data)
{
  g_print ("Text inserted\n");
}

int
main (int   argc,
char *argv[])
{
  GtkWidget *window;
  GtkWidget *entry;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

  entry = gtk_entry_new ();
  g_signal_connect (entry, "insert-text", G_CALLBACK (on_insert_text), NULL);
  gtk_entry_set_text(GTK_ENTRY (entry), "Hello World");
  gtk_container_add (GTK_CONTAINER (window), entry);  

  gtk_widget_show (entry);
  gtk_widget_show (window);

  gtk_main ();

  return 0;
}

