[Glade-devel] gtk builder and object id uniqueness



Hello Glade people!

I'm from the LinuxCNC project (www.linuxcnc.org).  We make 
free/open-source CNC machine control software for milling machines, 
lathes, 3d printers, robots, etc.  We use Glade for some of our GUIs, 
and we just ran in to a problem that I'd appreciate your input on.

One of our GUIs uses multiple .glade files and reads them into a single 
gtk builder.  This has worked well since the Ubuntu Hardy days.  But 
when we recently tried it on Ubuntu Precise and Debian Wheezy, we got 
unexpected behavior - a GtkSpinButton suddenly started using the wrong 
GtkAdjustment.

We believe the bad behavior comes from a bug in our code.  One of our 
glade files defines a GtkAdjustment with id 'adjustment1' and uses it in 
a GtkSpinButton.  Another glade file also defines a GtkAdjustment with 
id 'adjustment1' and uses it in a different GtkSpinButton.  This worked 
in Hardy and Lucid, but in Precise and Wheezy one of the GtkSpinButtons 
gets the wrong GtkAdjustment (ie, the adjustment from the other file).

GtkBuilder's add_from_file() doesn't complain, since no single file 
contains object id collisions.

Is there some way to guard against id collisions across glade files?  
Some of our glade files are managed by us, but we also have a couple of 
GUIs that can load user-provided glade files...  I tried wrapping 
add_from_file() to walk the Buildable objects already in the builder and 
compare their ids against the ids in the new glade file, but 
GtkAdjustment isn't a Buildable and i couldn't figure out how to access 
it's id.

What's the proper way to fix this id collision?  Is there any notion of 
a "local to this glade file" id namespace?

Should we simply change the id of every object in our glade files so 
they have globally unique ids?

Should we change our code to use a different gtk builder for each glade 
file?


-- 
Sebastian Kuzminsky




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