<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Martin Pitt &#187; vala</title>
	<atom:link href="http://www.piware.de/tag/vala/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.piware.de</link>
	<description>addicted to Ubuntu development</description>
	<lastBuildDate>Mon, 19 Jul 2010 13:55:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>gudev Vala bindings</title>
		<link>http://www.piware.de/2010/06/gudev-vala-bindings/</link>
		<comments>http://www.piware.de/2010/06/gudev-vala-bindings/#comments</comments>
		<pubDate>Sat, 12 Jun 2010 22:53:32 +0000</pubDate>
		<dc:creator>pitti</dc:creator>
				<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[udev]]></category>
		<category><![CDATA[vala]]></category>

		<guid isPermaLink="false">http://www.piware.de/?p=337</guid>
		<description><![CDATA[I just learned about vapigen to build a Vala .vapi interface from gobject introspection. Unfortunately it seems that through the way of g-ir-scanner some information gets lost and gir cannot transmit information such as the semantics of arrays (null-terminated or with length, etc.). I played with a &#8220;metadata&#8221; file for an hour (as described upstream), [...]]]></description>
			<content:encoded><![CDATA[<p>I just learned about <code>vapigen</code> to build a Vala .vapi interface from gobject introspection. Unfortunately it seems that through the way of g-ir-scanner some information gets lost and gir cannot transmit information such as the semantics of arrays (null-terminated or with length, etc.). I played with a &#8220;metadata&#8221; file for an hour (as <a href="http://live.gnome.org/Vala/Bindings">described upstream</a>), but it seems to be ignored entirely.</p>
<p>So for now I committed a <a href="http://git.kernel.org/?p=linux/hotplug/udev.git;a=commitdiff;h=3d3e0960a7fbb673b7d445d8ed131fcdeb7c2700">manually adjusted vapi</a> for <a href="http://www.kernel.org/pub/linux/utils/kernel/hotplug/gudev/ref-API.html">gudev</a>. This now makes it easy to write code that queries and listens to udev in Vala.</p>
<p>Small example:</p>
<pre>
using GUdev;

void
print_device(GUdev.Device d)
{
    stdout.printf("%s → %s\n", d.get_device_file(), d.get_sysfs_path());
    foreach (string s in d.get_device_file_symlinks())
        stdout.printf("  link: %s\n", s);
}

void
on_uevent(GUdev.Client client, string action, GUdev.Device dev)
{
    stdout.printf("[%s] ", action);
    print_device(dev);
}

int main(string[] args)
{
    var uc = new GUdev.Client({"usb"});

    print_device(uc.query_by_device_file(args[1]));

    stdout.printf("---- all block devices ---\n");
    GLib.List<GUdev.Device> devs = uc.query_by_subsystem("block");
    foreach (GUdev.Device d in devs)
        print_device(d);

    stdout.printf("---- usb events ---\n");
    uc.uevent.connect(on_uevent);
    new GLib.MainLoop().run();
    return 0;
}
</pre>
<p>Build with <code>valac --pkg gudev-1.0 udev.vala</code>, and perhaps specify <code>--vapidir</code> if you keep the <code>gudev-1.0.vapi</code> file somewhere locally.</p>
<p><strong>Update:</strong> I reverted the commit upstream for now, since Vala 0.8 already ships a gudev vapi. I must have overlooked that when I played with vapigen.. In the long run it&#8217;s probably better to generate vapis in the projects themselves to avoid API skew, but as long as the vapi can&#8217;t be generated automatically it does not make sense to have it in udev. Above code was updated for the vala provided one (which is lacking a return type specification for <code>query_by_subsystem()</code>).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.piware.de/2010/06/gudev-vala-bindings/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>&#8220;hello dbus&#8221; in vala</title>
		<link>http://www.piware.de/2009/11/hello-dbus-in-vala/</link>
		<comments>http://www.piware.de/2009/11/hello-dbus-in-vala/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 23:06:03 +0000</pubDate>
		<dc:creator>pitti</dc:creator>
				<category><![CDATA[personal]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[d-bus]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[vala]]></category>

		<guid isPermaLink="false">http://www.piware.de/?p=242</guid>
		<description><![CDATA[On the long flight back from UDS-Lucid I read the Vala tutorial on my ebook, and did some of the exercises. I was curious about Vala because it combines the speed and memory efficiency of C in a sane C#-like language with proper memory management, exceptions, and without the silly &#8220;close to the metal&#8221; faff [...]]]></description>
			<content:encoded><![CDATA[<p>On the long flight back from UDS-Lucid I read the <a href="http://live.gnome.org/Vala/Tutorial">Vala tutorial</a> on my ebook, and did some of the exercises. I was curious about Vala because it combines the speed and memory efficiency of C in a sane C#-like language with proper memory management, exceptions, and without the silly &#8220;close to the metal&#8221; faff that is usually required in C.</p>
<p>And indeed I wasn&#8217;t disappointed. It&#8217;s not as convenient as Python, but really not far from it, and it&#8217;s faaaast!</p>
<p>Today I finally got back to this and wrote my first D-Bus example in vala which does a  call to DeviceKit-disks:</p>
<blockquote><pre>
using DBus;

int main(string[] args)
{
    Connection con = Bus.get(BusType.SYSTEM);

    dynamic DBus.Object dk = con.get_object(
            "org.freedesktop.DeviceKit.Disks",
	    "/org/freedesktop/DeviceKit/Disks",
	    "org.freedesktop.DeviceKit.Disks");

    ObjectPath[] devs = dk.EnumerateDevices();
    foreach (ObjectPath o in devs)
	stdout.printf("%s\n", o);

    return 0;
}
</pre>
</blockquote>
<p>Compile and run it with</p>
<p><code>valac --pkg dbus-glib-1 dbus-dk.vala &#038;&#038; ./dbus-dk</code> </p>
<p>and voila!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.piware.de/2009/11/hello-dbus-in-vala/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
