On Mon, 2005-10-10 at 04:52 -0700, lucapetra (sent by Nabble.com) wrote:
> Thanks, this helps ;)
> 
> Now i have another question. How can I cast a gpointer to a struct?
> It seems to be very hard to do :(

Not at all, just casting, (Type) pointer.
Your problems is with callback functions, isn't it ?

typedef struct _MyData {
        ......
} MyData;

MyData *data; // your struct

g_signal_connect ((gpointer) one_button,
                  "clicked",
                  G_CALLBACK (on_button_clicked),
                  (gpointer) data); // casting to gpointer


/* callback function */
void
on_button_clicked (GtkButton * button,
                   gpointer user_data)
{
   MyData *data;

   data = (MyData*) user_data; // casting from gpointer
   /* you can now access data->whatever */  
}

Hope this helps.
-- 
Iago Rubio

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to