Re: Using data parameter for callback functions
- From: Tim Müller <zen18864 zen co uk>
- To: Malek Naffati <Redhat tuX gmx net>, gtk-app-devel-list gnome org
- Subject: Re: Using data parameter for callback functions
- Date: Sun, 25 Jan 2004 18:25:36 +0000
On Sunday 25 January 2004 18:00, Malek Naffati wrote:
I've yet successfully been trying to pass a window handle to a callback
function through the data parameter (snip)
static gboolean cancel_button_pressed(GtkWidget *widget, gpointer data)
{
gtk_widget_hide(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.
You have to check the API reference to see what the callback function for a
signal needs to look like:
http://developer.gnome.org/doc/API/2.0/gtk/GtkWidget.html#GtkWidget-button-press-event
In your case, the callback needs to be
static gboolean
cancel_button_pressed (GtkWidget *w, GdkEventButton *bevent, gpointer data)
{
gtk_widget_hide(GTK_WIDGET(data));
....
}
Also check out the Gtk+ Tutorial, esp. section 3.4:
http://www.gtk.org/tutorial/
http://www.gtk.org/tutorial/sec-events.html
Cheers
-Tim
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]