Re: Extra callback parameters



Russell Shaw wrote:

Hi,
I have a callback that is passed one user data item (cdata):

void colour_cb(GtkButton *button, gpointer data)
{...
}
g_signal_connect(G_OBJECT(colbutton),"clicked",G_CALLBACK(colour_cb),cdata);
Is it possible to modify g_object signals so that more than
one data parameter can be passed like:

You can create your GObject class and define a signal (g_signal_new) with specific parameters list.

void colour_cb(GtkButton *button, gpointer data1, gpointer data2)
{...
}
g_signal_connect(G_OBJECT(colbutton),"clicked",G_CALLBACK(colour_cb),cdata1,cdata2);

No. It's impossible - "clicked" signal is defined in gtkbutton.c and it takes no extra parameters. Common way is to pass a pointer to structure (fast and takes no extra memory) or use g_object_set_data (slower, consumes memory).

   Olexiy





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