#include <gtk/gtk.h>

static GtkWidget *vbox = NULL;
static GtkWidget *checkbutton = NULL;
gboolean shown = TRUE;

static void
activate_cb (GtkWidget *widget, gpointer user_data)
{
    if (shown) {
        g_object_ref (G_OBJECT (checkbutton));
        gtk_container_remove (GTK_CONTAINER (vbox), checkbutton);
    } else {
        gtk_box_pack_start (GTK_BOX (vbox), checkbutton, FALSE, FALSE, 0);
        g_object_unref (G_OBJECT (checkbutton));
    }

    shown = !shown;
}

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

    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_container_set_border_width (GTK_CONTAINER (window), 10);

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

    checkbutton = gtk_check_button_new_with_label ("I display the bug");
    gtk_box_pack_start (GTK_BOX (vbox), checkbutton, FALSE, FALSE, 0);

    button = gtk_button_new_from_stock (GTK_STOCK_OK);
    g_signal_connect (G_OBJECT (button), "activate",
                      G_CALLBACK (activate_cb), NULL);
    gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

    gtk_widget_show_all (window);

    gtk_main ();

    return 0;
}
