summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2005-02-05 18:26:21 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2005-02-05 18:26:21 +0000
commit3124794f1fe6e7a5e0e201f6a3e773ed58ad1e5e (patch)
tree90a66029117cc35558a438ee695f2c78e1132f64 /src
parentb601fdc3bc4b5b9a9d1a356dd458cfdd3213fa16 (diff)
Fl_File_Chooser was slow with large directories (STR #654)
FL/Fl_File_Browser.H: - Don't reload the directory view unless asked to. FL/Fl_File_Chooser.H: - Rebuilt using current FLUID. src/Fl_File_Browser.cxx: - Don't reload the directory view unless asked to. src/Fl_File_Chooser.cxx: - Fl_File_Chooser::show() calls rescan(). src/Fl_File_Chooser.fl: - Fl_File_Chooser::show() calls rescan(). src/Fl_File_Chooser2.cxx: - Only call rescan() when chooser is shown. src/Fl_File_Icon.cxx: - Add optimization for Windows - filenames with trailing slash are directories. test/file_chooser.cxx: - Only call show() once... git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4010 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_File_Browser.cxx38
-rw-r--r--src/Fl_File_Chooser.cxx3
-rw-r--r--src/Fl_File_Chooser.fl10
-rw-r--r--src/Fl_File_Chooser2.cxx16
-rw-r--r--src/Fl_File_Icon.cxx10
5 files changed, 41 insertions, 36 deletions
diff --git a/src/Fl_File_Browser.cxx b/src/Fl_File_Browser.cxx
index 7fec67192..acf35b64d 100644
--- a/src/Fl_File_Browser.cxx
+++ b/src/Fl_File_Browser.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_File_Browser.cxx,v 1.1.2.28 2004/04/11 04:38:57 easysw Exp $"
+// "$Id$"
//
// Fl_File_Browser routines.
//
@@ -584,34 +584,31 @@ Fl_File_Browser::load(const char *directory,// I - Directory to load
if (num_files <= 0)
return (0);
- for (i = 0, num_dirs = 0; i < num_files; i ++)
- {
+ for (i = 0, num_dirs = 0; i < num_files; i ++) {
if (strcmp(files[i]->d_name, ".") &&
- strcmp(files[i]->d_name, "./"))
- {
+ strcmp(files[i]->d_name, "./")) {
snprintf(filename, sizeof(filename), "%s/%s", directory_,
files[i]->d_name);
-#if defined(WIN32) && !defined(__CYGWIN__)
- if (files[i]->d_name[strlen(files[i]->d_name) - 1] == '/')
- {
+ icon = Fl_File_Icon::find(filename);
+ if (icon->type() == Fl_File_Icon::DIRECTORY) {
num_dirs ++;
- insert(num_dirs, files[i]->d_name, Fl_File_Icon::find(filename));
- }
+
+#if defined(WIN32) && !defined(__CYGWIN__)
+ // WIN32 already has the trailing slash... :)
+ insert(num_dirs, files[i]->d_name, icon);
#else
- if (fl_filename_isdir(filename))
- {
+ // Add a trailing slash to directory names...
char name[1024]; // Temporary directory name
snprintf(name, sizeof(name), "%s/", files[i]->d_name);
- num_dirs ++;
- insert(num_dirs, name, Fl_File_Icon::find(filename));
- }
+ insert(num_dirs, name, icon);
#endif // WIN32 && !__CYGWIN__
- else if (filetype_ == FILES &&
- fl_filename_match(files[i]->d_name, pattern_))
- add(files[i]->d_name, Fl_File_Icon::find(filename));
+ } else if (filetype_ == FILES &&
+ fl_filename_match(files[i]->d_name, pattern_)) {
+ add(files[i]->d_name, icon);
+ }
}
free(files[i]);
@@ -636,12 +633,9 @@ Fl_File_Browser::filter(const char *pattern) // I - Pattern string
pattern_ = pattern;
else
pattern_ = "*";
-
- // Reload the current directory...
- load(directory_);
}
//
-// End of "$Id: Fl_File_Browser.cxx,v 1.1.2.28 2004/04/11 04:38:57 easysw Exp $".
+// End of "$Id$".
//
diff --git a/src/Fl_File_Chooser.cxx b/src/Fl_File_Chooser.cxx
index f769c6bc7..4901f2ac8 100644
--- a/src/Fl_File_Chooser.cxx
+++ b/src/Fl_File_Chooser.cxx
@@ -1,4 +1,4 @@
-// generated by Fast Light User Interface Designer (fluid) version 1.0105
+// generated by Fast Light User Interface Designer (fluid) version 1.0107
#include "../FL/Fl_File_Chooser.H"
@@ -317,6 +317,7 @@ const char * Fl_File_Chooser::label() {
void Fl_File_Chooser::show() {
window->hotspot(fileList);
window->show();
+rescan();
fileName->take_focus();
}
diff --git a/src/Fl_File_Chooser.fl b/src/Fl_File_Chooser.fl
index 7c3744546..fed85b594 100644
--- a/src/Fl_File_Chooser.fl
+++ b/src/Fl_File_Chooser.fl
@@ -1,5 +1,5 @@
# data file for the Fltk User Interface Designer (fluid)
-version 1.0105
+version 1.0107
header_name {../FL/Fl_File_Chooser.H}
code_name {.cxx}
class FL_EXPORT Fl_File_Chooser {open
@@ -107,7 +107,7 @@ window->hide();} open
if (callback_)
(*callback_)(this, data_);
-window->hide();} selected
+window->hide();}
private xywh {300 345 85 25}
code0 {\#include <FL/fl_ask.H>}
code1 {okButton->label(fl_ok);}
@@ -245,11 +245,13 @@ showChoiceCB();} {}
}
decl {void rescan();} {public
}
- Function {show()} {return_type void
+ Function {show()} {open return_type void
} {
code {window->hotspot(fileList);
window->show();
-fileName->take_focus();} {}
+rescan();
+fileName->take_focus();} {selected
+ }
}
Function {shown()} {return_type int
} {
diff --git a/src/Fl_File_Chooser2.cxx b/src/Fl_File_Chooser2.cxx
index 045f04e6a..b615fe1ca 100644
--- a/src/Fl_File_Chooser2.cxx
+++ b/src/Fl_File_Chooser2.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_File_Chooser2.cxx,v 1.1.2.38 2004/09/07 20:59:16 easysw Exp $"
+// "$Id$"
//
// More Fl_File_Chooser routines.
//
@@ -196,8 +196,10 @@ Fl_File_Chooser::directory(const char *d)// I - Directory to change to
else
directory_[0] = '\0';
- // Rescan the directory...
- rescan();
+ if (shown()) {
+ // Rescan the directory...
+ rescan();
+ }
}
@@ -834,7 +836,11 @@ Fl_File_Chooser::showChoiceCB()
}
fileList->filter(pattern_);
- rescan();
+
+ if (shown()) {
+ // Rescan the directory...
+ rescan();
+ }
}
@@ -1160,5 +1166,5 @@ unquote_pathname(char *dst, // O - Destination string
//
-// End of "$Id: Fl_File_Chooser2.cxx,v 1.1.2.38 2004/09/07 20:59:16 easysw Exp $".
+// End of "$Id$".
//
diff --git a/src/Fl_File_Icon.cxx b/src/Fl_File_Icon.cxx
index 230db3c15..61ed3035f 100644
--- a/src/Fl_File_Icon.cxx
+++ b/src/Fl_File_Icon.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_File_Icon.cxx,v 1.1.2.17 2004/06/14 15:58:52 easysw Exp $"
+// "$Id$"
//
// Fl_File_Icon routines.
//
@@ -193,8 +193,10 @@ Fl_File_Icon::find(const char *filename,// I - Name of file */
// Get file information if needed...
if (filetype == ANY)
{
-#ifdef WIN32
- if (fl_filename_isdir(filename))
+#ifdef WIN32
+ if (filename[strlen(filename) - 1] == '/')
+ filetype = DIRECTORY;
+ else if (fl_filename_isdir(filename))
filetype = DIRECTORY;
else
filetype = PLAIN;
@@ -477,5 +479,5 @@ Fl_File_Icon::labeltype(const Fl_Label *o, // I - Label data
//
-// End of "$Id: Fl_File_Icon.cxx,v 1.1.2.17 2004/06/14 15:58:52 easysw Exp $".
+// End of "$Id$".
//