Dear there,
I am new to Gtk programming, please bear with me -:)
I have created GUI using Glade, where I have FileChooserButton(s) called filechooserbutton1, filechooserbutton2,and filechooserbutton3.
Following tutorials, I can compile and run, and see the main window. However, each time I click a button, I get segment fault. Gdb shows the following code are suspectful:
Code:
GtkFileChooser *b[3];
b[0]= (GtkFileChooser *)data->filechooserbutton1;
b[1]= (GtkFileChooser *)data->filechooserbutton2;
b[2]= (GtkFileChooser *)data->filechooserbutton3;
int i;
for (i=0;i<3;i++){
printf("%d: %x\n",i, b[i]);
}
for (i=1;i<3;i++){
file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(b[i]));
}
As the output is:
0: 7
1: 26d4210
2: 27fa1b0
The question is:
(1) Why didn't the filechooserbutton1 get a correct address?
(2) gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(b[1])) caused segmentation. But it has an address!