#include <glib.h>
#include <gtk/gtk.h>

static gboolean timeout_cb (GtkWindow *window)
{
	gtk_window_present (window);
	return FALSE;
}

static gboolean hide_cb (GtkWidget *window)
{
	gtk_widget_hide (window);
	g_timeout_add (2000, (GSourceFunc) timeout_cb, window);
	return TRUE;
}

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

	gtk_init (&argc, &argv);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

	button = gtk_button_new_with_label ("Hide window!");
	g_signal_connect_swapped (button, "clicked", G_CALLBACK (hide_cb), window);
	gtk_container_add (GTK_CONTAINER (window), button);

	gtk_window_move (GTK_WINDOW (window), 300, 400);
	
	gtk_widget_show_all (window);

	g_signal_connect (window, "delete-event", G_CALLBACK (hide_cb), NULL);

	gtk_main ();

	return 0;
}
