Hi, you have to make sure that the parameters of your callback function exactly match what's been described for this particular event. In your case your have to check the "clicked" event for a GtkButton which gives us:
void user_function(GtkButton *button, gpointer user_data) So this is how your callback function should look like: void on_button2_clicked(GtkButton *button, struct allStructs *by_ptr) Your struct should be the _second_ parameter and not the first (any only) one your made it. What you did is: You got a pointer to the GtkButton structure of your button and used _that_ as a pointer to your own struct. You are likely messing up the Button structure ... This is one ugly thing with the C bindings and the fact that everything is just casted by this G_CALLBACK() macro. That way the compiler isn't able to check these things and errors like yours happen. And these can be very nasty bugs since they cause people to write to memory they are not supposed to write to. A classic door for hackers ... Till Am Sonntag 19 Oktober 2008 schrieb beginner.c: > > I need to pass a struct using g_signal_connect, but the issue I'm having is > that I can't alter the elements of the struct within the called function > e.g. > > void on_button2_clicked (struct allStructs *by_ptr) > > { > gtk_label_set_text ((GtkLabel*)by_ptr->widgets.label, "whatever"); > } > > main > { > blah blah > struct allStructs baseStruct; > > g_signal_connect (G_OBJECT(baseStruct.widgets.nextButton), "clicked", > G_CALLBACK (on_button2_clicked), &baseStruct); > } > > Any idea's? If I pass this struct to any other function I have no problem > performing functions like in the callback. For some reason, I can't in the > callback. > _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list