Fixed filechooser to behave as documented when file pattern changes (STR #135s9)

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5355 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher
2006-08-24 14:23:24 +00:00
parent 062d347846
commit bd4d11e5e3
2 changed files with 23 additions and 7 deletions
+2
View File
@@ -1,5 +1,7 @@
CHANGES IN FLTK 1.1.8
- Fixed filechooser to behave as documented when
file pattern changes (STR #135s9)
- Completed the global function index and added an
alphabetical list of all methods (STR #1319)
- Avoiding problems with some platforms that don't
+21 -7
View File
@@ -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,20 @@ 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
strlcpy(retname, fc->value(), sizeof(retname));
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);