Re: Set up callbacks for dynamically created buttons



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);
        printf("Button %d was clicked\n", i);
}

and connect to it like:

g_signal_connect(G_OBJECT(buttons[i]), "clicked", G_CALLBACK(button_callback), GINT_TO_POINTER(i))

-- 
Daniel Pekelharing
<legendstar gmail com>




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