I\'m trying to learn how to make GUIs using gtk+ 3.0. I want to pass a simple argument, an integer, to a callback function, so that when I press the button the value of the
int a = 42;
`gpointer ptr = GINT_TO_POINTER (a)`
//GUINT_TO_POINTER (a), GBOOLEAN_TO_POINTER (a), GSIZE_TO_POINTER (a)
reverse:
int a2 = GPOINTER_TO_INT (ptr);
//GPOINTER_TO_UINT (ptr), GPOINTER_TO_...
The above works perfectly fine to pass integer data thru g_signal_connect. Used as follows.
GtkWidget *Parison_ON_Buttons[10];
for (i=0; i < 8; i++)
{
gpointer ONptr = GINT_TO_POINTER (i);
g_signal_connect(GTK_SPIN_BUTTON(Parison_ON_Buttons[i]), "activate", G_CALLBACK
(Get_Parison_ON_Values),ONptr);
}
static gboolean Get_Parison_ON_Values (GtkSpinButton *button, gpointer data)
{
int ONButtonNUmPressed = GPOINTER_TO_INT (data);
....
}