/* 
 * Copyright (C) 2007 Igalia
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 */

#include <gtk/gtk.h>

GtkWidget *fixed = NULL;
gint xpos = 10;
gint ypos = 10;

static void button_clicked (GtkButton *button,
                            gpointer   user_data)
{
  GtkWidget *frame = user_data;

  gtk_container_remove (GTK_CONTAINER (fixed), frame);
}

static void
spin_cb (GtkSpinButton *spin, gpointer user_data)
{
  GtkWidget *frame = user_data;
  gint value = gtk_spin_button_get_value_as_int (spin);


  gtk_fixed_move (GTK_FIXED (fixed), frame, xpos+value, ypos+value);
}

int main (int argc, char **argv)
{
  GtkWidget *window, *frame, *spin, *vbox, *remove_button, *frame_over;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_container_set_border_width (GTK_CONTAINER (window), 5);
  gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);

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

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

  fixed = gtk_fixed_new ();
  frame = gtk_frame_new ("Test");
  gtk_fixed_put (GTK_FIXED (fixed), frame, xpos, ypos+10);
  gtk_box_pack_start (GTK_BOX (vbox), fixed, TRUE, TRUE, 0);

  spin = gtk_spin_button_new_with_range (0, 200, 1);
  g_signal_connect (G_OBJECT (spin), "value-changed", G_CALLBACK (spin_cb), frame);

  gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), frame->style->ythickness);

  gtk_box_pack_start (GTK_BOX (vbox), spin, FALSE, FALSE, 0);

  remove_button = gtk_button_new_with_label ("Remove");

  gtk_box_pack_start (GTK_BOX (vbox), remove_button, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (remove_button), "clicked", G_CALLBACK (button_clicked), frame);


  frame_over = gtk_frame_new ("Frame over");
  gtk_fixed_put (GTK_FIXED (fixed), frame_over, xpos+40, ypos+30);


  frame_over = gtk_frame_new ("Frame over 2");
  gtk_fixed_put (GTK_FIXED (fixed), frame_over, xpos+20, ypos+80);

  frame_over = gtk_frame_new ("Frame over 2");
  gtk_fixed_put (GTK_FIXED (fixed), frame_over, xpos+100, ypos+100);

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}
