Set up callbacks for dynamically created buttons

2006-04-22 Thread 3saul
they're created? -- View this message in context: http://www.nabble.com/Set-up-callbacks-for-dynamically-created-buttons-t1490320.html#a4038183 Sent from the Gtk+ - Apps Dev forum at Nabble.com. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org

Re: Set up callbacks for dynamically created buttons

2006-04-22 Thread Daniel Pekelharing
On Fri, 2006-04-21 at 23:11 -0700, 3saul wrote: I'm creating some buttons using: buttons = g_new(GtkWidget*, n); for (i = 0; i n; i++) { buttons[i] = gtk_button_new... gtk_button_whatever(GTK_BUTTON(buttons[i])... ... gtk_box_pack_start(GTK_BOX(some_box), buttons[i]... } how

Re: Set up callbacks for dynamically created buttons

2006-04-22 Thread David Necas (Yeti)
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

Re: Set up callbacks for dynamically created buttons

2006-04-22 Thread Daniel Pekelharing
On Sat, 2006-04-22 at 10:33 +0200, David Necas (Yeti) wrote: 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. Thanks for pointing that out, I was not aware of these macros.. Not that it makes any

Re: Set up callbacks for dynamically created buttons

2006-04-22 Thread 3saul
So how should I implement this with the changes that David pointed out? -- View this message in context: http://www.nabble.com/Set-up-callbacks-for-dynamically-created-buttons-t1490320.html#a4039872 Sent from the Gtk+ - Apps Dev forum at Nabble.com

Re: Set up callbacks for dynamically created buttons

2006-04-22 Thread Daniel Pekelharing
On Sat, 2006-04-22 at 04:10 -0700, 3saul wrote: So how should I implement this with the changes that David pointed out? It's not a very complex change actually, something like this: void button_callback(GtkWidget *button, gpointer data) { gint i = GPOINTER_TO_INT(data);