Re: [Vala] connecting non-gobject callbacks
- From: "Travis Watkins" <amaranth ubuntu com>
- To: "Tilman Sauerbeck" <tilman code-monkey de>
- Cc: vala-list gnome org
- Subject: Re: [Vala] connecting non-gobject callbacks
- Date: Fri, 28 Dec 2007 12:40:49 -0600
On Dec 28, 2007 9:17 AM, Tilman Sauerbeck <tilman code-monkey de> wrote:
Hi,
I'm trying to write a client for XMMS2 in Vala.
XMMS2 doesn't use GObjects, but it uses callbacks in various places,
which makes it hard to use it in Vala.
XMMS2 uses a struct called xmmsc_result_t, to which you can connect a
callback like this:
static void handler(xmmsc_result_t *res, void *user_data) {...}
xmmsc_result_t *res;
xmmsc_result_notifier_set (res, handler, NULL);
So eventually "handler" will be called with res and NULL. The straight
forward Vala bindings make it impossible to connect an instance method
as a notifier for a Xmms.Result, since the callback is always passed a
xmmsc_result_t* as the first argument, but Vala needs the first argument
to be a Vala object resp gobject. Connecting to class methods/static
methods works just fine, but it's just not sufficient.
I think you're looking for the [InstanceLast] decorator. Then you just
call xmmsc_result_notifier_set but only give it res and handler and
your vala 'this' automatically gets put in for user_data.
--
Travis Watkins
http://www.realistanew.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]