Nerd wannabe

lazy weblog

what gtkaml is not

leave a comment »

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, glade is a library (and GtkBuilder comes bundled with Gtk+). You link against it and it parses your UI markup at runtime..

On the other side, gtkaml is a preprocessor. Your markup becomes code, Vala code, which and eventually becomes static C code.

language bindings

glade and GtkBuilder can be used from many different programming languages.

gtkaml is only available for Vala. However, widget 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.

syntax

GtkBuilder and glade have their own markup which usually must be written by means of an interactive tool (glade).

gtkaml simply maps tags to classes and attributes to properties/fields/signals.

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 capability which translates into g_signal_connect () function calls.

widget referencing

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 to inherit from GtkWidget (or a class more specialized).

creating custom widgets

GtkBuilder or glade do not have support for creating custom widgets.

gtkaml does only this. It creates custom widgets.

Conclusion: use GtkBuilder an glade to separate UI from behavior. Use gtkaml to write custom widgets (with code within) – in Vala.

Written by vlad

March 25, 2008 at 1:29 pm

Posted in gtkaml

Leave a Reply