new alert code

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3074 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2001-11-26 10:19:58 +00:00
parent 3b9c75708d
commit 85e30074c2
92 changed files with 543 additions and 482 deletions

View File

@ -151,6 +151,9 @@
@iE-mail: cfog@mech.ubc.ca @iE-mail: cfog@mech.ubc.ca
Support for two-column figure (figure*) and table (table*) Support for two-column figure (figure*) and table (table*)
environments. Fixed minibuffer entry of floats. environments. Fixed minibuffer entry of floats.
@bPanayotis "PAP" Papasotiriou
@iE-mail: papasot@physics.upatras.gr
support for kluwer document class.
@bJoacim Persson @bJoacim Persson
@iE-mail: sp2joap1@ida.his.se @iE-mail: sp2joap1@ida.his.se
po-file for Swedish, a tool for picking shortcuts, po-file for Swedish, a tool for picking shortcuts,

View File

@ -74,6 +74,7 @@ src/frontends/qt2/QToc.C
src/frontends/qt2/QURL.C src/frontends/qt2/QURL.C
src/frontends/qt2/QVCLog.C src/frontends/qt2/QVCLog.C
src/frontends/qt2/lengthcombo.C src/frontends/qt2/lengthcombo.C
src/frontends/xforms/Alert_pimpl.C
src/frontends/xforms/FileDialog.C src/frontends/xforms/FileDialog.C
src/frontends/xforms/FormAboutlyx.C src/frontends/xforms/FormAboutlyx.C
src/frontends/xforms/FormBibitem.C src/frontends/xforms/FormBibitem.C
@ -180,7 +181,6 @@ src/kbsequence.C
src/language.C src/language.C
src/layout.C src/layout.C
src/lyx_cb.C src/lyx_cb.C
src/lyx_gui_misc.C
src/lyx_main.C src/lyx_main.C
src/lyxfind.C src/lyxfind.C
src/lyxfont.C src/lyxfont.C

View File

@ -23,7 +23,7 @@
#include "support/FileInfo.h" #include "support/FileInfo.h"
#include "lyxscreen.h" #include "lyxscreen.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "lyx_gui_misc.h" #include "frontends/Alert.h"
#include "LaTeX.h" #include "LaTeX.h"
#include "BufferView_pimpl.h" #include "BufferView_pimpl.h"
#include "insets/insetcommand.h" //ChangeRefs #include "insets/insetcommand.h" //ChangeRefs
@ -63,7 +63,7 @@ bool BufferView::insertLyXFile(string const & filen)
FileInfo const fi(fname); FileInfo const fi(fname);
if (!fi.readable()) { if (!fi.readable()) {
WriteAlert(_("Error!"), Alert::alert(_("Error!"),
_("Specified file is unreadable: "), _("Specified file is unreadable: "),
MakeDisplayPath(fname, 50)); MakeDisplayPath(fname, 50));
return false; return false;
@ -73,7 +73,7 @@ bool BufferView::insertLyXFile(string const & filen)
ifstream ifs(fname.c_str()); ifstream ifs(fname.c_str());
if (!ifs) { if (!ifs) {
WriteAlert(_("Error!"), Alert::alert(_("Error!"),
_("Cannot open specified file: "), _("Cannot open specified file: "),
MakeDisplayPath(fname, 50)); MakeDisplayPath(fname, 50));
return false; return false;

View File

@ -28,6 +28,7 @@
#include "support/LAssert.h" #include "support/LAssert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "frontends/Dialogs.h" #include "frontends/Dialogs.h"
#include "frontends/Alert.h"
#include "insets/insetbib.h" #include "insets/insetbib.h"
#include "insets/insettext.h" #include "insets/insettext.h"
/// added for Dispatch functions /// added for Dispatch functions
@ -1814,7 +1815,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
if (!label.empty()) { if (!label.empty()) {
//bv_->savePosition(0); //bv_->savePosition(0);
if (!bv_->gotoLabel(label)) if (!bv_->gotoLabel(label))
WriteAlert(_("Error"), Alert::alert(_("Error"),
_("Couldn't find this label"), _("Couldn't find this label"),
_("in current document.")); _("in current document."));
} }

View File

@ -1,3 +1,7 @@
2001-11-23 John Levon <moz@compsoc.man.ac.uk>
* <various>: change to use Alert.h
2001-11-25 Dekel Tsur <dekelts@tau.ac.il> 2001-11-25 Dekel Tsur <dekelts@tau.ac.il>
* buffer.C (parseSingleLyXformat2Token): Insert an error inset * buffer.C (parseSingleLyXformat2Token): Insert an error inset

View File

@ -97,8 +97,8 @@
#include "lyxtext.h" #include "lyxtext.h"
#include "gettext.h" #include "gettext.h"
#include "language.h" #include "language.h"
#include "lyx_gui_misc.h" // WarnReadonly()
#include "frontends/Dialogs.h" #include "frontends/Dialogs.h"
#include "frontends/Alert.h"
#include "encoding.h" #include "encoding.h"
#include "exporter.h" #include "exporter.h"
#include "Lsstream.h" #include "Lsstream.h"
@ -234,9 +234,6 @@ void Buffer::setReadonly(bool flag)
updateTitles(); updateTitles();
users->owner()->getDialogs()->updateBufferDependent(false); 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 += tostr(unknown_layouts);
s += _(" paragraphs"); s += _(" paragraphs");
} }
WriteAlert(_("Textclass Loading Error!"), s, Alert::alert(_("Textclass Loading Error!"), s,
_("When reading " + fileName())); _("When reading " + fileName()));
} }
@ -377,7 +374,7 @@ bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par)
s += tostr(unknown_tokens); s += tostr(unknown_tokens);
s += _(" unknown tokens"); s += _(" unknown tokens");
} }
WriteAlert(_("Textclass Loading Error!"), s, Alert::alert(_("Textclass Loading Error!"), s,
_("When reading " + fileName())); _("When reading " + fileName()));
} }
@ -666,7 +663,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
if (pp.first) { if (pp.first) {
params.textclass = pp.second; params.textclass = pp.second;
} else { } else {
WriteAlert(string(_("Textclass error")), Alert::alert(string(_("Textclass error")),
string(_("The document uses an unknown textclass \"")) + string(_("The document uses an unknown textclass \"")) +
lex.getString() + string("\"."), lex.getString() + string("\"."),
string(_("LyX will not be able to produce output correctly."))); string(_("LyX will not be able to produce output correctly.")));
@ -678,7 +675,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
// or stop loading the file. // or stop loading the file.
// I can substitute but I don't see how I can // I can substitute but I don't see how I can
// stop loading... ideas?? ARRae980418 // stop loading... ideas?? ARRae980418
WriteAlert(_("Textclass Loading Error!"), Alert::alert(_("Textclass Loading Error!"),
string(_("Can't load textclass ")) + string(_("Can't load textclass ")) +
textclasslist.NameOfClass(params.textclass), textclasslist.NameOfClass(params.textclass),
_("-- substituting default")); _("-- substituting default"));
@ -1537,14 +1534,14 @@ bool Buffer::readFile(LyXLex & lex, Paragraph * par)
// current format // current format
} else if (file_format > LYX_FORMAT) { } else if (file_format > LYX_FORMAT) {
// future format // future format
WriteAlert(_("Warning!"), Alert::alert(_("Warning!"),
_("LyX file format is newer that what"), _("LyX file format is newer that what"),
_("is supported in this LyX version. Expect some problems.")); _("is supported in this LyX version. Expect some problems."));
} else if (file_format < LYX_FORMAT) { } else if (file_format < LYX_FORMAT) {
// old formats // old formats
if (file_format < 200) { if (file_format < 200) {
WriteAlert(_("ERROR!"), Alert::alert(_("ERROR!"),
_("Old LyX file format found. " _("Old LyX file format found. "
"Use LyX 0.10.x to read this!")); "Use LyX 0.10.x to read this!"));
return false; return false;
@ -1556,16 +1553,17 @@ bool Buffer::readFile(LyXLex & lex, Paragraph * par)
if (file_format < 213) if (file_format < 213)
the_end = true; the_end = true;
if (!the_end) if (!the_end) {
WriteAlert(_("Warning!"), Alert::alert(_("Warning!"),
_("Reading of document is not complete"), _("Reading of document is not complete"),
_("Maybe the document is truncated")); _("Maybe the document is truncated"));
}
return true; return true;
} else { // "\\lyxformat" not found } else { // "\\lyxformat" not found
WriteAlert(_("ERROR!"), _("Not a LyX file!")); Alert::alert(_("ERROR!"), _("Not a LyX file!"));
} }
} else } else
WriteAlert(_("ERROR!"), _("Unable to read file!")); Alert::alert(_("ERROR!"), _("Unable to read file!"));
return false; return false;
} }
@ -1661,7 +1659,7 @@ bool Buffer::writeFile(string const & fname, bool flag) const
lyxerr << _("Error! Document is read-only: ") lyxerr << _("Error! Document is read-only: ")
<< fname << endl; << fname << endl;
else else
WriteAlert(_("Error! Document is read-only: "), Alert::alert(_("Error! Document is read-only: "),
fname); fname);
return false; return false;
} }
@ -1674,7 +1672,7 @@ bool Buffer::writeFile(string const & fname, bool flag) const
lyxerr << _("Error! Cannot write file: ") lyxerr << _("Error! Cannot write file: ")
<< fname << endl; << fname << endl;
else else
WriteFSAlert(_("Error! Cannot write file: "), Alert::err_alert(_("Error! Cannot write file: "),
fname); fname);
return false; return false;
} }
@ -1685,7 +1683,7 @@ bool Buffer::writeFile(string const & fname, bool flag) const
lyxerr << _("Error! Cannot open file: ") lyxerr << _("Error! Cannot open file: ")
<< fname << endl; << fname << endl;
else else
WriteFSAlert(_("Error! Cannot open file: "), Alert::err_alert(_("Error! Cannot open file: "),
fname); fname);
return false; return false;
} }
@ -1922,7 +1920,7 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
{ {
ofstream ofs(fname.c_str()); ofstream ofs(fname.c_str());
if (!ofs) { if (!ofs) {
WriteFSAlert(_("Error: Cannot write file:"), fname); Alert::err_alert(_("Error: Cannot write file:"), fname);
return; return;
} }
writeFileAscii(ofs, linelen); writeFileAscii(ofs, linelen);
@ -1956,7 +1954,7 @@ void Buffer::makeLaTeXFile(string const & fname,
ofstream ofs(fname.c_str()); ofstream ofs(fname.c_str());
if (!ofs) { if (!ofs) {
WriteFSAlert(_("Error: Cannot open file: "), fname); Alert::err_alert(_("Error: Cannot open file: "), fname);
return; return;
} }
@ -2537,7 +2535,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
ofstream ofs(fname.c_str()); ofstream ofs(fname.c_str());
if (!ofs) { if (!ofs) {
WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), fname); Alert::alert(_("LYX_ERROR:"), _("Cannot write file"), fname);
return; return;
} }
@ -2975,7 +2973,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
{ {
ofstream ofs(fname.c_str()); ofstream ofs(fname.c_str());
if (!ofs) { if (!ofs) {
WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), fname); Alert::alert(_("LYX_ERROR:"), _("Cannot write file"), fname);
return; return;
} }
@ -3371,7 +3369,7 @@ int Buffer::runChktex()
int res = chktex.run(terr); // run chktex int res = chktex.run(terr); // run chktex
if (res == -1) { if (res == -1) {
WriteAlert(_("chktex did not work!"), Alert::alert(_("chktex did not work!"),
_("Could not run with file:"), name); _("Could not run with file:"), name);
} else if (res > 0) { } else if (res > 0) {
// Insert all errors as errors boxes // Insert all errors as errors boxes

View File

@ -22,6 +22,7 @@
#include <algorithm> #include <algorithm>
#include <functional> #include <functional>
#include "frontends/Alert.h"
#include "bufferlist.h" #include "bufferlist.h"
#include "lyx_main.h" #include "lyx_main.h"
#include "support/FileInfo.h" #include "support/FileInfo.h"
@ -97,9 +98,42 @@ 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 BufferList::qwriteAll()
{ {
bool askMoreConfirmation = false; bool are_unsaved = false;
string unsaved; string unsaved;
for (BufferStorage::iterator it = bstore.begin(); for (BufferStorage::iterator it = bstore.begin();
it != bstore.end(); ++it) { it != bstore.end(); ++it) {
@ -109,41 +143,13 @@ bool BufferList::qwriteAll()
fname = OnlyFilename((*it)->fileName()); fname = OnlyFilename((*it)->fileName());
else else
fname = MakeDisplayPath((*it)->fileName(), 50); fname = MakeDisplayPath((*it)->fileName(), 50);
bool reask = true; are_unsaved = qwriteOne(*it, fname, unsaved);
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;
} }
} }
}
} if (are_unsaved && lyxrc.exit_confirmation) {
if (askMoreConfirmation && return Alert::askQuestion(_("Some documents were not saved:"),
lyxrc.exit_confirmation && unsaved, _("Exit anyway?"));
!AskQuestion(_("Some documents were not saved:"),
unsaved, _("Exit anyway?"))) {
return false;
} }
return true; return true;
@ -183,7 +189,7 @@ bool BufferList::close(Buffer * buf)
fname = MakeDisplayPath(buf->fileName(), 50); fname = MakeDisplayPath(buf->fileName(), 50);
bool reask = true; bool reask = true;
while (reask) { while (reask) {
switch (AskConfirmation(_("Changes in document:"), switch (Alert::askConfirmation(_("Changes in document:"),
fname, fname,
_("Save document?"))){ _("Save document?"))){
case 1: // Yes case 1: // Yes
@ -351,7 +357,7 @@ Buffer * BufferList::readFile(string const & s, bool ronly)
FileInfo fileInfo2(s); FileInfo fileInfo2(s);
if (!fileInfo2.exist()) { if (!fileInfo2.exist()) {
WriteAlert(_("Error!"), _("Cannot open file"), Alert::alert(_("Error!"), _("Cannot open file"),
MakeDisplayPath(s)); MakeDisplayPath(s));
return 0; return 0;
} }
@ -365,7 +371,7 @@ Buffer * BufferList::readFile(string const & s, bool ronly)
if (fileInfoE.exist() && fileInfo2.exist()) { if (fileInfoE.exist() && fileInfo2.exist()) {
if (fileInfoE.getModificationTime() if (fileInfoE.getModificationTime()
> fileInfo2.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), MakeDisplayPath(s, 50),
_("Try to load that instead?"))) { _("Try to load that instead?"))) {
ts = e; ts = e;
@ -389,7 +395,7 @@ Buffer * BufferList::readFile(string const & s, bool ronly)
if (fileInfoA.exist() && fileInfo2.exist()) { if (fileInfoA.exist() && fileInfo2.exist()) {
if (fileInfoA.getModificationTime() if (fileInfoA.getModificationTime()
> fileInfo2.getModificationTime()) { > fileInfo2.getModificationTime()) {
if (AskQuestion(_("Autosave file is newer."), if (Alert::askQuestion(_("Autosave file is newer."),
MakeDisplayPath(s, 50), MakeDisplayPath(s, 50),
_("Load that one instead?"))) { _("Load that one instead?"))) {
ts = a; ts = a;
@ -461,7 +467,7 @@ Buffer * BufferList::newFile(string const & name, string tname, bool isNamed)
} }
} }
if (!templateok) { if (!templateok) {
WriteAlert(_("Error!"), _("Unable to open template"), Alert::alert(_("Error!"), _("Unable to open template"),
MakeDisplayPath(tname)); MakeDisplayPath(tname));
// no template, start with empty buffer // no template, start with empty buffer
b->paragraph = new Paragraph; b->paragraph = new Paragraph;
@ -492,7 +498,7 @@ Buffer * BufferList::loadLyXFile(string const & filename, bool tolastfiles)
// file already open? // file already open?
if (exists(s)) { if (exists(s)) {
if (AskQuestion(_("Document is already open:"), if (Alert::askQuestion(_("Document is already open:"),
MakeDisplayPath(s, 50), MakeDisplayPath(s, 50),
_("Do you want to reload that document?"))) { _("Do you want to reload that document?"))) {
// Reload is accomplished by closing and then loading // 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)) { if (LyXVC::file_not_found_hook(s)) {
// Ask if the file should be checked out for // Ask if the file should be checked out for
// viewing/editing, if so: load it. // 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? // How can we know _how_ to do the checkout?
// With the current VC support it has to be, // With the current VC support it has to be,
// a RCS file since CVS do not have special ,v files. // 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); return loadLyXFile(filename, tolastfiles);
} }
} }
if (AskQuestion(_("Cannot open specified file:"), if (Alert::askQuestion(_("Cannot open specified file:"),
MakeDisplayPath(s, 50), MakeDisplayPath(s, 50),
_("Create new document with this name?"))) _("Create new document with this name?")))
{ {

View File

@ -142,6 +142,9 @@ public:
Buffer * getBuffer(unsigned int); Buffer * getBuffer(unsigned int);
private: private:
/// ask to save a buffer on quit
bool qwriteOne(Buffer * buf, string const & fname, string & unsaved_list);
/// ///
BufferStorage bstore; BufferStorage bstore;

View File

@ -19,7 +19,7 @@
#include "BufferView.h" #include "BufferView.h"
#include "paragraph.h" #include "paragraph.h"
#include "lyxfont.h" #include "lyxfont.h"
#include "lyx_gui_misc.h" #include "frontends/Alert.h"
#include "lyxtext.h" #include "lyxtext.h"
#include "buffer.h" #include "buffer.h"
#include "support/lstrings.h" #include "support/lstrings.h"
@ -68,7 +68,7 @@ void lang(BufferView * bv, string const & l)
font.setLanguage(lang); font.setLanguage(lang);
toggleAndShow(bv, font); toggleAndShow(bv, font);
} else } 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); bv->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
if (font.language() != ignore_language || if (font.language() != ignore_language ||
font.number() != LyXFont::IGNORE) font.number() != LyXFont::IGNORE) {
{
LyXCursor & cursor = text->cursor; LyXCursor & cursor = text->cursor;
text->computeBidiTables(bv->buffer(), cursor.row()); text->computeBidiTables(bv->buffer(), cursor.row());
if (cursor.boundary() != if (cursor.boundary() !=

View File

@ -28,6 +28,7 @@
#include "lyx_gui_misc.h" #include "lyx_gui_misc.h"
#include "lyx_cb.h" // ShowMessage() #include "lyx_cb.h" // ShowMessage()
#include "support/lyxfunctional.h" #include "support/lyxfunctional.h"
#include "frontends/Alert.h"
#include "gettext.h" #include "gettext.h"
#include "BufferView.h" #include "BufferView.h"
#include "debug.h" #include "debug.h"
@ -168,7 +169,7 @@ bool Formats::view(Buffer const * buffer, string const & filename,
format->isChildFormat()) format->isChildFormat())
format = getFormat(format->parentFormat()); format = getFormat(format->parentFormat());
if (!format || format->viewer().empty()) { if (!format || format->viewer().empty()) {
WriteAlert(_("Cannot view file"), Alert::alert(_("Cannot view file"),
_("No information for viewing ") _("No information for viewing ")
+ prettyName(format_name)); + prettyName(format_name));
return false; return false;
@ -198,7 +199,7 @@ bool Formats::view(Buffer const * buffer, string const & filename,
int const res = one.startscript(Systemcalls::SystemDontWait, command); int const res = one.startscript(Systemcalls::SystemDontWait, command);
if (res) { if (res) {
WriteAlert(_("Cannot view file"), Alert::alert(_("Cannot view file"),
_("Error while executing"), _("Error while executing"),
command.substr(0, 50)); command.substr(0, 50));
return false; return false;
@ -574,7 +575,7 @@ bool Converters::convert(Buffer const * buffer,
EdgePath edgepath = getPath(from_format, to_format); EdgePath edgepath = getPath(from_format, to_format);
if (edgepath.empty()) { if (edgepath.empty()) {
WriteAlert(_("Cannot convert file"), Alert::alert(_("Cannot convert file"),
_("No information for converting from ") _("No information for converting from ")
+ formats.prettyName(from_format) + _(" to ") + formats.prettyName(from_format) + _(" to ")
+ formats.prettyName(to_format)); + formats.prettyName(to_format));
@ -665,10 +666,10 @@ bool Converters::convert(Buffer const * buffer,
if (res) { if (res) {
if (conv.to == "program") 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.")); _("You should try to fix them."));
else else
WriteAlert(_("Cannot convert file"), Alert::alert(_("Cannot convert file"),
"Error while executing", "Error while executing",
command.substr(0, 50)); command.substr(0, 50));
return false; return false;
@ -691,7 +692,7 @@ bool Converters::convert(Buffer const * buffer,
string to = subst(conv.result_dir, string to = subst(conv.result_dir,
token_base, to_base); token_base, to_base);
if (!lyx::rename(from, to)) { if (!lyx::rename(from, to)) {
WriteAlert(_("Error while trying to move directory:"), Alert::alert(_("Error while trying to move directory:"),
from, ("to ") + to); from, ("to ") + to);
return false; return false;
} }
@ -727,7 +728,7 @@ bool Converters::move(string const & from, string const & to, bool copy)
? lyx::copy(from2, to2) ? lyx::copy(from2, to2)
: lyx::rename(from2, to2); : lyx::rename(from2, to2);
if (!moved && no_errors) { if (!moved && no_errors) {
WriteAlert(_("Error while trying to move file:"), Alert::alert(_("Error while trying to move file:"),
from2, _("to ") + to2); from2, _("to ") + to2);
no_errors = false; no_errors = false;
} }
@ -818,13 +819,13 @@ bool Converters::scanLog(Buffer const * buffer, string const & command,
} }
string head; string head;
split(command, head, ' '); split(command, head, ' ');
WriteAlert(_("There were errors during running of ") + head, Alert::alert(_("There were errors during running of ") + head,
s, t); s, t);
return false; return false;
} else if (result & LaTeX::NO_OUTPUT) { } else if (result & LaTeX::NO_OUTPUT) {
string const s = _("The operation resulted in"); string const s = _("The operation resulted in");
string const t = _("an empty file."); string const t = _("an empty file.");
WriteAlert(_("Resulting file is empty"), s, t); Alert::alert(_("Resulting file is empty"), s, t);
return false; return false;
} }
return true; return true;
@ -872,7 +873,7 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command)
// check return value from latex.run(). // check return value from latex.run().
if ((result & LaTeX::NO_LOGFILE)) { if ((result & LaTeX::NO_LOGFILE)) {
WriteAlert(_("LaTeX did not work!"), Alert::alert(_("LaTeX did not work!"),
_("Missing log file:"), name); _("Missing log file:"), name);
} else if ((result & LaTeX::ERRORS)) { } else if ((result & LaTeX::ERRORS)) {
int num_errors = latex.getNumErrors(); int num_errors = latex.getNumErrors();
@ -886,12 +887,12 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command)
s += _(" errors detected."); s += _(" errors detected.");
t = _("You should try to fix them."); 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); s, t);
} else if (result & LaTeX::NO_OUTPUT) { } else if (result & LaTeX::NO_OUTPUT) {
string const s = _("The operation resulted in"); string const s = _("The operation resulted in");
string const t = _("an empty file."); string const t = _("an empty file.");
WriteAlert(_("Resulting file is empty"), s, t); Alert::alert(_("Resulting file is empty"), s, t);
} }
if (bv) if (bv)

View File

@ -22,7 +22,7 @@
#include "support/filetools.h" #include "support/filetools.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "converter.h" #include "converter.h"
#include "lyx_gui_misc.h" //WriteAlert #include "frontends/Alert.h"
#include "gettext.h" #include "gettext.h"
using std::vector; using std::vector;
@ -45,7 +45,7 @@ bool Exporter::Export(Buffer * buffer, string const & format,
} }
} }
if (backend_format.empty()) { if (backend_format.empty()) {
WriteAlert(_("Cannot export file"), Alert::alert(_("Cannot export file"),
_("No information for exporting to ") _("No information for exporting to ")
+ formats.prettyName(format)); + formats.prettyName(format));
return false; return false;
@ -72,7 +72,7 @@ bool Exporter::Export(Buffer * buffer, string const & format,
else if (backend_format == format) else if (backend_format == format)
buffer->makeLaTeXFile(filename, string(), true); buffer->makeLaTeXFile(filename, string(), true);
else if (contains(buffer->filepath, ' ')) { else if (contains(buffer->filepath, ' ')) {
WriteAlert(_("Cannot run latex."), Alert::alert(_("Cannot run latex."),
_("The path to the lyx file cannot contain spaces.")); _("The path to the lyx file cannot contain spaces."));
return false; return false;
} else } else

View File

@ -2,6 +2,7 @@
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "lyx_gui_misc.h"
#include "gettext.h" #include "gettext.h"
#include "frontends/xforms/xforms_helpers.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

88
src/frontends/Alert.C Normal file
View File

@ -0,0 +1,88 @@
/**
* \file Alert.C
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#include <cerrno>
#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<bool, string> 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<bool, string>(true, dflt);
} else {
return askForText_pimpl(msg, dflt);
}
}
}

31
src/frontends/Alert.h Normal file
View File

@ -0,0 +1,31 @@
/**
* \file Alert.h
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include "support/lstrings.h"
#include <algorithm>
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<bool, string> const askForText(string const & msg,
string const & dflt = string());
};

View File

@ -0,0 +1,15 @@
/**
* \file Alert_pimpl.h
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#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<bool, string> const askForText_pimpl(string const & msg, string const & dflt);

View File

@ -1,3 +1,10 @@
2001-11-22 John Levon <moz@compsoc.man.ac.uk>
* Makefile.am:
* Alert.h:
* Alert.C:
* Alert_pimpl.h: alerts etc.
2001-10-09 Herbert Voss <voss@perce.de> 2001-10-09 Herbert Voss <voss@perce.de>
* Dialogs.h: added showFile and showTexinfo signals. * Dialogs.h: added showFile and showTexinfo signals.

View File

@ -53,5 +53,8 @@ public:
/// The current visual depth /// The current visual depth
static static
int x11VisualDepth(); int x11VisualDepth();
/// the server's DPI estimate
static
float getScreenDPI();
}; };
#endif #endif

View File

@ -20,6 +20,9 @@ libfrontends_la_DEPENDENCIES = @FRONTEND_GUILIB@ \
controllers/libcontrollers.la controllers/libcontrollers.la
libfrontends_la_SOURCES=\ libfrontends_la_SOURCES=\
Alert.C \
Alert.h \
Alert_pimpl.h \
Dialogs.C \ Dialogs.C \
Dialogs.h \ Dialogs.h \
DialogBase.h \ DialogBase.h \

View File

@ -32,7 +32,7 @@
#include "support/filetools.h" #include "support/filetools.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "frontends/FileDialog.h" #include "frontends/FileDialog.h"
#include "lyx_gui_misc.h" // WriteAlert #include "frontends/Alert.h"
#include "gettext.h" #include "gettext.h"
#include "BufferView.h" #include "BufferView.h"
@ -193,7 +193,7 @@ string const ControlExternal::Browse(string const & input) const
contains(p, "~") || 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:"), "of these characters:"),
// xgettext:no-c-format // xgettext:no-c-format
_("'#', '~', '$' or '%'.")); _("'#', '~', '$' or '%'."));

View File

@ -28,7 +28,7 @@
#include "PrinterParams.h" #include "PrinterParams.h"
#include "Liason.h" #include "Liason.h"
#include "helper_funcs.h" // browseFile #include "helper_funcs.h" // browseFile
#include "lyx_gui_misc.h" // WriteAlert #include "frontends/Alert.h"
#include "gettext.h" #include "gettext.h"
#include "BufferView.h" #include "BufferView.h"
#include "support/LAssert.h" #include "support/LAssert.h"
@ -53,7 +53,7 @@ void ControlPrint::apply()
view().apply(); view().apply();
if (!printBuffer(lv_.buffer(), params())) { if (!printBuffer(lv_.buffer(), params())) {
WriteAlert(_("Error:"), Alert::alert(_("Error:"),
_("Unable to print"), _("Unable to print"),
_("Check that your parameters are correct")); _("Check that your parameters are correct"));
} }

View File

@ -58,7 +58,7 @@ void ControlTexinfo::runTexhash() const
//path to texhash through system //path to texhash through system
Systemcalls one(Systemcalls::System,"texhash"); Systemcalls one(Systemcalls::System,"texhash");
p.pop(); p.pop();
// WriteAlert(_("texhash run!"), // Alert::alert(_("texhash run!"),
// _("rebuilding of the TeX-tree could only be successfull"), // _("rebuilding of the TeX-tree could only be successfull"),
// _("if you have had user-write-permissions to the tex-dir.")); // _("if you have had user-write-permissions to the tex-dir."));
} }

View File

@ -25,7 +25,7 @@
#include "support/filetools.h" // OnlyPath, OnlyFilename #include "support/filetools.h" // OnlyPath, OnlyFilename
#include "support/lstrings.h" #include "support/lstrings.h"
#include "gettext.h" // _() #include "gettext.h" // _()
#include "lyx_gui_misc.h" // WriteAlert #include "frontends/Alert.h"
using std::pair; using std::pair;
using std::vector; using std::vector;
@ -99,7 +99,7 @@ string const browseFile(LyXView * lv, string const & filename,
if (result.second.find_first_of("#~$% ") == string::npos) if (result.second.find_first_of("#~$% ") == string::npos)
break; break;
WriteAlert(_("Filename can't contain any " Alert::alert(_("Filename can't contain any "
"of these characters:"), "of these characters:"),
_("space, '#', '~', '$' or '%'.")); _("space, '#', '~', '$' or '%'."));
} }

View File

@ -154,7 +154,7 @@ void FormPrint::apply()
copies_unsorted_->get_active(), copies_unsorted_->get_active(),
copies_count_->get_value_as_int()))) copies_count_->get_value_as_int())))
{ {
WriteAlert(_("Error:"), Alert::alert(_("Error:"),
_("Unable to print"), _("Unable to print"),
_("Check that your parameters are correct")); _("Check that your parameters are correct"));
} }

View File

@ -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() void GUIRunTime::setDefaults()
{ {
FL_IOPT cntl; FL_IOPT cntl;

View File

@ -362,14 +362,14 @@ bool QDocument::class_apply()
s += tostr(ret); s += tostr(ret);
s += _(" paragraphs couldn't be converted"); s += _(" paragraphs couldn't be converted");
} }
WriteAlert(_("Conversion Errors!"),s, Alert::alert(_("Conversion Errors!"),s,
_("into chosen document class")); _("into chosen document class"));
} }
params.textclass = new_class; params.textclass = new_class;
} else { } else {
// problem changing class -- warn user and retain old style // problem changing class -- warn user and retain old style
WriteAlert(_("Conversion Errors!"), Alert::alert(_("Conversion Errors!"),
_("Errors loading new document class."), _("Errors loading new document class."),
_("Reverting to original document class.")); _("Reverting to original document class."));
dialog_->docClassCO->setCurrentItem( params.textclass ); dialog_->docClassCO->setCurrentItem( params.textclass );
@ -993,7 +993,7 @@ void QDocument::CheckChoiceClass(FL_OBJECT * ob, long)
BufferParams params = lv_->buffer()->params; BufferParams params = lv_->buffer()->params;
if (params.textclass != tc 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?"))) { _("the defaults of this document class?"))) {
params.textclass = tc; params.textclass = tc;
params.useClassDefaults(); params.useClassDefaults();
@ -1001,7 +1001,7 @@ void QDocument::CheckChoiceClass(FL_OBJECT * ob, long)
} }
} else { } else {
// unable to load new style // unable to load new style
WriteAlert(_("Conversion Errors!"), Alert::alert(_("Conversion Errors!"),
_("Unable to switch to new document class."), _("Unable to switch to new document class."),
_("Reverting to original document class.")); _("Reverting to original document class."));
combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1); combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1);

View File

@ -0,0 +1,61 @@
/**
* \file Alert_pimpl.C
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#include FORMS_H_LOCATION
#include <algorithm>
#include <gettext.h>
#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<bool, string> 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<bool, string>(true, string(tmp));
else
return make_pair<bool, string>(false, string());
}

View File

@ -1,3 +1,14 @@
2001-11-23 John Levon <moz@compsoc.man.ac.uk>
* 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 <j.spitzmueller@gmx.de> 2001-11-20 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* forms/form_ref.fd, form_preferences.fd, form_citation.fd, * forms/form_ref.fd, form_preferences.fd, form_citation.fd,

View File

@ -18,7 +18,7 @@
#pragma implementation #pragma implementation
#endif #endif
#include "lyx_gui_misc.h" #include "Alert.h"
#include "FormDocument.h" #include "FormDocument.h"
#include "form_document.h" #include "form_document.h"
@ -378,7 +378,7 @@ namespace {
*/ */
bool saveParamsAsDefault(BufferParams const &params) bool saveParamsAsDefault(BufferParams const &params)
{ {
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?"), _("for the document layout as default?"),
_("(they will be valid for any new document)"))) _("(they will be valid for any new document)")))
return false; return false;
@ -754,13 +754,13 @@ bool FormDocument::class_apply()
s += tostr(ret); s += tostr(ret);
s += _(" paragraphs couldn't be converted"); s += _(" paragraphs couldn't be converted");
} }
WriteAlert(_("Conversion Errors!"),s, Alert::alert(_("Conversion Errors!"),s,
_("into chosen document class")); _("into chosen document class"));
} }
} else { } else {
// problem changing class -- warn user and retain old style // problem changing class -- warn user and retain old style
WriteAlert(_("Conversion Errors!"), Alert::alert(_("Conversion Errors!"),
_("Errors loading new document class."), _("Errors loading new document class."),
_("Reverting to original document class.")); _("Reverting to original document class."));
combo_doc_class->select(int(old_class) + 1); combo_doc_class->select(int(old_class) + 1);
@ -1396,7 +1396,7 @@ void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long)
} }
} else { } else {
// unable to load new style // unable to load new style
WriteAlert(_("Conversion Errors!"), Alert::alert(_("Conversion Errors!"),
_("Unable to switch to new document class."), _("Unable to switch to new document class."),
_("Reverting to original document class.")); _("Reverting to original document class."));
combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1); combo_doc_class->select(int(lv_->buffer()->params.textclass) + 1);

View File

@ -21,7 +21,7 @@ using std::map;
using std::max; using std::max;
using std::sort; using std::sort;
#include "lyx_gui_misc.h" // for WriteFSAlert #include "frontends/Alert.h"
#include "support/FileInfo.h" #include "support/FileInfo.h"
#include "support/lyxlib.h" #include "support/lyxlib.h"
#include "support/lstrings.h" #include "support/lstrings.h"
@ -223,7 +223,7 @@ void FileDialog::Private::Reread()
// Opens directory // Opens directory
DIR * pDirectory = ::opendir(pszDirectory.c_str()); DIR * pDirectory = ::opendir(pszDirectory.c_str());
if (!pDirectory) { if (!pDirectory) {
WriteFSAlert(_("Warning! Couldn't open directory."), Alert::err_alert(_("Warning! Couldn't open directory."),
pszDirectory); pszDirectory);
pszDirectory = lyx::getcwd(); pszDirectory = lyx::getcwd();
pDirectory = ::opendir(pszDirectory.c_str()); pDirectory = ::opendir(pszDirectory.c_str());
@ -389,7 +389,7 @@ void FileDialog::Private::SetDirectory(string const & Path)
// must check the directory exists // must check the directory exists
DIR * pDirectory = ::opendir(tmp.c_str()); DIR * pDirectory = ::opendir(tmp.c_str());
if (!pDirectory) { if (!pDirectory) {
WriteFSAlert(_("Warning! Couldn't open directory."), tmp); Alert::err_alert(_("Warning! Couldn't open directory."), tmp);
} else { } else {
::closedir(pDirectory); ::closedir(pDirectory);
pszDirectory = tmp; pszDirectory = tmp;

View File

@ -24,7 +24,7 @@
#include "LyXView.h" #include "LyXView.h"
#include "bmtable.h" #include "bmtable.h"
#include "debug.h" #include "debug.h"
#include "lyx_gui_misc.h" // scex, idex #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
#include "support/LAssert.h" #include "support/LAssert.h"

View File

@ -38,7 +38,6 @@
#include "debug.h" #include "debug.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/LAssert.h" #include "support/LAssert.h"
#include "lyx_gui_misc.h" // idex, scex
#include "lyxlex.h" #include "lyxlex.h"
#include "input_validators.h" #include "input_validators.h"
#include "xforms_helpers.h" #include "xforms_helpers.h"

View File

@ -144,3 +144,10 @@ int GUIRunTime::x11VisualDepth()
{ {
return fl_get_visual_depth(); 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;
}

View File

@ -13,6 +13,7 @@ LYXDATADIRS = forms
ETAGS_ARGS = --lang=c++ ETAGS_ARGS = --lang=c++
# Alphabetical order please. It makes it easier to figure out what's missing. # Alphabetical order please. It makes it easier to figure out what's missing.
libxforms_la_SOURCES = \ libxforms_la_SOURCES = \
Alert_pimpl.C \
bmtable.c \ bmtable.c \
bmtable.h \ bmtable.h \
Color.C \ Color.C \

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
#include "bmtable.h" #include "bmtable.h"

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
#include "bmtable.h" #include "bmtable.h"

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
#include "bmtable.h" #include "bmtable.h"

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext // File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "xforms_helpers.h"
#include "gettext.h" #include "gettext.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -67,7 +67,7 @@ sed -e "s/CLASSNAME/$CLASSNAME/" < $FDFIXC > $FDFIXC_MOD
# Modify .c file for use by LyX # 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 "// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext" > $COUT
echo "#include <config.h>" >> $COUT echo "#include <config.h>" >> $COUT
echo "#include \"lyx_gui_misc.h\"" >> $COUT echo "#include \"xforms_helpers.h\"" >> $COUT
echo "#include \"gettext.h\"" >> $COUT echo "#include \"gettext.h\"" >> $COUT
grep bmtable $CIN > /dev/null grep bmtable $CIN > /dev/null

View File

@ -119,7 +119,7 @@ void fl_print_range_filter(FL_OBJECT * ob,
piece = strip(piece) ; piece = strip(piece) ;
piece = frontStrip(piece) ; piece = frontStrip(piece) ;
if (!stringOnlyContains (piece, "0123456789-")) { if (!stringOnlyContains (piece, "0123456789-")) {
WriteAlert(_("ERROR! Unable to print!"), Alert::alert(_("ERROR! Unable to print!"),
_("Check 'range of pages'!")); _("Check 'range of pages'!"));
return; return;
} }

View File

@ -24,6 +24,42 @@ using std::ofstream;
using std::pair; using std::pair;
using std::vector; using std::vector;
// Extract shortcut from <ident>|<shortcut> 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 <ident>|<shortcut> 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 // Set an FL_OBJECT to activated or deactivated
void setEnabled(FL_OBJECT * ob, bool enable) void setEnabled(FL_OBJECT * ob, bool enable)
{ {

View File

@ -7,7 +7,24 @@
#pragma interface #pragma interface
#endif #endif
#include <config.h>
#include FORMS_H_LOCATION
#include "Color.h" #include "Color.h"
#include "support/lstrings.h"
#include <vector>
/// Extract shortcut from <ident>|<shortcut> string
char const * flyx_shortcut_extract(char const * sc);
/// Shortcut for flyx_shortcut_extract
#define scex flyx_shortcut_extract
/// Extract shortcut from <ident>|<shortcut> 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 /// Set an FL_OBJECT to activated or deactivated
void setEnabled(FL_OBJECT *, bool enable); void setEnabled(FL_OBJECT *, bool enable);

View File

@ -23,7 +23,7 @@
#include "bufferlist.h" #include "bufferlist.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "lyx_gui_misc.h" //WriteAlert #include "frontends/Alert.h"
#include "gettext.h" #include "gettext.h"
#include "BufferView.h" #include "BufferView.h"
@ -58,7 +58,7 @@ bool Importer::Import(LyXView * lv, string const & filename,
} }
} }
if (loader_format.empty()) { if (loader_format.empty()) {
WriteAlert(_("Cannot import file"), Alert::alert(_("Cannot import file"),
_("No information for importing from ") _("No information for importing from ")
+ formats.prettyName(format)); + formats.prettyName(format));
return false; return false;

View File

@ -1,3 +1,7 @@
2001-11-23 John Levon <moz@compsoc.man.ac.uk>
* various: update for Alert.h
2001-11-22 John Levon <moz@compsoc.man.ac.uk> 2001-11-22 John Levon <moz@compsoc.man.ac.uk>
* inset.h: fix comment * inset.h: fix comment

View File

@ -56,6 +56,7 @@
#include "lyxrc.h" #include "lyxrc.h"
#include "gettext.h" #include "gettext.h"
#include "lyx_gui_misc.h" // CancelCloseBoxCB #include "lyx_gui_misc.h" // CancelCloseBoxCB
#include "frontends/Alert.h"
#include "support/FileInfo.h" #include "support/FileInfo.h"
#include "support/lyxlib.h" #include "support/lyxlib.h"
#include "support/os.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; lyxerr[Debug::INFO] << "Editing InsetFig." << endl;
regenerate(); 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) { if (!form) {
form = create_form_Figure(); form = create_form_Figure();
fl_set_form_atclose(form->Figure, CancelCloseBoxCB, 0); fl_set_form_atclose(form->Figure, CancelCloseBoxCB, 0);
@ -2004,7 +1999,7 @@ void InsetFig::browseFile()
if (contains(p, "#") || contains(p, "~") || contains(p, "$") if (contains(p, "#") || contains(p, "~") || 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:"), "of these characters:"),
// xgettext:no-c-format // xgettext:no-c-format
_("space, '#', '~', '$' or '%'.")); _("space, '#', '~', '$' or '%'."));

View File

@ -24,6 +24,7 @@
#include "LyXView.h" #include "LyXView.h"
#include "lyxtext.h" #include "lyxtext.h"
#include "frontends/Dialogs.h" #include "frontends/Dialogs.h"
#include "frontends/Alert.h"
#include "debug.h" #include "debug.h"
using std::ostream; 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 // if selectall is activated then the fontchange was an outside general
// fontchange and this messages is not needed // fontchange and this messages is not needed
if (!selectall) if (!selectall)
WriteAlert(_("Impossible Operation!"), Alert::alert(_("Impossible Operation!"),
_("Not permitted to change font-types inside ERT-insets!"), _("Not permitted to change font-types inside ERT-insets!"),
_("Sorry.")); _("Sorry."));
} }

View File

@ -16,7 +16,7 @@
#include "insetlabel.h" #include "insetlabel.h"
#include "support/LOstream.h" #include "support/LOstream.h"
#include "lyx_gui_misc.h" //askForText #include "frontends/Alert.h"
#include "support/lstrings.h" //frontStrip, strip #include "support/lstrings.h" //frontStrip, strip
#include "lyxtext.h" #include "lyxtext.h"
#include "buffer.h" #include "buffer.h"
@ -44,12 +44,7 @@ vector<string> const InsetLabel::getLabelList() const
void InsetLabel::edit(BufferView * bv, int, int, unsigned int) void InsetLabel::edit(BufferView * bv, int, int, unsigned int)
{ {
if (bv->buffer()->isReadonly()) { pair<bool, string> result = Alert::askForText(_("Enter label:"), getContents());
WarnReadonly(bv->buffer()->fileName());
return;
}
pair<bool, string> result = askForText(_("Enter label:"), getContents());
if (result.first) { if (result.first) {
string new_contents = frontStrip(strip(result.second)); string new_contents = frontStrip(strip(result.second));
if (!new_contents.empty() && if (!new_contents.empty() &&

View File

@ -34,6 +34,7 @@
#include "LyXView.h" #include "LyXView.h"
#include "insets/insettext.h" #include "insets/insettext.h"
#include "frontends/Dialogs.h" #include "frontends/Dialogs.h"
#include "frontends/Alert.h"
#include "debug.h" #include "debug.h"
#include "WorkArea.h" #include "WorkArea.h"
#include "gettext.h" #include "gettext.h"
@ -1825,7 +1826,7 @@ void InsetTabular::tabularFeatures(BufferView * bv,
case LyXTabular::MULTICOLUMN: case LyXTabular::MULTICOLUMN:
{ {
if (sel_row_start != sel_row_end) { if (sel_row_start != sel_row_end) {
WriteAlert(_("Impossible Operation!"), Alert::alert(_("Impossible Operation!"),
_("Multicolumns can only be horizontally."), _("Multicolumns can only be horizontally."),
_("Sorry.")); _("Sorry."));
return; return;

View File

@ -32,7 +32,7 @@
#include "layout.h" #include "layout.h"
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "Painter.h" #include "Painter.h"
#include "lyx_gui_misc.h" #include "frontends/Alert.h"
#include "lyxtext.h" #include "lyxtext.h"
#include "lyxcursor.h" #include "lyxcursor.h"
#include "CutAndPaste.h" #include "CutAndPaste.h"
@ -1188,7 +1188,7 @@ InsetText::localDispatch(BufferView * bv,
if (!autoBreakRows) { if (!autoBreakRows) {
if (CutAndPaste::nrOfParagraphs() > 1) { if (CutAndPaste::nrOfParagraphs() > 1) {
WriteAlert(_("Impossible operation"), Alert::alert(_("Impossible operation"),
_("Cannot include more than one paragraph!"), _("Cannot include more than one paragraph!"),
_("Sorry.")); _("Sorry."));
break; break;

View File

@ -20,7 +20,7 @@
#include "layout.h" #include "layout.h"
#include "lyxlex.h" #include "lyxlex.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "lyx_gui_misc.h" #include "frontends/Alert.h"
#include "debug.h" #include "debug.h"
#include "gettext.h" #include "gettext.h"
#include "support/LAssert.h" #include "support/LAssert.h"
@ -1366,7 +1366,7 @@ bool LyXTextClassList::Read ()
"textclass file `" << MakeDisplayPath(real_file, 1000) "textclass file `" << MakeDisplayPath(real_file, 1000)
<< "'. Exiting." << endl; << "'. 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\""), _("Check that the file \"textclass.lst\""),
_("is installed correctly. Sorry, has to exit :-(")); _("is installed correctly. Sorry, has to exit :-("));
return false; return false;
@ -1430,7 +1430,7 @@ bool LyXTextClassList::Read ()
if (classlist.empty()) { if (classlist.empty()) {
lyxerr << "LyXTextClassList::Read: no textclasses found!" lyxerr << "LyXTextClassList::Read: no textclasses found!"
<< endl; << 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\""), _("Check the contents of the file \"textclass.lst\""),
_("Sorry, has to exit :-(")); _("Sorry, has to exit :-("));
return false; return false;

View File

@ -16,7 +16,6 @@
#include <iostream> #include <iostream>
#include "lyx_cb.h" #include "lyx_cb.h"
#include "lyx_gui_misc.h"
#include "lyx_main.h" #include "lyx_main.h"
#include "buffer.h" #include "buffer.h"
#include "bufferlist.h" #include "bufferlist.h"
@ -26,6 +25,7 @@
#include "LyXView.h" #include "LyXView.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "lyxtext.h" #include "lyxtext.h"
#include "frontends/Alert.h"
#include "frontends/FileDialog.h" #include "frontends/FileDialog.h"
#include "frontends/GUIRunTime.h" #include "frontends/GUIRunTime.h"
#include "insets/insetlabel.h" #include "insets/insetlabel.h"
@ -141,7 +141,7 @@ bool MenuWrite(BufferView * bv, Buffer * buffer)
if (!buffer->save()) { if (!buffer->save()) {
string const fname = buffer->fileName(); string const fname = buffer->fileName();
string const s = MakeAbsPath(fname); 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), MakeDisplayPath(s, 50),
_("(If not, document is not saved.)"))) { _("(If not, document is not saved.)"))) {
return WriteAs(bv, buffer); return WriteAs(bv, buffer);
@ -196,7 +196,7 @@ bool WriteAs(BufferView * bv, Buffer * buffer, string const & filename)
// Same name as we have already? // Same name as we have already?
if (!buffer->isUnnamed() && fname == oldname) { 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), MakeDisplayPath(fname, 50),
_("Save anyway?"))) _("Save anyway?")))
return false; 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? // No, but do we have another file with this name open?
else if (!buffer->isUnnamed() && bufferlist.exists(fname)) { 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), MakeDisplayPath(fname, 50),
_("Replace with current document?"))) _("Replace with current document?")))
{ {
@ -221,7 +221,7 @@ bool WriteAs(BufferView * bv, Buffer * buffer, string const & filename)
} // Check whether the file exists } // Check whether the file exists
else { else {
FileInfo const myfile(fname); FileInfo const myfile(fname);
if (myfile.isOK() && !AskQuestion(_("Document already exists:"), if (myfile.isOK() && !Alert::askQuestion(_("Document already exists:"),
MakeDisplayPath(fname, 50), MakeDisplayPath(fname, 50),
_("Replace file?"))) _("Replace file?")))
return false; return false;
@ -251,7 +251,7 @@ int MenuRunChktex(Buffer * buffer)
int ret; int ret;
if (buffer->isSGML()) { if (buffer->isSGML()) {
WriteAlert(_("Chktex does not work with SGML derived documents.")); Alert::alert(_("Chktex does not work with SGML derived documents."));
return 0; return 0;
} else } else
ret = buffer->runChktex(); ret = buffer->runChktex();
@ -269,9 +269,9 @@ int MenuRunChktex(Buffer * buffer)
s += _(" warnings found."); s += _(" warnings found.");
t = _("Use `Navigate->Error' to find them."); t = _("Use `Navigate->Error' to find them.");
} }
WriteAlert(_("Chktex run successfully"), s, t); Alert::alert(_("Chktex run successfully"), s, t);
} else { } else {
WriteAlert(_("Error!"), _("It seems chktex does not work.")); Alert::alert(_("Error!"), _("It seems chktex does not work."));
} }
return ret; return ret;
} }
@ -430,14 +430,14 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
FileInfo fi(fname); FileInfo fi(fname);
if (!fi.readable()) { if (!fi.readable()) {
WriteFSAlert(_("Error! Specified file is unreadable: "), Alert::err_alert(_("Error! Specified file is unreadable: "),
MakeDisplayPath(fname, 50)); MakeDisplayPath(fname, 50));
return; return;
} }
ifstream ifs(fname.c_str()); ifstream ifs(fname.c_str());
if (!ifs) { if (!ifs) {
WriteFSAlert(_("Error! Cannot open specified file: "), Alert::err_alert(_("Error! Cannot open specified file: "),
MakeDisplayPath(fname, 50)); MakeDisplayPath(fname, 50));
return; return;
} }
@ -512,7 +512,7 @@ void MenuInsertLabel(BufferView * bv, string const & arg)
} }
pair<bool, string> result = pair<bool, string> result =
askForText(_("Enter new label to insert:"), text); Alert::askForText(_("Enter new label to insert:"), text);
if (result.first) { if (result.first) {
label = frontStrip(strip(result.second)); label = frontStrip(strip(result.second));
} }
@ -539,7 +539,7 @@ void Reconfigure(BufferView * bv)
p.pop(); p.pop();
bv->owner()->message(_("Reloading configuration...")); bv->owner()->message(_("Reloading configuration..."));
lyxrc.read(LibFileSearch(string(), "lyxrc.defaults")); 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"), _("You need to restart LyX to make use of any"),
_("updated document class specifications.")); _("updated document class specifications."));
} }

View File

@ -14,43 +14,25 @@
#pragma implementation #pragma implementation
#endif #endif
#include <cerrno> #include FORMS_H_LOCATION
#include "lyx_gui_misc.h" #include "lyx_gui_misc.h"
#include "BufferView.h"
#include "buffer.h"
#include "gettext.h"
#include "figure_form.h" #include "figure_form.h"
#include "lyx_cb.h"
#include "lyx_main.h"
#include "print_form.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_figure * fd_form_figure;
extern FD_form_sendto * fd_form_sendto; extern FD_form_sendto * fd_form_sendto;
extern void HideFiguresPopups(); extern void HideFiguresPopups();
// The code below is just waiting to go away really ...
// Prevents LyX from being killed when the close box is pressed in a popup.
extern "C" extern "C"
int CancelCloseBoxCB(FL_FORM *, void *) int CancelCloseBoxCB(FL_FORM *, void *)
{ {
return FL_CANCEL; return FL_CANCEL;
} }
// Redraw the form (on receipt of a Signal indicating, for example,
// that the xform colors have been re-mapped).
void RedrawAllBufferRelatedDialogs() void RedrawAllBufferRelatedDialogs()
{ {
if (fd_form_figure->form_figure->visible) { 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() 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) { if (fd_form_figure->form_figure->visible) {
fl_hide_form(fd_form_figure->form_figure); fl_hide_form(fd_form_figure->form_figure);
} }
@ -80,171 +54,7 @@ void CloseAllBufferRelatedDialogs()
HideFiguresPopups(); HideFiguresPopups();
} }
// This is another function we really don't want.
// Again the Signal/Slot mechanism is tailor made for this task.
void updateAllVisibleBufferRelatedDialogs(bool) void updateAllVisibleBufferRelatedDialogs(bool)
{ {
HideFiguresPopups(); HideFiguresPopups();
} }
// Extract shortcut from <ident>|<shortcut> 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 <ident>|<shortcut> 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<bool, string> const
askForText(string const & msg, string const & dflt)
{
if (!lyxrc.use_gui) {
lyxerr << "----------------------------------------" << endl
<< msg << endl
<< "Assuming answer is " << dflt
<< "----------------------------------------" << endl;
return make_pair<bool, string>(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<bool, string>(true, string(tmp));
else
return make_pair<bool, string>(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;
}

View File

@ -19,8 +19,6 @@
#endif #endif
#include FORMS_H_LOCATION #include FORMS_H_LOCATION
#include "LString.h"
#include <utility> /* needed for pair<> definition */
/// Prevents LyX from being killed when the close box is pressed in a popup. /// Prevents LyX from being killed when the close box is pressed in a popup.
extern "C" extern "C"
@ -36,42 +34,4 @@ void CloseAllBufferRelatedDialogs();
/// Ensures info in visible popups are always correct. /// Ensures info in visible popups are always correct.
void updateAllVisibleBufferRelatedDialogs(bool switched = false); void updateAllVisibleBufferRelatedDialogs(bool switched = false);
/* These shortcut extractors should be shifted to frontends/xforms/ eventually */
/// Extract shortcut from <ident>|<shortcut> string
char const * flyx_shortcut_extract(char const * sc);
/// Shortcut for flyx_shortcut_extract
#define scex flyx_shortcut_extract
/// Extract shortcut from <ident>|<shortcut> 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<bool, string> 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 #endif

View File

@ -22,7 +22,8 @@
#include "lyx_gui.h" #include "lyx_gui.h"
#include "LyXView.h" #include "LyXView.h"
#include "lyxfunc.h" #include "lyxfunc.h"
#include "lyx_gui_misc.h" #include "frontends/Alert.h"
#include "frontends/GUIRunTime.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "support/path.h" #include "support/path.h"
#include "support/filetools.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: // Calculate screen dpi as average of x-DPI and y-DPI:
if (lyxrc.use_gui) { if (lyxrc.use_gui) {
lyxrc.dpi = getScreenDPI(); lyxrc.dpi = GUIRunTime::getScreenDPI();
lyxerr[Debug::INIT] << "DPI setting detected to be " lyxerr[Debug::INIT] << "DPI setting detected to be "
<< lyxrc.dpi + 0.5 << endl; << lyxrc.dpi + 0.5 << endl;
} else { } else {
@ -612,7 +613,7 @@ void LyX::queryUserLyXDir(bool explicit_userdir)
// If the user specified explicitely a directory, ask whether // If the user specified explicitely a directory, ask whether
// to create it (otherwise, always create it) // to create it (otherwise, always create it)
if (explicit_userdir && 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."), _("It is needed to keep your own configuration."),
_("Should I try to set it up for you (recommended)?"))) { _("Should I try to set it up for you (recommended)?"))) {
lyxerr << _("Running without personal LyX directory.") << endl; lyxerr << _("Running without personal LyX directory.") << endl;
@ -651,7 +652,7 @@ bool LyX::readRcFile(string const & name)
lyxerr[Debug::INIT] << "Found " << name lyxerr[Debug::INIT] << "Found " << name
<< " in " << lyxrc_path << endl; << " in " << lyxrc_path << endl;
if (lyxrc.read(lyxrc_path) < 0) { if (lyxrc.read(lyxrc_path) < 0) {
WriteAlert(_("LyX Warning!"), Alert::alert(_("LyX Warning!"),
_("Error while reading ") + lyxrc_path + ".", _("Error while reading ") + lyxrc_path + ".",
_("Using built-in defaults.")); _("Using built-in defaults."));
return false; return false;
@ -910,5 +911,3 @@ bool LyX::easyParse(int * argc, char * argv[])
return gui; return gui;
} }

View File

@ -7,7 +7,7 @@
#include "lyxtext.h" #include "lyxtext.h"
#include "lyxfind.h" #include "lyxfind.h"
#include "LyXView.h" #include "LyXView.h"
#include "lyx_gui_misc.h" #include "frontends/Alert.h"
#include "support/textutils.h" #include "support/textutils.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "BufferView.h" #include "BufferView.h"
@ -53,7 +53,7 @@ int LyXReplace(BufferView * bv,
if (searchstr.length() == 0 if (searchstr.length() == 0
|| (searchstr.length() == 1 && searchstr[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.")); "nor an empty character."));
return 0; return 0;
} }
@ -201,12 +201,11 @@ bool IsStringInText(Paragraph * par, Paragraph::size_type pos,
} }
if (size == string::size_type(i)) { if (size == string::size_type(i)) {
// if necessary, check whether string matches word // if necessary, check whether string matches word
if (!mw || if (!mw)
(mw && ((pos <= 0 || !IsLetterCharOrDigit(par->getChar(pos - 1))) return true;
if ((pos <= 0 || !IsLetterCharOrDigit(par->getChar(pos - 1)))
&& (pos + Paragraph::size_type(size) >= par->size() && (pos + Paragraph::size_type(size) >= par->size()
|| !IsLetterCharOrDigit(par->getChar(pos + size)))) || !IsLetterCharOrDigit(par->getChar(pos + size)))) {
))
{
return true; return true;
} }
} }

View File

@ -86,6 +86,7 @@
#include "frontends/Dialogs.h" #include "frontends/Dialogs.h"
#include "frontends/Toolbar.h" #include "frontends/Toolbar.h"
#include "frontends/Menubar.h" #include "frontends/Menubar.h"
#include "frontends/Alert.h"
#include "FloatList.h" #include "FloatList.h"
#include "converter.h" #include "converter.h"
#include "exporter.h" #include "exporter.h"
@ -1739,7 +1740,7 @@ void LyXFunc::menuNew(bool fromTemplate)
// Check if the document already is open // Check if the document already is open
if (bufferlist.exists(s)) { if (bufferlist.exists(s)) {
switch (AskConfirmation(_("Document is already open:"), switch (Alert::askConfirmation(_("Document is already open:"),
MakeDisplayPath(s, 50), MakeDisplayPath(s, 50),
_("Do you want to close that document now?\n" _("Do you want to close that document now?\n"
"('No' will just switch to the open version)"))) "('No' will just switch to the open version)")))
@ -1760,7 +1761,7 @@ void LyXFunc::menuNew(bool fromTemplate)
// Check whether the file already exists // Check whether the file already exists
FileInfo fi(s); FileInfo fi(s);
if (fi.readable() && if (fi.readable() &&
AskQuestion(_("File already exists:"), Alert::askQuestion(_("File already exists:"),
MakeDisplayPath(s, 50), MakeDisplayPath(s, 50),
_("Do you want to open the document?"))) { _("Do you want to open the document?"))) {
// loads document // loads document
@ -1866,7 +1867,7 @@ void LyXFunc::open(string const & fname)
// necessary // necessary
string const fullpath = FileSearch(string(), filename, "lyx"); string const fullpath = FileSearch(string(), filename, "lyx");
if (fullpath.empty()) { if (fullpath.empty()) {
WriteAlert(_("Error"), _("Could not find file"), filename); Alert::alert(_("Error"), _("Could not find file"), filename);
return; return;
} }
@ -1950,7 +1951,7 @@ void LyXFunc::doImport(string const & argument)
// Check if the document already is open // Check if the document already is open
if (bufferlist.exists(lyxfile)) { if (bufferlist.exists(lyxfile)) {
switch (AskConfirmation(_("Document is already open:"), switch (Alert::askConfirmation(_("Document is already open:"),
MakeDisplayPath(lyxfile, 50), MakeDisplayPath(lyxfile, 50),
_("Do you want to close that document now?\n" _("Do you want to close that document now?\n"
"('No' will just switch to the open version)"))) "('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 // Check if a LyX document by the same root exists in filesystem
FileInfo const f(lyxfile, true); 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), MakeDisplayPath(lyxfile),
_("already exists. Overwrite?"))) { _("already exists. Overwrite?"))) {
owner->message(_("Canceled")); owner->message(_("Canceled"));

View File

@ -6,6 +6,7 @@
#include <unistd.h> #include <unistd.h>
#include "frontends/Alert.h"
#include "lyxvc.h" #include "lyxvc.h"
#include "vc-backend.h" #include "vc-backend.h"
#include "debug.h" #include "debug.h"
@ -83,7 +84,7 @@ void LyXVC::registrer()
// If the document is changed, we might want to save it // If the document is changed, we might want to save it
if (!vcs->owner()->isLyxClean() && if (!vcs->owner()->isLyxClean() &&
AskQuestion(_("Changes in document:"), Alert::askQuestion(_("Changes in document:"),
MakeDisplayPath(vcs->owner()->fileName(), 50), MakeDisplayPath(vcs->owner()->fileName(), 50),
_("Save document and proceed?"))) { _("Save document and proceed?"))) {
vcs->owner()->getUser()->owner() vcs->owner()->getUser()->owner()
@ -98,12 +99,12 @@ void LyXVC::registrer()
lyxerr[Debug::LYXVC] << "LyXVC: registrer" << endl; lyxerr[Debug::LYXVC] << "LyXVC: registrer" << endl;
pair<bool, string> tmp = pair<bool, string> tmp =
askForText(_("LyX VC: Initial description"), Alert::askForText(_("LyX VC: Initial description"),
_("(no initial description)")); _("(no initial description)"));
if (!tmp.first || tmp.second.empty()) { if (!tmp.first || tmp.second.empty()) {
// should we insist on checking tmp.second.empty()? // should we insist on checking tmp.second.empty()?
lyxerr[Debug::LYXVC] << "LyXVC: user cancelled" << endl; lyxerr[Debug::LYXVC] << "LyXVC: user cancelled" << endl;
WriteAlert(_("Info"), Alert::alert(_("Info"),
_("This document has NOT been registered.")); _("This document has NOT been registered."));
return; return;
} }
@ -116,7 +117,7 @@ void LyXVC::checkIn()
{ {
// If the document is changed, we might want to save it // If the document is changed, we might want to save it
if (!vcs->owner()->isLyxClean() && if (!vcs->owner()->isLyxClean() &&
AskQuestion(_("Changes in document:"), Alert::askQuestion(_("Changes in document:"),
MakeDisplayPath(vcs->owner()->fileName(), 50), MakeDisplayPath(vcs->owner()->fileName(), 50),
_("Save document and proceed?"))) { _("Save document and proceed?"))) {
vcs->owner()->getUser()->owner() vcs->owner()->getUser()->owner()
@ -130,7 +131,7 @@ void LyXVC::checkIn()
} }
lyxerr[Debug::LYXVC] << "LyXVC: checkIn" << endl; lyxerr[Debug::LYXVC] << "LyXVC: checkIn" << endl;
pair<bool, string> tmp = askForText(_("LyX VC: Log Message")); pair<bool, string> tmp = Alert::askForText(_("LyX VC: Log Message"));
if (tmp.first) { if (tmp.first) {
if (tmp.second.empty()) { if (tmp.second.empty()) {
tmp.second = _("(no log message)"); tmp.second = _("(no log message)");
@ -146,7 +147,7 @@ void LyXVC::checkOut()
{ {
lyxerr[Debug::LYXVC] << "LyXVC: checkOut" << endl; lyxerr[Debug::LYXVC] << "LyXVC: checkOut" << endl;
if (!vcs->owner()->isLyxClean() if (!vcs->owner()->isLyxClean()
&& !AskQuestion(_("Changes in document:"), && !Alert::askQuestion(_("Changes in document:"),
MakeDisplayPath(vcs->owner()->fileName(), 50), MakeDisplayPath(vcs->owner()->fileName(), 50),
_("Ignore changes and proceed with check out?"))) { _("Ignore changes and proceed with check out?"))) {
return; return;
@ -163,7 +164,7 @@ void LyXVC::revert()
// Here we should check if the buffer is dirty. And if it is // Here we should check if the buffer is dirty. And if it is
// we should warn the user that reverting will discard all // we should warn the user that reverting will discard all
// changes made since the last check in. // 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."), _("to the document since the last check in."),
_("Do you still want to do it?"))) { _("Do you still want to do it?"))) {

View File

@ -30,7 +30,7 @@
#include "BufferView.h" #include "BufferView.h"
#include "gettext.h" #include "gettext.h"
#include "debug.h" #include "debug.h"
#include "lyx_gui_misc.h" #include "frontends/Alert.h"
#include "support/LOstream.h" #include "support/LOstream.h"
#include "support/LAssert.h" #include "support/LAssert.h"
#include "support/lyxlib.h" #include "support/lyxlib.h"
@ -423,8 +423,8 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
string const default_label = string const default_label =
(lyxrc.label_init_length >= 0) ? "eq:" : ""; (lyxrc.label_init_length >= 0) ? "eq:" : "";
pair<bool, string> const res = old_label.empty() pair<bool, string> const res = old_label.empty()
? askForText(_("Enter new label to insert:"), default_label) ? Alert::askForText(_("Enter new label to insert:"), default_label)
: askForText(_("Enter label:"), old_label); : Alert::askForText(_("Enter label:"), old_label);
lyxerr << "res: " << res.first << " - '" << res.second << "'\n"; lyxerr << "res: " << res.first << " - '" << res.second << "'\n";
if (!res.first) if (!res.first)

View File

@ -2,6 +2,7 @@
#include <config.h> #include <config.h>
#include "lyx_gui_misc.h" #include "lyx_gui_misc.h"
#include "gettext.h" #include "gettext.h"
#include "frontends/xforms/xforms_helpers.h"
/* Form definition file generated with fdesign. */ /* Form definition file generated with fdesign. */

View File

@ -28,6 +28,7 @@
#endif #endif
#include <cstdlib> #include <cstdlib>
#include <cstdio>
#include <fcntl.h> #include <fcntl.h>
#include <cerrno> #include <cerrno>
#include "debug.h" #include "debug.h"
@ -35,7 +36,7 @@
#include "filetools.h" #include "filetools.h"
#include "LSubstring.h" #include "LSubstring.h"
#include "lyx_gui_misc.h" #include "frontends/Alert.h"
#include "FileInfo.h" #include "FileInfo.h"
#include "support/path.h" // I know it's OS/2 specific (SMiyata) #include "support/path.h" // I know it's OS/2 specific (SMiyata)
#include "gettext.h" #include "gettext.h"
@ -397,7 +398,7 @@ int DeleteAllFilesInDir (string const & path)
// directory_iterator dit(path); // directory_iterator dit(path);
// directory_iterator dend; // directory_iterator dend;
// if (dit == dend) { // if (dit == dend) {
// WriteFSAlert(_("Error! Cannot open directory:"), path); // Alert::err_alert(_("Error! Cannot open directory:"), path);
// return -1; // return -1;
// } // }
// for (; dit != dend; ++dit) { // for (; dit != dend; ++dit) {
@ -406,13 +407,13 @@ int DeleteAllFilesInDir (string const & path)
// continue; // continue;
// string unlinkpath(AddName(path, filename)); // string unlinkpath(AddName(path, filename));
// if (lyx::unlink(unlinkpath)) // if (lyx::unlink(unlinkpath))
// WriteFSAlert(_("Error! Could not remove file:"), // Alert::err_alert(_("Error! Could not remove file:"),
// unlinkpath); // unlinkpath);
// } // }
// return 0; // return 0;
DIR * dir = ::opendir(path.c_str()); DIR * dir = ::opendir(path.c_str());
if (!dir) { if (!dir) {
WriteFSAlert (_("Error! Cannot open directory:"), path); Alert::err_alert (_("Error! Cannot open directory:"), path);
return -1; return -1;
} }
struct dirent * de; struct dirent * de;
@ -431,7 +432,7 @@ int DeleteAllFilesInDir (string const & path)
deleted = (DeleteAllFilesInDir(unlinkpath) == 0); deleted = (DeleteAllFilesInDir(unlinkpath) == 0);
deleted &= (lyx::unlink(unlinkpath) == 0); deleted &= (lyx::unlink(unlinkpath) == 0);
if (!deleted) { if (!deleted) {
WriteFSAlert (_("Error! Could not remove file:"), Alert::err_alert(_("Error! Could not remove file:"),
unlinkpath); unlinkpath);
return_value = -1; return_value = -1;
} }
@ -455,7 +456,7 @@ string const CreateTmpDir(string const & tempdir, string const & mask)
lyx::unlink(tmpfl.c_str()); lyx::unlink(tmpfl.c_str());
if (tmpfl.empty() || lyx::mkdir(tmpfl, 0700)) { if (tmpfl.empty() || lyx::mkdir(tmpfl, 0700)) {
WriteFSAlert(_("Error! Couldn't create temporary directory:"), Alert::err_alert(_("Error! Couldn't create temporary directory:"),
tempdir); tempdir);
return string(); return string();
} }
@ -472,7 +473,7 @@ int DestroyTmpDir(string const & tmpdir, bool Allfiles)
return -1; return -1;
} }
if (lyx::rmdir(tmpdir)) { if (lyx::rmdir(tmpdir)) {
WriteFSAlert(_("Error! Couldn't delete temporary directory:"), Alert::err_alert(_("Error! Couldn't delete temporary directory:"),
tmpdir); tmpdir);
return -1; return -1;
} }
@ -491,7 +492,7 @@ string const CreateBufferTmpDir(string const & pathfor)
// of EMX mkstemp(). // of EMX mkstemp().
string const tmpfl = tmpdir + "/lyx_tmpbuf" + tostr(count++); string const tmpfl = tmpdir + "/lyx_tmpbuf" + tostr(count++);
if (lyx::mkdir(tmpfl, 0777)) { if (lyx::mkdir(tmpfl, 0777)) {
WriteFSAlert(_("Error! Couldn't create temporary directory:"), Alert::err_alert(_("Error! Couldn't create temporary directory:"),
tmpdir); tmpdir);
return string(); return string();
} }
@ -536,13 +537,13 @@ bool createDirectory(string const & path, int permission)
string temp(strip(os::slashify_path(path), '/')); string temp(strip(os::slashify_path(path), '/'));
if (temp.empty()) { if (temp.empty()) {
WriteAlert(_("Internal error!"), Alert::alert(_("Internal error!"),
_("Call to createDirectory with invalid name")); _("Call to createDirectory with invalid name"));
return false; return false;
} }
if (lyx::mkdir(temp, permission)) { if (lyx::mkdir(temp, permission)) {
WriteFSAlert (_("Error! Couldn't create directory:"), temp); Alert::err_alert (_("Error! Couldn't create directory:"), temp);
return false; return false;
} }
return true; return true;
@ -1103,7 +1104,7 @@ void removeAutosaveFile(string const & filename)
FileInfo const fileinfo(a); FileInfo const fileinfo(a);
if (fileinfo.exist()) { if (fileinfo.exist()) {
if (lyx::unlink(a) != 0) { if (lyx::unlink(a) != 0) {
WriteFSAlert(_("Could not delete auto-save file!"), a); Alert::err_alert(_("Could not delete auto-save file!"), a);
} }
} }
} }

View File

@ -13,16 +13,16 @@ int Path::pop()
// throw logical_error(); // throw logical_error();
// The use of WriteFSAlerrt makes this impossible // The use of WriteFSAlerrt makes this impossible
// to inline. // to inline.
//WriteFSAlert(_("Error: Dir already popped: "), //Alert::err_alert(_("Error: Dir already popped: "),
// pushedDir_); // pushedDir_);
return 0; return 0;
} }
if (lyx::chdir(pushedDir_)) { if (lyx::chdir(pushedDir_)) {
// should throw an exception // should throw an exception
// throw DirChangeError(); // throw DirChangeError();
// The use of WriteFSAlert makes this impossible // The use of Alert::err_alert makes this impossible
// to inline. // to inline.
//WriteFSAlert( //Alert::err_alert(
// _("Error: Could not change to directory: "), // _("Error: Could not change to directory: "),
// pushedDir_); // pushedDir_);
} }

View File

@ -24,9 +24,9 @@ public:
if (pushedDir_.empty() || lyx::chdir(path)) { if (pushedDir_.empty() || lyx::chdir(path)) {
// should throw an exception // should throw an exception
// throw DirChangeError(); // throw DirChangeError();
// The use of WriteFSAlert makes this // The use of Alert::err_alert makes this
// impossible to inline. // impossible to inline.
//WriteFSAlert(_("Error: Could not change to directory: "), //Alert::err_alert(_("Error: Could not change to directory: "),
// path); // path);
} }
} else { } else {

View File

@ -26,7 +26,7 @@
#include "debug.h" #include "debug.h"
#include "vspace.h" #include "vspace.h"
#include "layout.h" #include "layout.h"
#include "lyx_gui_misc.h" #include "frontends/Alert.h"
#include "buffer.h" #include "buffer.h"
#include "BufferView.h" #include "BufferView.h"
#include "Painter.h" #include "Painter.h"
@ -266,9 +266,6 @@ void LyXTabular::AppendRow(int cell)
void LyXTabular::DeleteRow(int row) 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 if (rows_ == 1) return; // Not allowed to delete last row
row_info.erase(row_info.begin() + row); //&row_info[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" lyxerr << "Tabular format < 5 is not supported anymore\n"
"Get an older version of LyX (< 1.1.x) for conversion!" "Get an older version of LyX (< 1.1.x) for conversion!"
<< endl; << endl;
WriteAlert(_("Warning:"), Alert::alert(_("Warning:"),
_("Tabular format < 5 is not supported anymore\n"), _("Tabular format < 5 is not supported anymore\n"),
_("Get an older version of LyX (< 1.1.x) for conversion!")); _("Get an older version of LyX (< 1.1.x) for conversion!"));
if (version > 2) { if (version > 2) {
@ -2657,10 +2654,3 @@ LyXTabular::BoxType LyXTabular::UseParbox(int cell) const
} }
return BOX_NONE; return BOX_NONE;
} }
/* Emacs:
* Local variables:
* tab-width: 4
* End:
* vi:set tabstop=4:
*/