Re: [gtk-list] How to use a gpointer?



On Wed, 3 Mar 1999, Christian B. Westermann wrote:

> Can anybody show me how to use a gpointer. In the following example I
> want to use the variable 'value' in my function 'handle_value'. I filled
> the spaces with ??? where I don't know how to do it.
> 
> -------------------------------------
> int value=10, *value_ptr;
> value_ptr=&value;
> .
> .
> .
> gtk_signal_connect(GTK_OBJECT(button),"clicked",				
> GTK_SIGNAL_FUNC(handle_value),(gpointer)???);

as far as gpointer is void*:

gtk_signal_connect(GTK_OBJECT(button),"clicked",
GTK_SIGNAL_FUNC(handle_value),(gpointer)(&value));

> .
> .
> .
> static void handle_value(GtkWidget *widget,gpointer data)
> {
> int the_value;
> 
> the_value=??????data; 
and the_value=*((int*)date);
This should work.

_____
Alexander Kotelnikov
Saint-Petersburg, Russia
mailto:sacha@ak2614.spb.edu



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