Xfce Stopwatch Plugin
I needed an excuse to try Mike‘s
Vala bindings for Xfce,
so I created a new little plugin for the panel, the
xfce4-stopwatch-plugin.
In the original release announcement on July 28th, I wrote:
This is the first release of the stopwatch panel plugin, which you can
use to time yourself on different tasks. It’s stable and usable, but
quite minimal still.
The functionality is best summarized with this image from the web site:
Vala
From their web site,
Vala is a new programming language
that aims to bring modern programming language features to GNOME developers
without imposing any additional runtime requirements and without using a
different ABI compared to applications and libraries written in C.
Instead of having to write tons of
boilerplate code
to create new GObjects in C and for other common tasks in developing GTK-based
applications, Vala builds these features into the language. The Vala code you
write passes through the Vala compiler, which produces GObject-based C code.
From there, GCC compiles that to a binary as usual. There is no runtime, so
Vala-produced code can run as fast as hand-coded C.
Vala makes it easy to write fast, object-oriented code for GTK-based projects.
With Mike’s Xfce bindings for Vala, you gain access to Xfce’s libraries from
Vala, letting you write panel plugins or other Xfce projects in Vala. It’s a
cool idea and something I definitely wanted to try.
Developing the Stopwatch Plugin
In general, Vala is pretty easy to write if you’ve worked with GObject before.
I did hit a few bugs while developing even this simple plugin, so it’s evident
that Vala and the Xfce bindings aren’t mature yet:
-
I filed GNOME Bug 587150,
a bug in Vala’s POSIX bindings for thetime_ttype. Vala treats it
as a GObject instead of an integer, making it unusable to pass around your
program in many ways. This bug hasn’t seen any attention yet, but I’ve worked
around it for Stopwatch by not usingtime_t.Update: Evan Nemerson fixed this one.
-
I patched
a small bug in Xfce’s Vala bindings for the
XfceHVBox
widget. The Vala compiler was producing calls toxfce_hv_box_new()
instead ofxfce_hvbox_new(), which of course caused a problem when
GCC tried to resolve the symbol. -
I also filed GNOME Bug 589930,
a bug in Vala’s generated code forsscanf. It always added an
extra NULL argument at the end of the arguments list. Jürg Billeter fixed this
one quickly with
this commit,
which made it into Vala 0.7.5.
Despite these hurdles, writing the Stopwatch plugin in Vala has been a
pleasure. Admittedly the plugin doesn’t do much, but the code is very short and
straight-forward.
Stopwatch will probably see just one or two more releases before it’s
feature-complete. I’d also like to port the Places plugin to Vala at some
point, but I’m waiting to see how volume management plays out once
ThunarVFS is gone.