#include <gtkmm.h>

void on_vbox_destroyed(GtkVBox* object, gpointer data)
{
  g_warning("on_vbox_destroyed");
  g_warning("Data of GtkVBox: refcount: %d\n",
            ((GObject*)object)->ref_count);
}


class MyDialog : public Gtk::Dialog
{
public:
   MyDialog()
   {
     Gtk::VBox *vb = get_vbox();
     GtkVBox* vbo = vb->gobj();
     g_warning("Data of GtkVBox: gtkmmobject=%10X, gobject_=%10X, gtypename: %s, refcount: %d\n",
               vb,
               vbo,
               G_OBJECT_TYPE_NAME(vbo),
               ((GObject*)vbo)->ref_count);
     g_signal_connect(G_OBJECT(vbo), "destroy",
                      G_CALLBACK(on_vbox_destroyed), 0);

  }
};

class MainWin : public Gtk::Window
{
public:
  MainWin()
  {
    Gtk::Button *pB = manage(new class Gtk::Button("open"));
    add(*pB);
    pB->signal_clicked().connect( SigC::slot(*this, &MainWin::on_button_clicked) );

    show_all_children();
  }

  void on_button_clicked()
  {
    MyDialog d;
    int res = d.run();
  }

};

int main(int argc, char**argv)
{
  Gtk::Main app(&argc, &argv);

  MainWin mainwin;

  app.run(mainwin);
}
