RE: How can I use g_signal_connect() to pass a gponiter parameter



> -----Original Message-----
> From: Jean Bréfort
> 
> Le dimanche 01 février 2009 à 10:22 -0800, frantishek a écrit :
> > My code does it just by the book:
> >
> > void setPermission(GtkWidget *window, gpointer p)
> > {
> > 	g_print("%s\n", (gchar*) p);
> > }
> >
> > g_signal_connect_swapped (G_OBJECT (radio1), "clicked", G_CALLBACK
> > (setPermission), (gpointer) "Clicked 0");
> 
> You are using g_singal_connect_swapped, so your gpointer becomes the
> first argument of the callback which should be
> 
> void setPermission(gpointer p)
> {
> 	g_print("%s\n", (gchar*) p);
> }

Or, better, leave the signal handler as-is and use g_signal_connect rather than g_signal_connect_swapped. The latter is really for a case where the signal handler takes a widget as its first parameter and you want to pass it a different widget to the one that emits the signal, which you can pass as the data to g_signal_connect_swapped. So for the above example, there's no reason to use g_signal_connect_swapped.

Ian




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