kill Alert::alert()

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6653 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-03-31 01:15:44 +00:00
parent 25b275f182
commit 315e07fabc
21 changed files with 214 additions and 126 deletions

View File

@ -1,3 +1,13 @@
2003-03-31 John Levon <levon@movementarian.org>
* bufferlist.C: "Load original" -> "Load Original"
* converter.C:
* exporter.C:
* importer.C:
* lyx_main.C:
* format.C: more Alert cleanups
2003-03-30 Lars Gullik Bjønnes <larsbj@gullik.net>
* text2.C (removeParagraph): make it take a RowList::iterator as

View File

@ -365,7 +365,7 @@ Buffer * BufferList::readFile(string const & s, bool ronly)
text += file + _(" exists.\n\nRecover emergency save?");
#endif
int const ret = Alert::prompt(_("Load emergency save?"),
text, 0, _("&Recover"), _("&Load original"));
text, 0, _("&Recover"), _("&Load Original"));
if (ret == 0) {
ts = e;

View File

@ -364,9 +364,17 @@ bool Converters::convert(Buffer const * buffer,
Alert::error(_("Build errors"),
_("There were errors during the build process."));
} else {
Alert::alert(_("Cannot convert file"),
_("Error while executing"),
command.substr(0, 50));
#if USE_BOOST_FORMAT
// FIXME: this should go out of here. For example, here we cannot say if
// it is a document (.lyx) or something else. Same goes for elsewhere.
Alert::error(_("Cannot convert file"),
boost::io::str(boost::format(_("An error occurred whilst running %1$s"))
% command.substr(0, 50)));
#else
Alert::error(_("Cannot convert file"),
_("An error occurred whilst running ")
+ command.substr(0, 50));
#endif
}
return false;
}
@ -389,11 +397,12 @@ bool Converters::convert(Buffer const * buffer,
token_base, to_base);
if (!lyx::rename(from, to)) {
#if USE_BOOST_FORMAT
Alert::alert(_("Error while trying to move directory:"),
from, boost::io::str(boost::format(_("to %1$s")) % to));
Alert::error(_("Cannot convert file"),
boost::io::str(boost::format(_(
"Could not move a temporary file from %1$s to %2$s.")) % from % to));
#else
Alert::alert(_("Error while trying to move directory:"),
from, _("to ") + to);
Alert::error(_("Cannot convert file"),
_("Could not move a temporary file from ") + from + _(" to ") + to + ".");
#endif
return false;
}
@ -431,11 +440,12 @@ bool Converters::move(string const & from, string const & to, bool copy)
: lyx::rename(from2, to2);
if (!moved && no_errors) {
#if USE_BOOST_FORMAT
Alert::alert(_("Error while trying to move file:"),
from2, boost::io::str(boost::format(_("to %1$s")) % to2));
Alert::error(_("Cannot convert file"),
boost::io::str(boost::format(_(
"Could not move a temporary file from %1$s to %2$s.")) % from2 % to2));
#else
Alert::alert(_("Error while trying to move file:"),
from2, _("to ") + to2);
Alert::error(_("Cannot convert file"),
_("Could not move a temporary file from ") + from2 + _(" to ") + to2 + ".");
#endif
no_errors = false;
}
@ -568,8 +578,18 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command)
// check return value from latex.run().
if ((result & LaTeX::NO_LOGFILE)) {
Alert::alert(_("LaTeX did not work!"),
_("Missing log file:"), name);
string str;
#if USE_BOOST_FORMAT
boost::format fmt(_("LaTeX did not run successfully. Additionally, LyX "
"could not locate the LaTeX log %1$s."));
fmt % name;
str = fmt.str();
#else
str += _("LaTeX did not run successfully. Additionally, LyX "
"could not locate the LaTeX log ");
str += name + ".";
#endif
Alert::error(_("LaTeX failed"), str);
} else if ((result & LaTeX::ERRORS)) {
alertErrors("LaTeX", latex.getNumErrors());
} else if (result & LaTeX::NO_OUTPUT) {

View File

@ -1,12 +1,12 @@
/* This file is part of
* ======================================================
/**
* \file exporter.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* LyX, The Document Processor
* \author unknown
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
* ====================================================== */
* Full author contact details are available in file CREDITS
*/
#include <config.h>
@ -16,6 +16,7 @@
#include "buffer.h"
#include "lyx_cb.h" //ShowMessage()
#include "support/filetools.h"
#include "support/BoostFormat.h"
#include "lyxrc.h"
#include "converter.h"
#include "format.h"
@ -56,9 +57,16 @@ bool Exporter::Export(Buffer * buffer, string const & format,
}
}
if (backend_format.empty()) {
Alert::alert(_("Cannot export file"),
_("No information for exporting to ")
+ formats.prettyName(format));
#if USE_BOOST_FORMAT
// FIXME: better english ...
Alert::error(_("Couldn't export file"),
boost::io::str(boost::format(_("No information for exporting the format %1$s."))
% formats.prettyName(format)));
#else
Alert::error(_("Couldn't export file"),
_("No information for exporting the format ")
+ formats.prettyName(format) + ".");
#endif
return false;
}
} else
@ -83,8 +91,8 @@ bool Exporter::Export(Buffer * buffer, string const & format,
else if (backend_format == format)
buffer->makeLaTeXFile(filename, string(), true);
else if (contains(buffer->filePath(), ' ')) {
Alert::alert(_("Cannot run LaTeX."),
_("The path to the lyx file cannot contain spaces."));
Alert::error(_("File name error"),
_("The directory path to the document cannot contain spaces."));
return false;
} else
buffer->makeLaTeXFile(filename, buffer->filePath(), false);

View File

@ -158,12 +158,14 @@ bool Formats::view(Buffer const * buffer, string const & filename,
format->isChildFormat())
format = getFormat(format->parentFormat());
if (!format || format->viewer().empty()) {
// I believe this is the wrong place to show alerts, it should be done by
// the caller (this should be "utility" code
#if USE_BOOST_FORMAT
Alert::alert(_("Cannot view file"),
Alert::error(_("Cannot view file"),
boost::io::str(boost::format(_("No information for viewing %1$s"))
% prettyName(format_name)));
#else
Alert::alert(_("Cannot view file"),
Alert::error(_("Cannot view file"),
_("No information for viewing ")
+ prettyName(format_name));
#endif
@ -199,9 +201,15 @@ bool Formats::view(Buffer const * buffer, string const & filename,
int const res = one.startscript(Systemcall::DontWait, command);
if (res) {
Alert::alert(_("Cannot view file"),
_("Error while executing"),
command.substr(0, 50));
#if USE_BOOST_FORMAT
Alert::error(_("Cannot view file"),
boost::io::str(boost::format(_("An error occurred whilst running %1$s"))
% command.substr(0, 50)));
#else
Alert::error(_("Cannot view file"),
_("An error occurred whilst running ")
+ command.substr(0, 50));
#endif
return false;
}
return true;

View File

@ -21,18 +21,6 @@ using std::endl;
using std::pair;
using std::make_pair;
void Alert::alert(string const & s1, string const & s2, string const & s3)
{
if (!lyxrc.use_gui) {
lyxerr << "------------------------------" << endl
<< s1 << endl << s2 << endl << s3 << endl
<< "------------------------------" << endl;
} else {
alert_pimpl(s1, s2, s3);
}
}
int Alert::prompt(string const & title, string const & question,
int default_button,
string const & b1, string const & b2, string const & b3)

View File

@ -33,13 +33,13 @@ int prompt(string const & title, string const & question,
string const & b1, string const & b2, string const & b3 = string());
/**
* Display a warning to the user. Title should be a short summary.
* Display a warning to the user. Title should be a short (general) summary.
* Only use this if the user cannot perform some remedial action.
*/
void warning(string const & title, string const & message);
/**
* Display a warning to the user. Title should be a short summary.
* Display a warning to the user. Title should be a short (general) summary.
* Only use this if the user cannot perform some remedial action.
*/
void error(string const & title, string const & message);
@ -52,10 +52,6 @@ void error(string const & title, string const & message);
*/
void information(string const & title, string const & message);
/// show an alert message. DO NOT USE !!
void alert(string const & title, string const & s1 = string(),
string const & s2 = string());
/// Asks for a text. DO NOT USE !!
std::pair<bool, string> const
askForText(string const & msg,

View File

@ -12,8 +12,6 @@
// GUI-specific implementations
void alert_pimpl(string const & s1, string const & s2, string const & s3);
int prompt_pimpl(string const & title, string const & question,
int default_button,
string const & b1, string const & b2, string const & b3);

View File

@ -1,3 +1,9 @@
2003-03-31 John Levon <levon@movementarian.org>
* Alert_pimpl.h:
* Alert.h:
* Alert.C: finally kill alert()
2003-03-30 Lars Gullik Bjønnes <larsbj@gullik.net>
* screen.C (drawFromTo): adjust for RowList.

View File

@ -1,3 +1,8 @@
2003-03-31 John Levon <levon@movementarian.org>
* ControlPrint.C:
* ControlDocument.C: more Alert cleanups
2003-03-29 John Levon <levon@movementarian.org>
* ControlSpellchecker.C: Alert cleanup

View File

@ -121,36 +121,60 @@ void ControlDocument::classApply()
old_class, new_class,
&*(lv_.buffer()->paragraphs.begin()),
lv_.buffer()->params);
if (ret) {
string s;
if (ret == 1) {
s = _("One paragraph couldn't be converted");
} else {
if (!ret)
return;
string s;
#if USE_BOOST_FORMAT
boost::format fmt(_("%1$s paragraphs couldn't be converted"));
fmt % ret;
s = fmt.str();
#else
s += tostr(ret);
s += _(" paragraphs couldn't be converted");
#endif
}
Alert::alert(_("Conversion Errors!"),s,
_("into chosen document class"));
if (ret == 1) {
boost::format fmt(_("One paragraph could not be converted\n"
"into the document class %2$s."));
fmt % textclasslist[new_class].name();
s = fmt.str();
} else {
boost::format fmt(_("%1$s paragraphs could not be converted\n"
"into the document class %2$s."));
fmt % tostr(ret);
fmt % textclasslist[new_class].name();
s = fmt.str();
}
#else
if (ret == 1) {
s += _("One paragraph could not be converted\n"
"into the document class ");
s += textclasslist[new_class].name() + ".";
} else {
s += tostr(ret);
s += _(" paragraphs could not be converted\n"
"into the document class ");
s += textclasslist[new_class].name() + ".";
}
#endif
Alert::warning(_("Class conversion errors"), s);
}
bool ControlDocument::loadTextclass(lyx::textclass_type tc) const
{
bool const success = textclasslist[tc].load();
if (!success) {
// problem changing class
// -- warn user (to retain old style)
Alert::alert(_("Conversion Errors!"),
_("Errors loading new document class."),
_("Reverting to original document class."));
}
if (success)
return success;
string s;
#if USE_BOOST_FORMAT
boost::format fmt(_("The document could not be converted\n"
"into the document class %1$s."));
fmt % textclasslist[tc].name();
s = fmt.str();
#else
s += _("The document could not be converted\n"
"into the document class ");
s += textclasslist[tc].name() + ".";
#endif
Alert::error(_("Could not change class"), s);
return success;
}

View File

@ -29,6 +29,7 @@
#include "support/filetools.h"
#include "support/path.h"
#include "support/systemcall.h"
#include "support/BoostFormat.h"
#include "debug.h" // for lyxerr
@ -81,6 +82,26 @@ string const ControlPrint::Browse(string const & in_name)
}
namespace {
void showPrintError(string const & name)
{
#if USE_BOOST_FORMAT
boost::format fmt(_("Could not print the document %1$s.\n"
"Check that your printer is set up correctly."));
fmt % MakeDisplayPath(name, 50);
string str = fmt.str();
#else
string str = _("Could not print the document ");
str += MakeDisplayPath(name, 50);
str += _(".\nCheck that your printer is set up correctly.");
#endif
Alert::error(_("Print document failed"), str);
}
}
/// print the current buffer
void ControlPrint::apply()
{
@ -142,9 +163,7 @@ void ControlPrint::apply()
command += converters.dvips_options(buffer()) + ' ';
if (!Exporter::Export(buffer(), "dvi", true)) {
Alert::alert(_("Error:"),
_("Unable to print"),
_("Check that your parameters are correct"));
showPrintError(buffer()->fileName());
return;
}
@ -205,9 +224,6 @@ void ControlPrint::apply()
lyxerr[Debug::LATEX] << "ControlPrint::apply(): print command = \""
<< command << '"' << endl;
if (res != 0) {
Alert::alert(_("Error:"),
_("Unable to print"),
_("Check that your parameters are correct"));
}
if (res != 0)
showPrintError(buffer()->fileName());
}

View File

@ -29,14 +29,6 @@
using std::pair;
using std::make_pair;
void alert_pimpl(string const & s1, string const & s2, string const & s3)
{
QMessageBox::warning(0, "LyX",
toqstr(s1 + '\n' + '\n' + s2 + '\n' + s3));
}
int prompt_pimpl(string const & tit, string const & question,
int default_button,
string const & b1, string const & b2, string const & b3)

View File

@ -1,3 +1,7 @@
2003-03-31 John Levon <levon@movementarian.org>
* Alert_pimpl.C: remove alert()
2003-03-29 John Levon <levon@movementarian.org>
* QBrowseBox.C: handle transparent pixmaps

View File

@ -25,13 +25,6 @@ using std::pair;
using std::make_pair;
using std::endl;
void alert_pimpl(string const & s1, string const & s2, string const & s3)
{
fl_set_resource("flAlert.dismiss.label", _("Dismiss"));
fl_show_alert(s1.c_str(), s2.c_str(), s3.c_str(), 0);
}
void warning_pimpl(string const &, string const & message)
{
fl_show_messages(message.c_str());
@ -60,7 +53,6 @@ int prompt_pimpl(string const &, string const & question,
boost::tie(b1label, b1sc) = parse_shortcut(b1);
boost::tie(b2label, b2sc) = parse_shortcut(b2);
boost::tie(b3label, b3sc) = parse_shortcut(b3);
lyxerr << "Parsed " << b1 << " as " << b1label << " and " << b1sc << endl;
if (b3.empty()) {
fl_set_choices_shortcut(b1sc.c_str(), b2sc.c_str(), "");

View File

@ -1,3 +1,7 @@
2003-03-31 John Levon <levon@movementarian.org>
* Alert_pimpl.C: remove alert()
2003-03-29 John Levon <levon@movementarian.org>
* bmtable.c: handle transparent pixels

View File

@ -1,12 +1,13 @@
/* This file is part of
* ======================================================
/**
* \file exporter.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* LyX, The Document Processor
* \author unknown
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
* ====================================================== */
* Full author contact details are available in file CREDITS
*/
#include <config.h>
@ -62,13 +63,14 @@ bool Importer::Import(LyXView * lv, string const & filename,
}
if (loader_format.empty()) {
#if USE_BOOST_FORMAT
Alert::alert(_("Cannot import file"),
boost::io::str(boost::format(_("No information for importing from %1$s"))
// FIXME: better english ...
Alert::error(_("Couldn't import file"),
boost::io::str(boost::format(_("No information for importing the format %1$s."))
% formats.prettyName(format)));
#else
Alert::alert(_("Cannot import file"),
_("No information for importing from ")
+ formats.prettyName(format));
Alert::error(_("Couldn't import file"),
_("No information for importing the format ")
+ formats.prettyName(format) + ".");
#endif
return false;
}

View File

@ -1,3 +1,7 @@
2003-03-31 John Levon <levon@movementarian.org>
* insettext.C: Alert fix
2003-03-30 Lars Gullik Bjønnes <larsbj@gullik.net>
* insettext.C (ascent): adjust for RowList

View File

@ -654,8 +654,16 @@ string const InsetGraphics::prepareFile(Buffer const * buf) const
<< temp_file
<< (success ? " succeeded\n" : " failed\n");
if (!success) {
Alert::alert(_("Cannot copy file"), orig_file_with_path,
_("into tempdir"));
#if USE_BOOST_FORMAT
boost::format fmt(_("Could not copy the file\n%1$s\ninto the temporary directory."));
fmt % orig_file_with_path;
string str = fmt.str();
#else
string str = _("Could not copy the file\n");
str += orig_file_with_path;
str += _("\ninto the temporary directory.");
#endif
Alert::error(_("Graphics display failed"), str);
return orig_file;
}
}
@ -689,15 +697,19 @@ string const InsetGraphics::prepareFile(Buffer const * buf) const
<< command << endl;
Systemcall one;
one.startscript(Systemcall::Wait, command);
if (!IsFileReadable(ChangeExtension(outfile_base, to)))
if (!IsFileReadable(ChangeExtension(outfile_base, to))) {
#if USE_BOOST_FORMAT
Alert::alert(_("Cannot convert Image (not existing file?)"),
boost::io::str(boost::format(_("No information for converting from %1$s to %2$s"))
% from % to));
boost::format fmt(_("No information for converting %1$s format files to %1$s.\n"
"Try defining a convertor in the preferences."));
fmt % from % to;
string str = fmt.str();
#else
Alert::alert(_("Cannot convert Image (not existing file?)"),
_("No information for converting from ") + from + " to " + to);
string str = _("No information for converting ");
str += from + _(" format files to " + to;
str += ".\nTry defining a convertor in the preferences.");
#endif
Alert::error(_("Could not convert image"), str);
}
}
return RemoveExtension(temp_file);

View File

@ -1290,9 +1290,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev)
#ifdef WITH_WARNINGS
#warning FIXME horrendously bad UI
#endif
Alert::alert(_("Impossible operation!"),
_("Cannot include more than one paragraph!"),
_("Sorry."));
Alert::error(_("Paste failed"), _("Cannot include more than one paragraph."));
break;
}
}

View File

@ -641,13 +641,14 @@ bool LyX::readRcFile(string const & name)
<< " in " << lyxrc_path << endl;
if (lyxrc.read(lyxrc_path) < 0) {
#if USE_BOOST_FORMAT
Alert::alert(_("LyX Warning!"),
boost::io::str(boost::format(_("Error while reading %1$s.")) % lyxrc_path),
_("Using built-in defaults."));
Alert::warning(_("Could not read preferences"),
boost::io::str(boost::format(
_("Error while reading the preferences file\n%1$s.\n"
"LyX will use the built-in defaults.")) % lyxrc_path));
#else
Alert::alert(_("LyX Warning!"),
_("Error while reading ") + lyxrc_path,
_("Using built-in defaults."));
Alert::warning(_("Could not read preferences"),
string(_("Error while reading the preferences file\n"))
+ lyxrc_path + _("LyX will use the built-in defaults."));
#endif
return false;
}