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

Travis Staloch twostepted at yahoo.com
Wed Jun 14 23:55:14 EDT 2006


Tristan,

Thanks for your help.  I've modified my code so that all of the windows are opened up at startup and then hidden/shown as needed.  This seems alot snappier than before and has helped in that regard.  However, it has caused a couple of problems.  The first, a minor problem, is that you can see all of the windows open up for a split second and then hide at startup.  Here's how each  window now gets created at init.  I'm keeping Gtk.Window references to each of the windows using this method:

protected Gtk.Window getWindowHandle(string sWindowName)
{
  Glade.XML gxml = new Glade.XML(sPATH_TO_GLADE_XML,sWindowName, null);
  gxml.Autoconnect (this);
  Gtk.Window wnd = (Gtk.Window)gxml.GetWidget(sWindowName);
  wnd.HideAll();
  gxml.Dispose();
  return wnd;
}

Is there a better way to create these windows, especially one that keeps them from being initially shown?  Also, is there a better way to use the Glade.XML rather than creating/destroying for each window I want to open?  Can I reuse the same Glade.XML and ask it for different windows?

The second problem is that some of control references don't seem to work now.  I believe that the problem results from having named all my back and next buttons the same (btnBack, btnNext).  And now that I've Autoconnect()ed to each of the windows consecutively, the last in the list is the only one which remains connected.  Does that sound right?

Thanks for any advice.  Regards,

--Travis

Tristan Van Berkom <tvb at gnome.org> wrote: 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.


 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/glade-users/attachments/20060614/c154300e/attachment.html


More information about the Glade-users mailing list