On Fri, 2005-07-01 at 14:18 +, Stephen Kennedy wrote:
> I'm trying to work around this bug where old glade files do
> not load with libglade-2.4.1
> http://bugzilla.gnome.org/show_bug.cgi?id=160586
>
> One workaround is to ship two sets of glade files and
> choose which one to load based on the libglade version.
>
> Any ideas on how to programmatically determine libglade version?
> Or any other workarounds?
>
> Stephen.
Here is how I did it so far on a gentoo system. Your method for
checking the installed version will be different for a different
distribution. ver_match() pads the version strings to three digits per
so 2.4.1 would become 002.004.001-r000. "-r000" being the install
ebuild revision number. Then checks for a match in the ranges specified.
portagelib is our programs interface to the imported portage modules
(gentoo's package management system). I will most likely need to
modify the code to choose which version to use if both ranges are
installed. In gentoo I recommended that libglade-2.4.1 be masked due to
bugs and incompatibility with existing apps. I also recommended it be
slotted differently than current libglade-2 versions (which could mean
there may be up to 3 simultaneous libglade versions installed on the
system).
def check_glade():
"""determine the libglade version installed
and return the correct glade file to use"""
porthole_gladefile = "porthole.glade"
# determine glade version
versions = portagelib.get_installed("gnome-base/libglade")
if versions:
dprint(versions)
old, new = ver_match(versions, ["2.0.1","2.4.0-r99"],
["2.4.1","2.99.99"])
if old:
porthole_gladefile = "porthole.glade"
elif new:
porthole_gladefile = "porthole-new.glade"
else:
dprint("MAINWINDOW: No version list returned for libglade")
return None
dprint("MAINWINDOW: __init__(); glade file = %s" %porthole_gladefile)
return porthole_gladefile
def ver_match(versions, range1, range2 = None):
"""looks for a version match in range1 and optionaly in range2"""
if not versions:
return None
plist = pad_ver(get_versions_only(versions))
r1 = pad_ver(range1)
if range2:
r2 = pad_ver(range2)
if not plist:
dprint("VERSION_SORT: ver_match(); plist[] creation error")
return False, False
match1 = False
match2 = False
for x in plist:
if (x >= r1[0] and x <= r1[1]):
dprint("VERSION_SORT: ver_match(); match1 %s, %s:%s"
%(x,r1[0],r1[1]))
match1 = True
if range2 and (x >= r2[0] and x <= r2[1]):
dprint("VERSION_SORT: ver_match(); match2 %s, %s:%s"
%(x,r2[0],r2[1]))
match2 = True
return match1, match2
class MainWindow:
"""Main Window class to setup and manage main window interface."""
def __init__(self, preferences = None, config = None):
preferences.use_gladefile = check_glade()
# setup prefs
self.prefs = preferences
self.config = config
# setup glade
self.gladefile = self.prefs.DATA_PATH + self.prefs.use_gladefile
self.wtree = gtk.glade.XML(self.gladefile, "main_window",
self.prefs.APP)
[snip]
--
Brian <[EMAIL PROTECTED]>
___
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/