what gtkaml is not
Updated nov. 2010
I noticed that the first reaction when people hear about gtkaml is “But GtkBuilder/glade already does this!” or “How is gtkaml better than glade?” or something along these lines.
Let me put this straight: there is no resemblance between gtkaml and glade (other than using markup). None. They are not mutually exclusive, and do not do the same thing.
You can tell this by looking at them!
what they are
First, libglade is a library (and GtkBuilder comes bundled with Gtk+). You link against it and it parses your UI markup at runtime.. Glade is also a visual editor for that markup.
On the other side, gtkaml is a preprocessor. Your markup becomes code, Vala code, which and eventually becomes static C code.
glade and GtkBuilder can be used from many different programming languages.
gtkaml is only available for Vala. However, libraries created with Vala can be used from any language.
run-time vs compile-time
GtkBuilder and glade make it possible to change the UI markup without compiling. This is because they call Gtk+ functions from libgtk, functions determined at runtime.
gtkaml only knows what you meant when compiling – it uses Vala’s AST to do this. You have to recompile to change the UI, therefore.
GtkBuilder and glade have their own markup which is verbose and usually must be written by means of an interactive tool (glade).
Every new Gtk property or class must have Glade/GtkBuilder support for it to work.
gtkaml simply maps tag names to classes and tag attributes to properties/fields/signals.
Because of the run-time capabilities, GtkBuilder and glade require you to export your signal handlers from your own executable, like an .so/.dll does, or to write GtkBuilderConnectFunc’s for them.
gtkaml simply uses Vala’s signal .connect() which translates into g_signal_connect () function calls.
GtkBuilder requires calling gtk_builder_get_object (“by name”) to get a reference to a widget. Similarly, glade has lookup_widget (“by name”).
gtkaml optionally lets you declare widgets as public or private fields, so you can use them directly.
using custom widgets
glade requires specific code to instantiate custom widgets (set_custom_handler ()). GtkBuilder requires the widgets to implement GtkBuildable (which is a Good Thing).
gtkaml only needs them widgets to be compatible with the parent add method (wether is Container.add or something else).
Update: They don’t even have to be widgets, they can be Clutter actors or some business model objects.
creating custom widgets
GtkBuilder or glade do not have support for creating custom widgets.
gtkaml does only this. It creates custom (composite) widgets.
other than Gtk
glade and GtkBuilder are Gtk+ specific.
gtkaml can now accomodate any library that has a Vala vapi file (such as Clutter, Hildon, MX really, any) – you only have to point out in an .implicits file the methods used to add childs to a container.
Conclusion: use GtkBuilder if you need to change the GUI without recompiling. Use gtkaml to write custom composite widgets (with Vala code within) or use a gtkaml with the MVC pattern to separate view from behavior.