2001-11-26 10:19:58 +00:00
|
|
|
/**
|
|
|
|
* \file Alert.C
|
|
|
|
* Copyright 2001 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
|
|
|
* \author John Levon <moz@compsoc.man.ac.uk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2002-02-16 15:59:55 +00:00
|
|
|
|
|
|
|
#include "Alert.h"
|
|
|
|
|
2001-11-26 10:19:58 +00:00
|
|
|
#include "debug.h"
|
2002-03-21 21:21:28 +00:00
|
|
|
#include "lyxrc.h"
|
|
|
|
|
2001-11-26 10:19:58 +00:00
|
|
|
#include "Alert_pimpl.h"
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
#include <cerrno>
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-11-26 10:19:58 +00:00
|
|
|
using std::endl;
|
2002-02-16 15:59:55 +00:00
|
|
|
using std::pair;
|
|
|
|
using std::make_pair;
|
2001-11-26 10:19:58 +00:00
|
|
|
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
void Alert::alert(string const & s1, string const & s2, string const & s3)
|
|
|
|
{
|
|
|
|
if (!lyxrc.use_gui) {
|
|
|
|
lyxerr << "------------------------------" << endl
|
|
|
|
<< s1 << endl << s2 << endl << s3 << endl
|
|
|
|
<< "------------------------------" << endl;
|
2002-03-21 21:21:28 +00:00
|
|
|
} else {
|
2002-02-16 15:59:55 +00:00
|
|
|
alert_pimpl(s1, s2, s3);
|
2001-11-26 10:19:58 +00:00
|
|
|
}
|
2002-02-16 15:59:55 +00:00
|
|
|
}
|
2001-11-26 10:19:58 +00:00
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
|
|
|
|
void Alert::err_alert(string const & s1, string const & s2)
|
|
|
|
{
|
|
|
|
alert(s1, s2, strerror(errno));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Alert::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);
|
2001-11-26 10:19:58 +00:00
|
|
|
}
|
2002-02-16 15:59:55 +00:00
|
|
|
}
|
2001-11-26 10:19:58 +00:00
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
|
|
|
|
int Alert::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);
|
2001-11-26 10:19:58 +00:00
|
|
|
}
|
2002-02-16 15:59:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pair<bool, string> const Alert::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);
|
|
|
|
} else {
|
|
|
|
return askForText_pimpl(msg, dflt);
|
2001-11-26 10:19:58 +00:00
|
|
|
}
|
|
|
|
}
|