Re: [gtk-list] stubs and callbacks



David Monniaux <monniaux@clipper.ens.fr> writes:
> I have problems with callbacks.
> I'd like to use gtk_signal_connect to bind a signal to a generic function
> with a specific parameter.
> I used:
> value mlgtk_callback_exec(GtkObject *obj, value x)
> 
> gtk_signal_connect(object, name, mlgtk_callback_exec, SOME_VALUE);
> 
> Will x be equal to SOME_VALUE or to a pointer on SOME_VALUE?

Which signal are you connecting? Maybe the signal has arguments of its
own and you'll need to skip those arguments.

The SOME_VALUE can only be pointer type, thus passing anything else in
that cept pointer should give type error.

struct foo *f;
gint foo_event_signal(GtkObject *o, GdkEventButton*, struct foo *f);

gtk_signal_connect(object,"button_press_event",foo_event_signal,f);

It is a problem with C that there's no type checking and compiler cannot
detect bad connect() calls. :(

-- 
-- Tero Pulkkinen -- terop@modeemi.cs.tut.fi --



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