If you just need to select a file, run a separate program for this. As @ Dummy00001 said in a comment, you can run zenity --file-selection as a child process and read its standard output.
char filename[1024]; FILE *f = popen("zenity --file-selection", "r"); fgets(filename, 1024, f);
Or you can also write your own program to complete the task. Thus, you can customize the interface as you wish.
source share