On Dec 28, 2007 9:17 AM, Tilman Sauerbeck <[EMAIL PROTECTED]> 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
_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to