#include <gtk/gtk.h>


GtkAdjustment *adjustment;
GtkWidget     *label;


static void
check_value(void)
{
  gchar *text = g_strdup_printf("%f", gtk_adjustment_get_value(adjustment));

  gtk_label_set_text(GTK_LABEL(label), text);
  g_free(text);
}


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

  gtk_init(&argc, &argv);

  window      = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  vbox        = gtk_vbox_new(FALSE, 12);
  adjustment  = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, -1000.0, 1000.0,
						  1.0, 10.0, 0.0));
  spin_button = gtk_spin_button_new(adjustment, 0.0, 0);
  button      = gtk_button_new_with_mnemonic("_Check value");
  label       = gtk_label_new(NULL);

  gtk_container_add(GTK_CONTAINER(window), vbox);
  gtk_container_set_border_width(GTK_CONTAINER(window), 12);

  gtk_box_pack_start_defaults(GTK_BOX(vbox), spin_button);
  gtk_box_pack_start_defaults(GTK_BOX(vbox), button);
  gtk_box_pack_start_defaults(GTK_BOX(vbox), label);

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

  gtk_widget_show_all(window);

  gtk_main();

  return 0;
}
