[Gtk-sharp-list] glade autoconnect strangeness

Peter Williams peter@newton.cx
Fri, 14 Jan 2005 17:25:25 -0500


Hi,

This is the expected behavior if you look at the code: gtk-
sharp/glade/XML.custom. Basically, when you call Autoconnect(), it
iterates through all fields with the [Widget] attribute and sets them
with a GetWidget() call. So any [Widget] attribute that doesn't
correspond to a defined widget in the current XML file will be nulled
out.

You could argue whether this is desirable behavior or not (it would be
easy to not clear the field if it's already non-null). But it's not hard
to work around. Usually people just have a one-to-one mapping between
XML files and classes. It shouldn't be hard to define an inner class
that takes care of your dialog box.

Peter

On Fri, 2005-01-14 at 03:16 -0800, Adam Lydick wrote:
> I noticed some strange behavior with Glade# (libglade-cil , version
> 1.0.4).
> 
> If I wire up widget references with .Autoconnect from more than one
> top-level widget to a single class, the second instance seems to clobber
> the mappings of the previous one. (eg: the old references are set to
> "null" before the first .Autoconnect and after the second, but not after
> the first.)
> 
> Am I imagining things? Or is this how it is supposed to work?
> 
> A snippit of my broken code follows:
> 
> //load winMain
> 
> //my [Glade.Widget] instanceVar is null here.
> 
> Glade.XML gxml = 
> 	new Glade.XML (null, "cashflow.glade", "winMain", null);
> gxml.Autoconnect (this); 
> 	    
> //my [Glade.Widget] instanceVar is NOT null here.
> 	
> //FIXME: glade clobbers old autoconnected entries on the 2nd pass...
> //load winDateRange (a popup window on winMain)
> //gxml = new Glade.XML (null, "cashflow.glade", "winDateRange", null);
> //gxml.Autoconnect(this);
> 
> //my [Glade.Widget] instanceVar is null here, if not used by
> winDateRange
> 
> Thanks again,
> 
-- 
Peter Williams                          peter@newton.cx

"[Ninjas] are cool; and by cool, I mean totally sweet."
                              -- REAL Ultimate Power