I'm having the hardest time getting an integer passed to a callback function, since the last argument of g_signal_connect
is required to be a pointer. Here is where I connect the signal to the callback:
for (i=0;i<10;i++)
{
...
gtk_widget_set_events(tab_ebs[i],GDK_BUTTON_PRESS_MASK);
g_signal_connect (G_OBJECT (tab_ebs[i]), "button_press_event", G_CALLBACK (tab_clicked_cb), GINT_TO_POINTER(i));
}
and here is the callback:
void tab_clicked_cb (gpointer p)
{
printf("tab #%d clicked\n", GPOINTER_TO_INT(p));
}
What I get in stdout, are statements such as:
tab #6578976 clicked
tab #6579264 clicked
tab #6579552 clicked
tab #6579840 clicked
When I only have ten tabs. How can I pass an integer to a callback fcn on a 64 bit system? Thanks.
nos got me half way there. Turns out I was also missing an argument for the event in my callback function. Here is the form that worked:
void tab_clicked (GtkWidget *widget, GdkEventButton *ev, gpointer p)
{
printf("tab #%d clicked\n", GPOINTER_TO_INT(p));
}