Travis Watkins [2007-12-28 12:40]: > 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.
Thanks Travis, that's exactly what I need :) I saw InstanceLast being used before, but I never knew what it meant. I think I'll contribute to the tutorial soonish.. Regards, Tilman -- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail?
pgpfnvfIRtsgo.pgp
Description: PGP signature
_______________________________________________ Vala-list mailing list Vala-list@gnome.org http://mail.gnome.org/mailman/listinfo/vala-list