Re: [gtkmm] some help needed for a standard process



Thx, Carl!

Actually, the ctor of FileSelection creates the Gtk::FileSelection:
m_Dialog = new Gtk::FileSelection(title);

What is my problem?



FileSelection::FileSelection(const string& title)
{
  m_Dialog = new Gtk::FileSelection(title);
  m_Dialog->set_transient_for(*this);
  m_Dialog->set_select_multiple(false);
  m_Dialog->hide_fileop_buttons();
  m_Dialog->set_filename("constraints.dat");

  int response = m_Dialog->run();
  switch(response)
  {
    case(Gtk::RESPONSE_OK):
    {
      m_selectedFile = string(m_Dialog->get_filename());
      break;
    }
    case(Gtk::RESPONSE_CANCEL):
    {
      m_selectedFile = "";
      break;
    }
  }
}


Suggestion:  this seems like it would be better as has-a instead of
is-a. Let FileSelection::ctor create the Gtk::FileSelection. getSelectedFile() can hook up the signals to destroy the Gtk::FileSel at
the appropriate time, and then call the run() on the filesel.  It can
also hook up the signal to grab the filename to be returned after run()
is done.








[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]