#include <gtk/gtk.h>

GtkWidget *window2;

gboolean
on_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
	gtk_widget_hide(widget);

	return TRUE;
}

void on_btn_clicked(GtkWidget *caller, gpointer data)
{
	gtk_widget_show(window2);
}

int main(int argc, char **argv)
{
	GtkWidget *window1;
	GtkWidget *button1;

	gtk_init(&argc, &argv);

	window1 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	window2 = gtk_window_new(GTK_WINDOW_TOPLEVEL);

	gtk_widget_set_sensitive(window1, TRUE);
	gtk_widget_set_sensitive(window2, FALSE);

	button1 = gtk_button_new();
	gtk_button_set_label(GTK_BUTTON(button1), "Click me!");

	gtk_container_add(GTK_CONTAINER(window1), button1);

	gtk_window_set_modal(GTK_WINDOW(window2), TRUE);
	gtk_window_set_transient_for(GTK_WINDOW(window2), GTK_WINDOW(window1));

	gtk_widget_show(button1);
	gtk_widget_show(window1);

	g_signal_connect(window2, "delete_event", on_delete_event, NULL);
	g_signal_connect(button1, "clicked", on_btn_clicked, NULL);

	gtk_main();

	return 0;
}

