From 78380102f6e5d4bbe6bacb0df21aa6afec8ff903 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Sat, 9 Apr 2016 17:29:12 +0200 Subject: [PATCH] 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. --- dialogs.c | 4 +++- gtk/xoptions.c | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dialogs.c b/dialogs.c index f138bb7..43f762e 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 51d8754..7a3a831 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) -- 1.7.0.4