From 7feb5a9dfeeae416cb86e7019ffda697c94c8f90 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Mon, 6 Jun 2011 16:11:22 +0000 Subject: Added "Show hidden files" check button to the file chooser panel. This had been previously done in r.8282 and r.8286 without accounting for the existence of the Fl_File_Chooser.fl file. With this commit, files Fl_File_Chooser.{cxx, H} are properly generated by Fl_File_Chooser.fl git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8785 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_File_Chooser2.cxx | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'src/Fl_File_Chooser2.cxx') diff --git a/src/Fl_File_Chooser2.cxx b/src/Fl_File_Chooser2.cxx index 7b9105e00..37a788145 100644 --- a/src/Fl_File_Chooser2.cxx +++ b/src/Fl_File_Chooser2.cxx @@ -347,6 +347,7 @@ #include #include #include +#include #include #include @@ -1151,7 +1152,7 @@ Fl_File_Chooser::rescan() // Build the file list... fileList->load(directory_, sort); #ifndef WIN32 - if (!show_hidden->value()) remove_hidden_files(); + if (!showHiddenButton->value()) remove_hidden_files(); #endif // Update the preview box... update_preview(); @@ -1178,7 +1179,7 @@ void Fl_File_Chooser::rescan_keep_filename() // Build the file list... fileList->load(directory_, sort); #ifndef WIN32 - if (!show_hidden->value()) remove_hidden_files(); + if (!showHiddenButton->value()) remove_hidden_files(); #endif // Update the preview box... update_preview(); @@ -1576,8 +1577,42 @@ Fl_File_Chooser::value(const char *filename) break; } } + +void Fl_File_Chooser::show() +{ + window->hotspot(fileList); + window->show(); + Fl::flush(); + fl_cursor(FL_CURSOR_WAIT); + rescan_keep_filename(); + fl_cursor(FL_CURSOR_DEFAULT); + fileName->take_focus(); +#ifdef WIN32 + showHiddenButton->hide(); +#endif +} +void Fl_File_Chooser::showHidden(int value) +{ + if (value) { + fileList->load(directory()); + } else { + remove_hidden_files(); + fileList->redraw(); + } +} + +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); +} + // // 'compare_dirnames()' - Compare two directory names. // -- cgit v1.2.3