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
Support for two-column figure (figure*) and table (table*)
environments. Fixed minibuffer entry of floats.
@bPanayotis "PAP" Papasotiriou
@iE-mail: papasot@physics.upatras.gr
support for kluwer document class.
@bJoacim Persson
@iE-mail: sp2joap1@ida.his.se
po-file for Swedish, a tool for picking shortcuts,

View File

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

View File

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

View File

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

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>
* buffer.C (parseSingleLyXformat2Token): Insert an error inset

View File

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

View File

@ -22,6 +22,7 @@
#include <algorithm>
#include <functional>
#include "frontends/Alert.h"
#include "bufferlist.h"
#include "lyx_main.h"
#include "support/FileInfo.h"
@ -97,53 +98,58 @@ bool BufferList::empty() const
}
bool BufferList::qwriteOne(Buffer * buf, string const & fname, string & unsaved_list)
{
bool reask = true;
while (reask) {
switch (Alert::askConfirmation(_("Changes in document:"),
fname,
_("Save document?"))) {
case 1: // Yes
// FIXME: WriteAs can be asynch !
if (buf->isUnnamed())
reask = !WriteAs(current_view, buf);
else {
reask = !MenuWrite(current_view, buf);
}
break;
case 2: // No
// if we crash after this we could
// have no autosave file but I guess
// this is really inprobable (Jug)
if (buf->isUnnamed()) {
removeAutosaveFile(buf->fileName());
}
unsaved_list += MakeDisplayPath(fname, 50) + "\n";
return true;
case 3: // Cancel
return false;
}
}
return false;
}
bool BufferList::qwriteAll()
{
bool askMoreConfirmation = false;
bool are_unsaved = false;
string unsaved;
for (BufferStorage::iterator it = bstore.begin();
it != bstore.end(); ++it) {
it != bstore.end(); ++it) {
if (!(*it)->isLyxClean()) {
string fname;
if ((*it)->isUnnamed())
fname = OnlyFilename((*it)->fileName());
else
fname = MakeDisplayPath((*it)->fileName(), 50);
bool reask = true;
while (reask) {
switch (AskConfirmation(_("Changes in document:"),
fname,
_("Save document?"))) {
case 1: // Yes
if ((*it)->isUnnamed())
reask = !WriteAs(current_view, (*it));
else {
reask = !MenuWrite(current_view, (*it));
}
break;
case 2: // No
// if we crash after this we could
// have no autosave file but I guess
// this is really inprobable (Jug)
if ((*it)->isUnnamed()) {
removeAutosaveFile((*it)->fileName());
}
askMoreConfirmation = true;
unsaved += MakeDisplayPath(fname, 50);
unsaved += "\n";
reask = false;
break;
case 3: // Cancel
return false;
}
}
are_unsaved = qwriteOne(*it, fname, unsaved);
}
}
if (askMoreConfirmation &&
lyxrc.exit_confirmation &&
!AskQuestion(_("Some documents were not saved:"),
unsaved, _("Exit anyway?"))) {
return false;
if (are_unsaved && lyxrc.exit_confirmation) {
return Alert::askQuestion(_("Some documents were not saved:"),
unsaved, _("Exit anyway?"));
}
return true;
@ -183,7 +189,7 @@ bool BufferList::close(Buffer * buf)
fname = MakeDisplayPath(buf->fileName(), 50);
bool reask = true;
while (reask) {
switch (AskConfirmation(_("Changes in document:"),
switch (Alert::askConfirmation(_("Changes in document:"),
fname,
_("Save document?"))){
case 1: // Yes
@ -351,7 +357,7 @@ Buffer * BufferList::readFile(string const & s, bool ronly)
FileInfo fileInfo2(s);
if (!fileInfo2.exist()) {
WriteAlert(_("Error!"), _("Cannot open file"),
Alert::alert(_("Error!"), _("Cannot open file"),
MakeDisplayPath(s));
return 0;
}
@ -365,7 +371,7 @@ Buffer * BufferList::readFile(string const & s, bool ronly)
if (fileInfoE.exist() && fileInfo2.exist()) {
if (fileInfoE.getModificationTime()
> fileInfo2.getModificationTime()) {
if (AskQuestion(_("An emergency save of this document exists!"),
if (Alert::askQuestion(_("An emergency save of this document exists!"),
MakeDisplayPath(s, 50),
_("Try to load that instead?"))) {
ts = e;
@ -389,7 +395,7 @@ Buffer * BufferList::readFile(string const & s, bool ronly)
if (fileInfoA.exist() && fileInfo2.exist()) {
if (fileInfoA.getModificationTime()
> fileInfo2.getModificationTime()) {
if (AskQuestion(_("Autosave file is newer."),
if (Alert::askQuestion(_("Autosave file is newer."),
MakeDisplayPath(s, 50),
_("Load that one instead?"))) {
ts = a;
@ -461,7 +467,7 @@ Buffer * BufferList::newFile(string const & name, string tname, bool isNamed)
}
}
if (!templateok) {
WriteAlert(_("Error!"), _("Unable to open template"),
Alert::alert(_("Error!"), _("Unable to open template"),
MakeDisplayPath(tname));
// no template, start with empty buffer
b->paragraph = new Paragraph;
@ -492,7 +498,7 @@ Buffer * BufferList::loadLyXFile(string const & filename, bool tolastfiles)
// file already open?
if (exists(s)) {
if (AskQuestion(_("Document is already open:"),
if (Alert::askQuestion(_("Document is already open:"),
MakeDisplayPath(s, 50),
_("Do you want to reload that document?"))) {
// Reload is accomplished by closing and then loading
@ -523,7 +529,7 @@ Buffer * BufferList::loadLyXFile(string const & filename, bool tolastfiles)
if (LyXVC::file_not_found_hook(s)) {
// Ask if the file should be checked out for
// viewing/editing, if so: load it.
if (AskQuestion(_("Do you want to retrieve file under version control?"))) {
if (Alert::askQuestion(_("Do you want to retrieve file under version control?"))) {
// How can we know _how_ to do the checkout?
// With the current VC support it has to be,
// a RCS file since CVS do not have special ,v files.
@ -531,7 +537,7 @@ Buffer * BufferList::loadLyXFile(string const & filename, bool tolastfiles)
return loadLyXFile(filename, tolastfiles);
}
}
if (AskQuestion(_("Cannot open specified file:"),
if (Alert::askQuestion(_("Cannot open specified file:"),
MakeDisplayPath(s, 50),
_("Create new document with this name?")))
{

View File

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

View File

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

View File

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

View File

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

View File

@ -2,6 +2,7 @@
#include <config.h>
#include "lyx_gui_misc.h"
#include "gettext.h"
#include "frontends/xforms/xforms_helpers.h"
/* 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>
* Dialogs.h: added showFile and showTexinfo signals.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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()
{
FL_IOPT cntl;

View File

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

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>
* forms/form_ref.fd, form_preferences.fd, form_citation.fd,

View File

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

View File

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

View File

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

View File

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

View File

@ -144,3 +144,10 @@ int GUIRunTime::x11VisualDepth()
{
return fl_get_visual_depth();
}
float GUIRunTime::getScreenDPI()
{
Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen);
return ((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
(WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2;
}

View File

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

View File

@ -1,6 +1,6 @@
// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
#include <config.h>
#include "lyx_gui_misc.h"
#include "xforms_helpers.h"
#include "gettext.h"
/* 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
echo "// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext" > $COUT
echo "#include <config.h>" >> $COUT
echo "#include \"lyx_gui_misc.h\"" >> $COUT
echo "#include \"xforms_helpers.h\"" >> $COUT
echo "#include \"gettext.h\"" >> $COUT
grep bmtable $CIN > /dev/null

View File

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

View File

@ -24,6 +24,42 @@ using std::ofstream;
using std::pair;
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
void setEnabled(FL_OBJECT * ob, bool enable)
{

View File

@ -7,7 +7,24 @@
#pragma interface
#endif
#include <config.h>
#include FORMS_H_LOCATION
#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
void setEnabled(FL_OBJECT *, bool enable);

View File

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

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>
* inset.h: fix comment

View File

@ -56,6 +56,7 @@
#include "lyxrc.h"
#include "gettext.h"
#include "lyx_gui_misc.h" // CancelCloseBoxCB
#include "frontends/Alert.h"
#include "support/FileInfo.h"
#include "support/lyxlib.h"
#include "support/os.h"
@ -1218,17 +1219,11 @@ string const InsetFig::editMessage() const
}
void InsetFig::edit(BufferView * bv, int, int, unsigned int)
void InsetFig::edit(BufferView *, int, int, unsigned int)
{
lyxerr[Debug::INFO] << "Editing InsetFig." << endl;
regenerate();
// We should have RO-versions of the form instead.
// The actual prevention of altering a readonly doc
// is done in CallbackFig()
if (bv->buffer()->isReadonly())
WarnReadonly(bv->buffer()->fileName());
if (!form) {
form = create_form_Figure();
fl_set_form_atclose(form->Figure, CancelCloseBoxCB, 0);
@ -2004,7 +1999,7 @@ void InsetFig::browseFile()
if (contains(p, "#") || contains(p, "~") || contains(p, "$")
|| contains(p, "%") || contains(p, " ")) {
WriteAlert(_("Filename can't contain any "
Alert::alert(_("Filename can't contain any "
"of these characters:"),
// xgettext:no-c-format
_("space, '#', '~', '$' or '%'."));

View File

@ -24,6 +24,7 @@
#include "LyXView.h"
#include "lyxtext.h"
#include "frontends/Dialogs.h"
#include "frontends/Alert.h"
#include "debug.h"
using std::ostream;
@ -232,7 +233,7 @@ void InsetERT::setFont(BufferView *, LyXFont const &, bool, bool selectall)
// if selectall is activated then the fontchange was an outside general
// fontchange and this messages is not needed
if (!selectall)
WriteAlert(_("Impossible Operation!"),
Alert::alert(_("Impossible Operation!"),
_("Not permitted to change font-types inside ERT-insets!"),
_("Sorry."));
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -14,43 +14,25 @@
#pragma implementation
#endif
#include <cerrno>
#include FORMS_H_LOCATION
#include "lyx_gui_misc.h"
#include "BufferView.h"
#include "buffer.h"
#include "gettext.h"
#include "figure_form.h"
#include "lyx_cb.h"
#include "lyx_main.h"
#include "print_form.h"
#include "LyXView.h"
#include "bufferview_funcs.h"
#include "support/filetools.h"
#include "lyxrc.h"
#include "debug.h"
using std::pair;
using std::make_pair;
using std::endl;
extern BufferView * current_view;
extern FD_form_figure * fd_form_figure;
extern FD_form_sendto * fd_form_sendto;
extern void HideFiguresPopups();
// Prevents LyX from being killed when the close box is pressed in a popup.
// The code below is just waiting to go away really ...
extern "C"
int CancelCloseBoxCB(FL_FORM *, void *)
{
return FL_CANCEL;
}
// Redraw the form (on receipt of a Signal indicating, for example,
// that the xform colors have been re-mapped).
void RedrawAllBufferRelatedDialogs()
{
if (fd_form_figure->form_figure->visible) {
@ -61,16 +43,8 @@ void RedrawAllBufferRelatedDialogs()
}
}
// Prevents LyX from crashing when no buffers available
// This is also one of the functions that we _really_ dont want
// we should try to finds way to help us with that.
// The signal/slot mechanism can probably help.
void CloseAllBufferRelatedDialogs()
{
// don't forget to check that dynamically created forms
// have been created otherwise hiding one could cause a crash
// need the visible check otherwise XForms prints a warning
// if hiding an invisible form
if (fd_form_figure->form_figure->visible) {
fl_hide_form(fd_form_figure->form_figure);
}
@ -80,171 +54,7 @@ void CloseAllBufferRelatedDialogs()
HideFiguresPopups();
}
// This is another function we really don't want.
// Again the Signal/Slot mechanism is tailor made for this task.
void updateAllVisibleBufferRelatedDialogs(bool)
{
HideFiguresPopups();
}
// Extract shortcut from <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
#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.
extern "C"
@ -36,42 +34,4 @@ void CloseAllBufferRelatedDialogs();
/// Ensures info in visible popups are always correct.
void updateAllVisibleBufferRelatedDialogs(bool switched = false);
/* These shortcut extractors should be shifted to frontends/xforms/ eventually */
/// Extract shortcut from <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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,7 +26,7 @@
#include "debug.h"
#include "vspace.h"
#include "layout.h"
#include "lyx_gui_misc.h"
#include "frontends/Alert.h"
#include "buffer.h"
#include "BufferView.h"
#include "Painter.h"
@ -266,9 +266,6 @@ void LyXTabular::AppendRow(int cell)
void LyXTabular::DeleteRow(int row)
{
// Why make it so hard? (Lgb)
//if (!(rows_ - 1))
//return;
if (rows_ == 1) return; // Not allowed to delete last row
row_info.erase(row_info.begin() + row); //&row_info[row]);
@ -1442,7 +1439,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
lyxerr << "Tabular format < 5 is not supported anymore\n"
"Get an older version of LyX (< 1.1.x) for conversion!"
<< endl;
WriteAlert(_("Warning:"),
Alert::alert(_("Warning:"),
_("Tabular format < 5 is not supported anymore\n"),
_("Get an older version of LyX (< 1.1.x) for conversion!"));
if (version > 2) {
@ -2651,16 +2648,9 @@ LyXTabular::BoxType LyXTabular::UseParbox(int cell) const
for (; par; par = par->next()) {
for (int i = 0; i < par->size(); ++i) {
if (par->getChar(i) == Paragraph::META_NEWLINE)
if (par->getChar(i) == Paragraph::META_NEWLINE)
return BOX_PARBOX;
}
}
return BOX_NONE;
}
/* Emacs:
* Local variables:
* tab-width: 4
* End:
* vi:set tabstop=4:
*/