The following code snippet is from the GTK+ 3 tutorial from GNOME given here.
static void
print_hello (GtkWidget *widget,
gpointer data)
{
g_print ("Hello World\n");
}
static gboolean
on_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
g_print ("delete event occurred\n");
return TRUE;
}
The program is very simple, and it only has a toplevel window and a button. And this is how the callbacks have been connected:
g_signal_connect (window, "delete-event", G_CALLBACK (on_delete_event), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
My question is regarding the arguments we pass to the callback functions. Why is it that in the on_delete_event handler we pass the second argument GdkEvent* data?
Alternatively, why do we pass no such argument to the first callback function. What is the use of the GdkEvent parameter in this scenario?
I'm sorry if the question shows lack of research, but for me neither the tutorial, nor the resource on event structures was clear enough in describing callbacks.