#include <gtk/gtk.h>


static void
on_container_add (GtkContainer *container,
                  GtkWidget    *child,
                  gpointer      data)
{
  g_debug ("added %s (%p) to container %s (%p)",
           G_OBJECT_TYPE_NAME (child), (gpointer) child,
           G_OBJECT_TYPE_NAME (container), (gpointer) container);
}

static void
on_container_remove (GtkContainer *container,
                     GtkWidget    *child,
                     gpointer      data)
{
  g_debug ("removed %s (%p) from container %s (%p)",
           G_OBJECT_TYPE_NAME (child), (gpointer) child,
           G_OBJECT_TYPE_NAME (container), (gpointer) container);
}

int
main (int     argc,
      char  **argv)
{
  GtkWidget *window;
  GtkWidget *box;
  GtkWidget *widget;
  
  gtk_init (&argc, &argv);
  
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (window, "add", G_CALLBACK (on_container_add), NULL);
  g_signal_connect (window, "remove", G_CALLBACK (on_container_remove), NULL);
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
  
  box = gtk_vbox_new (FALSE, 0);
  g_signal_connect (box, "add", G_CALLBACK (on_container_add), NULL);
  g_signal_connect (box, "remove", G_CALLBACK (on_container_remove), NULL);
  gtk_container_add (GTK_CONTAINER (window), box);
  
  gtk_box_pack_start (GTK_BOX (box), gtk_label_new ("Hello"), FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (box), gtk_label_new ("World"), FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (box), gtk_label_new ("How"), FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (box), gtk_label_new ("Are"), FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (box), gtk_label_new ("You"), FALSE, TRUE, 0);
  gtk_container_add (GTK_CONTAINER (box), gtk_button_new_with_label ("this works"));
  gtk_container_add (GTK_CONTAINER (box), gtk_label_new ("this too"));
  
  gtk_widget_show_all (window);
  gtk_main ();
  
  return 0;
}
