g_signal_connect question
- From: deepspace <dsp edu physics uoc gr>
- To: gtk-list gnome org
- Subject: g_signal_connect question
- Date: Wed, 04 Aug 2004 04:37:43 +0000
Hi ;)
I am having a strupid problem here , and i hope someone will take the
time to help me out
i know what i am doing is wrong but i can't find the right way to do it.
look at the code
struct args{
gint numdice;
gint sides;
};
void roll(struct args * p)
{
g_print("IN FUNC sides is %d \n",p->sides);
}
int main(int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *button1;
struct args arg,*p;
arg.numdice=(gint)1;
arg.sides=(gint)10;
g_print("sides is %d\n",arg.sides);
p= &arg;
g_print("sides by pointer is %d\n",p->sides);
gtk_init(&argc,&argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
button1= gtk_button_new_with_label("button1");
g_signal_connect(GTK_OBJECT(button1),"clicked",GTK_SIGNAL_FUNC(roll),p);
gtk_container_add (GTK_CONTAINER(window),button1);
gtk_container_border_width(GTK_CONTAINER(window),15);
gtk_widget_show(window);
gtk_widget_show(button1);
//main loop
gtk_main();
//end
return 0;
}
ok , so until the gtk_main arg.sides is 10 as it should be ...
but upon the start of the application , when i click the button and
roll() is called p.sides becomes 7 and p.numdice 1035929
why?
how can it be fixed?
isn't this the way to pass arguments to the function through
g_signal_connect?
thank you for reading
:)
DsP
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]