]> git.lyx.org Git - lyx.git/blob - src/frontends/Alert.C
(John): translate dialog titles.
[lyx.git] / src / frontends / Alert.C
1 /**
2  * \file Alert.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author John Levon <moz@compsoc.man.ac.uk>
7  */
8
9 #include <config.h>
10
11 #include "Alert.h"
12
13 #include "debug.h"
14 #include "lyxrc.h"
15
16 #include "Alert_pimpl.h"
17
18 #include <cerrno>
19
20 using std::endl;
21 using std::pair;
22 using std::make_pair;
23
24
25 void Alert::alert(string const & s1, string const & s2, string const & s3)
26 {
27         if (!lyxrc.use_gui) {
28                 lyxerr << "------------------------------" << endl
29                        << s1 << endl << s2 << endl << s3 << endl
30                        << "------------------------------" << endl;
31         } else {
32                 alert_pimpl(s1, s2, s3);
33         }
34 }
35
36
37 void Alert::err_alert(string const & s1, string const & s2)
38 {
39         alert(s1, s2, strerror(errno));
40 }
41
42
43 bool Alert::askQuestion(string const & s1, string const & s2,
44                         string const & s3, bool default_value)
45 {
46         if (!lyxrc.use_gui) {
47                 lyxerr << "----------------------------------------" << endl
48                        << s1 << endl;
49                 if (!s2.empty())
50                         lyxerr << s2 << endl;
51                 if (!s3.empty())
52                         lyxerr << s3 << endl;
53                 lyxerr << "Assuming answer is "
54                        << (default_value ? "yes" : "no")
55                        << endl
56                        << "----------------------------------------" << endl;
57                 return default_value;
58         } else {
59                 return askQuestion_pimpl(s1, s2, s3);
60         }
61 }
62
63
64 int Alert::askConfirmation(string const & s1, string const & s2,
65                            string const & s3, int default_value)
66 {
67         if (!lyxrc.use_gui) {
68                 lyxerr << "----------------------------------------" << endl
69                        << s1 << endl;
70                 if (!s2.empty())
71                         lyxerr << s2 << endl;
72                 if (!s3.empty())
73                         lyxerr << s3 << endl;
74                 lyxerr << "Assuming answer is ";
75                 if (default_value == 1)
76                         lyxerr << "yes";
77                 else if (default_value == 2)
78                         lyxerr << "no";
79                 else
80                         lyxerr << "cancel";
81                 lyxerr << endl
82                        << "----------------------------------------" << endl;
83                 return default_value;
84         } else {
85                 return askConfirmation_pimpl(s1, s2, s3);
86         }
87 }
88
89
90 pair<bool, string> const Alert::askForText(string const & msg,
91                                            string const & dflt)
92 {
93         if (!lyxrc.use_gui) {
94                 lyxerr << "----------------------------------------" << endl
95                        << msg << endl
96                        << "Assuming answer is " << dflt
97                        << "----------------------------------------" << endl;
98                 return make_pair<bool, string>(true, dflt);
99         } else {
100                 return askForText_pimpl(msg, dflt);
101         }
102 }