On Sat, Apr 22, 2006 at 09:22:44AM +0200, Daniel Pekelharing wrote:
> 
> gint button_callback(GtkWidget *button, gint i)
> {
>       printf("Button %d was clicked\n", i);
> }
> 
> and connect to it like:
> 
> g_signal_connect(G_OBJECT(buttons[i]), "clicked", 
> G_CALLBACK(button_callback), (gpointer)i)

Please do not do this.  Perhaps it works on your i386 box,
but the macros GINT_TO_POINTER() and GPOINTER_TO_INT() exist
for a good reason.

> Alternatively if you want to pass some other data to the callback you
> could determine which button was pressed by calling
> gtk_button_get_label(GTK_BUTTON(button)
> from withing the callback to determine the label of the button.

Alternatively (and better), you can use g_object_set_data()
to attach arbitrary data to each button.

Yeti


--
That's enough.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to