A couple of basic issues regarding dialogs



Hello.

I reckon even beginners will be able to tackle this one. I am working on my first real-life GTKmm application, using Glade to design the interface and libglademm to load the widgets.

Besides my application's main window, I decided to add an 'about' window. So, back in Glade, I added a Dialog window with a single 'OK' button and added the about contents to its vbox. Then I used the code below to do the appropriate widget loading and signal binding:

  // 'About' menu item
  refGlade->get_widget("mnuAbout", menuItem);
  if (! menuItem)
    throw std::runtime_error("Widget not found: mnuAbout");
  menuItem->signal_activate().connect(
    sigc::mem_fun(*this, &BdlexMainWindow::mnuAboutActivated));

  // About dialog
  refGlade->get_widget("dlgAbout", mDlgAbout);
  if (! mDlgAbout)
    throw std::runtime_error("Widget not found: dlgAbout");

  // About dialog's 'OK' button
  refGlade->get_widget("butOkAbout", button);
  if (! button)
    throw std::runtime_error("Widget not found: butOkAbout");
  button->signal_clicked().connect(
    sigc::mem_fun(*this, &BdlexMainWindow::butOkAboutClicked));

  void BdlexMainWindow::mnuAboutActivated()
  {
    mDlgAbout->run();
  }

  void BdlexMainWindow::butOkAboutClicked()
  {
    mDlgAbout->hide();
  }

My question is whether there is a more straightforward or shorter way, especially with regards to the dialog's standard 'OK' button. Do I really have to write a handler member function just to order the dialog to hide?

Another issue I found with the about dialog is that, when I set it to be non-resizable, only its horizontal size remains constant; it is still possible to change its vertical size in run time. Could anyone suggest what I might be missing?

Thank you,

--
Ney André de Mello Zunino




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