Question about passing data to and from widgets.
Chia-I Wu
olv at openmoko.org
Tue Nov 20 06:59:40 CET 2007
On Fri, Nov 16, 2007 at 08:01:05PM -0600, Judson Bishop wrote:
> Which works unitl I try to connect it to a callback from the toolbar because
> the toolitem is not the parent, the weather window is, from line 56 of
> weather.c
> g_signal_connect(toolitem, "clicked", G_CALLBACK (config_dialog_create),
> weather);
>
> I don't have the ability to pass both the parent widget (weather) and the
> weather_data. I think what I need to be passing is the weather_data
> structure that contains a window pointer that changes to point to different
> widgets as it is passed around and is also the container for data I need in
> the program.
This is one way to achieve that. Another way is to associate the
weather_data with the widget by:
g_object_set_data(G_OBJECT(weather), "mydata", weather_data);
and pass the widget to g_signal_connect.
Then in the callback function, you can get the data back by:
weather_data = g_object_get_data(G_OBJECT(weather), "mydata");
--
Regards,
olv
More information about the openmoko-devel
mailing list