From 0693c70f577624e66fd660a888f2d2bcd3fc180b Mon Sep 17 00:00:00 2001 From: Greg Ercolano Date: Fri, 10 Jul 2020 21:49:00 -0700 Subject: First pass at fixing issue 99 A lot of code touched because low level functions needed to pass up error messages reliably, and this had to propagate up the entire driver hierarchy. Tested OK *in English* on: > Linux > OSX 10.10.x > Windows VS2017 > Windows mingw64 I have no way to test on Android, but it might work. TODO: Needs testing in other languages to verify proper UTF8 error messages, esp. with Windows VS, due to complexities with FormatMessage() -- see get_ms_errmsg() --- src/Fl_File_Chooser2.cxx | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'src/Fl_File_Chooser2.cxx') diff --git a/src/Fl_File_Chooser2.cxx b/src/Fl_File_Chooser2.cxx index de2b7c160..ec04bd77c 100644 --- a/src/Fl_File_Chooser2.cxx +++ b/src/Fl_File_Chooser2.cxx @@ -1020,17 +1020,15 @@ void Fl_File_Chooser::preview(int e) Fl_Group *p = previewBox->parent(); if (e) { int w = p->w() * 2 / 3; - fileList->resize(fileList->x(), fileList->y(), - w, fileList->h()); - previewBox->resize(fileList->x()+w, previewBox->y(), - p->w()-w, previewBox->h()); + fileList->resize(fileList->x(), fileList->y(), w, fileList->h()); + errorBox->resize(errorBox->x(), errorBox->y(), w, errorBox->h()); + previewBox->resize(fileList->x()+w, previewBox->y(), p->w()-w, previewBox->h()); previewBox->show(); update_preview(); } else { - fileList->resize(fileList->x(), fileList->y(), - p->w(), fileList->h()); - previewBox->resize(p->x()+p->w(), previewBox->y(), - 0, previewBox->h()); + fileList->resize(fileList->x(), fileList->y(), p->w(), fileList->h()); + errorBox->resize(errorBox->x(), errorBox->y(), p->w(), errorBox->h()); + previewBox->resize(p->x()+p->w(), previewBox->y(), 0, previewBox->h()); previewBox->hide(); } p->init_sizes(); @@ -1070,7 +1068,14 @@ Fl_File_Chooser::rescan() okButton->deactivate(); // Build the file list... - fileList->load(directory_, sort); + if ( fileList->load(directory_, sort) <= 0 ) { + if ( fileList->errmsg() ) errorBox->label(fileList->errmsg()); // show OS errormsg when possible + else errorBox->label("No files found..."); + show_error_box(1); + } else { + show_error_box(0); + } + if (Fl::system_driver()->dot_file_hidden() && !showHiddenButton->value()) remove_hidden_files(); // Update the preview box... update_preview(); @@ -1094,7 +1099,13 @@ void Fl_File_Chooser::rescan_keep_filename() strlcpy(pathname, fn, sizeof(pathname)); // Build the file list... - fileList->load(directory_, sort); + if (fileList->load(directory_, sort) <= 0) { + if ( fileList->errmsg() ) errorBox->label(fileList->errmsg()); // show OS errormsg when possible + else errorBox->label("No files found..."); + show_error_box(1); + } else { + show_error_box(0); + } if (Fl::system_driver()->dot_file_hidden() && !showHiddenButton->value()) remove_hidden_files(); // Update the preview box... update_preview(); -- cgit v1.2.3