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

static void progressbar_cb (GtkToggleButton *button, GtkWidget *pbar)
{
	g_object_set (pbar, "visible", gtk_toggle_button_get_active (button), NULL);
}

static void grip_cb (GtkToggleButton *button, GtkStatusbar *statusbar)
{
	gtk_statusbar_set_has_resize_grip (statusbar, gtk_toggle_button_get_active (button));
}

static void selectable_cb (GtkToggleButton *button, GtkStatusbar *statusbar)
{
	gtk_label_set_selectable (GTK_LABEL (statusbar->label), gtk_toggle_button_get_active (button));
}

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

	gtk_init (&argc, &argv);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

	vbox = gtk_vbox_new (FALSE, 0);
	gtk_container_add (GTK_CONTAINER (window), vbox);

	statusbar = gtk_statusbar_new ();
	gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (statusbar), FALSE);

	pbar = gtk_progress_bar_new ();
	gtk_box_pack_end (GTK_BOX (statusbar), pbar, FALSE, FALSE, 5);
	gtk_statusbar_push (GTK_STATUSBAR (statusbar),
			    gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar), "test"),
			    "Really looooooooooooooooooooooooooooooooooooooooooooooooooooooo"
			    "oooooooooooooooooooooooooooooooooooooooooooooooooooooooong text");
	gtk_box_pack_end (GTK_BOX (vbox), statusbar, FALSE, FALSE, 0);

	button = gtk_toggle_button_new_with_label ("Toggle to show/hide the progressbar widget");
	g_signal_connect (button, "toggled", G_CALLBACK (progressbar_cb), pbar);
	gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 10);

        button = gtk_toggle_button_new_with_label ("Toggle to show/hide the resize grip");
        g_signal_connect (button, "toggled", G_CALLBACK (grip_cb), statusbar);
        gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 10);
	
        button = gtk_toggle_button_new_with_label ("Toggle to make label selectable/non selectable");
        g_signal_connect (button, "toggled", G_CALLBACK (selectable_cb), statusbar);
        gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 10);

	gtk_widget_show_all (window); gtk_widget_hide (pbar);

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

	gtk_main ();

	return 0;
}
