From: H.G.Muller Date: Sat, 9 Apr 2016 15:29:12 +0000 (+0200) Subject: Start button-activated browse near old field contents GTK X-Git-Url: http://hgm.nubati.net/cgi-bin/gitweb.cgi?p=xboard.git;a=commitdiff_plain;h=78380102f6e5d4bbe6bacb0df21aa6afec8ff903 Start button-activated browse near old field contents GTK The file chooser activated by Browse buttons for filling a File or Path text edit started in the last directory it visited for that file type. But for the initial browse after startup it started in the current directory. Now it starts in the directory derived from the filaname currently in the text edit, if there is one, and only in the last- visited directory for the file type if the text-edit was empty. --- diff --git a/dialogs.c b/dialogs.c index f138bb73..43f762ec 100644 --- a/dialogs.c +++ b/dialogs.c @@ -3329,7 +3329,9 @@ StartDir (char *filter, char *newName) ASSIGN(*res, newName); for(p=*res; q=strchr(p, '/');) p = q + 1; *p = NULLCHAR; } - if(*curDir) chdir(curDir); + } + if(*curDir) { + chdir(curDir); *curDir = NULLCHAR; } else { getcwd(curDir, MSG_SIZ); diff --git a/gtk/xoptions.c b/gtk/xoptions.c index 51d87543..7a3a8317 100644 --- a/gtk/xoptions.c +++ b/gtk/xoptions.c @@ -1113,9 +1113,11 @@ void BrowseGTK(GtkWidget *widget, gpointer gdata) gtkfilter = gtk_file_filter_new(); gtkfilter_all = gtk_file_filter_new(); - char fileext[MSG_SIZ], *filter = currentOption[opt_i].textValue; + char fileext[MSG_SIZ], *filter = currentOption[opt_i].textValue, *old; - StartDir(filter, NULL); // change to start directory for this file type + GetWidgetText(¤tOption[opt_i], &old); // start in same directory as current widget contents + StartDir(filter, old); // change to start directory for this file type + g_free(old); /* select file or folder depending on option_type */ if (currentOption[opt_i].type == PathName)