Converting GTK 1.2 glade XML file to something glade can now read

1.4k views Asked by At

In old project I wrote circa 2000 I have a glade file that I would like to convert to something glade can now read, and I will use in PyGtk. I have scoured SO for similar questions and see things for the code changes, but I am just interested right now in converting the glade file.

When I run gtk-builder-convert I get Python traceback:

Traceback (most recent call last):
  File "/usr/bin/gtk-builder-convert", line 799, in <module>
     sys.exit(main(sys.argv))
      File "/usr/bin/gtk-builder-convert", line 787, in main
   conv.parse_file(input_filename)
  File "/usr/bin/gtk-builder-convert", line 162, in parse_file
    self._parse()
  File "/usr/bin/gtk-builder-convert", line 234, in _parse
   assert glade_iface, ("Badly formed XML, there is "
AssertionError: Badly formed XML, there is no <glade-interface> tag.

which is indeed true. The file starts:

<?xml version="1.0"?>
<GTK-Interface>

Suggestions?

3

There are 3 answers

0
rocky On BEST ANSWER

Thanks to the information from ebassi, what I wound up doing is running libglade-convert to get this to gtk 2.0 and then gtk-builder-convert to go the rest of the way. Of course there were lots of errors and it is imperfect, but its a start.

1
pythoner On

It worked on Linux for me using Gtk3+ and Glade3+ installed from conda by following steps.

  1. Open your Gtk1+ older glade XML file designed in Glade1+ user interface in Glade3+ user interface.
  2. Click on Save button in Glade3+ user interface.
  3. Open terminal to conda activate gtk-builder-convert infile outfile.

Good Luck!

0
ebassi On

If your XML file starts with GTK-Interface then it means it you were using GTK+ 1.2.

It's very unlikely you can mechanically transform such an old Glade file into something that can be used with modern API — even if you constrain yourself to the legacy 2.0 version of the GTK+ API. Your UI description will contain deprecated properties, signals, and classes — and there is no direct, 1:1 mapping for those.

The last time the XML format for the UI definition was changed was 2007, with the introduction of GtkBuilder, but the format was heavily based on the Glade XML for GTK+ 2.0, to the point that a simple mechanical script like gtk-builder-convert could transform the older format into the new one. Your XML predates even that.