[Glade-users] Best Practice for Glade.XML - open/close new window

Tristan Van Berkom tvb at gnome.org
Tue Jun 13 09:16:04 EDT 2006


Travis Staloch wrote:
> I have around 7 similar windows which are defined in a
> .glade xml file.  My app shows these windows
> consecutively as its back/next buttons are pressed. 
> The reason I'm asking about this is that the app seems
> slightly slow and has shown some funny behavior
> between opening new windows.  Can anyone spot any
> mistakes with this?
> 
> Each time I show a new window:
>   gxml = new Glade.XML(sPATH_TO_GLADE_XML,
> sWindowName, null);
>   gxml.Autoconnect (this);
>   wndCurrent =
> (Gtk.Window)gxml.GetWidget(sWindowName);
>   // ... set properties of wndCurrent ...
> 
> And when I'm done with the window:
>   gxml.Dispose();
>   wndCurrent.HideAll();
>   wndCurrent.Destroy();
>   wndCurrent.Dispose();
> 
> Thanks for any advice. 

I think calling only wndCurrent.Destroy() should be enough (it should be disposed
and hidden as a side effect).. that is besides the point...

It will be faster if you create your windows once at initialization
and just show/hide them, alternatively; you are probably better off
with a GnomeDruid type of design; if GnomeDruid is not available to you;
you can simply use a GtkNotebook and hide the tabs, use forward/backward
buttons to navigate pages in your notebook.

Cheers,
                        -Tristan

Note that libglade does a two-pass parse; it parses the glade file into
internal structures and then builds the widgets based on these, the future
gtk builder should be faster in this respect.


More information about the Glade-users mailing list