Re: A couple of basic issues regarding dialogs



On Fri, 2004-12-24 at 19:41 -0300, Ney Andr�e Mello Zunino wrote:
> 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");

I personally don't think it's very useful to throw an exception here,
because 
1. This problem should not happen.
2. There is no useful way to respond to deal with it.
3. libglademm already shows a runtime warning on the console.

But that's just personal taste.

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

Don't forget that you need to delete this dialog somewhere too.

>    // 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();

You probably men mDlgAbout->show(). run() does not return until a button
is clicked.

>    }
> 
>    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?

You might move that into a derived dialog class. Or maybe the new
GtkAboutDialog does this better - I haven't tried it yet.

> 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?

Do try gtk-list gnome if you don't get an answer to that here.

-- 
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com





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