Hello All,
Happy New Year to everyone. I am new to this forum!
I am starting to write an interpreter/compiler (which may generate C code dynamically and uses GTK on Linux/Debian/Sid/AMD64 with gtk2.12) which include a persistency mechanism: all the "heap" (from a particular root, in garbage collector parlance) is wriiten to a file which is reloaded at a later execution.
I am interested in being able to store most of the GTK GUI in a persistent fashion. So far, I see two options: using GtkBuilder or using GtkUIManager
The advantage of GtkBuilder is that apparently it has been designed for the very purpose of GTK serialization. Tjhe disadvantage is that it it quite new, and not very well documented.
The advantage of GtkUIManager is that it is easier for menu & buttons. Unfortunately; it cannot persist other widgets (like even partly text widgets).
My main wish is just to get several examples of GTKBuilder XML files or texts. Apparently, there are few examples!
More precisely, the following code does work as I would expect (i.e. making a menu with a single text item)
Code:
const char* xmlstr = "<interface>"
"<object class='GtkMenu' id='globalmenu'>"
"<child>"
"<object class='GtkMenuItem' id='globitem1'>"
"<child>"
"<object class='GtkLabel' id='globlab1'>"
"<property name='label'>first menu item</property>"
"</object>"
"</child>" "</object>" "</child>" "</object>" "</interface>";
gtk_builder_add_from_string (firstbuilder,
xmlstr,
(gsize) -1, &err);
But I don't really understand if I really have to name every widget with an id= attribute, even those simple widgets (like the label above) which are only the unique child of their container. I'm afraid of a namespace cluttering.
So if you have code to show, please do.
PS. My stuff will be GPL or LGPL, but it is to early to release anything.
Regards.
Basile Starynkevitch (France)