From: Jean-Marc Lasgouttes Date: Mon, 26 Nov 2001 10:19:58 +0000 (+0000) Subject: new alert code X-Git-Tag: 1.6.10~20297 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=85e30074c271cb2d13b984e9dcb223d7bdde19f4;p=lyx.git new alert code git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3074 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/lib/CREDITS b/lib/CREDITS index 3eef3e7f7d..ad67d75c58 100644 --- a/lib/CREDITS +++ b/lib/CREDITS @@ -151,6 +151,9 @@ @iE-mail: cfog@mech.ubc.ca Support for two-column figure (figure*) and table (table*) environments. Fixed minibuffer entry of floats. +@bPanayotis "PAP" Papasotiriou +@iE-mail: papasot@physics.upatras.gr + support for kluwer document class. @bJoacim Persson @iE-mail: sp2joap1@ida.his.se po-file for Swedish, a tool for picking shortcuts, diff --git a/po/POTFILES.in b/po/POTFILES.in index 525ba0e7c2..60d41c1241 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -74,6 +74,7 @@ src/frontends/qt2/QToc.C src/frontends/qt2/QURL.C src/frontends/qt2/QVCLog.C src/frontends/qt2/lengthcombo.C +src/frontends/xforms/Alert_pimpl.C src/frontends/xforms/FileDialog.C src/frontends/xforms/FormAboutlyx.C src/frontends/xforms/FormBibitem.C @@ -180,7 +181,6 @@ src/kbsequence.C src/language.C src/layout.C src/lyx_cb.C -src/lyx_gui_misc.C src/lyx_main.C src/lyxfind.C src/lyxfont.C diff --git a/src/BufferView2.C b/src/BufferView2.C index e927499555..9641a26017 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -23,7 +23,7 @@ #include "support/FileInfo.h" #include "lyxscreen.h" #include "support/filetools.h" -#include "lyx_gui_misc.h" +#include "frontends/Alert.h" #include "LaTeX.h" #include "BufferView_pimpl.h" #include "insets/insetcommand.h" //ChangeRefs @@ -63,7 +63,7 @@ bool BufferView::insertLyXFile(string const & filen) FileInfo const fi(fname); if (!fi.readable()) { - WriteAlert(_("Error!"), + Alert::alert(_("Error!"), _("Specified file is unreadable: "), MakeDisplayPath(fname, 50)); return false; @@ -73,7 +73,7 @@ bool BufferView::insertLyXFile(string const & filen) ifstream ifs(fname.c_str()); if (!ifs) { - WriteAlert(_("Error!"), + Alert::alert(_("Error!"), _("Cannot open specified file: "), MakeDisplayPath(fname, 50)); return false; diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 3d4851e509..fdbd79098c 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -28,6 +28,7 @@ #include "support/LAssert.h" #include "support/lstrings.h" #include "frontends/Dialogs.h" +#include "frontends/Alert.h" #include "insets/insetbib.h" #include "insets/insettext.h" /// added for Dispatch functions @@ -1814,7 +1815,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) if (!label.empty()) { //bv_->savePosition(0); if (!bv_->gotoLabel(label)) - WriteAlert(_("Error"), + Alert::alert(_("Error"), _("Couldn't find this label"), _("in current document.")); } diff --git a/src/ChangeLog b/src/ChangeLog index 85507493f6..c921167f6f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2001-11-23 John Levon + + * : change to use Alert.h + 2001-11-25 Dekel Tsur * buffer.C (parseSingleLyXformat2Token): Insert an error inset diff --git a/src/buffer.C b/src/buffer.C index 437ae91b6d..c9777568b1 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -97,8 +97,8 @@ #include "lyxtext.h" #include "gettext.h" #include "language.h" -#include "lyx_gui_misc.h" // WarnReadonly() #include "frontends/Dialogs.h" +#include "frontends/Alert.h" #include "encoding.h" #include "exporter.h" #include "Lsstream.h" @@ -234,9 +234,6 @@ void Buffer::setReadonly(bool flag) updateTitles(); users->owner()->getDialogs()->updateBufferDependent(false); } - if (read_only) { - WarnReadonly(filename); - } } @@ -365,7 +362,7 @@ bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par) s += tostr(unknown_layouts); s += _(" paragraphs"); } - WriteAlert(_("Textclass Loading Error!"), s, + Alert::alert(_("Textclass Loading Error!"), s, _("When reading " + fileName())); } @@ -377,7 +374,7 @@ bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par) s += tostr(unknown_tokens); s += _(" unknown tokens"); } - WriteAlert(_("Textclass Loading Error!"), s, + Alert::alert(_("Textclass Loading Error!"), s, _("When reading " + fileName())); } @@ -666,19 +663,19 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par, if (pp.first) { params.textclass = pp.second; } else { - WriteAlert(string(_("Textclass error")), + Alert::alert(string(_("Textclass error")), string(_("The document uses an unknown textclass \"")) + lex.getString() + string("\"."), string(_("LyX will not be able to produce output correctly."))); params.textclass = 0; } if (!textclasslist.Load(params.textclass)) { - // if the textclass wasn't loaded properly - // we need to either substitute another - // or stop loading the file. - // I can substitute but I don't see how I can - // stop loading... ideas?? ARRae980418 - WriteAlert(_("Textclass Loading Error!"), + // if the textclass wasn't loaded properly + // we need to either substitute another + // or stop loading the file. + // I can substitute but I don't see how I can + // stop loading... ideas?? ARRae980418 + Alert::alert(_("Textclass Loading Error!"), string(_("Can't load textclass ")) + textclasslist.NameOfClass(params.textclass), _("-- substituting default")); @@ -1537,14 +1534,14 @@ bool Buffer::readFile(LyXLex & lex, Paragraph * par) // current format } else if (file_format > LYX_FORMAT) { // future format - WriteAlert(_("Warning!"), + Alert::alert(_("Warning!"), _("LyX file format is newer that what"), _("is supported in this LyX version. Expect some problems.")); } else if (file_format < LYX_FORMAT) { // old formats if (file_format < 200) { - WriteAlert(_("ERROR!"), + Alert::alert(_("ERROR!"), _("Old LyX file format found. " "Use LyX 0.10.x to read this!")); return false; @@ -1556,16 +1553,17 @@ bool Buffer::readFile(LyXLex & lex, Paragraph * par) if (file_format < 213) the_end = true; - if (!the_end) - WriteAlert(_("Warning!"), + if (!the_end) { + Alert::alert(_("Warning!"), _("Reading of document is not complete"), _("Maybe the document is truncated")); + } return true; } else { // "\\lyxformat" not found - WriteAlert(_("ERROR!"), _("Not a LyX file!")); + Alert::alert(_("ERROR!"), _("Not a LyX file!")); } } else - WriteAlert(_("ERROR!"), _("Unable to read file!")); + Alert::alert(_("ERROR!"), _("Unable to read file!")); return false; } @@ -1661,7 +1659,7 @@ bool Buffer::writeFile(string const & fname, bool flag) const lyxerr << _("Error! Document is read-only: ") << fname << endl; else - WriteAlert(_("Error! Document is read-only: "), + Alert::alert(_("Error! Document is read-only: "), fname); return false; } @@ -1674,7 +1672,7 @@ bool Buffer::writeFile(string const & fname, bool flag) const lyxerr << _("Error! Cannot write file: ") << fname << endl; else - WriteFSAlert(_("Error! Cannot write file: "), + Alert::err_alert(_("Error! Cannot write file: "), fname); return false; } @@ -1685,7 +1683,7 @@ bool Buffer::writeFile(string const & fname, bool flag) const lyxerr << _("Error! Cannot open file: ") << fname << endl; else - WriteFSAlert(_("Error! Cannot open file: "), + Alert::err_alert(_("Error! Cannot open file: "), fname); return false; } @@ -1922,7 +1920,7 @@ void Buffer::writeFileAscii(string const & fname, int linelen) { ofstream ofs(fname.c_str()); if (!ofs) { - WriteFSAlert(_("Error: Cannot write file:"), fname); + Alert::err_alert(_("Error: Cannot write file:"), fname); return; } writeFileAscii(ofs, linelen); @@ -1956,7 +1954,7 @@ void Buffer::makeLaTeXFile(string const & fname, ofstream ofs(fname.c_str()); if (!ofs) { - WriteFSAlert(_("Error: Cannot open file: "), fname); + Alert::err_alert(_("Error: Cannot open file: "), fname); return; } @@ -2537,7 +2535,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) ofstream ofs(fname.c_str()); if (!ofs) { - WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), fname); + Alert::alert(_("LYX_ERROR:"), _("Cannot write file"), fname); return; } @@ -2975,7 +2973,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) { ofstream ofs(fname.c_str()); if (!ofs) { - WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), fname); + Alert::alert(_("LYX_ERROR:"), _("Cannot write file"), fname); return; } @@ -3371,7 +3369,7 @@ int Buffer::runChktex() int res = chktex.run(terr); // run chktex if (res == -1) { - WriteAlert(_("chktex did not work!"), + Alert::alert(_("chktex did not work!"), _("Could not run with file:"), name); } else if (res > 0) { // Insert all errors as errors boxes diff --git a/src/bufferlist.C b/src/bufferlist.C index c5af831668..3d39fd6de8 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -22,6 +22,7 @@ #include #include +#include "frontends/Alert.h" #include "bufferlist.h" #include "lyx_main.h" #include "support/FileInfo.h" @@ -97,53 +98,58 @@ bool BufferList::empty() const } +bool BufferList::qwriteOne(Buffer * buf, string const & fname, string & unsaved_list) +{ + bool reask = true; + while (reask) { + switch (Alert::askConfirmation(_("Changes in document:"), + fname, + _("Save document?"))) { + case 1: // Yes + // FIXME: WriteAs can be asynch ! + if (buf->isUnnamed()) + reask = !WriteAs(current_view, buf); + else { + reask = !MenuWrite(current_view, buf); + } + break; + case 2: // No + // if we crash after this we could + // have no autosave file but I guess + // this is really inprobable (Jug) + if (buf->isUnnamed()) { + removeAutosaveFile(buf->fileName()); + } + + unsaved_list += MakeDisplayPath(fname, 50) + "\n"; + return true; + case 3: // Cancel + return false; + } + } + return false; +} + + bool BufferList::qwriteAll() { - bool askMoreConfirmation = false; + bool are_unsaved = false; string unsaved; for (BufferStorage::iterator it = bstore.begin(); - it != bstore.end(); ++it) { + it != bstore.end(); ++it) { if (!(*it)->isLyxClean()) { string fname; if ((*it)->isUnnamed()) fname = OnlyFilename((*it)->fileName()); else fname = MakeDisplayPath((*it)->fileName(), 50); - bool reask = true; - while (reask) { - switch (AskConfirmation(_("Changes in document:"), - fname, - _("Save document?"))) { - case 1: // Yes - if ((*it)->isUnnamed()) - reask = !WriteAs(current_view, (*it)); - else { - reask = !MenuWrite(current_view, (*it)); - } - break; - case 2: // No - // if we crash after this we could - // have no autosave file but I guess - // this is really inprobable (Jug) - if ((*it)->isUnnamed()) { - removeAutosaveFile((*it)->fileName()); - } - askMoreConfirmation = true; - unsaved += MakeDisplayPath(fname, 50); - unsaved += "\n"; - reask = false; - break; - case 3: // Cancel - return false; - } - } + are_unsaved = qwriteOne(*it, fname, unsaved); } } - if (askMoreConfirmation && - lyxrc.exit_confirmation && - !AskQuestion(_("Some documents were not saved:"), - unsaved, _("Exit anyway?"))) { - return false; + + if (are_unsaved && lyxrc.exit_confirmation) { + return Alert::askQuestion(_("Some documents were not saved:"), + unsaved, _("Exit anyway?")); } return true; @@ -183,7 +189,7 @@ bool BufferList::close(Buffer * buf) fname = MakeDisplayPath(buf->fileName(), 50); bool reask = true; while (reask) { - switch (AskConfirmation(_("Changes in document:"), + switch (Alert::askConfirmation(_("Changes in document:"), fname, _("Save document?"))){ case 1: // Yes @@ -351,7 +357,7 @@ Buffer * BufferList::readFile(string const & s, bool ronly) FileInfo fileInfo2(s); if (!fileInfo2.exist()) { - WriteAlert(_("Error!"), _("Cannot open file"), + Alert::alert(_("Error!"), _("Cannot open file"), MakeDisplayPath(s)); return 0; } @@ -365,7 +371,7 @@ Buffer * BufferList::readFile(string const & s, bool ronly) if (fileInfoE.exist() && fileInfo2.exist()) { if (fileInfoE.getModificationTime() > fileInfo2.getModificationTime()) { - if (AskQuestion(_("An emergency save of this document exists!"), + if (Alert::askQuestion(_("An emergency save of this document exists!"), MakeDisplayPath(s, 50), _("Try to load that instead?"))) { ts = e; @@ -389,7 +395,7 @@ Buffer * BufferList::readFile(string const & s, bool ronly) if (fileInfoA.exist() && fileInfo2.exist()) { if (fileInfoA.getModificationTime() > fileInfo2.getModificationTime()) { - if (AskQuestion(_("Autosave file is newer."), + if (Alert::askQuestion(_("Autosave file is newer."), MakeDisplayPath(s, 50), _("Load that one instead?"))) { ts = a; @@ -461,7 +467,7 @@ Buffer * BufferList::newFile(string const & name, string tname, bool isNamed) } } if (!templateok) { - WriteAlert(_("Error!"), _("Unable to open template"), + Alert::alert(_("Error!"), _("Unable to open template"), MakeDisplayPath(tname)); // no template, start with empty buffer b->paragraph = new Paragraph; @@ -492,7 +498,7 @@ Buffer * BufferList::loadLyXFile(string const & filename, bool tolastfiles) // file already open? if (exists(s)) { - if (AskQuestion(_("Document is already open:"), + if (Alert::askQuestion(_("Document is already open:"), MakeDisplayPath(s, 50), _("Do you want to reload that document?"))) { // Reload is accomplished by closing and then loading @@ -523,7 +529,7 @@ Buffer * BufferList::loadLyXFile(string const & filename, bool tolastfiles) if (LyXVC::file_not_found_hook(s)) { // Ask if the file should be checked out for // viewing/editing, if so: load it. - if (AskQuestion(_("Do you want to retrieve file under version control?"))) { + if (Alert::askQuestion(_("Do you want to retrieve file under version control?"))) { // How can we know _how_ to do the checkout? // With the current VC support it has to be, // a RCS file since CVS do not have special ,v files. @@ -531,7 +537,7 @@ Buffer * BufferList::loadLyXFile(string const & filename, bool tolastfiles) return loadLyXFile(filename, tolastfiles); } } - if (AskQuestion(_("Cannot open specified file:"), + if (Alert::askQuestion(_("Cannot open specified file:"), MakeDisplayPath(s, 50), _("Create new document with this name?"))) { diff --git a/src/bufferlist.h b/src/bufferlist.h index 9520605070..adb65fde2c 100644 --- a/src/bufferlist.h +++ b/src/bufferlist.h @@ -142,6 +142,9 @@ public: Buffer * getBuffer(unsigned int); private: + /// ask to save a buffer on quit + bool qwriteOne(Buffer * buf, string const & fname, string & unsaved_list); + /// BufferStorage bstore; diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index b8f1b5eff9..87d2a29486 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -19,7 +19,7 @@ #include "BufferView.h" #include "paragraph.h" #include "lyxfont.h" -#include "lyx_gui_misc.h" +#include "frontends/Alert.h" #include "lyxtext.h" #include "buffer.h" #include "support/lstrings.h" @@ -68,7 +68,7 @@ void lang(BufferView * bv, string const & l) font.setLanguage(lang); toggleAndShow(bv, font); } else - WriteAlert(_("Error! unknown language"),l); + Alert::alert(_("Error! unknown language"),l); } @@ -226,8 +226,7 @@ void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall) bv->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); if (font.language() != ignore_language || - font.number() != LyXFont::IGNORE) - { + font.number() != LyXFont::IGNORE) { LyXCursor & cursor = text->cursor; text->computeBidiTables(bv->buffer(), cursor.row()); if (cursor.boundary() != diff --git a/src/converter.C b/src/converter.C index 93e7957730..0250142766 100644 --- a/src/converter.C +++ b/src/converter.C @@ -28,6 +28,7 @@ #include "lyx_gui_misc.h" #include "lyx_cb.h" // ShowMessage() #include "support/lyxfunctional.h" +#include "frontends/Alert.h" #include "gettext.h" #include "BufferView.h" #include "debug.h" @@ -168,7 +169,7 @@ bool Formats::view(Buffer const * buffer, string const & filename, format->isChildFormat()) format = getFormat(format->parentFormat()); if (!format || format->viewer().empty()) { - WriteAlert(_("Cannot view file"), + Alert::alert(_("Cannot view file"), _("No information for viewing ") + prettyName(format_name)); return false; @@ -198,7 +199,7 @@ bool Formats::view(Buffer const * buffer, string const & filename, int const res = one.startscript(Systemcalls::SystemDontWait, command); if (res) { - WriteAlert(_("Cannot view file"), + Alert::alert(_("Cannot view file"), _("Error while executing"), command.substr(0, 50)); return false; @@ -574,7 +575,7 @@ bool Converters::convert(Buffer const * buffer, EdgePath edgepath = getPath(from_format, to_format); if (edgepath.empty()) { - WriteAlert(_("Cannot convert file"), + Alert::alert(_("Cannot convert file"), _("No information for converting from ") + formats.prettyName(from_format) + _(" to ") + formats.prettyName(to_format)); @@ -665,10 +666,10 @@ bool Converters::convert(Buffer const * buffer, if (res) { if (conv.to == "program") - WriteAlert(_("There were errors during the Build process."), + Alert::alert(_("There were errors during the Build process."), _("You should try to fix them.")); else - WriteAlert(_("Cannot convert file"), + Alert::alert(_("Cannot convert file"), "Error while executing", command.substr(0, 50)); return false; @@ -691,7 +692,7 @@ bool Converters::convert(Buffer const * buffer, string to = subst(conv.result_dir, token_base, to_base); if (!lyx::rename(from, to)) { - WriteAlert(_("Error while trying to move directory:"), + Alert::alert(_("Error while trying to move directory:"), from, ("to ") + to); return false; } @@ -727,7 +728,7 @@ bool Converters::move(string const & from, string const & to, bool copy) ? lyx::copy(from2, to2) : lyx::rename(from2, to2); if (!moved && no_errors) { - WriteAlert(_("Error while trying to move file:"), + Alert::alert(_("Error while trying to move file:"), from2, _("to ") + to2); no_errors = false; } @@ -818,13 +819,13 @@ bool Converters::scanLog(Buffer const * buffer, string const & command, } string head; split(command, head, ' '); - WriteAlert(_("There were errors during running of ") + head, + Alert::alert(_("There were errors during running of ") + head, s, t); return false; } else if (result & LaTeX::NO_OUTPUT) { string const s = _("The operation resulted in"); string const t = _("an empty file."); - WriteAlert(_("Resulting file is empty"), s, t); + Alert::alert(_("Resulting file is empty"), s, t); return false; } return true; @@ -872,7 +873,7 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command) // check return value from latex.run(). if ((result & LaTeX::NO_LOGFILE)) { - WriteAlert(_("LaTeX did not work!"), + Alert::alert(_("LaTeX did not work!"), _("Missing log file:"), name); } else if ((result & LaTeX::ERRORS)) { int num_errors = latex.getNumErrors(); @@ -886,12 +887,12 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command) s += _(" errors detected."); t = _("You should try to fix them."); } - WriteAlert(_("There were errors during the LaTeX run."), + Alert::alert(_("There were errors during the LaTeX run."), s, t); } else if (result & LaTeX::NO_OUTPUT) { string const s = _("The operation resulted in"); string const t = _("an empty file."); - WriteAlert(_("Resulting file is empty"), s, t); + Alert::alert(_("Resulting file is empty"), s, t); } if (bv) diff --git a/src/exporter.C b/src/exporter.C index 8cea7fd389..68922a87fd 100644 --- a/src/exporter.C +++ b/src/exporter.C @@ -22,7 +22,7 @@ #include "support/filetools.h" #include "lyxrc.h" #include "converter.h" -#include "lyx_gui_misc.h" //WriteAlert +#include "frontends/Alert.h" #include "gettext.h" using std::vector; @@ -45,7 +45,7 @@ bool Exporter::Export(Buffer * buffer, string const & format, } } if (backend_format.empty()) { - WriteAlert(_("Cannot export file"), + Alert::alert(_("Cannot export file"), _("No information for exporting to ") + formats.prettyName(format)); return false; @@ -72,7 +72,7 @@ bool Exporter::Export(Buffer * buffer, string const & format, else if (backend_format == format) buffer->makeLaTeXFile(filename, string(), true); else if (contains(buffer->filepath, ' ')) { - WriteAlert(_("Cannot run latex."), + Alert::alert(_("Cannot run latex."), _("The path to the lyx file cannot contain spaces.")); return false; } else diff --git a/src/figure_form.C b/src/figure_form.C index 2227be0549..5a257d6411 100644 --- a/src/figure_form.C +++ b/src/figure_form.C @@ -2,6 +2,7 @@ #include #include "lyx_gui_misc.h" #include "gettext.h" +#include "frontends/xforms/xforms_helpers.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/Alert.C b/src/frontends/Alert.C new file mode 100644 index 0000000000..474d536759 --- /dev/null +++ b/src/frontends/Alert.C @@ -0,0 +1,88 @@ +/** + * \file Alert.C + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#include + +#include + +#include "debug.h" +#include "lyxrc.h" + +#include "Alert_pimpl.h" + +using std::endl; + +namespace Alert { + + void 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); + } + } + + void err_alert(string const & s1, string const & s2) { + alert(s1, s2, strerror(errno)); + } + + bool askQuestion(string const & s1, string const & s2, string const & s3, bool default_value) { + if (!lyxrc.use_gui) { + lyxerr << "----------------------------------------" << endl + << s1 << endl; + if (!s2.empty()) + lyxerr << s2 << endl; + if (!s3.empty()) + lyxerr << s3 << endl; + lyxerr << "Assuming answer is " + << (default_value ? "yes" : "no") + << endl + << "----------------------------------------" << endl; + return default_value; + } else { + return askQuestion_pimpl(s1, s2, s3); + } + } + + int askConfirmation(string const & s1, string const & s2, string const & s3, int default_value) { + if (!lyxrc.use_gui) { + lyxerr << "----------------------------------------" << endl + << s1 << endl; + if (!s2.empty()) + lyxerr << s2 << endl; + if (!s3.empty()) + lyxerr << s3 << endl; + lyxerr << "Assuming answer is "; + if (default_value == 1) + lyxerr << "yes"; + else if (default_value == 2) + lyxerr << "no"; + else + lyxerr << "cancel"; + lyxerr << endl + << "----------------------------------------" << endl; + return default_value; + } else { + return askConfirmation_pimpl(s1, s2, s3); + } + } + + std::pair const askForText(string const & msg, string const & dflt) { + if (!lyxrc.use_gui) { + lyxerr << "----------------------------------------" << endl + << msg << endl + << "Assuming answer is " << dflt + << "----------------------------------------" << endl; + return std::make_pair(true, dflt); + } else { + return askForText_pimpl(msg, dflt); + } + } +} diff --git a/src/frontends/Alert.h b/src/frontends/Alert.h new file mode 100644 index 0000000000..ead6f8a606 --- /dev/null +++ b/src/frontends/Alert.h @@ -0,0 +1,31 @@ +/** + * \file Alert.h + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#include "support/lstrings.h" +#include + +namespace Alert { + /// show an alert message + void alert(string const & s1, string const & s2 = string(), + string const & s3 = string()); + + /// show an alert message and strerror(errno) + void err_alert(string const & s1, string const & s2 = string()); + + /// ask a question + bool askQuestion(string const & s1, string const & s2 = string(), + string const & s3 = string(), bool default_value = true); + + /// Returns 1 for yes, 2 for no, 3 for cancel. + int askConfirmation(string const & s1, string const & s2 = string(), + string const & s3 = string(), int default_value = 1); + + /// Asks for a text + std::pair const askForText(string const & msg, + string const & dflt = string()); +}; diff --git a/src/frontends/Alert_pimpl.h b/src/frontends/Alert_pimpl.h new file mode 100644 index 0000000000..cedbde7909 --- /dev/null +++ b/src/frontends/Alert_pimpl.h @@ -0,0 +1,15 @@ +/** + * \file Alert_pimpl.h + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#include "debug.h" + +// GUI-specific implementations +void alert_pimpl(string const & s1, string const & s2, string const & s3); +bool askQuestion_pimpl(string const & s1, string const & s2, string const & s3); +int askConfirmation_pimpl(string const & s1, string const & s2, string const & s3); +std::pair const askForText_pimpl(string const & msg, string const & dflt); diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index a6543aa6cd..62b95805ae 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,10 @@ +2001-11-22 John Levon + + * Makefile.am: + * Alert.h: + * Alert.C: + * Alert_pimpl.h: alerts etc. + 2001-10-09 Herbert Voss * Dialogs.h: added showFile and showTexinfo signals. diff --git a/src/frontends/GUIRunTime.h b/src/frontends/GUIRunTime.h index 48694441b7..5bfc5c57cb 100644 --- a/src/frontends/GUIRunTime.h +++ b/src/frontends/GUIRunTime.h @@ -53,5 +53,8 @@ public: /// The current visual depth static int x11VisualDepth(); + /// the server's DPI estimate + static + float getScreenDPI(); }; #endif diff --git a/src/frontends/Makefile.am b/src/frontends/Makefile.am index 7a441b7774..5072965fba 100644 --- a/src/frontends/Makefile.am +++ b/src/frontends/Makefile.am @@ -20,6 +20,9 @@ libfrontends_la_DEPENDENCIES = @FRONTEND_GUILIB@ \ controllers/libcontrollers.la libfrontends_la_SOURCES=\ + Alert.C \ + Alert.h \ + Alert_pimpl.h \ Dialogs.C \ Dialogs.h \ DialogBase.h \ diff --git a/src/frontends/controllers/ControlExternal.C b/src/frontends/controllers/ControlExternal.C index 73e5433df1..f9e357f566 100644 --- a/src/frontends/controllers/ControlExternal.C +++ b/src/frontends/controllers/ControlExternal.C @@ -32,7 +32,7 @@ #include "support/filetools.h" #include "support/lstrings.h" #include "frontends/FileDialog.h" -#include "lyx_gui_misc.h" // WriteAlert +#include "frontends/Alert.h" #include "gettext.h" #include "BufferView.h" @@ -193,7 +193,7 @@ string const ControlExternal::Browse(string const & input) const contains(p, "~") || contains(p, "$") || contains(p, "%")) { - WriteAlert(_("Filename can't contain any " + Alert::alert(_("Filename can't contain any " "of these characters:"), // xgettext:no-c-format _("'#', '~', '$' or '%'.")); diff --git a/src/frontends/controllers/ControlPrint.C b/src/frontends/controllers/ControlPrint.C index a9fb35a0c3..cd9cb263c4 100644 --- a/src/frontends/controllers/ControlPrint.C +++ b/src/frontends/controllers/ControlPrint.C @@ -28,7 +28,7 @@ #include "PrinterParams.h" #include "Liason.h" #include "helper_funcs.h" // browseFile -#include "lyx_gui_misc.h" // WriteAlert +#include "frontends/Alert.h" #include "gettext.h" #include "BufferView.h" #include "support/LAssert.h" @@ -53,7 +53,7 @@ void ControlPrint::apply() view().apply(); if (!printBuffer(lv_.buffer(), params())) { - WriteAlert(_("Error:"), + Alert::alert(_("Error:"), _("Unable to print"), _("Check that your parameters are correct")); } diff --git a/src/frontends/controllers/ControlTexinfo.C b/src/frontends/controllers/ControlTexinfo.C index 5dccb1afbd..ce4ddbb91e 100644 --- a/src/frontends/controllers/ControlTexinfo.C +++ b/src/frontends/controllers/ControlTexinfo.C @@ -58,7 +58,7 @@ void ControlTexinfo::runTexhash() const //path to texhash through system Systemcalls one(Systemcalls::System,"texhash"); p.pop(); -// WriteAlert(_("texhash run!"), +// Alert::alert(_("texhash run!"), // _("rebuilding of the TeX-tree could only be successfull"), // _("if you have had user-write-permissions to the tex-dir.")); } diff --git a/src/frontends/controllers/helper_funcs.C b/src/frontends/controllers/helper_funcs.C index 91b07996c2..d3fdf4435e 100644 --- a/src/frontends/controllers/helper_funcs.C +++ b/src/frontends/controllers/helper_funcs.C @@ -25,7 +25,7 @@ #include "support/filetools.h" // OnlyPath, OnlyFilename #include "support/lstrings.h" #include "gettext.h" // _() -#include "lyx_gui_misc.h" // WriteAlert +#include "frontends/Alert.h" using std::pair; using std::vector; @@ -99,7 +99,7 @@ string const browseFile(LyXView * lv, string const & filename, if (result.second.find_first_of("#~$% ") == string::npos) break; - WriteAlert(_("Filename can't contain any " + Alert::alert(_("Filename can't contain any " "of these characters:"), _("space, '#', '~', '$' or '%'.")); } diff --git a/src/frontends/gnome/FormPrint.C b/src/frontends/gnome/FormPrint.C index 960fb06429..d2ee57de3b 100644 --- a/src/frontends/gnome/FormPrint.C +++ b/src/frontends/gnome/FormPrint.C @@ -154,7 +154,7 @@ void FormPrint::apply() copies_unsorted_->get_active(), copies_count_->get_value_as_int()))) { - WriteAlert(_("Error:"), + Alert::alert(_("Error:"), _("Unable to print"), _("Check that your parameters are correct")); } diff --git a/src/frontends/qt2/GUIRunTime.C b/src/frontends/qt2/GUIRunTime.C index 564afc2592..4692ba0729 100644 --- a/src/frontends/qt2/GUIRunTime.C +++ b/src/frontends/qt2/GUIRunTime.C @@ -118,6 +118,14 @@ int GUIRunTime::x11VisualDepth() } +float GUIRunTime::getScreenDPI() +{ + Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen); + return ((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) + + (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2; +} + + void GUIRunTime::setDefaults() { FL_IOPT cntl; diff --git a/src/frontends/qt2/QDocument.C b/src/frontends/qt2/QDocument.C index 920a7f2cc1..88906d724f 100644 --- a/src/frontends/qt2/QDocument.C +++ b/src/frontends/qt2/QDocument.C @@ -362,14 +362,14 @@ bool QDocument::class_apply() s += tostr(ret); s += _(" paragraphs couldn't be converted"); } - WriteAlert(_("Conversion Errors!"),s, + Alert::alert(_("Conversion Errors!"),s, _("into chosen document class")); } params.textclass = new_class; } else { // problem changing class -- warn user and retain old style - WriteAlert(_("Conversion Errors!"), + Alert::alert(_("Conversion Errors!"), _("Errors loading new document class."), _("Reverting to original document class.")); dialog_->docClassCO->setCurrentItem( params.textclass ); @@ -993,7 +993,7 @@ void QDocument::CheckChoiceClass(FL_OBJECT * ob, long) BufferParams params = lv_->buffer()->params; if (params.textclass != tc - && AskQuestion(_("Should I set some parameters to"), + && Alert::askQuestion(_("Should I set some parameters to"), _("the defaults of this document class?"))) { params.textclass = tc; params.useClassDefaults(); @@ -1001,7 +1001,7 @@ void QDocument::CheckChoiceClass(FL_OBJECT * ob, long) } } else { // unable to load new style - WriteAlert(_("Conversion Errors!"), + Alert::alert(_("Conversion Errors!"), _("Unable to switch to new document class."), _("Reverting to original document class.")); combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1); diff --git a/src/frontends/xforms/Alert_pimpl.C b/src/frontends/xforms/Alert_pimpl.C new file mode 100644 index 0000000000..33436e3233 --- /dev/null +++ b/src/frontends/xforms/Alert_pimpl.C @@ -0,0 +1,61 @@ +/** + * \file Alert_pimpl.C + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#include + +#include FORMS_H_LOCATION + +#include + +#include +#include "xforms_helpers.h" + +#include "Alert.h" +#include "Alert_pimpl.h" + +using std::pair; +using std::make_pair; + +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); +} + + +bool askQuestion_pimpl(string const & s1, string const & s2, string const & s3) +{ + fl_set_resource("flQuestion.yes.label", idex(_("Yes|Yy#y"))); + fl_set_resource("flQuestion.no.label", idex(_("No|Nn#n"))); + return fl_show_question((s1 + "\n" + s2 + "\n" + s3).c_str(), 0); +} + + +int askConfirmation_pimpl(string const & s1, string const & s2, string const & s3) +{ + fl_set_choices_shortcut(scex(_("Yes|Yy#y")), + scex(_("No|Nn#n")), + scex(_("Cancel|^["))); + return fl_show_choice(s1.c_str(), s2.c_str(), s3.c_str(), + 3, idex(_("Yes|Yy#y")), + idex(_("No|Nn#n")), + idex(_("Cancel|^[")), 3); +} + + +pair const askForText_pimpl(string const & msg, string const & dflt) +{ + fl_set_resource("flInput.cancel.label", idex(_("Cancel|^["))); + fl_set_resource("flInput.ok.label", idex(_("OK|#O"))); + fl_set_resource("flInput.clear.label", idex(_("Clear|#e"))); + char const * tmp = fl_show_input(msg.c_str(), dflt.c_str()); + if (tmp != 0) + return make_pair(true, string(tmp)); + else + return make_pair(false, string()); +} diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index fd9e228572..efbb13730a 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,14 @@ +2001-11-23 John Levon + + * Makefile.am: + * Alert_pimpl.C: Alert etc. + + * xforms_helpers.h: + * xforms_helpers.C: + * forms/fdfix.sh: move idex etc. to here + + * GUIRunTime.C: move getScreenDPI() to here + 2001-11-20 Jürgen Spitzmüller * forms/form_ref.fd, form_preferences.fd, form_citation.fd, diff --git a/src/frontends/xforms/FormDocument.C b/src/frontends/xforms/FormDocument.C index ef32b626ad..24246d1049 100644 --- a/src/frontends/xforms/FormDocument.C +++ b/src/frontends/xforms/FormDocument.C @@ -18,8 +18,8 @@ #pragma implementation #endif -#include "lyx_gui_misc.h" - +#include "Alert.h" + #include "FormDocument.h" #include "form_document.h" #include "Dialogs.h" @@ -378,7 +378,7 @@ namespace { */ bool saveParamsAsDefault(BufferParams const ¶ms) { - if (!AskQuestion(_("Do you want to save the current settings"), + if (!Alert::askQuestion(_("Do you want to save the current settings"), _("for the document layout as default?"), _("(they will be valid for any new document)"))) return false; @@ -754,13 +754,13 @@ bool FormDocument::class_apply() s += tostr(ret); s += _(" paragraphs couldn't be converted"); } - WriteAlert(_("Conversion Errors!"),s, + Alert::alert(_("Conversion Errors!"),s, _("into chosen document class")); } } else { // problem changing class -- warn user and retain old style - WriteAlert(_("Conversion Errors!"), + Alert::alert(_("Conversion Errors!"), _("Errors loading new document class."), _("Reverting to original document class.")); combo_doc_class->select(int(old_class) + 1); @@ -1396,7 +1396,7 @@ void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long) } } else { // unable to load new style - WriteAlert(_("Conversion Errors!"), + Alert::alert(_("Conversion Errors!"), _("Unable to switch to new document class."), _("Reverting to original document class.")); combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1); diff --git a/src/frontends/xforms/FormFiledialog.C b/src/frontends/xforms/FormFiledialog.C index 3dc6233008..70a3094fcf 100644 --- a/src/frontends/xforms/FormFiledialog.C +++ b/src/frontends/xforms/FormFiledialog.C @@ -21,7 +21,7 @@ using std::map; using std::max; using std::sort; -#include "lyx_gui_misc.h" // for WriteFSAlert +#include "frontends/Alert.h" #include "support/FileInfo.h" #include "support/lyxlib.h" #include "support/lstrings.h" @@ -223,7 +223,7 @@ void FileDialog::Private::Reread() // Opens directory DIR * pDirectory = ::opendir(pszDirectory.c_str()); if (!pDirectory) { - WriteFSAlert(_("Warning! Couldn't open directory."), + Alert::err_alert(_("Warning! Couldn't open directory."), pszDirectory); pszDirectory = lyx::getcwd(); pDirectory = ::opendir(pszDirectory.c_str()); @@ -389,7 +389,7 @@ void FileDialog::Private::SetDirectory(string const & Path) // must check the directory exists DIR * pDirectory = ::opendir(tmp.c_str()); if (!pDirectory) { - WriteFSAlert(_("Warning! Couldn't open directory."), tmp); + Alert::err_alert(_("Warning! Couldn't open directory."), tmp); } else { ::closedir(pDirectory); pszDirectory = tmp; diff --git a/src/frontends/xforms/FormMathsBitmap.C b/src/frontends/xforms/FormMathsBitmap.C index 0239867db3..51a960223d 100644 --- a/src/frontends/xforms/FormMathsBitmap.C +++ b/src/frontends/xforms/FormMathsBitmap.C @@ -24,7 +24,7 @@ #include "LyXView.h" #include "bmtable.h" #include "debug.h" -#include "lyx_gui_misc.h" // scex, idex +#include "xforms_helpers.h" #include "gettext.h" #include "support/LAssert.h" diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index 9027b8e74c..083a47c27b 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -38,7 +38,6 @@ #include "debug.h" #include "support/filetools.h" #include "support/LAssert.h" -#include "lyx_gui_misc.h" // idex, scex #include "lyxlex.h" #include "input_validators.h" #include "xforms_helpers.h" diff --git a/src/frontends/xforms/GUIRunTime.C b/src/frontends/xforms/GUIRunTime.C index ae3c7fabfc..9d4305856a 100644 --- a/src/frontends/xforms/GUIRunTime.C +++ b/src/frontends/xforms/GUIRunTime.C @@ -144,3 +144,10 @@ int GUIRunTime::x11VisualDepth() { return fl_get_visual_depth(); } + +float GUIRunTime::getScreenDPI() +{ + Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen); + return ((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) + + (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2; +} diff --git a/src/frontends/xforms/Makefile.am b/src/frontends/xforms/Makefile.am index b5d112021e..e9fcdf2bd1 100644 --- a/src/frontends/xforms/Makefile.am +++ b/src/frontends/xforms/Makefile.am @@ -13,6 +13,7 @@ LYXDATADIRS = forms ETAGS_ARGS = --lang=c++ # Alphabetical order please. It makes it easier to figure out what's missing. libxforms_la_SOURCES = \ + Alert_pimpl.C \ bmtable.c \ bmtable.h \ Color.C \ diff --git a/src/frontends/xforms/form_aboutlyx.C b/src/frontends/xforms/form_aboutlyx.C index 90631bdbf0..3af800144f 100644 --- a/src/frontends/xforms/form_aboutlyx.C +++ b/src/frontends/xforms/form_aboutlyx.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_bibitem.C b/src/frontends/xforms/form_bibitem.C index a2ffad5524..d4cb2a397e 100644 --- a/src/frontends/xforms/form_bibitem.C +++ b/src/frontends/xforms/form_bibitem.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_bibtex.C b/src/frontends/xforms/form_bibtex.C index 8113b90097..2cb9d195b4 100644 --- a/src/frontends/xforms/form_bibtex.C +++ b/src/frontends/xforms/form_bibtex.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_browser.C b/src/frontends/xforms/form_browser.C index 326e955295..1461173f75 100644 --- a/src/frontends/xforms/form_browser.C +++ b/src/frontends/xforms/form_browser.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_character.C b/src/frontends/xforms/form_character.C index 99c089f438..73158cb025 100644 --- a/src/frontends/xforms/form_character.C +++ b/src/frontends/xforms/form_character.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_citation.C b/src/frontends/xforms/form_citation.C index 63fc203535..e1283163ef 100644 --- a/src/frontends/xforms/form_citation.C +++ b/src/frontends/xforms/form_citation.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_document.C b/src/frontends/xforms/form_document.C index 8ddd56e37c..2d9d63bbfa 100644 --- a/src/frontends/xforms/form_document.C +++ b/src/frontends/xforms/form_document.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" #include "bmtable.h" diff --git a/src/frontends/xforms/form_error.C b/src/frontends/xforms/form_error.C index 591fa980fd..04d7c200d2 100644 --- a/src/frontends/xforms/form_error.C +++ b/src/frontends/xforms/form_error.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_ert.C b/src/frontends/xforms/form_ert.C index e310e2301e..aa5274bb03 100644 --- a/src/frontends/xforms/form_ert.C +++ b/src/frontends/xforms/form_ert.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_external.C b/src/frontends/xforms/form_external.C index 42a2aeb88b..3c50ba861d 100644 --- a/src/frontends/xforms/form_external.C +++ b/src/frontends/xforms/form_external.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_filedialog.C b/src/frontends/xforms/form_filedialog.C index 3753d0046c..5ddce85089 100644 --- a/src/frontends/xforms/form_filedialog.C +++ b/src/frontends/xforms/form_filedialog.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_float.C b/src/frontends/xforms/form_float.C index 342dbca0d5..f4c073b5d7 100644 --- a/src/frontends/xforms/form_float.C +++ b/src/frontends/xforms/form_float.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_graphics.C b/src/frontends/xforms/form_graphics.C index e8933410e6..17c0778b3c 100644 --- a/src/frontends/xforms/form_graphics.C +++ b/src/frontends/xforms/form_graphics.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_include.C b/src/frontends/xforms/form_include.C index 1ebc27fdd0..113e53d246 100644 --- a/src/frontends/xforms/form_include.C +++ b/src/frontends/xforms/form_include.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_index.C b/src/frontends/xforms/form_index.C index a1ff9c7b37..1ee1a363df 100644 --- a/src/frontends/xforms/form_index.C +++ b/src/frontends/xforms/form_index.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_maths_deco.C b/src/frontends/xforms/form_maths_deco.C index 27dab33de1..f42c57fa2a 100644 --- a/src/frontends/xforms/form_maths_deco.C +++ b/src/frontends/xforms/form_maths_deco.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" #include "bmtable.h" diff --git a/src/frontends/xforms/form_maths_delim.C b/src/frontends/xforms/form_maths_delim.C index 19abad27d5..6bbcb5115e 100644 --- a/src/frontends/xforms/form_maths_delim.C +++ b/src/frontends/xforms/form_maths_delim.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" #include "bmtable.h" diff --git a/src/frontends/xforms/form_maths_matrix.C b/src/frontends/xforms/form_maths_matrix.C index 2347431cfb..53c52ad519 100644 --- a/src/frontends/xforms/form_maths_matrix.C +++ b/src/frontends/xforms/form_maths_matrix.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_maths_panel.C b/src/frontends/xforms/form_maths_panel.C index 29cfe4e123..10effbce91 100644 --- a/src/frontends/xforms/form_maths_panel.C +++ b/src/frontends/xforms/form_maths_panel.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_maths_space.C b/src/frontends/xforms/form_maths_space.C index 931a336108..e3b9e2788c 100644 --- a/src/frontends/xforms/form_maths_space.C +++ b/src/frontends/xforms/form_maths_space.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_minipage.C b/src/frontends/xforms/form_minipage.C index d706c63a30..1d9e30ded4 100644 --- a/src/frontends/xforms/form_minipage.C +++ b/src/frontends/xforms/form_minipage.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_paragraph.C b/src/frontends/xforms/form_paragraph.C index 9635d4d09f..2fc61655ab 100644 --- a/src/frontends/xforms/form_paragraph.C +++ b/src/frontends/xforms/form_paragraph.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_preamble.C b/src/frontends/xforms/form_preamble.C index 85e301e14b..39502e2df8 100644 --- a/src/frontends/xforms/form_preamble.C +++ b/src/frontends/xforms/form_preamble.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_preferences.C b/src/frontends/xforms/form_preferences.C index 4762431ff5..19ccb6eacb 100644 --- a/src/frontends/xforms/form_preferences.C +++ b/src/frontends/xforms/form_preferences.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_print.C b/src/frontends/xforms/form_print.C index 13b01f751d..1fcf4a7e78 100644 --- a/src/frontends/xforms/form_print.C +++ b/src/frontends/xforms/form_print.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_ref.C b/src/frontends/xforms/form_ref.C index bc03e354d4..0986d4d944 100644 --- a/src/frontends/xforms/form_ref.C +++ b/src/frontends/xforms/form_ref.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_search.C b/src/frontends/xforms/form_search.C index 00bd8ba0ab..5b496f7038 100644 --- a/src/frontends/xforms/form_search.C +++ b/src/frontends/xforms/form_search.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_spellchecker.C b/src/frontends/xforms/form_spellchecker.C index 6afe9d1ea5..6892eed544 100644 --- a/src/frontends/xforms/form_spellchecker.C +++ b/src/frontends/xforms/form_spellchecker.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_tabular.C b/src/frontends/xforms/form_tabular.C index 76eb5af3a3..f65d0d2d3c 100644 --- a/src/frontends/xforms/form_tabular.C +++ b/src/frontends/xforms/form_tabular.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_tabular_create.C b/src/frontends/xforms/form_tabular_create.C index 80d46292c0..e30cb99202 100644 --- a/src/frontends/xforms/form_tabular_create.C +++ b/src/frontends/xforms/form_tabular_create.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_texinfo.C b/src/frontends/xforms/form_texinfo.C index 4b94255af5..397680ae98 100644 --- a/src/frontends/xforms/form_texinfo.C +++ b/src/frontends/xforms/form_texinfo.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_thesaurus.C b/src/frontends/xforms/form_thesaurus.C index 3713917400..bc1d5e56a4 100644 --- a/src/frontends/xforms/form_thesaurus.C +++ b/src/frontends/xforms/form_thesaurus.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_toc.C b/src/frontends/xforms/form_toc.C index 46538a0e38..bb90e84b58 100644 --- a/src/frontends/xforms/form_toc.C +++ b/src/frontends/xforms/form_toc.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/form_url.C b/src/frontends/xforms/form_url.C index 4d5e4b002e..63a443622b 100644 --- a/src/frontends/xforms/form_url.C +++ b/src/frontends/xforms/form_url.C @@ -1,6 +1,6 @@ // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext #include -#include "lyx_gui_misc.h" +#include "xforms_helpers.h" #include "gettext.h" /* Form definition file generated with fdesign. */ diff --git a/src/frontends/xforms/forms/fdfix.sh b/src/frontends/xforms/forms/fdfix.sh index 8579e3e1c8..217b88f9c8 100644 --- a/src/frontends/xforms/forms/fdfix.sh +++ b/src/frontends/xforms/forms/fdfix.sh @@ -67,7 +67,7 @@ sed -e "s/CLASSNAME/$CLASSNAME/" < $FDFIXC > $FDFIXC_MOD # Modify .c file for use by LyX echo "// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext" > $COUT echo "#include " >> $COUT -echo "#include \"lyx_gui_misc.h\"" >> $COUT +echo "#include \"xforms_helpers.h\"" >> $COUT echo "#include \"gettext.h\"" >> $COUT grep bmtable $CIN > /dev/null diff --git a/src/frontends/xforms/input_validators.C b/src/frontends/xforms/input_validators.C index f22740e67e..cc237bf3de 100644 --- a/src/frontends/xforms/input_validators.C +++ b/src/frontends/xforms/input_validators.C @@ -119,7 +119,7 @@ void fl_print_range_filter(FL_OBJECT * ob, piece = strip(piece) ; piece = frontStrip(piece) ; if (!stringOnlyContains (piece, "0123456789-")) { - WriteAlert(_("ERROR! Unable to print!"), + Alert::alert(_("ERROR! Unable to print!"), _("Check 'range of pages'!")); return; } diff --git a/src/frontends/xforms/xforms_helpers.C b/src/frontends/xforms/xforms_helpers.C index 5a0271c9b4..03f34eeae5 100644 --- a/src/frontends/xforms/xforms_helpers.C +++ b/src/frontends/xforms/xforms_helpers.C @@ -24,6 +24,42 @@ using std::ofstream; using std::pair; using std::vector; +// Extract shortcut from | string +char const * flyx_shortcut_extract(char const * sc) +{ + // Find '|' in the sc and return the string after that. + register char const * sd = sc; + while(sd[0]!= 0 && sd[0] != '|') ++sd; + + if (sd[0] == '|') { + ++sd; + //lyxerr << sd << endl; + return sd; + } + return ""; +} + + +// Extract identifier from | string +char const * flyx_ident_extract(char const * sc) +{ + register char const * se = sc; + while(se[0]!= 0 && se[0] != '|') ++se; + + if (se[0] == 0) return sc; + + char * sb = new char[se - sc + 1]; + int index = 0; + register char const * sd = sc; + while (sd != se) { + sb[index] = sd[0]; + ++index; ++sd; + } + sb[index] = 0; + return sb; +} + + // Set an FL_OBJECT to activated or deactivated void setEnabled(FL_OBJECT * ob, bool enable) { diff --git a/src/frontends/xforms/xforms_helpers.h b/src/frontends/xforms/xforms_helpers.h index 8604faa9c7..f17fdd0758 100644 --- a/src/frontends/xforms/xforms_helpers.h +++ b/src/frontends/xforms/xforms_helpers.h @@ -7,7 +7,24 @@ #pragma interface #endif +#include + +#include FORMS_H_LOCATION + #include "Color.h" +#include "support/lstrings.h" + +#include + +/// Extract shortcut from | string +char const * flyx_shortcut_extract(char const * sc); +/// Shortcut for flyx_shortcut_extract +#define scex flyx_shortcut_extract + +/// Extract shortcut from | string +char const * flyx_ident_extract(char const * sc); +/// Shortcut for flyx_ident_extract +#define idex flyx_ident_extract /// Set an FL_OBJECT to activated or deactivated void setEnabled(FL_OBJECT *, bool enable); diff --git a/src/importer.C b/src/importer.C index 961cb23b8b..65c3ce185c 100644 --- a/src/importer.C +++ b/src/importer.C @@ -23,7 +23,7 @@ #include "bufferlist.h" #include "support/filetools.h" -#include "lyx_gui_misc.h" //WriteAlert +#include "frontends/Alert.h" #include "gettext.h" #include "BufferView.h" @@ -58,7 +58,7 @@ bool Importer::Import(LyXView * lv, string const & filename, } } if (loader_format.empty()) { - WriteAlert(_("Cannot import file"), + Alert::alert(_("Cannot import file"), _("No information for importing from ") + formats.prettyName(format)); return false; diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 6b93fa5635..c6909bac74 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2001-11-23 John Levon + + * various: update for Alert.h + 2001-11-22 John Levon * inset.h: fix comment diff --git a/src/insets/figinset.C b/src/insets/figinset.C index 2c6352033f..659e489c97 100644 --- a/src/insets/figinset.C +++ b/src/insets/figinset.C @@ -56,6 +56,7 @@ #include "lyxrc.h" #include "gettext.h" #include "lyx_gui_misc.h" // CancelCloseBoxCB +#include "frontends/Alert.h" #include "support/FileInfo.h" #include "support/lyxlib.h" #include "support/os.h" @@ -1218,17 +1219,11 @@ string const InsetFig::editMessage() const } -void InsetFig::edit(BufferView * bv, int, int, unsigned int) +void InsetFig::edit(BufferView *, int, int, unsigned int) { lyxerr[Debug::INFO] << "Editing InsetFig." << endl; regenerate(); - // We should have RO-versions of the form instead. - // The actual prevention of altering a readonly doc - // is done in CallbackFig() - if (bv->buffer()->isReadonly()) - WarnReadonly(bv->buffer()->fileName()); - if (!form) { form = create_form_Figure(); fl_set_form_atclose(form->Figure, CancelCloseBoxCB, 0); @@ -2004,7 +1999,7 @@ void InsetFig::browseFile() if (contains(p, "#") || contains(p, "~") || contains(p, "$") || contains(p, "%") || contains(p, " ")) { - WriteAlert(_("Filename can't contain any " + Alert::alert(_("Filename can't contain any " "of these characters:"), // xgettext:no-c-format _("space, '#', '~', '$' or '%'.")); diff --git a/src/insets/insetert.C b/src/insets/insetert.C index f1bef0a34f..4aeb306f0b 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -24,6 +24,7 @@ #include "LyXView.h" #include "lyxtext.h" #include "frontends/Dialogs.h" +#include "frontends/Alert.h" #include "debug.h" using std::ostream; @@ -232,7 +233,7 @@ void InsetERT::setFont(BufferView *, LyXFont const &, bool, bool selectall) // if selectall is activated then the fontchange was an outside general // fontchange and this messages is not needed if (!selectall) - WriteAlert(_("Impossible Operation!"), + Alert::alert(_("Impossible Operation!"), _("Not permitted to change font-types inside ERT-insets!"), _("Sorry.")); } diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index b7065f4a8d..590b50a65d 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -16,7 +16,7 @@ #include "insetlabel.h" #include "support/LOstream.h" -#include "lyx_gui_misc.h" //askForText +#include "frontends/Alert.h" #include "support/lstrings.h" //frontStrip, strip #include "lyxtext.h" #include "buffer.h" @@ -44,12 +44,7 @@ vector const InsetLabel::getLabelList() const void InsetLabel::edit(BufferView * bv, int, int, unsigned int) { - if (bv->buffer()->isReadonly()) { - WarnReadonly(bv->buffer()->fileName()); - return; - } - - pair result = askForText(_("Enter label:"), getContents()); + pair result = Alert::askForText(_("Enter label:"), getContents()); if (result.first) { string new_contents = frontStrip(strip(result.second)); if (!new_contents.empty() && diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 2d482028e2..fa5becf69e 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -34,6 +34,7 @@ #include "LyXView.h" #include "insets/insettext.h" #include "frontends/Dialogs.h" +#include "frontends/Alert.h" #include "debug.h" #include "WorkArea.h" #include "gettext.h" @@ -1825,7 +1826,7 @@ void InsetTabular::tabularFeatures(BufferView * bv, case LyXTabular::MULTICOLUMN: { if (sel_row_start != sel_row_end) { - WriteAlert(_("Impossible Operation!"), + Alert::alert(_("Impossible Operation!"), _("Multicolumns can only be horizontally."), _("Sorry.")); return; diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 3d984c2a30..b4f3dbbf35 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -32,7 +32,7 @@ #include "layout.h" #include "LaTeXFeatures.h" #include "Painter.h" -#include "lyx_gui_misc.h" +#include "frontends/Alert.h" #include "lyxtext.h" #include "lyxcursor.h" #include "CutAndPaste.h" @@ -1188,7 +1188,7 @@ InsetText::localDispatch(BufferView * bv, if (!autoBreakRows) { if (CutAndPaste::nrOfParagraphs() > 1) { - WriteAlert(_("Impossible operation"), + Alert::alert(_("Impossible operation"), _("Cannot include more than one paragraph!"), _("Sorry.")); break; diff --git a/src/layout.C b/src/layout.C index 484f3a34cc..ba04bcb15d 100644 --- a/src/layout.C +++ b/src/layout.C @@ -20,7 +20,7 @@ #include "layout.h" #include "lyxlex.h" #include "support/filetools.h" -#include "lyx_gui_misc.h" +#include "frontends/Alert.h" #include "debug.h" #include "gettext.h" #include "support/LAssert.h" @@ -1366,7 +1366,7 @@ bool LyXTextClassList::Read () "textclass file `" << MakeDisplayPath(real_file, 1000) << "'. Exiting." << endl; - WriteAlert(_("LyX wasn't able to find its layout descriptions!"), + Alert::alert(_("LyX wasn't able to find its layout descriptions!"), _("Check that the file \"textclass.lst\""), _("is installed correctly. Sorry, has to exit :-(")); return false; @@ -1430,7 +1430,7 @@ bool LyXTextClassList::Read () if (classlist.empty()) { lyxerr << "LyXTextClassList::Read: no textclasses found!" << endl; - WriteAlert(_("LyX wasn't able to find any layout description!"), + Alert::alert(_("LyX wasn't able to find any layout description!"), _("Check the contents of the file \"textclass.lst\""), _("Sorry, has to exit :-(")); return false; diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 739a744735..d94564d492 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -16,7 +16,6 @@ #include #include "lyx_cb.h" -#include "lyx_gui_misc.h" #include "lyx_main.h" #include "buffer.h" #include "bufferlist.h" @@ -26,6 +25,7 @@ #include "LyXView.h" #include "lyxrc.h" #include "lyxtext.h" +#include "frontends/Alert.h" #include "frontends/FileDialog.h" #include "frontends/GUIRunTime.h" #include "insets/insetlabel.h" @@ -141,7 +141,7 @@ bool MenuWrite(BufferView * bv, Buffer * buffer) if (!buffer->save()) { string const fname = buffer->fileName(); string const s = MakeAbsPath(fname); - if (AskQuestion(_("Save failed. Rename and try again?"), + if (Alert::askQuestion(_("Save failed. Rename and try again?"), MakeDisplayPath(s, 50), _("(If not, document is not saved.)"))) { return WriteAs(bv, buffer); @@ -196,7 +196,7 @@ bool WriteAs(BufferView * bv, Buffer * buffer, string const & filename) // Same name as we have already? if (!buffer->isUnnamed() && fname == oldname) { - if (!AskQuestion(_("Same name as document already has:"), + if (!Alert::askQuestion(_("Same name as document already has:"), MakeDisplayPath(fname, 50), _("Save anyway?"))) return false; @@ -204,7 +204,7 @@ bool WriteAs(BufferView * bv, Buffer * buffer, string const & filename) } // No, but do we have another file with this name open? else if (!buffer->isUnnamed() && bufferlist.exists(fname)) { - if (AskQuestion(_("Another document with same name open!"), + if (Alert::askQuestion(_("Another document with same name open!"), MakeDisplayPath(fname, 50), _("Replace with current document?"))) { @@ -221,7 +221,7 @@ bool WriteAs(BufferView * bv, Buffer * buffer, string const & filename) } // Check whether the file exists else { FileInfo const myfile(fname); - if (myfile.isOK() && !AskQuestion(_("Document already exists:"), + if (myfile.isOK() && !Alert::askQuestion(_("Document already exists:"), MakeDisplayPath(fname, 50), _("Replace file?"))) return false; @@ -251,7 +251,7 @@ int MenuRunChktex(Buffer * buffer) int ret; if (buffer->isSGML()) { - WriteAlert(_("Chktex does not work with SGML derived documents.")); + Alert::alert(_("Chktex does not work with SGML derived documents.")); return 0; } else ret = buffer->runChktex(); @@ -269,9 +269,9 @@ int MenuRunChktex(Buffer * buffer) s += _(" warnings found."); t = _("Use `Navigate->Error' to find them."); } - WriteAlert(_("Chktex run successfully"), s, t); + Alert::alert(_("Chktex run successfully"), s, t); } else { - WriteAlert(_("Error!"), _("It seems chktex does not work.")); + Alert::alert(_("Error!"), _("It seems chktex does not work.")); } return ret; } @@ -430,14 +430,14 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph) FileInfo fi(fname); if (!fi.readable()) { - WriteFSAlert(_("Error! Specified file is unreadable: "), + Alert::err_alert(_("Error! Specified file is unreadable: "), MakeDisplayPath(fname, 50)); return; } ifstream ifs(fname.c_str()); if (!ifs) { - WriteFSAlert(_("Error! Cannot open specified file: "), + Alert::err_alert(_("Error! Cannot open specified file: "), MakeDisplayPath(fname, 50)); return; } @@ -512,7 +512,7 @@ void MenuInsertLabel(BufferView * bv, string const & arg) } pair result = - askForText(_("Enter new label to insert:"), text); + Alert::askForText(_("Enter new label to insert:"), text); if (result.first) { label = frontStrip(strip(result.second)); } @@ -539,7 +539,7 @@ void Reconfigure(BufferView * bv) p.pop(); bv->owner()->message(_("Reloading configuration...")); lyxrc.read(LibFileSearch(string(), "lyxrc.defaults")); - WriteAlert(_("The system has been reconfigured."), + Alert::alert(_("The system has been reconfigured."), _("You need to restart LyX to make use of any"), _("updated document class specifications.")); } diff --git a/src/lyx_gui_misc.C b/src/lyx_gui_misc.C index dc4c6ca537..fb98996455 100644 --- a/src/lyx_gui_misc.C +++ b/src/lyx_gui_misc.C @@ -14,43 +14,25 @@ #pragma implementation #endif -#include +#include FORMS_H_LOCATION + #include "lyx_gui_misc.h" -#include "BufferView.h" -#include "buffer.h" -#include "gettext.h" #include "figure_form.h" -#include "lyx_cb.h" -#include "lyx_main.h" #include "print_form.h" -#include "LyXView.h" -#include "bufferview_funcs.h" -#include "support/filetools.h" -#include "lyxrc.h" -#include "debug.h" - -using std::pair; -using std::make_pair; -using std::endl; - -extern BufferView * current_view; extern FD_form_figure * fd_form_figure; extern FD_form_sendto * fd_form_sendto; extern void HideFiguresPopups(); - -// Prevents LyX from being killed when the close box is pressed in a popup. +// The code below is just waiting to go away really ... + extern "C" int CancelCloseBoxCB(FL_FORM *, void *) { return FL_CANCEL; } - -// Redraw the form (on receipt of a Signal indicating, for example, -// that the xform colors have been re-mapped). void RedrawAllBufferRelatedDialogs() { if (fd_form_figure->form_figure->visible) { @@ -61,16 +43,8 @@ void RedrawAllBufferRelatedDialogs() } } -// Prevents LyX from crashing when no buffers available -// This is also one of the functions that we _really_ dont want -// we should try to finds way to help us with that. -// The signal/slot mechanism can probably help. void CloseAllBufferRelatedDialogs() { - // don't forget to check that dynamically created forms - // have been created otherwise hiding one could cause a crash - // need the visible check otherwise XForms prints a warning - // if hiding an invisible form if (fd_form_figure->form_figure->visible) { fl_hide_form(fd_form_figure->form_figure); } @@ -80,171 +54,7 @@ void CloseAllBufferRelatedDialogs() HideFiguresPopups(); } -// This is another function we really don't want. -// Again the Signal/Slot mechanism is tailor made for this task. void updateAllVisibleBufferRelatedDialogs(bool) { HideFiguresPopups(); } - -// Extract shortcut from | string -char const * flyx_shortcut_extract(char const * sc) -{ - // Find '|' in the sc and return the string after that. - register char const * sd = sc; - while(sd[0]!= 0 && sd[0] != '|') ++sd; - - if (sd[0] == '|') { - ++sd; - //lyxerr << sd << endl; - return sd; - } - return ""; -} - - -// Extract identifier from | string -char const * flyx_ident_extract(char const * sc) -{ - register char const * se = sc; - while(se[0]!= 0 && se[0] != '|') ++se; - - if (se[0] == 0) return sc; - - char * sb = new char[se - sc + 1]; - int index = 0; - register char const * sd = sc; - while (sd != se) { - sb[index] = sd[0]; - ++index; ++sd; - } - sb[index] = 0; - return sb; -} - - -// -void WriteAlert(string const & s1, string const & s2, string const & s3) -{ - LyXView * lview = 0; - if (current_view && current_view->owner()) - lview = current_view->owner(); - if (lview) { - /// Write to minibuffer - lview->prohibitInput(); - string const msg = s1 + ' ' + s2 + ' ' + s3; - lview->message(msg); - fl_set_resource("flAlert.dismiss.label", _("Dismiss")); - fl_show_alert(s1.c_str(), s2.c_str(), s3.c_str(), 0); - lview->allowInput(); - } else { - /// Write to lyxerr - lyxerr << "----------------------------------------" << endl - << s1 << endl << s2 << endl << s3 << endl - << "----------------------------------------" << endl; - } -} - - -// Alarms user of something related to files -void WriteFSAlert(string const & s1, string const & s2) -{ - WriteAlert(s1, s2, strerror(errno)); -} - - -bool AskQuestion(string const & s1, string const & s2, string const & s3, - bool default_value) -{ - if (!lyxrc.use_gui) { - lyxerr << "----------------------------------------" << endl - << s1 << endl; - if (!s2.empty()) - lyxerr << s2 << endl; - if (!s3.empty()) - lyxerr << s3 << endl; - lyxerr << "Assuming answer is " - << (default_value ? "yes" : "no") - << endl - << "----------------------------------------" << endl; - return default_value; - } - - fl_set_resource("flQuestion.yes.label", idex(_("Yes|Yy#y"))); - fl_set_resource("flQuestion.no.label", idex(_("No|Nn#n"))); - return fl_show_question((s1 + "\n" + s2 + "\n" + s3).c_str(), 0); -} - - -// Returns 1 for yes, 2 for no, 3 for cancel. -int AskConfirmation(string const & s1, string const & s2, string const & s3, - int default_value) -{ - if (!lyxrc.use_gui) { - lyxerr << "----------------------------------------" << endl - << s1 << endl; - if (!s2.empty()) - lyxerr << s2 << endl; - if (!s3.empty()) - lyxerr << s3 << endl; - lyxerr << "Assuming answer is "; - if (default_value == 1) - lyxerr << "yes"; - else if (default_value == 2) - lyxerr << "no"; - else - lyxerr << "cancel"; - lyxerr << endl - << "----------------------------------------" << endl; - return default_value; - } - - fl_set_choices_shortcut(scex(_("Yes|Yy#y")), - scex(_("No|Nn#n")), - scex(_("Cancel|^["))); - return fl_show_choice(s1.c_str(), s2.c_str(), s3.c_str(), - 3, idex(_("Yes|Yy#y")), - idex(_("No|Nn#n")), - idex(_("Cancel|^[")), 3); -} - - -// Asks for a text -pair const -askForText(string const & msg, string const & dflt) -{ - if (!lyxrc.use_gui) { - lyxerr << "----------------------------------------" << endl - << msg << endl - << "Assuming answer is " << dflt - << "----------------------------------------" << endl; - return make_pair(true, dflt); - } - - fl_set_resource("flInput.cancel.label", idex(_("Cancel|^["))); - fl_set_resource("flInput.ok.label", idex(_("OK|#O"))); - fl_set_resource("flInput.clear.label", idex(_("Clear|#e"))); - char const * tmp = fl_show_input(msg.c_str(), dflt.c_str()); - if (tmp != 0) - return make_pair(true, string(tmp)); - else - return make_pair(false, string()); -} - - -// Inform the user that the buffer is read-only, and that changes in the -// dialog box that is to appear will be ignored. -void WarnReadonly(string const & file) -{ - WriteAlert(_("Any changes will be ignored"), - _("The document is read-only:"), - MakeDisplayPath(file)); -} - -/// Get the dpi setting of the current screen -float getScreenDPI() -{ - Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen); //DefaultScreen(fl_get_display()); - return ((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) + - (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2; -} diff --git a/src/lyx_gui_misc.h b/src/lyx_gui_misc.h index 8ce53f9a00..661eb9c751 100644 --- a/src/lyx_gui_misc.h +++ b/src/lyx_gui_misc.h @@ -19,8 +19,6 @@ #endif #include FORMS_H_LOCATION -#include "LString.h" -#include /* needed for pair<> definition */ /// Prevents LyX from being killed when the close box is pressed in a popup. extern "C" @@ -36,42 +34,4 @@ void CloseAllBufferRelatedDialogs(); /// Ensures info in visible popups are always correct. void updateAllVisibleBufferRelatedDialogs(bool switched = false); -/* These shortcut extractors should be shifted to frontends/xforms/ eventually */ - -/// Extract shortcut from | string -char const * flyx_shortcut_extract(char const * sc); -/// Shortcut for flyx_shortcut_extract -#define scex flyx_shortcut_extract - -/// Extract shortcut from | string -char const * flyx_ident_extract(char const * sc); -/// Shortcut for flyx_ident_extract -#define idex flyx_ident_extract - -/// Show message -void WriteAlert(string const & s1, string const & s2 = string(), - string const & s3 = string()); - -/// Alarms user of something related to files -void WriteFSAlert(string const & s1, string const & s2 = string()); - -/// Asks "Yes" or "No". Returns true for yes, false for no -bool AskQuestion(string const & s1, string const & s2 = string(), - string const & s3 = string(), bool default_value = true); - -/// Asks "Yes", "No" or "Cancel". Returns 1 for yes, 2 for no, 3 for cancel -int AskConfirmation(string const & s1, string const & s2 = string(), - string const & s3 = string(), int default_value = 1); - -/// returns a bool: false=cancelled, true=okay. string contains returned text -std::pair const -askForText(string const & msg, - string const & dflt = string()); - -/// Informs the user that changes in the coming form will be ignored -void WarnReadonly(string const & file); - -/// Get the dpi setting of the current screen -float getScreenDPI(); - #endif diff --git a/src/lyx_main.C b/src/lyx_main.C index 68cd2f04b3..1dfd3ced2f 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -22,7 +22,8 @@ #include "lyx_gui.h" #include "LyXView.h" #include "lyxfunc.h" -#include "lyx_gui_misc.h" +#include "frontends/Alert.h" +#include "frontends/GUIRunTime.h" #include "lyxrc.h" #include "support/path.h" #include "support/filetools.h" @@ -433,7 +434,7 @@ void LyX::init(bool gui) // Calculate screen dpi as average of x-DPI and y-DPI: if (lyxrc.use_gui) { - lyxrc.dpi = getScreenDPI(); + lyxrc.dpi = GUIRunTime::getScreenDPI(); lyxerr[Debug::INIT] << "DPI setting detected to be " << lyxrc.dpi + 0.5 << endl; } else { @@ -612,7 +613,7 @@ void LyX::queryUserLyXDir(bool explicit_userdir) // If the user specified explicitely a directory, ask whether // to create it (otherwise, always create it) if (explicit_userdir && - !AskQuestion(_("You have specified an invalid LyX directory."), + !Alert::askQuestion(_("You have specified an invalid LyX directory."), _("It is needed to keep your own configuration."), _("Should I try to set it up for you (recommended)?"))) { lyxerr << _("Running without personal LyX directory.") << endl; @@ -651,7 +652,7 @@ bool LyX::readRcFile(string const & name) lyxerr[Debug::INIT] << "Found " << name << " in " << lyxrc_path << endl; if (lyxrc.read(lyxrc_path) < 0) { - WriteAlert(_("LyX Warning!"), + Alert::alert(_("LyX Warning!"), _("Error while reading ") + lyxrc_path + ".", _("Using built-in defaults.")); return false; @@ -910,5 +911,3 @@ bool LyX::easyParse(int * argc, char * argv[]) return gui; } - - diff --git a/src/lyxfind.C b/src/lyxfind.C index e5d0f75afb..777ad3e101 100644 --- a/src/lyxfind.C +++ b/src/lyxfind.C @@ -7,7 +7,7 @@ #include "lyxtext.h" #include "lyxfind.h" #include "LyXView.h" -#include "lyx_gui_misc.h" +#include "frontends/Alert.h" #include "support/textutils.h" #include "support/lstrings.h" #include "BufferView.h" @@ -53,7 +53,7 @@ int LyXReplace(BufferView * bv, if (searchstr.length() == 0 || (searchstr.length() == 1 && searchstr[0] == ' ')) { - WriteAlert(_("Sorry!"), _("You cannot replace a single space, " + Alert::alert(_("Sorry!"), _("You cannot replace a single space, " "nor an empty character.")); return 0; } @@ -201,12 +201,11 @@ bool IsStringInText(Paragraph * par, Paragraph::size_type pos, } if (size == string::size_type(i)) { // if necessary, check whether string matches word - if (!mw || - (mw && ((pos <= 0 || !IsLetterCharOrDigit(par->getChar(pos - 1))) - && (pos + Paragraph::size_type(size) >= par->size() - || !IsLetterCharOrDigit(par->getChar(pos + size)))) - )) - { + if (!mw) + return true; + if ((pos <= 0 || !IsLetterCharOrDigit(par->getChar(pos - 1))) + && (pos + Paragraph::size_type(size) >= par->size() + || !IsLetterCharOrDigit(par->getChar(pos + size)))) { return true; } } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index dcd18e2877..360a7a31df 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -86,6 +86,7 @@ #include "frontends/Dialogs.h" #include "frontends/Toolbar.h" #include "frontends/Menubar.h" +#include "frontends/Alert.h" #include "FloatList.h" #include "converter.h" #include "exporter.h" @@ -1739,7 +1740,7 @@ void LyXFunc::menuNew(bool fromTemplate) // Check if the document already is open if (bufferlist.exists(s)) { - switch (AskConfirmation(_("Document is already open:"), + switch (Alert::askConfirmation(_("Document is already open:"), MakeDisplayPath(s, 50), _("Do you want to close that document now?\n" "('No' will just switch to the open version)"))) @@ -1760,7 +1761,7 @@ void LyXFunc::menuNew(bool fromTemplate) // Check whether the file already exists FileInfo fi(s); if (fi.readable() && - AskQuestion(_("File already exists:"), + Alert::askQuestion(_("File already exists:"), MakeDisplayPath(s, 50), _("Do you want to open the document?"))) { // loads document @@ -1866,7 +1867,7 @@ void LyXFunc::open(string const & fname) // necessary string const fullpath = FileSearch(string(), filename, "lyx"); if (fullpath.empty()) { - WriteAlert(_("Error"), _("Could not find file"), filename); + Alert::alert(_("Error"), _("Could not find file"), filename); return; } @@ -1950,7 +1951,7 @@ void LyXFunc::doImport(string const & argument) // Check if the document already is open if (bufferlist.exists(lyxfile)) { - switch (AskConfirmation(_("Document is already open:"), + switch (Alert::askConfirmation(_("Document is already open:"), MakeDisplayPath(lyxfile, 50), _("Do you want to close that document now?\n" "('No' will just switch to the open version)"))) @@ -1971,7 +1972,7 @@ void LyXFunc::doImport(string const & argument) // Check if a LyX document by the same root exists in filesystem FileInfo const f(lyxfile, true); - if (f.exist() && !AskQuestion(_("A document by the name"), + if (f.exist() && !Alert::askQuestion(_("A document by the name"), MakeDisplayPath(lyxfile), _("already exists. Overwrite?"))) { owner->message(_("Canceled")); diff --git a/src/lyxvc.C b/src/lyxvc.C index a5b9afd0d9..c487f7887a 100644 --- a/src/lyxvc.C +++ b/src/lyxvc.C @@ -6,6 +6,7 @@ #include +#include "frontends/Alert.h" #include "lyxvc.h" #include "vc-backend.h" #include "debug.h" @@ -83,7 +84,7 @@ void LyXVC::registrer() // If the document is changed, we might want to save it if (!vcs->owner()->isLyxClean() && - AskQuestion(_("Changes in document:"), + Alert::askQuestion(_("Changes in document:"), MakeDisplayPath(vcs->owner()->fileName(), 50), _("Save document and proceed?"))) { vcs->owner()->getUser()->owner() @@ -98,12 +99,12 @@ void LyXVC::registrer() lyxerr[Debug::LYXVC] << "LyXVC: registrer" << endl; pair tmp = - askForText(_("LyX VC: Initial description"), + Alert::askForText(_("LyX VC: Initial description"), _("(no initial description)")); if (!tmp.first || tmp.second.empty()) { // should we insist on checking tmp.second.empty()? lyxerr[Debug::LYXVC] << "LyXVC: user cancelled" << endl; - WriteAlert(_("Info"), + Alert::alert(_("Info"), _("This document has NOT been registered.")); return; } @@ -116,7 +117,7 @@ void LyXVC::checkIn() { // If the document is changed, we might want to save it if (!vcs->owner()->isLyxClean() && - AskQuestion(_("Changes in document:"), + Alert::askQuestion(_("Changes in document:"), MakeDisplayPath(vcs->owner()->fileName(), 50), _("Save document and proceed?"))) { vcs->owner()->getUser()->owner() @@ -130,7 +131,7 @@ void LyXVC::checkIn() } lyxerr[Debug::LYXVC] << "LyXVC: checkIn" << endl; - pair tmp = askForText(_("LyX VC: Log Message")); + pair tmp = Alert::askForText(_("LyX VC: Log Message")); if (tmp.first) { if (tmp.second.empty()) { tmp.second = _("(no log message)"); @@ -146,7 +147,7 @@ void LyXVC::checkOut() { lyxerr[Debug::LYXVC] << "LyXVC: checkOut" << endl; if (!vcs->owner()->isLyxClean() - && !AskQuestion(_("Changes in document:"), + && !Alert::askQuestion(_("Changes in document:"), MakeDisplayPath(vcs->owner()->fileName(), 50), _("Ignore changes and proceed with check out?"))) { return; @@ -163,7 +164,7 @@ void LyXVC::revert() // Here we should check if the buffer is dirty. And if it is // we should warn the user that reverting will discard all // changes made since the last check in. - if (AskQuestion(_("When you revert, you will loose all changes made"), + if (Alert::askQuestion(_("When you revert, you will loose all changes made"), _("to the document since the last check in."), _("Do you still want to do it?"))) { diff --git a/src/mathed/formula.C b/src/mathed/formula.C index bc70649fb3..83fe96b561 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -30,7 +30,7 @@ #include "BufferView.h" #include "gettext.h" #include "debug.h" -#include "lyx_gui_misc.h" +#include "frontends/Alert.h" #include "support/LOstream.h" #include "support/LAssert.h" #include "support/lyxlib.h" @@ -423,8 +423,8 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action, string const default_label = (lyxrc.label_init_length >= 0) ? "eq:" : ""; pair const res = old_label.empty() - ? askForText(_("Enter new label to insert:"), default_label) - : askForText(_("Enter label:"), old_label); + ? Alert::askForText(_("Enter new label to insert:"), default_label) + : Alert::askForText(_("Enter label:"), old_label); lyxerr << "res: " << res.first << " - '" << res.second << "'\n"; if (!res.first) diff --git a/src/print_form.C b/src/print_form.C index b2665d7772..746505a2e0 100644 --- a/src/print_form.C +++ b/src/print_form.C @@ -2,6 +2,7 @@ #include #include "lyx_gui_misc.h" #include "gettext.h" +#include "frontends/xforms/xforms_helpers.h" /* Form definition file generated with fdesign. */ diff --git a/src/support/filetools.C b/src/support/filetools.C index 3a332bd536..cb77c4b5cf 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -28,6 +28,7 @@ #endif #include +#include #include #include #include "debug.h" @@ -35,7 +36,7 @@ #include "filetools.h" #include "LSubstring.h" -#include "lyx_gui_misc.h" +#include "frontends/Alert.h" #include "FileInfo.h" #include "support/path.h" // I know it's OS/2 specific (SMiyata) #include "gettext.h" @@ -397,7 +398,7 @@ int DeleteAllFilesInDir (string const & path) // directory_iterator dit(path); // directory_iterator dend; // if (dit == dend) { - // WriteFSAlert(_("Error! Cannot open directory:"), path); + // Alert::err_alert(_("Error! Cannot open directory:"), path); // return -1; // } // for (; dit != dend; ++dit) { @@ -406,13 +407,13 @@ int DeleteAllFilesInDir (string const & path) // continue; // string unlinkpath(AddName(path, filename)); // if (lyx::unlink(unlinkpath)) - // WriteFSAlert(_("Error! Could not remove file:"), + // Alert::err_alert(_("Error! Could not remove file:"), // unlinkpath); // } // return 0; DIR * dir = ::opendir(path.c_str()); if (!dir) { - WriteFSAlert (_("Error! Cannot open directory:"), path); + Alert::err_alert (_("Error! Cannot open directory:"), path); return -1; } struct dirent * de; @@ -431,8 +432,8 @@ int DeleteAllFilesInDir (string const & path) deleted = (DeleteAllFilesInDir(unlinkpath) == 0); deleted &= (lyx::unlink(unlinkpath) == 0); if (!deleted) { - WriteFSAlert (_("Error! Could not remove file:"), - unlinkpath); + Alert::err_alert(_("Error! Could not remove file:"), + unlinkpath); return_value = -1; } } @@ -455,7 +456,7 @@ string const CreateTmpDir(string const & tempdir, string const & mask) lyx::unlink(tmpfl.c_str()); if (tmpfl.empty() || lyx::mkdir(tmpfl, 0700)) { - WriteFSAlert(_("Error! Couldn't create temporary directory:"), + Alert::err_alert(_("Error! Couldn't create temporary directory:"), tempdir); return string(); } @@ -472,7 +473,7 @@ int DestroyTmpDir(string const & tmpdir, bool Allfiles) return -1; } if (lyx::rmdir(tmpdir)) { - WriteFSAlert(_("Error! Couldn't delete temporary directory:"), + Alert::err_alert(_("Error! Couldn't delete temporary directory:"), tmpdir); return -1; } @@ -491,7 +492,7 @@ string const CreateBufferTmpDir(string const & pathfor) // of EMX mkstemp(). string const tmpfl = tmpdir + "/lyx_tmpbuf" + tostr(count++); if (lyx::mkdir(tmpfl, 0777)) { - WriteFSAlert(_("Error! Couldn't create temporary directory:"), + Alert::err_alert(_("Error! Couldn't create temporary directory:"), tmpdir); return string(); } @@ -536,13 +537,13 @@ bool createDirectory(string const & path, int permission) string temp(strip(os::slashify_path(path), '/')); if (temp.empty()) { - WriteAlert(_("Internal error!"), + Alert::alert(_("Internal error!"), _("Call to createDirectory with invalid name")); return false; } if (lyx::mkdir(temp, permission)) { - WriteFSAlert (_("Error! Couldn't create directory:"), temp); + Alert::err_alert (_("Error! Couldn't create directory:"), temp); return false; } return true; @@ -1103,7 +1104,7 @@ void removeAutosaveFile(string const & filename) FileInfo const fileinfo(a); if (fileinfo.exist()) { if (lyx::unlink(a) != 0) { - WriteFSAlert(_("Could not delete auto-save file!"), a); + Alert::err_alert(_("Could not delete auto-save file!"), a); } } } diff --git a/src/support/path.C b/src/support/path.C index fba75b46be..54e4fcb8d9 100644 --- a/src/support/path.C +++ b/src/support/path.C @@ -13,16 +13,16 @@ int Path::pop() // throw logical_error(); // The use of WriteFSAlerrt makes this impossible // to inline. - //WriteFSAlert(_("Error: Dir already popped: "), + //Alert::err_alert(_("Error: Dir already popped: "), // pushedDir_); return 0; } if (lyx::chdir(pushedDir_)) { // should throw an exception // throw DirChangeError(); - // The use of WriteFSAlert makes this impossible + // The use of Alert::err_alert makes this impossible // to inline. - //WriteFSAlert( + //Alert::err_alert( // _("Error: Could not change to directory: "), // pushedDir_); } diff --git a/src/support/path.h b/src/support/path.h index 6081881062..88dba32bfa 100644 --- a/src/support/path.h +++ b/src/support/path.h @@ -24,9 +24,9 @@ public: if (pushedDir_.empty() || lyx::chdir(path)) { // should throw an exception // throw DirChangeError(); - // The use of WriteFSAlert makes this + // The use of Alert::err_alert makes this // impossible to inline. - //WriteFSAlert(_("Error: Could not change to directory: "), + //Alert::err_alert(_("Error: Could not change to directory: "), // path); } } else { diff --git a/src/tabular.C b/src/tabular.C index 58b9dbcd0c..07316512f8 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -26,7 +26,7 @@ #include "debug.h" #include "vspace.h" #include "layout.h" -#include "lyx_gui_misc.h" +#include "frontends/Alert.h" #include "buffer.h" #include "BufferView.h" #include "Painter.h" @@ -266,9 +266,6 @@ void LyXTabular::AppendRow(int cell) void LyXTabular::DeleteRow(int row) { - // Why make it so hard? (Lgb) - //if (!(rows_ - 1)) - //return; if (rows_ == 1) return; // Not allowed to delete last row row_info.erase(row_info.begin() + row); //&row_info[row]); @@ -1442,7 +1439,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl) lyxerr << "Tabular format < 5 is not supported anymore\n" "Get an older version of LyX (< 1.1.x) for conversion!" << endl; - WriteAlert(_("Warning:"), + Alert::alert(_("Warning:"), _("Tabular format < 5 is not supported anymore\n"), _("Get an older version of LyX (< 1.1.x) for conversion!")); if (version > 2) { @@ -2651,16 +2648,9 @@ LyXTabular::BoxType LyXTabular::UseParbox(int cell) const for (; par; par = par->next()) { for (int i = 0; i < par->size(); ++i) { - if (par->getChar(i) == Paragraph::META_NEWLINE) + if (par->getChar(i) == Paragraph::META_NEWLINE) return BOX_PARBOX; } } return BOX_NONE; } - -/* Emacs: - * Local variables: - * tab-width: 4 - * End: - * vi:set tabstop=4: - */