#include <gtk/gtk.h>

static void
dialog_cb (GtkButton *button, gpointer data)
{
  GtkWidget *widget;
  GtkWidget *toplevel;

  toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
  widget = gtk_message_dialog_new (NULL,
                                   GTK_DIALOG_MODAL,
                                   GTK_MESSAGE_QUESTION,
                                   GTK_BUTTONS_OK,
                                   "No choice here");
  gtk_widget_realize (widget);
  gdk_window_set_transient_for (gtk_widget_get_window (widget), gtk_widget_get_window (toplevel));
  gtk_dialog_run (GTK_DIALOG (widget));
  gtk_widget_destroy (widget);
}

static void
test_cb (GtkButton *button, gpointer data)
{
  g_print ("test clicked\n");
}

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

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_container_add (GTK_CONTAINER (window), box);
  button = gtk_button_new_with_label ("dialog");
  g_signal_connect (button, "clicked", G_CALLBACK (dialog_cb), NULL);
  gtk_container_add (GTK_CONTAINER (box), button);
  button = gtk_button_new_with_label ("test");
  g_signal_connect (button, "clicked", G_CALLBACK (test_cb), NULL);
  gtk_container_add (GTK_CONTAINER (box), button);

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}
