Hello everyone.
I realize this isn't a GTK forum, but I am still hoping that someone might know how to get this going.
I used glade to make a GTK GUI. It has several buttons and each one has its own callback function. Meaning that my program is running on an infinite cycle. When a clicked-button signal is sent, the function associated to that signal is executed.
I'd like to know what is the best way to pass data through these functions
The following code happens when I press an "OK" button in a File Chooser Dialog
Code:
void OK_FCD_clicked ()
{
int n;
GSList * FileList;
GtkWidget *filechooserdialog = GTK_WIDGET(gtk_builder_get_object(builderG, "filechooserdialog1")); // gets the widget from the builder object
FileList = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(filechooserdialog)); //puts the selected files path in the GSlist FileList
guint nFiles = g_slist_length(FileList); //number of files selected
PathList paths[nFiles]; //struct I created to organize the data
for (n=0; n<nFiles;n++) //cycle to put the GSlist data into my struct
{
paths[n].number=n;
paths[n].filename=g_slist_nth_data(FileList,n);
paths[n].total=nFiles;
}
for (n=0; n<nFiles;n++) printf("%d - %s\n",paths[n].number,paths[n].filename); //this cycle just prints out the information I just organized
}
The PathList struct is the following:
Code:
typedef struct {int number; char * filename; int total;} PathList;
Now I need to use that information in other callback functions, but I am not sure how to pass the data through all these functions.
I realize it is possible to do it with a global variable, but I'm thinking that one is a poor solution.
Best regards