2001-11-26 10:19:58 +00:00
|
|
|
/**
|
|
|
|
* \file Alert.C
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-11-26 10:19:58 +00:00
|
|
|
*
|
2002-12-01 22:59:25 +00:00
|
|
|
* \author John Levon
|
2002-09-05 14:10:50 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2001-11-26 10:19:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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
|
|
|
|
2002-06-10 07:57:39 +00:00
|
|
|
#ifndef CXX_GLOBAL_CSTD
|
|
|
|
using std::strerror;
|
|
|
|
#endif
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-29 07:09:13 +00:00
|
|
|
int Alert::prompt(string const & title, string const & question,
|
|
|
|
int default_button,
|
|
|
|
string const & b1, string const & b2, string const & b3)
|
2002-02-16 15:59:55 +00:00
|
|
|
{
|
2003-03-29 07:09:13 +00:00
|
|
|
if (lyxrc.use_gui)
|
|
|
|
return prompt_pimpl(title, question, default_button, b1, b2, b3);
|
|
|
|
|
|
|
|
lyxerr << title << endl;
|
|
|
|
lyxerr << "----------------------------------------" << endl;
|
|
|
|
lyxerr << question << endl;
|
|
|
|
lyxerr << "Assuming answer is ";
|
|
|
|
switch (default_button) {
|
|
|
|
case 0: lyxerr << b1 << endl;
|
|
|
|
case 1: lyxerr << b2 << endl;
|
|
|
|
case 2: lyxerr << b3 << endl;
|
2001-11-26 10:19:58 +00:00
|
|
|
}
|
2003-03-29 07:09:13 +00:00
|
|
|
return default_button;
|
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
|
|
|
}
|
|
|
|
}
|