Gtk2Hs, Glade, Multiple windows/dialog in one interface file.

Is it possible to have multiple windows in a glade file, and display only one when the program starts, then show/hide the others as the need arises ? I can't find how... I have a main window with a menu. One entry shows the about dialog which is also defined in the glade file : aboutmenu <- xmlGetWidget xml castToMenuItem "apropos1" onActivateLeaf aboutmenu $ do widgetShowAll aboutdialog My problems are multiple : 1) how do I handle the close button that is automatically generated ? I tried doing this ... aboutdialog <- xmlGetWidget xml castToAboutDialog "aboutdialog1" onDestroy aboutdialog $ do widgetHide aboutdialog But the Close button doesn't work, and if I close the about dialog by the upper right cross button, it does disappear, but if I select again the menuitem, then a tiny empty dialog opens, as if the about dialog has been stripped out of all his inner components. And I get this line : (<interactive>:10852): Gtk-CRITICAL **: gtk_container_foreach: assertion `GTK_IS_CONTAINER (container)' failed I tried looking at the demos, but it doesn't help. The closest that could have helped uses an about dialog it creates, instead of reading from a glade file.

On Jul 8, 2007, at 15:37 , D.V. wrote:
Is it possible to have multiple windows in a glade file, and display only one when the program starts, then show/hide the others as the need arises ?
You can but it's not well documented. I found that it was necessary to load the window each time you need it. (you must re-load the XML each time)
(Just g) <- xmlNewWithRootAndDomain (pathLoad ++ "hwatchmwp.glade") (Just "vwin") Nothing w <- xmlGetWidget g castToDialog "vwin"
(I assume it'll work because it did at program startup. Arguably I should actually do error checking instead...) I *think* the right way to handle the close button is the onDelete (not onDestroy which happens far too late to back out) handler. (I just noticed that I'm not actually handling it, where I'd thought I was. Oops.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

On Jul 8, 2007, at 16:00 , D.V. wrote:
I'm not sure I understand xmlNewWithRootAndDomain, I'll make some tests.
I found that it was necessary to load the window each time you need it. (you must re-load the XML each time)
I was hoping I could only hide the dialog and not destroy it.
As I mentioned afterward, try hiding it in the OnDelete hook. (And return True (I think) so the standard handler doesn't go ahead and destroy the window afterward.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

Oh ! Okay I tried and YOU ROCK ! Thanks a lot. Now it hides and comes back at will. But I still can't react to that Close button that's automatically added to that About Dialog. Here's my latest (random) try : aboutdialog <- xmlGetWidget xml castToAboutDialog "aboutdialog1" onDelete aboutdialog $ \event -> do widgetHide aboutdialog return True onResponse aboutdialog $ \resp -> do case resp of ResponseClose -> widgetHide aboutdialog otherwise -> return ()

On Jul 8, 2007, at 16:24 , D.V. wrote:
But I still can't react to that Close button that's automatically added to that About Dialog.
Here's my latest (random) try :
aboutdialog <- xmlGetWidget xml castToAboutDialog "aboutdialog1" onDelete aboutdialog $ \event -> do widgetHide aboutdialog return True onResponse aboutdialog $ \resp -> do case resp of ResponseClose -> widgetHide aboutdialog otherwise -> return ()
That looks reasonable to me, unfortunately I'd guess the dialog already got dealt with in the stock Close button handler. You might need to dig inside the AboutDialog and install your own onClicked handler on the Close button. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
participants (2)
-
Brandon S. Allbery KF8NH
-
D.V.