Re: passing parameters



samuel.berthelot wrote:
Hi,
Is it right to do something like this ?

int = 0;
gtk_signal_connect (GTK_OBJECT(glarea), "motion_notify_event",
                        GTK_SIGNAL_FUNC(glarea_motion_notify), gpointer(id);

int glarea_motion_notify (GtkWidget* widget, GdkEventMotion* event, gpointer id)
{
    //whatever
}

Actually my code doesn't work. But I need to pass the id variable as a parameter.
Any idea ?
Is this not working
(I mean besides the fact that GTK_OBJECT should be G_OBJECT and
gtk_signal_* should be g_signal_* and that `gpointer' is actualy
a type and not a function and that you got a parse error in your
call to `gtk_signal_connect'; missing closing parenthasis) ?

If the user_data argument for this signal has been removed
(or never existed); which I doubt is the case (almost all
event signals if not all of them; provide a user_data arg);
You can consider using:
   `g_object_set_data(G_OBJECT(glarea), "id", (gpointer)id)'
and
   `id = g_object_get_data(G_OBJECT(glarea), "id")'


Cheers,
                        -Tristan







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