As part of my current duties at Canonical I have to deal a lot with different parts of the Linux middleware stack. GSettings, dconf, PulseAudio…
Most of what I do these days is Vala and C (preferably Vala) and once I started dealing with NetworkManager I noticed the lack of Vala bindings for the GObject wrappers. My first reaction was to just write the whole thing in C but eventually I figured the whole thing was easier to maintain if I just took a week to write the bindings.
After a few bug fixes upstream in Vala and NetworkManager, the Vala bindings are now part of NetworkManager upstream.
Here's an example on how to get all driver names for each device:
1 2 3 4 5 6 7 8 9 10 11 12 |
using NM; static int main (string[] args) { var client = new NM.Client(); var devices = client.get_devices (); for (uint i = 0; i < devices.length; i++) { message ("%s", devices.get(i).driver); } return 0; } |
Bug reports and patches are more than welcome! Please, give the bindings a try as well, they could use some real world testing.
The latest tarballs already include them, I expect them to land in Ubuntu Quantal soon, make sure to file bugs against OpenSUSE and Fedora and other distros if the packages are not deploying the bindings yet.
I would like to thank Jens Georg (phako), Juerg Billeter (juergbi) and Dan Williams (dcbw) for the help debugging issues, reviewing patches and other guidance.
Happy hacking!
Well done Alberto !
LikeLike
Isn’t it possible to generate the D-Bus client code at build time using the official interface description files?
LikeLike
It is, but then we would be creating bindings from an un-gir, undocumented API. With the GObject wrappers we have the gtk-docs as a reference.
LikeLike
Thanks Juanjo!
LikeLike
Ah, of course!
I was just wondering whether there was a problem with the Vala D-Bus binding tool 🙂
LikeLike
Awesome work!
LikeLike
“you can’t be working for canonical since you contributed upstream with code”
I wonder where are all those people that complain about the lack of upstream updates from canonical.
LikeLike
Thanks for the awesome work. FYI, you can have a free foreach if you rename the property as “size” instead of “length”, such as foreach (var device in devices) { … }. See https://live.gnome.org/Vala/Tutorial#Methods_With_Syntax_Support .
LikeLike