/*
 *
 * gcc -Wall `pkg-config --libs --cflags gtk+-2.0` -o test test.c
 *
 */

#include <gtk/gtkexpander.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkdialog.h>
#include <gtk/gtkwidget.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkvbox.h>

static void
expander_callback (GtkExpander *expander,
                   GParamSpec *param_spec,
                   GtkWidget *widget)
{
   if (gtk_expander_get_expanded (expander))
      gtk_widget_show (widget);
   else
      gtk_widget_hide (widget);
}

int
main (int argc, char **argv)
{
   GtkWidget *dialog, *expander, *label, *vbox;

   gtk_init (&argc, &argv);

   dialog = gtk_dialog_new_with_buttons ("Test", NULL, 
                                          GTK_DIALOG_NO_SEPARATOR,
                                          "Button 1", 1,
                                          "Button 2", 2,
                                          NULL);
   
   gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);

   vbox = gtk_vbox_new (FALSE, 4);
   gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),  vbox);
   gtk_widget_show (vbox);

   /* gtk_widget_set_redraw_on_allocate (vbox, TRUE); */

   expander = gtk_expander_new ("An Expander");
   gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
   gtk_container_add (GTK_CONTAINER (vbox), expander);
   gtk_widget_show (expander);

   label = gtk_label_new ("Hide the expander, then open it.\n"
                          "The text should be completly visible.");
   gtk_container_add (GTK_CONTAINER (vbox), label);
   gtk_widget_show (label);

   g_signal_connect (expander, "notify::expanded",
                     G_CALLBACK (expander_callback), label);

   gtk_dialog_run (GTK_DIALOG (dialog));

   gtk_widget_destroy (dialog);

   return 0;
}
