RE: Newbie questions



Title: RE: Newbie questions

Ok, you can pass whatever you want to the callback using your gpointer data:

gboolean on_expose_event(GtkWidget *widget, GtkEvent *event, gpointer data)
{
   struct my_struct_t *ms = (my_struct_t *)data;
   ...
   /* Use ms as you wish */
   ...
   return TRUE;
}

or even you can do:

gboolean on_expose_event(GtkWidget *widget, GtkEvent *event, struct my_struct_t *ms)
{
   ...
   /* Use ms as you wish */
   ...
   return TRUE;
}

later in your code:

   ...
   struct my_struct_t ms;
   ms.something = something;
   ...
   gtk_signal_connect(GTK_OBJECT(drawing_area), "expose_event", GTK_SIGNAL_FUNC(on_expose_event), &ms);
   ...
   gtk_main();
   ...

just be carefull about the number of parameters your callback function has:

   gboolean on_expose_event(GtkWidget *widget, gpointer data);

will give you an error when trying to access data as a (my_struct_t *)


Esteban Q.



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