GObject Introspection and Grilo: A winner combination
About GObject Introspection
A few days ago Adrian Perez wrote about GObject Introspection (abbreviated GI), explaining why it is gaining so much momentum. While you're really encouraged to visit his blog entry to see the work he did on Lua's GI bindings, I'll take some of his words:
In short, it (GObject Introspection) works like this:
- Library developers add annotations to the documentation comments of functions.
- The GI support tools generate XML and compiled API metadata.
- You have a library to use that metadata at runtime.
The last thing is very interesting, especially the runtime usage of metadata... because it enables dynamic language bindings. This means that developers no longer have to build e.g. the Python bindings for themselves but just annotating the source code!
GObject Introspection in Grilo
As Grilo's primary focus is to allow application developers concentrate on making good user interfaces, without having to deal with the low level stuff done at the framework level, we consider very important providing them with the ability to use their language of choice. At the same time, we'd like to avoid devoting time to write manual bindings, and that's the reason we put so much effort on GObject Introspection support: right now, if not all, most of the API is accessible via GI, and we're working to fix the less binding-friendly parts.
Building Grilo with GObject Introspection enabled
The best way to try Grilo from GI is, in my opinion, using jhbuild. Clone it with
git clone git://git.gnome.org/jhbuild
build and install it, and copy the configuration file provided sample.jhbuildrc to ~/.jhbuilrc. The project page explains everything in detail, from installation details to tweaking the configuration file, but if you don't want to do it, that's fine. You'll probably need to install the build prerequisites, by invoking
$jhbuild bootstrap
To see the dependencies needed to get grilo and grilo plugins installed you can type
$jhbuild list grilo grilo-plugins
But to get the most from Grilo, you'd go for:
$jhbuild build gtk+ pygobject grilo grilo-plugins
That will install grilo core and plugins, pygobject (which includes Python's glue to use GObject Introspection, and has gobject-introspection as a dependency) and Gtk+, needed to run the grilo-test-ui sample done with GI. After a rather long build, you should have an environment with Grilo installed with GI support.
From there, type
$jhbuild shell
to enter the jhbuild environment and go to your Grilo's checkout directory. If everything has worked fine, you should be able to do:
$ python Python 2.5.2 (r252:60911, Aug 6 2010, 16:46:34) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from gi.repository import Grl >>> Grl.init([]) >>>
Under tools/python/ there's a grilo-test-ui.py program, which showcases all the combined potential of GI and Grilo: run it with
$python tools/python/grilo-test-ui.py
and enjoy
(And then, start doing you own apps
)
GObject Introspection has landed in Grilo!
If you're using Grilo from git, last patches enabled improved GObject Introspection so you can start using Python with PyGObject to develop your applications.
A Python clone of the grilo-test-ui is provided, and should give you an idea of what can be done with these new bindings: basically enjoy all the power in Grilo without needing to touch C code, and without us having to maintain manually created bindings.
If you're a JavaScript user, then you need to watch bug #616961. As JavaScript doesn't support GParamSpecs yet (#626047), you'll need this patch which replaces GParamSpec annotations with uints. And now, time for unit testing with PyGObject!
Another (general) status report
Some quick notes (the list of things which would deserve a full blog entry for themselves just keeps growing...)
- My manager (I don't like how "boss" sounds) retired last week. Although he visited us a couple of days more to spend some time with us, things will be, at least, different. We'll surely miss him.
- I started working with Grilo at Igalia, as the practicum work for the Free Software Master. I've been assigned a challenging task: improve the bindings infrastructure. Currently I'm getting familiar with the project, reading the doc and playing with the examples: it looks really interesting!
- Yesterday I received permissions to upload to extras-devel, so... maevies & butaca-server are available now! Of course, all said warnings about extras-devel still apply. In my case, it's about memory consumption: the backend doesn't free the objects exposed via DBus, so you have to kill it to get that done. It's a small footprint and all that, but it's not nice and of course not the way I want it: having it uploaded to extras will get me motivated to fix it
(Sure, there will be other issues as well, and I'll set up the bugtracker as soon as possible) - I've started with the slides for the JaMp talk at GUADEC-ES. There's still time left, but with these things, you never know...


