Re: [Vala] Adding a GIOChannel to GMainLoop



On Wed, 2007-10-24 at 10:17 -0500, Travis Watkins wrote:
On 10/24/07, Xavier Bestel <xavier bestel free fr> wrote:
but when called, it looks like "src" contains "cond", "cond" contains
"data" and "data" contains garbage.
Looking at the C code, the problem is that my callback is a method from
another object, so a "self" argument is inserted in the proto:

gboolean ml_connect_data_received (MLConnect* self, GIOChannel* src, GIOCondition cond, gpointer data) {
        g_return_val_if_fail (IS_ML_CONNECT (self), FALSE);
        fprintf (stdout, "data received");
}

Can I pass an object's method as a callback ? Looking at GIOFunc's
proto, the caller's "self" should probably be stored in "data" ...


Try adding [InstanceLast] to the method like this:

[InstanceLast] public bool data_recieved (IOChannel src, IOCondition cond)

Notice the data argument is missing, that'll be filled in with the
self argument.

Yes, thanks, that's what I've been told on IRC.
Apparently Vala has a solution to each problem, it's just not easy to
find :)

        Xav





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]