]> git.lyx.org Git - features.git/commitdiff
More Alert/ error message fixes
authorJohn Levon <levon@movementarian.org>
Sat, 29 Mar 2003 11:34:53 +0000 (11:34 +0000)
committerJohn Levon <levon@movementarian.org>
Sat, 29 Mar 2003 11:34:53 +0000 (11:34 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6629 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/buffer.C
src/bufferlist.C
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlSpellchecker.C

index 2e4d9c7a740f6d85c8ad901e4b50acd50da7c09c..27a4dfbbf9150983ed073a8b021988d3bd836da2 100644 (file)
@@ -2,6 +2,9 @@
 
        * bufferview_funcs.C: remove pointless Alert
 
+       * buffer.C: fix confusing error message when
+       a template is chmoded 000
+
 2003-03-29  John Levon  <levon@movementarian.org>
 
        * BufferView.C:
index 80544bf7422ba288d96b4e1f9a5235be9c91ea72..2fad83c2f3172931fb26452d8a3793ac68b169fa 100644 (file)
@@ -501,87 +501,96 @@ bool Buffer::readFile(LyXLex & lex, string const & filename)
 // FIXME: all the below Alerts should give the filename..
 bool Buffer::readFile(LyXLex & lex, string const & filename, ParagraphList::iterator pit)
 {
-       if (lex.isOK()) {
-               lex.next();
-               string const token(lex.getString());
-               if (token == "\\lyxformat") { // the first token _must_ be...
-                       lex.eatLine();
-                       string tmp_format = lex.getString();
-                       //lyxerr << "LyX Format: `" << tmp_format << '\'' << endl;
-                       // if present remove ".," from string.
-                       string::size_type dot = tmp_format.find_first_of(".,");
-                       //lyxerr << "           dot found at " << dot << endl;
-                       if (dot != string::npos)
-                               tmp_format.erase(dot, 1);
-                       file_format = strToInt(tmp_format);
-                       //lyxerr << "format: " << file_format << endl;
-                       if (file_format == LYX_FORMAT) {
-                               // current format
-                       } else if (file_format > LYX_FORMAT) {
-                               Alert::warning(_("Document format failure"),
-                                       _("This document was created with a newer version of "
-                                       "LyX. This is likely to cause problems."));
-                       } else if (file_format < LYX_FORMAT) {
-                               // old formats
-                               if (file_format < 200) {
-                                       Alert::error(_("Document format failure"),
-                                               _("This LyX document is too old to be read "
-                                               "by this version of LyX. Try LyX 0.10."));
-                                       return false;
-                               } else if (!filename.empty()) {
-                                       string command =
-                                               LibFileSearch("lyx2lyx", "lyx2lyx");
-                                       if (command.empty()) {
-                                               Alert::error(_("Conversion script not found"),
-                                                       _("The document is from an earlier version "
-                                                         "of LyX, but the conversion script lyx2lyx "
-                                                         "could not be found."));
-                                               return false;
-                                       }
-                                       command += " -t"
-                                               +tostr(LYX_FORMAT) + ' '
-                                               + QuoteName(filename);
-                                       lyxerr[Debug::INFO] << "Running '"
-                                                           << command << '\''
-                                                           << endl;
-                                       cmd_ret const ret = RunCommand(command);
-                                       if (ret.first) {
-                                               Alert::error(_("Conversion script failed"),
-                                                       _("The document is from an earlier version "
-                                                         "of LyX, but the lyx2lyx script failed "
-                                                         "to convert it."));
-                                               return false;
-                                       }
-                                       istringstream is(STRCONV(ret.second));
-                                       LyXLex tmplex(0, 0);
-                                       tmplex.setStream(is);
-                                       return readFile(tmplex, string(), pit);
-                               } else {
-                                       // This code is reached if lyx2lyx failed (for
-                                       // some reason) to change the file format of
-                                       // the file.
-                                       lyx::Assert(false);
-                                       return false;
-                               }
-                       }
-                       bool the_end = readBody(lex, pit);
-                       params.setPaperStuff();
+       if (!lex.isOK()) {
+               Alert::error(_("Document could not be read"),
+                       _("The specified document could not be read."));
+               return false;
+       }
+
+       lex.next();
+       string const token(lex.getString());
+
+       if (!lex.isOK()) {
+               Alert::error(_("Document could not be read"),
+                       _("The specified document could not be read."));
+               return false;
+       }
 
-                       if (!the_end) {
-                               Alert::error(_("Document format failure"),
-                                       _("The document ended unexpectedly, which means "
-                                         "that it is probably corrupted."));
+       // the first token _must_ be...
+       if (token != "\\lyxformat") {
+               Alert::error(_("Document format failure"),
+                       _("The specified document is not a LyX document."));
+               return false;
+       }
+
+       lex.eatLine();
+       string tmp_format = lex.getString();
+       //lyxerr << "LyX Format: `" << tmp_format << '\'' << endl;
+       // if present remove ".," from string.
+       string::size_type dot = tmp_format.find_first_of(".,");
+       //lyxerr << "           dot found at " << dot << endl;
+       if (dot != string::npos)
+                       tmp_format.erase(dot, 1);
+       file_format = strToInt(tmp_format);
+       //lyxerr << "format: " << file_format << endl;
+       if (file_format == LYX_FORMAT) {
+               // current format
+       } else if (file_format > LYX_FORMAT) {
+               Alert::warning(_("Document format failure"),
+                       _("This document was created with a newer version of "
+                       "LyX. This is likely to cause problems."));
+       } else if (file_format < LYX_FORMAT) {
+               // old formats
+               if (file_format < 200) {
+                       Alert::error(_("Document format failure"),
+                               _("This LyX document is too old to be read "
+                               "by this version of LyX. Try LyX 0.10."));
+                       return false;
+               } else if (!filename.empty()) {
+                       string command =
+                               LibFileSearch("lyx2lyx", "lyx2lyx");
+                       if (command.empty()) {
+                               Alert::error(_("Conversion script not found"),
+                                       _("The document is from an earlier version "
+                                         "of LyX, but the conversion script lyx2lyx "
+                                         "could not be found."));
+                               return false;
                        }
-                       return true;
+                       command += " -t"
+                               +tostr(LYX_FORMAT) + ' '
+                               + QuoteName(filename);
+                       lyxerr[Debug::INFO] << "Running '"
+                                           << command << '\''
+                                           << endl;
+                       cmd_ret const ret = RunCommand(command);
+                       if (ret.first) {
+                               Alert::error(_("Conversion script failed"),
+                                       _("The document is from an earlier version "
+                                         "of LyX, but the lyx2lyx script failed "
+                                         "to convert it."));
+                               return false;
+                       }
+                       istringstream is(STRCONV(ret.second));
+                       LyXLex tmplex(0, 0);
+                       tmplex.setStream(is);
+                       return readFile(tmplex, string(), pit);
                } else {
-                       Alert::error(_("Document format failure"),
-                               _("The specified document is not a LyX document."));
+                       // This code is reached if lyx2lyx failed (for
+                       // some reason) to change the file format of
+                       // the file.
+                       lyx::Assert(false);
+                       return false;
                }
-       } else {
-               Alert::error(_("Document could not be read"),
-                       _("The specified document could not be read."));
        }
-       return false;
+       bool the_end = readBody(lex, pit);
+       params.setPaperStuff();
+
+       if (!the_end) {
+               Alert::error(_("Document format failure"),
+                       _("The document ended unexpectedly, which means "
+                         "that it is probably corrupted."));
+       }
+       return true;
 }
 
 
index cf4b46cee12cd2b9ddd449170a63347a87a62e2c..1c7c9b563f20c022fe1a22cd12f04e34eb41a623 100644 (file)
@@ -331,8 +331,16 @@ Buffer * BufferList::readFile(string const & s, bool ronly)
        FileInfo fileInfo2(s);
 
        if (!fileInfo2.exist()) {
-               Alert::alert(_("Error!"), _("Cannot open file"),
-                       MakeDisplayPath(s));
+               string const file = MakeDisplayPath(s, 50);
+#if USE_BOOST_FORMAT
+               boost::format fmt(_("The specified document\n%1$s\ncould not be read."));
+               fmt % file;
+               string text = fmt.str();
+#else
+               string text = _("The specified document\n");
+               text += file + _(" could not be read.");
+#endif
+               Alert::error(_("Could not read document"), text);
                return 0;
        }
 
@@ -463,8 +471,16 @@ Buffer * BufferList::newFile(string const & name, string tname, bool isNamed)
                        }
                }
                if (!templateok) {
-                       Alert::alert(_("Error!"), _("Unable to open template"),
-                                  MakeDisplayPath(tname));
+                       string const file = MakeDisplayPath(tname, 50);
+#if USE_BOOST_FORMAT
+                       boost::format fmt(_("The specified document template\n%1$s\ncould not be read."));
+                       fmt % file;
+                       string text = fmt.str();
+#else
+                       string text = _("The specified document template\n");
+                       text += file + _(" could not be read.");
+#endif
+                       Alert::error(_("Could not read template"), text);
                        // no template, start with empty buffer
                        b->paragraphs.set(new Paragraph);
                        b->paragraphs.begin()->layout(b->params.getLyXTextClass().defaultLayout());
index f6f78f5a4c81b03a8d47d9894cd0cc661ca1c914..ab9bda9b0f25e70139b92e7787d6b8488350ae3e 100644 (file)
@@ -1,3 +1,7 @@
+2003-03-29  John Levon  <levon@movementarian.org>
+
+       * ControlSpellchecker.C: Alert cleanup
+
 2003-03-29  John Levon  <levon@movementarian.org>
 
        * helper_funcs.C: Alert cleanup
index 3cfba26973819552bf17fd37be74c1c0a586aa5b..576c7b6c293ff7993332d3d079fbf5824a3eb156 100644 (file)
@@ -115,7 +115,7 @@ void ControlSpellchecker::startSession()
                message = _("The spell-checker could not be started.\n"
                         "Maybe it is mis-configured.");
 
-       Alert::alert(_("The spell-checker has failed"), message);
+       Alert::error(_("The spell-checker has failed"), message);
        speller_.reset(0);
 }
 
@@ -208,7 +208,7 @@ bool ControlSpellchecker::checkAlive()
        view().hide();
        speller_.reset(0);
 
-       Alert::alert(_("The spell-checker has failed"), message);
+       Alert::error(_("The spell-checker has failed"), message);
        return false;
 }
 
@@ -239,7 +239,7 @@ void ControlSpellchecker::showSummary()
 #endif
 
        view().hide();
-       Alert::alert(_("Spell-checking is complete"), message);
+       Alert::information(_("Spell-checking is complete"), message);
 }