Skip to content

Commit

Permalink
Fl_File_Chooser no longer resets the type() when choosing a
Browse files Browse the repository at this point in the history
single file, and it now works when selecting multiple directories
(STR #747)

Fl_File_Icon::load_system_icons() now only loads 16x16 and 32x32
icon images to improve startup performance.

Fixed an error dialog message in FLUID.



git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4189 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
michaelrsweet committed Mar 25, 2005
1 parent a343b0d commit 2ccbfdc
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 143 deletions.
5 changes: 5 additions & 0 deletions CHANGES
Expand Up @@ -2,6 +2,11 @@ CHANGES IN FLTK 1.1.7

- Documentation fixes (STR #648, STR #692, STR #730, STR
#744, STR #745)
- Fl_File_Chooser no longer resets the type() when
choosing a single file, and it now works when selecting
multiple directories (STR #747)
- Fl_File_Icon::load_system_icons() now only loads 16x16
and 32x32 icon images to improve startup performance.
- Pressing Enter in the file chooser when selecting a
directory will choose that directory if it is currently
shown (STR #746)
Expand Down
2 changes: 1 addition & 1 deletion fluid/fluid.cxx
Expand Up @@ -651,7 +651,7 @@ void write_cb(Fl_Widget *, void *) {
if (!x) {
fl_message("Can't write %s: %s", cname, strerror(errno));
} else if (completion_button->value()) {
fl_message("Wrote %s", cname, 0);
fl_message("Wrote %s", cname);
}
}
}
Expand Down
77 changes: 38 additions & 39 deletions src/Fl_File_Chooser2.cxx
Expand Up @@ -113,38 +113,32 @@ static void unquote_pathname(char *, const char *, int);
//

int // O - Number of selected files
Fl_File_Chooser::count()
{
Fl_File_Chooser::count() {
int i; // Looping var
int fcount; // Number of selected files
const char *filename; // Filename in input field or list


if (!(type_ & MULTI))
{
// Check to see if the file name input field is blank...
filename = fileName->value();

// printf("Fl_File_Chooser::count(): filename=\"%s\"\n", filename);

if (!filename || !filename[0])
return (0);
filename = fileName->value();

// Is the file name just the current directory?
return (strcmp(filename, directory_) != 0);
if (!(type_ & MULTI)) {
// Check to see if the file name input field is blank...
if (!filename || !filename[0]) return 0;
else return 1;
}

for (i = 1, fcount = 0; i <= fileList->size(); i ++)
if (fileList->selected(i))
{
if (fileList->selected(i)) {
// See if this file is a directory...
filename = (char *)fileList->text(i);

if (filename[strlen(filename) - 1] != '/')
fcount ++;
}

return (fcount);
if (fcount) return fcount;
else if (!filename || !filename[0]) return 0;
else return 1;
}


Expand Down Expand Up @@ -511,11 +505,6 @@ Fl_File_Chooser::fileNameCB()
#endif /* WIN32 || __EMX__ */
directory(pathname);
} else if ((type_ & CREATE) || access(pathname, 0) == 0) {
// New file or file exists... If we are in multiple selection mode,
// switch to single selection mode...
if (type_ & MULTI)
type(SINGLE);

// Update the preview box...
update_preview();

Expand Down Expand Up @@ -1015,8 +1004,10 @@ Fl_File_Chooser::value(int f) // I - File number
static char pathname[1024]; // Filename + directory


name = fileName->value();

if (!(type_ & MULTI)) {
name = fileName->value();
// Return the filename in the filename field...
if (!name || !name[0]) return NULL;
else if (fl_filename_isdir(name)) {
if (type_ & DIRECTORY) {
Expand All @@ -1029,28 +1020,40 @@ Fl_File_Chooser::value(int f) // I - File number
} else return name;
}

// Return a filename from the list...
for (i = 1, fcount = 0; i <= fileList->size(); i ++)
if (fileList->selected(i)) {
// See if this file is a directory...
// See if this file is a selected file/directory...
name = fileList->text(i);

if (name[strlen(name) - 1] != '/') {
// Not a directory, see if this this is "the one"...
fcount ++;

if (fcount == f) {
if (directory_[0]) {
snprintf(pathname, sizeof(pathname), "%s/%s", directory_, name);
} else {
strlcpy(pathname, name, sizeof(pathname));
}
fcount ++;

return (pathname);
if (fcount == f) {
if (directory_[0]) {
snprintf(pathname, sizeof(pathname), "%s/%s", directory_, name);
} else {
strlcpy(pathname, name, sizeof(pathname));
}

// Strip trailing slash, if any...
strlcpy(pathname, name, sizeof(pathname));
slash = pathname + strlen(pathname) - 1;
if (*slash == '/') *slash = '\0';
return pathname;
}
}

return (NULL);
// If nothing is selected, use the filename field...
if (!name || !name[0]) return NULL;
else if (fl_filename_isdir(name)) {
if (type_ & DIRECTORY) {
// Strip trailing slash, if any...
strlcpy(pathname, name, sizeof(pathname));
slash = pathname + strlen(pathname) - 1;
if (*slash == '/') *slash = '\0';
return pathname;
} else return NULL;
} else return name;
}


Expand Down Expand Up @@ -1078,10 +1081,6 @@ Fl_File_Chooser::value(const char *filename) // I - Filename + directory
return;
}

// Switch to single-selection mode as needed
if (type_ & MULTI)
type(SINGLE);

// See if there is a directory in there...
fl_filename_absolute(pathname, sizeof(pathname), filename);

Expand Down

0 comments on commit 2ccbfdc

Please sign in to comment.