Updated Fl_File_Chooser to correctly deselect other items when

the user picks a file or directory in multiple selection mode
(only files or directories, not both at once...)

Use the fl_file_chooser_ok_label() function in FLUID.



git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4191 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2005-03-25 18:58:18 +00:00
parent 2ccbfdccc9
commit f5ed012b28
5 changed files with 41 additions and 7 deletions

View File

@ -2,6 +2,8 @@ CHANGES IN FLTK 1.1.7
- Documentation fixes (STR #648, STR #692, STR #730, STR
#744, STR #745)
- Fl_File_Chooser now correctly handles multiple
selections that are a mix of files and directories.
- Fl_File_Chooser no longer resets the type() when
choosing a single file, and it now works when selecting
multiple directories (STR #747)

View File

@ -780,7 +780,9 @@ void Fl_Comment_Type::open() {
}
else if (w == comment_load) {
// load a comment from disk
fl_file_chooser_ok_label("Use File");
const char *fname = fl_file_chooser("Pick a comment", 0L, 0L);
fl_file_chooser_ok_label(NULL);
if (fname) {
if (comment_input->buffer()->loadfile(fname)) {
fl_alert("Error loading file\n%s", fname);

View File

@ -212,7 +212,9 @@ Fluid_Image::~Fluid_Image() {
const char *ui_find_image_name;
Fluid_Image *ui_find_image(const char *oldname) {
goto_source_dir();
fl_file_chooser_ok_label("Use Image");
const char *name = fl_file_chooser("Image?","Image Files (*.{bm,bmp,gif,jpg,pbm,pgm,png,ppm,xbm,xpm})",oldname,1);
fl_file_chooser_ok_label(NULL);
ui_find_image_name = name;
Fluid_Image *ret = (name && *name) ? Fluid_Image::find(name) : 0;
leave_source_dir();

View File

@ -176,9 +176,9 @@ static char* cutfname(int which = 0) {
void save_cb(Fl_Widget *, void *v) {
const char *c = filename;
if (v || !c || !*c) {
fl_ok = "Save";
fl_file_chooser_ok_label("Save");
c=fl_file_chooser("Save To:", "FLUID Files (*.f[ld])", c);
fl_ok = "OK";
fl_file_chooser_ok_label(NULL);
if (!c) return;
if (!access(c, 0)) {
@ -436,9 +436,9 @@ void open_cb(Fl_Widget *, void *v) {
}
const char *c;
const char *oldfilename;
fl_ok = "Open";
fl_file_chooser_ok_label("Open");
c = fl_file_chooser("Open:", "FLUID Files (*.f[ld])", filename);
fl_ok = "OK";
fl_file_chooser_ok_label(NULL);
if (!c) return;
oldfilename = filename;
filename = NULL;
@ -964,9 +964,9 @@ void print_cb(Fl_Return_Button *, void *) {
outfile = popen(command, "w");
} else {
// Print to file...
fl_ok = "Print";
fl_file_chooser_ok_label("Print");
const char *outname = fl_file_chooser("Print To", "PostScript (*.ps)", NULL, 1);
fl_ok = "OK";
fl_file_chooser_ok_label(NULL);
if (outname && !access(outname, 0)) {
if (fl_choice("The file \"%s\" already exists.\n"

View File

@ -415,8 +415,36 @@ Fl_File_Chooser::fileListCB()
}
else
{
// Strip any trailing slash from the directory name...
// Check if the user clicks on a directory when picking files;
// if so, make sure only that item is selected...
filename = pathname + strlen(pathname) - 1;
if ((type_ & MULTI) && !(type_ & DIRECTORY)) {
if (*filename == '/') {
// Clicked on a directory, deselect everything else...
int i = fileList->value();
fileList->deselect();
fileList->select(i);
} else {
// Clicked on a file - see if there are other directories selected...
int i;
const char *temp;
for (i = 1; i <= fileList->size(); i ++) {
if (i != fileList->value() && fileList->selected(i)) {
temp = fileList->text(i);
temp += strlen(temp) - 1;
if (*temp == '/') break; // Yes, selected directory
}
}
if (i <= fileList->size()) {
i = fileList->value();
fileList->deselect();
fileList->select(i);
}
}
}
// Strip any trailing slash from the directory name...
if (*filename == '/') *filename = '\0';
// puts("Setting fileName from fileListCB...");