#include <gtk/gtk.h>

static void destroy_cb (GtkDialog *dialog, gpointer data)
{
  gtk_main_quit ();
}

static void response_cb (GtkWidget *dialog, int response, gpointer data)
{
  g_print ("Response %d\n", response);
  gtk_widget_destroy(dialog);
}

static void entry_changed_cb (GtkEntry *entry, gpointer data)
{
  g_print ("Entry text is now \"%s\"\n", gtk_entry_get_text (entry));
}

static void entry_text_notify_cb(GtkEntry *entry, GParamSpec *pspec, gpointer data)
{
  char *text;
  g_object_get(entry, "text", &text, NULL);
  g_print ("Entry text property is now \"%s\"\n", text);
  g_free (text);
}

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

  window = gtk_dialog_new_with_buttons("Title", NULL, 0, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
  vbox = gtk_vbox_new (FALSE, 6);
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (window)->vbox), vbox);
  entry = gtk_entry_new ();
  g_signal_connect (entry, "changed", G_CALLBACK (entry_changed_cb), NULL);
  g_signal_connect (entry, "notify::text", G_CALLBACK (entry_text_notify_cb), NULL);
  gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
  gtk_widget_show_all (vbox);
  g_signal_connect (window, "destroy", G_CALLBACK (destroy_cb), NULL);
  g_signal_connect (window, "response", G_CALLBACK (response_cb), NULL);
  gtk_window_present (GTK_WINDOW (window));
  gtk_main ();
  return 0;
}
