/* Compile with
gcc \
	`pkg-config --cflags gtk+-2.0 glib-2.0` \
	`pkg-config --libs gtk+-2.0 glib-2.0` \
	-o bug_351600_testcase \
	bug_351600_testcase.c
*/
#include <gtk/gtk.h>

on_destroy (GtkWidget * widget, gpointer data)
{
	gtk_main_quit ();
}

GtkWidget *label;
GtkWidget *btn;

static gboolean set_sens_again(gpointer data)
{
	gtk_widget_set_sensitive(btn, TRUE);
	gtk_label_set_text(GTK_LABEL(label), "Try to click again on the button.");
	return FALSE;
}

static void btn_clicked(GtkWidget *button, gpointer data)
{
	gtk_label_set_text(GTK_LABEL(label), "Setting the button insensitive for 1 second. Don't move your mouse.");
	gtk_widget_set_sensitive(btn, FALSE);
	g_timeout_add(1000, set_sens_again, NULL);
}

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

	gtk_init (&argc, &argv);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

	gtk_container_set_border_width (GTK_CONTAINER (window), 20);

	gtk_window_set_title (GTK_WINDOW (window), "Bug #351600");

	gtk_window_set_default_size (GTK_WINDOW (window), 400, 50);

	g_signal_connect (G_OBJECT (window), "destroy",
        	      G_CALLBACK (on_destroy), NULL);

	btn = gtk_button_new_with_label("Click me");

	label = gtk_label_new("Click the button to start\n");
	
	box = gtk_vbox_new(FALSE, 6);
	
	gtk_box_pack_start(GTK_BOX(box), btn, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
	
	gtk_container_add (GTK_CONTAINER (window), box);

	
	g_signal_connect(G_OBJECT(btn), "clicked",
			 G_CALLBACK(btn_clicked), NULL);

	gtk_widget_show_all (window);

	gtk_main ();

	return 0;
}
