#include <gtk/gtk.h>

#include <string.h>
#include <stdio.h>

static void
on_entry_changed(GtkEntry* entry, void* data)
{
  const gchar* text = gtk_entry_get_text(entry);
  printf("Entry changed: %s\n", text);
}

static void
on_entry_editing_done(GtkEntry* entry, void* data)
{
  const gchar* text = gtk_entry_get_text(entry);
  printf("Entry editing done: %s\n", text);
}

static void
on_entry_activate(GtkEntry* entry, void* data)
{
  const gchar* text = gtk_entry_get_text(entry);
  printf("Entry activate: %s\n", text);
}

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

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_container_set_border_width (GTK_CONTAINER (window), 5);
  g_signal_connect (window, "destroy", gtk_main_quit, NULL);

  /* GtkEntry */
  entry = gtk_entry_new ();
  gtk_container_add (GTK_CONTAINER (window), entry);

  g_signal_connect (entry, "changed", G_CALLBACK (on_entry_changed), NULL);
  g_signal_connect (entry, "editing-done", G_CALLBACK (on_entry_editing_done), NULL);
  g_signal_connect (entry, "activate", G_CALLBACK (on_entry_activate), NULL);

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}

