Using data parameter for callback functions

I've yet successfully been trying to pass a window handle to a callback function through the data parameter 

g_signal_connect (G_OBJECT (cancel_button), "button_press_event",
  G_CALLBACK (cancel_button_pressed), GTK_OBJECT(window));


static gboolean cancel_button_pressed(GtkWidget *widget, gpointer data)
        return TRUE;

This results in a segfault...
The Address of data in cancel_button_pressed does not reference
the parameter passed to it in  g_signal_connect. Why is this?
Am I getting something wrong here.

The GIMP about dialog uses a global variable to store the window handle
which I pretty much "dislike". 

Also I've used gtk_widget_hide. I believe to remember that Windows API(tm?!) does it the same way, not really 
unallocating space  
used for widgets. Does gtk+ use garbage collection?  

 - Malek

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