diff --git a/FL/Fl_File_Chooser.H b/FL/Fl_File_Chooser.H index 3b8777d97..21fa8ddd8 100644 --- a/FL/Fl_File_Chooser.H +++ b/FL/Fl_File_Chooser.H @@ -123,6 +123,9 @@ private: Fl_Return_Button *favOkButton; void cb_favOkButton_i(Fl_Return_Button*, void*); static void cb_favOkButton(Fl_Return_Button*, void*); + Fl_Check_Button *show_hidden; + static void show_hidden_cb(Fl_Check_Button*, void*); + void remove_hidden_files(); public: ~Fl_File_Chooser(); void callback(void (*cb)(Fl_File_Chooser *, void *), void *d = 0); @@ -213,6 +216,10 @@ public: [standard text may be customized at run-time] */ static const char *show_label; + /** + [standard text may be customized at run-time] + */ + static const char *hidden_label; /** the sort function that is used when loading the contents of a directory. diff --git a/FL/Fl_Native_File_Chooser_FLTK.H b/FL/Fl_Native_File_Chooser_FLTK.H index e97ffb037..5176ab77d 100644 --- a/FL/Fl_Native_File_Chooser_FLTK.H +++ b/FL/Fl_Native_File_Chooser_FLTK.H @@ -72,6 +72,8 @@ - Under X windows, it's best if you call Fl_File_Icon::load_system_icons() at the start of main(), to enable the nicer looking file browser widgets. + Use the static public attributes of class Fl_File_Chooser to localize + the browser. - Some operating systems support certain OS specific options; see Fl_Native_File_Chooser::options() for a list. @@ -95,6 +97,8 @@ public: NEW_FOLDER = 0x0002, ///< Show 'New Folder' icon (if supported) PREVIEW = 0x0004 ///< enable preview mode }; + /** Localizable message */ + static const char *file_exists_message; private: int _btype; // kind-of browser to show() int _options; // general options @@ -106,16 +110,8 @@ private: char *_prevvalue; // Returned filename char *_directory; char *_errmsg; // error message - char *_old_dir; Fl_File_Chooser *_file_chooser; - // added by MG - Fl_File_Browser *my_fileList; - Fl_Check_Button *show_hidden; - int prev_filtervalue; - static void show_hidden_cb(Fl_Check_Button *o, void *data); - static void remove_hidden_files(Fl_File_Browser *my_fileList); - // Private methods void errmsg(const char *msg); int type_fl_file(int); diff --git a/FL/Fl_Native_File_Chooser_MAC.H b/FL/Fl_Native_File_Chooser_MAC.H index 0a980e182..b34dcf118 100644 --- a/FL/Fl_Native_File_Chooser_MAC.H +++ b/FL/Fl_Native_File_Chooser_MAC.H @@ -49,6 +49,7 @@ public: NEW_FOLDER = 0x0002, // Show 'New Folder' icon (if supported) PREVIEW = 0x0004 // enable preview mode }; + static const char *file_exists_message; private: int _btype; // kind-of browser to show() int _options; // general options diff --git a/FL/Fl_Native_File_Chooser_WIN32.H b/FL/Fl_Native_File_Chooser_WIN32.H index 00f64e235..505136e7e 100644 --- a/FL/Fl_Native_File_Chooser_WIN32.H +++ b/FL/Fl_Native_File_Chooser_WIN32.H @@ -52,6 +52,7 @@ public: NEW_FOLDER = 0x0002, // Show 'New Folder' icon (if supported) PREVIEW = 0x0004, // enable preview mode }; + static const char *file_exists_message; private: int _btype; // kind-of browser to show() int _options; // general options diff --git a/src/Fl_File_Chooser.cxx b/src/Fl_File_Chooser.cxx index b71a778a3..d3a43e1cf 100644 --- a/src/Fl_File_Chooser.cxx +++ b/src/Fl_File_Chooser.cxx @@ -88,6 +88,26 @@ void Fl_File_Chooser::cb_previewButton(Fl_Check_Button* o, void* v) { ((Fl_File_Chooser*)(o->parent()->parent()->parent()->user_data()))->cb_previewButton_i(o,v); } +void Fl_File_Chooser::remove_hidden_files() +{ + int count = fileList->size(); + for(int num = count; num >= 1; num--) { + const char *p = fileList->text(num); + if (*p == '.' && strcmp(p, "../") != 0) fileList->remove(num); + } + fileList->topline(1); +} + +void Fl_File_Chooser::show_hidden_cb(Fl_Check_Button* o, void* data) { + Fl_File_Chooser *mychooser = (Fl_File_Chooser *)data; + if (o->value()) { + mychooser->browser()->load(mychooser->directory()); + } else { + mychooser->remove_hidden_files(); + mychooser->browser()->redraw(); + } +} + void Fl_File_Chooser::cb_fileName_i(Fl_File_Input*, void*) { fileNameCB(); } @@ -208,6 +228,15 @@ Fl_File_Chooser::Fl_File_Chooser(const char *d, const char *p, int t, const char previewButton->callback((Fl_Callback*)cb_previewButton); previewButton->label(preview_label); } // Fl_Check_Button* previewButton + + { show_hidden = new Fl_Check_Button( + previewButton->x() + previewButton->w() + 30, 275, 140, 20, "Show hidden files"); + show_hidden->down_box(FL_DOWN_BOX); + show_hidden->value(0); + show_hidden->callback((Fl_Callback*)show_hidden_cb, this); + show_hidden->label(hidden_label); + } // Fl_Check_Button* show_hidden + { Fl_Box* o = new Fl_Box(115, 275, 365, 20); Fl_Group::current()->resizable(o); } // Fl_Box* o diff --git a/src/Fl_File_Chooser2.cxx b/src/Fl_File_Chooser2.cxx index d3d0d05cb..1237735ed 100644 --- a/src/Fl_File_Chooser2.cxx +++ b/src/Fl_File_Chooser2.cxx @@ -74,7 +74,11 @@