RE: Newbie with probs Help!



On Sun, 19 Nov 2000, Nicolas Raitman wrote:
I would not have bothered you if I could find the answer... I am reading a
very good book and also the tutorials... besides... the answers I got were
not the ones that I expcted, I mean, they were not answers to my problems...

i would say the last mail from "Carlos Pereira" tells it all:

How can I pass more than one argument to the gtk_signal_connect function,
I mean:
gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(showname),
label1, label2, button1);
do u understand? I do not know if this is correct? I know I can do the
following:
gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(showname),
label1);
but is it ok the first version??

No, the first version is wrong, you can only pass ONE parameter 
to the callback function. That's why you have to pass a pointer
to a structure or use set_data/get_data. This is not a problem
at all, as your structure can have as many variables as you wish,
and you can use as many set_data/get_data as you wish.

for example:

typedef struct _my_struct {
variable A;
variable B;
variable C;
variable D;
variable E;
variable F;
etc...
} my_struct;

my_struct *label1;

gtk_signal_connect(GTK_OBJECT(button), "clicked", 
GTK_SIGNAL_FUNC(showname), label1);

Carlos

so please help... I am osrry to be so insistent , but I like a lot gtk and I
cannot go on with an open source project in which I am working...

as said before: just pack your widgets in a struct and pass a pointer to this
struct as 2nd argument to your callback function.

regards ...
clemens




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