Hi all,
I am having a problem with GtkFileChooser when the chooser action is set to
GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER, i.e., I want to allow the user to
specify any existing or as-yet-nonexistent directory. The documentation says
that use of GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER:
"... Indicates a mode for creating a new folder. The file chooser will let the
user name an existing or new folder."
This certainly implies that if the user specifies an existing directory the
dialog will not complain that it cannot create the specified directory because
it already exists. Unfortunately, this is exactly what is happening to me! I
get a popup message that says:
The folder could not be created
Error creating /yadayadayada...: File exists
The chooser dialog remains visible while this message is displayed and after it
is dismissed, waiting for me to select something else.
Curiously, this seems to happen only when I specify the current working
directory (CWD) of the process. If I specify any other pre-existing directory
this error does not occur. If I run this program from a different directory and
specify my original CWD where it failed before, the error does not occur. It
seems perfectly reasonable to me to make the CWD the default directory of
choice for the user and I do not want to change this.
Can anyone explain this bizarre behavior? I am using gtk 3.22.24 (MacPorts
release) under MacOS 10.12.6.
The relevant code follows, somewhat simplified from its original state to make
it more intelligible here. Please advise if you see something stupid.
GtkWidget *d;
GtkFileChooser *fc;
char cwdbuf[BIGBUF];
int rspID;
if ((d= gtk_file_chooser_dialog_new("Dir Select", NULL,
(GtkFileChooserAction) GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER, "Cancel",
GTK_RESPONSE_CANCEL, "Continue", GTK_RESPONSE_ACCEPT, NULL)) == (GtkWidget *)
0)
return -1;
fc= GTK_FILE_CHOOSER(d);
if (getcwd(cwdbuf, (size_t) MAXPATHLEN) == (char *) 0)
return -1;
gtk_file_chooser_set_current_name(fc, cwdbuf);
rspID= gtk_dialog_run(GTK_DIALOG(d));
The error occurs within gtk_dialog_run() of course, as the dialog remains
displayed and I can change the selection after I dismiss the error message.
I have also tried doing
gtk_file_chooser_set_create_folders(fc, FALSE);
prior to calling gtk_dialog_run() but that makes no difference.
Thanks in advance for any ideas!
Roger Davis
Univ. of Hawaii
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list