Jacob Kroon wrote:
Hi, I'm looking for a way to serialize GObject-derived classes into XML. I'm basically writing a block-diagram editor, similar to Simulink/Matlab, where I have a Diagram class, and diff. block classes, and I'd like to be able to save the diagrams to a file, so my idea is to implement a way to serialize the blocks and the diagram. All interesting attributes are implemented as GObject attributes, so if I can could implement block_to_xml() and diagram_to_xml() functions, things would work out nicely I think. Of course I would have to go the other way too, when loading diagrams, xml_to_block() and xml_to_diagram(). The trouble is I don't really know where to start, is this something that has been documented elsewhere, or does anyone know of some example code or ideas I could look into? My initial idea is to implement some sort of GObject serializer, which outputs the classname, and the same for all properties the GObject has registered.
Well, you can look at the glade-3 & libglade source, which basicly does exactly what you want (if I understand correctly), but also implements an editor. Particularly, look at glade-property-class.c & glade-widget-class.c from glade-3 (glade3 in gnome cvs) and look at glade-xml.c from libglade. Cheers, -Tristan _______________________________________________ gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list