
#include <gtkmm/main.h>
#include <gtkmm/window.h>
#include <gtkmm/dialog.h>
#include <gtkmm/button.h>

class MyDialog: public Gtk::Dialog
{
public:
  MyDialog()
  {
    Gtk::Button *pB = manage(new class Gtk::Button("close"));
    get_action_area()->pack_start(*pB);
    get_vbox()->set_spacing(0);
    pB->show();
    pB->signal_clicked().connect(SigC::slot(*this, &MyDialog::on_button_clicked));
    
  }
  void on_button_clicked()
  {
    hide();
    response(Gtk::RESPONSE_CANCEL);
  }
};

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));
  }

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

};

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

  MainWin mainwin;
  mainwin.show_all_children();

  app.run(mainwin);
}
