From 360538a42b9bf28061ab813a0f9a5aae9cc72c30 Mon Sep 17 00:00:00 2001 From: John Levon Date: Sat, 29 Mar 2003 12:03:54 +0000 Subject: [PATCH] couple more Alert fixes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6630 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 4 +++ src/converter.C | 82 ++++++++++++++++++++++++------------------------- 2 files changed, 45 insertions(+), 41 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 27a4dfbbf9..183b664e12 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2003-03-29 John Levon + + * converters.C: more Alert cleanups + 2003-03-29 John Levon * bufferview_funcs.C: remove pointless Alert diff --git a/src/converter.C b/src/converter.C index 1c7fbe1679..ce9070e7cf 100644 --- a/src/converter.C +++ b/src/converter.C @@ -360,13 +360,14 @@ bool Converters::convert(Buffer const * buffer, } if (res) { - if (conv.to == "program") - Alert::alert(_("There were errors during the Build process."), - _("You should try to fix them.")); - else + if (conv.to == "program") { + Alert::error(_("Build errors"), + _("There were errors during the build process.")); + } else { Alert::alert(_("Cannot convert file"), _("Error while executing"), command.substr(0, 50)); + } return false; } } @@ -465,6 +466,36 @@ bool Converters::formatIsUsed(string const & format) } +namespace { + +void alertErrors(string const & prog, int nr_errors) +{ + string s; +#if USE_BOOST_FORMAT + if (nr_errors == 1) { + boost::format fmt(_("One error detected when running %1$s.\n")); + fmt % prog; + s = fmt.str(); + } else { + boost::format fmt(_("%1$s errors detected when running %2$s.\n")); + fmt % tostr(nr_errors); + fmt % prog; + s = fmt.str(); + } +#else + if (num_errors == 1) { + s = _("One error detected"); + } else { + s = tostr(num_errors); + s += _(" errors detected."); + } +#endif + Alert::error(_("Errors found"), s); +} + +} + + bool Converters::scanLog(Buffer const * buffer, string const & command, string const & filename) { @@ -492,31 +523,13 @@ bool Converters::scanLog(Buffer const * buffer, string const & command, } if ((result & LaTeX::ERRORS)) { - int num_errors = latex.getNumErrors(); - string s; - string t; - if (num_errors == 1) { - s = _("One error detected"); - t = _("You should try to fix it."); - } else { - s = tostr(num_errors); - s += _(" errors detected."); - t = _("You should try to fix them."); - } string head; split(command, head, ' '); -#if USE_BOOST_FORMAT - Alert::alert(boost::io::str(boost::format(_("There were errors during running of %1$s")) % head), - s, t); -#else - Alert::alert(_("There were errors during running of ") + head, - s, t); -#endif + alertErrors(head, latex.getNumErrors()); return false; } else if (result & LaTeX::NO_OUTPUT) { - string const s = _("The operation resulted in"); - string const t = _("an empty file."); - Alert::alert(_("Resulting file is empty"), s, t); + Alert::warning(_("Output is empty"), + _("An empty output file was generated.")); return false; } return true; @@ -558,23 +571,10 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command) Alert::alert(_("LaTeX did not work!"), _("Missing log file:"), name); } else if ((result & LaTeX::ERRORS)) { - int num_errors = latex.getNumErrors(); - string s; - string t; - if (num_errors == 1) { - s = _("One error detected"); - t = _("You should try to fix it."); - } else { - s = tostr(num_errors); - s += _(" errors detected."); - t = _("You should try to fix them."); - } - Alert::alert(_("There were errors during the LaTeX run."), - s, t); + alertErrors("LaTeX", latex.getNumErrors()); } else if (result & LaTeX::NO_OUTPUT) { - string const s = _("The operation resulted in"); - string const t = _("an empty file."); - Alert::alert(_("Resulting file is empty"), s, t); + Alert::warning(_("Output is empty"), + _("An empty output file was generated.")); } if (bv) -- 2.39.5