After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 447995 - Add a script that converts libglade files
Add a script that converts libglade files
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Class: GtkBuilder
unspecified
Other Linux
: High blocker
: ---
Assigned To: GtkBuilder maintainers
GtkBuilder maintainers
Depends on:
Blocks:
 
 
Reported: 2007-06-15 19:44 UTC by Johan (not receiving bugmail) Dahlin
Modified: 2011-02-04 16:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (10.39 KB, patch)
2007-06-15 19:53 UTC, Johan (not receiving bugmail) Dahlin
none Details | Review
Changed the converter to search internal children only when updating packings. (10.41 KB, patch)
2007-06-17 21:48 UTC, Markku Vire
none Details | Review
update patch (9.98 KB, patch)
2007-06-24 21:21 UTC, Johan (not receiving bugmail) Dahlin
none Details | Review

Description Johan (not receiving bugmail) Dahlin 2007-06-15 19:44:22 UTC
There should be a migration path for interfaces created using ui builders only supporting the libglade format.
Comment 1 Johan (not receiving bugmail) Dahlin 2007-06-15 19:53:35 UTC
Created attachment 90034 [details] [review]
patch

A python converter which can do a simple conversion of libglade/gazpacho interfaces.

Still missing menus/toolsbars -> uimanager+actions.
Comment 2 Markku Vire 2007-06-17 21:38:51 UTC
The script fails for me with the following backtrace:

Traceback (most recent call last):
  • File "/usr/local/bin/gtk-builder-convert", line 249 in ?
    main()
  • File "/usr/local/bin/gtk-builder-convert", line 245 in main
    conv.convert()
  • File "/usr/local/bin/gtk-builder-convert", line 61 in convert
    self._convert(node.getAttribute("class"), node)
  • File "/usr/local/bin/gtk-builder-convert", line 187 in _convert
    func(node)
  • File "/usr/local/bin/gtk-builder-convert", line 209 in _object_GtkNotebook
    self._packing_prop_to_child_attr(node, "type", "tab")
  • File "/usr/local/bin/gtk-builder-convert", line 97 in _packing_prop_to_child_attr
    assert len(packing_props) == 1 AssertionError

The length of packing props was 13, btw. Looks like that 

  packing_props = child.getElementsByTagName("packing")

is to blame, since it searches recursively. I understood that we are only interested the node's own packing properties here, right?
Comment 3 Markku Vire 2007-06-17 21:48:04 UTC
Created attachment 90175 [details] [review]
Changed the converter to search internal children only when updating packings.
Comment 4 Jens Granseuer 2007-06-23 14:03:26 UTC
The script fails for me when trying to convert the following file:
http://svn.gnome.org/viewcvs/gnome-control-center/trunk/capplets/appearance/appearance.glade?revision=7759&view=markup

Traceback (most recent call last):
  • File "./gtk-builder-convert.py", line 246 in ?
    main()
  • File "./gtk-builder-convert.py", line 242 in main
    conv.convert()
  • File "./gtk-builder-convert.py", line 60 in convert
    self._convert(node.getAttribute("class"), node)
  • File "./gtk-builder-convert.py", line 185 in _convert
    self._default_widget_converter(node)
  • File "./gtk-builder-convert.py", line 203 in _default_widget_converter
    "tooltip", attrs)
  • File "./gtk-builder-convert.py", line 144 in _widget_prop_to_container_obj
    assert glade_iface, ("Bad formed XML, there are "
AssertionError: Bad formed XML, there are no <glade-interface> tag.

Comment 5 Johan (not receiving bugmail) Dahlin 2007-06-24 21:21:16 UTC
Created attachment 90588 [details] [review]
update patch

I updated this script to;
* Fix the bug mentioned above
* Convert tooltips properties to tooltips-text
* Remove <accessibility> tags which we do not support yet

It still doesn't do menus so we're still not getting very far when parsing apperance.glade.
Comment 6 Johan (not receiving bugmail) Dahlin 2007-06-26 02:43:25 UTC
I committed an updated version which can also convert menus, it's getting pretty close at converting the whole control center glade file Dennis attached.

Revision 18232
Comment 7 Bogdan Nicula 2007-06-26 14:25:33 UTC
Thanks for this, but I think it doesn't support UTF8.
Comment 8 Johan (not receiving bugmail) Dahlin 2007-06-26 14:28:09 UTC
(In reply to comment #7)
> Thanks for this, but I think it doesn't support UTF8.
> 

Can you please open up a new bug and attach a file with included UTF-8 data which the script fails to parse. Thanks.
Comment 9 Bogdan Nicula 2007-06-26 14:47:01 UTC
The fix I just verified is just to tack at the end `.encode('utf-8')' on the line 355 to read:
print conv.to_xml().encode('utf-8')

Comment 10 Wouter Bolsterlee (uws) 2007-09-29 12:49:05 UTC
Perhaps this is doable as XSLT program as well?