/*
 * compile with:
gcc -o maximize `pkg-config --cflags --libs gtk+-2.0` maximize.c
 */

#include <gtk/gtk.h>

static void
short_button_clicked_cb (GtkButton * button, gpointer user_data)
{
  GtkWidget *vbox;
  GtkWidget *label;

  vbox = GTK_WIDGET (user_data);
  label = gtk_label_new ("Did that make the window fill the screen?");
  gtk_widget_show (label);
  gtk_box_pack_start_defaults (GTK_BOX (vbox), label);
}

static void
long_button_clicked_cb (GtkButton * button, gpointer user_data)
{
  GtkWidget *vbox;
  GtkWidget *label;

  vbox = GTK_WIDGET (user_data);
  label = gtk_label_new ("Did that not make the window fill the screen"
			 " because it's longer?");
  gtk_widget_show (label);
  gtk_box_pack_start_defaults (GTK_BOX (vbox), label);
}

int
main (int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget *vbox;
  GtkWidget *label;
  GtkWidget *button;
  GtkWidget *button_box;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (G_OBJECT (window), "destroy",
		    G_CALLBACK (gtk_main_quit), 0);
  g_signal_connect (G_OBJECT (window), "delete_event",
		    G_CALLBACK (gtk_main_quit), 0);

  gtk_window_set_default_size (GTK_WINDOW (window), 300, 200);
  gtk_window_maximize (GTK_WINDOW (window));

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

  label = gtk_label_new ("Unmaximize the window, then click a button");
  gtk_box_pack_start_defaults (GTK_BOX (vbox), label);

  button_box = gtk_hbutton_box_new ();
  gtk_button_box_set_layout (GTK_BUTTON_BOX (button_box),
			     GTK_BUTTONBOX_CENTER);
  gtk_box_pack_end_defaults (GTK_BOX (vbox), button_box);

  button = gtk_button_new_with_label ("Click me for a short label");
  gtk_box_pack_start_defaults (GTK_BOX (button_box), button);
  g_signal_connect (button, "clicked", G_CALLBACK (short_button_clicked_cb),
		    vbox);

  button = gtk_button_new_with_label ("Click me for a long label");
  gtk_box_pack_start_defaults (GTK_BOX (button_box), button);
  g_signal_connect (button, "clicked", G_CALLBACK (long_button_clicked_cb),
		    vbox);

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}
