#include <gtk/gtk.h>

static void
activate (GtkApplication *app,
          gpointer        user_data)
{
  GtkWidget *window;
  GtkWidget *popup;
  GtkWidget *vbox;
  GtkWidget *text;
  GtkWidget *entry;
  GtkEntryBuffer *buffer;

  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "Window");
  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
  popup = gtk_window_new (GTK_WINDOW_POPUP);
  gtk_window_set_transient_for (GTK_WINDOW (popup), GTK_WINDOW (window));
  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
  gtk_container_add (GTK_CONTAINER (popup), vbox);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
  text = gtk_entry_new ();
  /* Create a buffer */
  buffer = gtk_entry_buffer_new (NULL, 0);

  /* Create our first entry */
  entry = gtk_entry_new_with_buffer (buffer);
  gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
  gtk_grab_add (popup);
  
  g_object_unref (buffer);
  gtk_widget_show_all (window);
  gtk_widget_show_all (popup);
}

int
main (int    argc,
      char **argv)
{
  GtkApplication *app;
  int status;

  app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
  g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
  status = g_application_run (G_APPLICATION (app), argc, argv);
  g_object_unref (app);

  return status;
}
