Ok, there must be a really simple way of doing this, that I'm just overlooking. Let's say I have a button, and upon click I want to pass 3 widgets, and 2 local variables. (one points to a dir, and the other points to a file). So far, I have this:
Code:
#define GLADE_FILE "/usr/share/testapp/testapp.glade"
typedef struct
{
GtkWidget *host_entry;
GtkWidget *port_entry;
GtkWidget *options_entry;
} MyWidgets;
void on_connect_btn_clicked(GtkButton *widget, gpointer user_data)
{
MyWidgets *widgets;
widgets = (MyWidgets *)user_data;
const gchar *port;
const gchar *user;
const gchar *options;
host = gtk_entry_get_text (GTK_ENTRY (widgets->host_entry));
port = gtk_entry_get_text (GTK_ENTRY (widgets->port_entry));
options = gtk_entry_get_text (GTK_ENTRY (widgets->options_entry));
//how do I reference *appdir and *appfile here???
}
int main (int argc, char *argv[])
{
GladeXML *gxml;
MyWidgets *widgets;
const gchar *user = g_get_home_dir();
gchar *appdir = g_build_path("/", user, ".testapp", NULL);
gchar *appfile = g_build_filename(appdir, "settings", NULL);
widgets = g_slice_new (MyWidgets);
gtk_init (&argc, &argv);
gxml = glade_xml_new (GLADE_FILE, NULL, NULL);
widgets->main_dialog = glade_xml_get_widget (gxml, "main_dialog");
widgets->host_entry = glade_xml_get_widget (gxml, "host_entry");
widgets->port_entry = glade_xml_get_widget (gxml, "port_entry");
widgets->options_entry = glade_xml_get_widget (gxml, "options_entry");
glade_xml_signal_connect_data (gxml, "on_connect_btn_clicked",
G_CALLBACK (on_connect_btn_clicked),
widgets);
...obviously this is just a snippet, as I'm trying to keep it simple to explain my question. What is the proper (best?) way to pass the pointers *appdir and *appfile into the glade_xml_signal_connect_data function, along with the already working "widgets" parameter?
Thanks,
-Lup