summaryrefslogtreecommitdiff
path: root/src/fl_file_dir.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/fl_file_dir.cxx')
-rw-r--r--src/fl_file_dir.cxx36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/fl_file_dir.cxx b/src/fl_file_dir.cxx
index a91b0f3..ff23c22 100644
--- a/src/fl_file_dir.cxx
+++ b/src/fl_file_dir.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_file_dir.cxx 4288 2005-04-16 00:13:17Z mike $"
+// "$Id: fl_file_dir.cxx 5417 2006-09-05 09:57:41Z matt $"
//
// File chooser widget for the Fast Light Tool Kit (FLTK).
//
@@ -74,12 +74,19 @@ fl_file_chooser(const char *message, // I - Message in titlebar
fc->callback(callback, 0);
} else {
fc->type(Fl_File_Chooser::CREATE);
+ // see, if we use the same pattern between calls
+ char same_pattern = 0;
+ const char *fcf = fc->filter();
+ if ( fcf && pat && strcmp(fcf, pat)==0)
+ same_pattern = 1;
+ else if ( (fcf==0L || *fcf==0) && (pat==0L || *pat==0) )
+ same_pattern = 1;
+ // now set the pattern to the new pattern (even if they are the same)
fc->filter(pat);
fc->label(message);
- if (!fname || !*fname) {
- if (fc->filter() != pat && (!pat || !fc->filter() ||
- strcmp(pat, fc->filter())) && fc->value()) {
+ if (!fname) { // null pointer reuses same filename if pattern didn't change
+ if (!same_pattern && fc->value()) {
// if pattern is different, remove name but leave old directory:
strlcpy(retname, fc->value(), sizeof(retname));
@@ -93,13 +100,24 @@ fl_file_chooser(const char *message, // I - Message in titlebar
else
*p = '\0';
}
-
// Set the directory...
- fc->directory(retname);
+ fc->value(retname);
+ } else {
+ // re-use the previously selected name
}
+ } else if (!*fname) { // empty filename reuses directory with empty name
+ const char *fcv = fc->value();
+ if (fcv)
+ strlcpy(retname, fc->value(), sizeof(retname));
+ else
+ *retname = 0;
+ const char *n = fl_filename_name(retname);
+ if (n) *((char*)n) = 0;
+ fc->value("");
+ fc->directory(retname);
+ } else {
+ fc->value(fname);
}
- else
- fc->value(fname);
}
fc->ok_label(current_label);
@@ -156,5 +174,5 @@ fl_dir_chooser(const char *message, // I - Message for titlebar
//
-// End of "$Id: fl_file_dir.cxx 4288 2005-04-16 00:13:17Z mike $".
+// End of "$Id: fl_file_dir.cxx 5417 2006-09-05 09:57:41Z matt $".
//