[Ilugc] Re: how to send mutiple gpointers from g_signal_connect
- From: vijaykumar@xxxxxxxxxxxx (Vijay Kumar)
- Date: Fri Jun 11 12:04:17 2010
Prabhu Gnana Sundar <prabhugs@...> writes:
I have been working on a project to develop a test bed. I am
creating a GUI using Gtk programming. Here now I am required
to read inputs from multiple Gtk Entries and process them on
a click of a Gtk Button. But I am unable to find how to send
multiple gpointers through g_signal_connect. Please guide me.
One approach is to keep the pointers to the entry widgets global. But
keeping them global is a bad idea, makes the code hard to read and
maintain.
The other solution is to create a structure for your application, that
keeps track of application state including the pointers to the entry
widgets.
struct AppState {
GtkWidget *entry1;
GtkWidget *entry2;
GtkWidget *entry3;
... other application state ...
};
1. Create an instance of the state structure in main()
2. Update the state structure when the widgets are created.
3. Pass its pointer to all g_signal_connect() invocations.
HTH.
Regards,
Vijay
Other related posts: