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"
|
2003-03-31 02:59:34 +00:00
|
|
|
#include "lyx_gui.h"
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-11-26 10:19:58 +00:00
|
|
|
#include "Alert_pimpl.h"
|
|
|
|
|
|
|
|
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
|
|
|
|
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-31 02:59:34 +00:00
|
|
|
if (lyx_gui::use_gui)
|
2003-03-29 07:09:13 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-29 09:02:08 +00:00
|
|
|
void Alert::warning(string const & title, string const & message)
|
|
|
|
{
|
2003-03-31 02:59:34 +00:00
|
|
|
if (lyx_gui::use_gui)
|
2003-03-29 09:02:08 +00:00
|
|
|
return warning_pimpl(title, message);
|
|
|
|
|
|
|
|
lyxerr << "Warning: " << title << endl;
|
|
|
|
lyxerr << "----------------------------------------" << endl;
|
|
|
|
lyxerr << message << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Alert::error(string const & title, string const & message)
|
|
|
|
{
|
2003-03-31 02:59:34 +00:00
|
|
|
if (lyx_gui::use_gui)
|
2003-03-29 09:02:08 +00:00
|
|
|
return error_pimpl(title, message);
|
|
|
|
|
|
|
|
lyxerr << "Error: " << title << endl;
|
|
|
|
lyxerr << "----------------------------------------" << endl;
|
|
|
|
lyxerr << message << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Alert::information(string const & title, string const & message)
|
|
|
|
{
|
2003-03-31 02:59:34 +00:00
|
|
|
if (lyx_gui::use_gui)
|
2003-03-29 09:02:08 +00:00
|
|
|
return information_pimpl(title, message);
|
|
|
|
|
|
|
|
lyxerr << title << endl;
|
|
|
|
lyxerr << "----------------------------------------" << endl;
|
|
|
|
lyxerr << message << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
pair<bool, string> const Alert::askForText(string const & msg,
|
|
|
|
string const & dflt)
|
|
|
|
{
|
2003-03-31 02:59:34 +00:00
|
|
|
if (!lyx_gui::use_gui) {
|
2002-02-16 15:59:55 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|