Hellow!
I want to get file name user select by FileChooserButton. I tried to do it this way:
Code:
//declaration of global widget and array for file name
GtkWidget *fc_button_o;
char file_name_i;
//callback function for file name writing in array
void set_file_name ()
{
printf ("Setting input file name\n");
file_name_i = (char) gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (fc_button_o));
printf ("Input file name is: %s\n", file_name_i);
}
int main(int argc, char *argv[]) // of course only important code part here
{
fc_button_o = gtk_file_chooser_button_new ("Browse", GTK_FILE_CHOOSER_ACTION_OPEN);
g_signal_connect (G_OBJECT (fc_button_o), "file-set", G_CALLBACK (set_file_name), NULL);
}
Then I try to compile this in Code::Blocks IDE and push the file chooser button which gives me:
Code:
Setting input file name
Segmentation fault
which means that something wrong with string containing gtk_file_chooser_get_filename function. Please help me to find out what is wrong.