How to use Glade XML file to generate c++ code for GTK?

Viewed 3574

I know how to use Glade generated XML file (*.glade) and to load it in c++ code. But for educational purpose I need to see the c++ source code alternative to the XML file. I just want to see the same GUI (made on Glade with output in XML format), but in c++ source code with the GTK+ library classes explicitly defined.

Meanwhile I've found this tool and hopefully it is compatible with the latest Glade XML code.

2 Answers

The only way I do it is to make a c file with glib-compile-resource and add it as a resource. Note glib-compile-resource only compiles resources listed /defined in a defined xml file. You have to create resources.xml. All you do is regenerate the c file and add it to your program. with gcc resource.c youprogram.cpp etc. In your code use builder->add_from_resouce. See Glade and Builder. That way you dont have to worry about generating cpp files.

While it is not what you have asked for, maybe GtkInspector will help. It allows to inspect native Gtk at runtime and manipulate it, you can gain insights ("What was actually applied to Gtk?") and modify internals on the fly - without recompiling.

It can be compared to Web Inspector from WebKit.

Related