Re: Threads & Glade
- From: Iago Rubio <iago iagorubio com>
- To: gtk-app-devel-list gnome org
- Subject: Re: Threads & Glade
- Date: Mon, 10 Oct 2005 18:25:38 +0200
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]