Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-studio / tags / 0.61.09 / src / synfigapp / uimanager.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file uimanager.cpp
3 **      \brief Template File
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
10 **      This package is free software; you can redistribute it and/or
11 **      modify it under the terms of the GNU General Public License as
12 **      published by the Free Software Foundation; either version 2 of
13 **      the License, or (at your option) any later version.
14 **
15 **      This package is distributed in the hope that it will be useful,
16 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
17 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 **      General Public License for more details.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === H E A D E R S ======================================================= */
24
25 #ifdef USING_PCH
26 #       include "pch.h"
27 #else
28 #ifdef HAVE_CONFIG_H
29 #       include <config.h>
30 #endif
31
32 #include "uimanager.h"
33 #include <iostream>
34 #include <string>
35
36 #include "general.h"
37
38 #endif
39
40 /* === U S I N G =========================================================== */
41
42 using namespace std;
43 using namespace etl;
44 using namespace synfig;
45 using namespace synfigapp;
46
47 /* === M A C R O S ========================================================= */
48
49 /* === M E T H O D S ======================================================= */
50
51 UIInterface::Response
52 ConsoleUIInterface::yes_no(const std::string &title, const std::string &message,Response dflt)
53 {
54         cout<<title<<": "<<message<<' ';
55         if(dflt==RESPONSE_NO)
56                 cout<<_("(no/yes)")<<endl;
57         else
58                 cout<<_("(yes/no)")<<endl;
59         string resp;
60         cin>>resp;
61
62         if(dflt==RESPONSE_NO)
63         {
64                 if(resp=="yes")
65                         return RESPONSE_YES;
66                 else
67                         return RESPONSE_NO;
68         }
69         else
70         {
71                 if(resp=="no")
72                         return RESPONSE_NO;
73                 else
74                         return RESPONSE_YES;
75         }
76 }
77
78 UIInterface::Response
79 ConsoleUIInterface::yes_no_cancel(const std::string &title, const std::string &message, Response dflt)
80 {
81         cout<<title<<": "<<message<<' ';
82         if(dflt==RESPONSE_NO)
83                 cout<<_("(no/yes)")<<endl;
84         else
85                 cout<<_("(yes/no)")<<endl;
86         string resp;
87         cin>>resp;
88
89         if(dflt==RESPONSE_NO)
90         {
91                 if(resp=="yes")
92                         return RESPONSE_YES;
93                 else
94                         return RESPONSE_NO;
95         }
96         else
97         {
98                 if(resp=="no")
99                         return RESPONSE_NO;
100                 else
101                         return RESPONSE_YES;
102         }
103 }
104
105 UIInterface::Response
106 ConsoleUIInterface::ok_cancel(const std::string &title, const std::string &message,Response dflt)
107 {
108         cout<<title<<": "<<message<<' ';
109         if(dflt==RESPONSE_CANCEL)
110                 cout<<_("(cancel/ok)")<<endl;
111         else
112                 cout<<_("(ok/cancel)")<<endl;
113         string resp;
114         cin>>resp;
115
116         if(dflt==RESPONSE_CANCEL)
117         {
118                 if(resp=="ok")
119                         return RESPONSE_OK;
120                 else
121                         return RESPONSE_CANCEL;
122         }
123         else
124         {
125                 if(resp=="cancel")
126                         return RESPONSE_CANCEL;
127                 else
128                         return RESPONSE_OK;
129         }
130 }
131
132 bool
133 ConsoleUIInterface::task(const std::string &task)
134 {
135         cout<<task<<endl;
136         return true;
137 }
138
139 bool
140 ConsoleUIInterface::error(const std::string &task)
141 {
142         cout<<_("error: ")<<task<<endl;
143         return true;
144 }
145
146 bool
147 ConsoleUIInterface::warning(const std::string &task)
148 {
149         cout<<_("warning: ")<<task<<endl;
150         return true;
151 }
152
153 bool
154 ConsoleUIInterface::amount_complete(int /*current*/, int /*total*/)
155 {
156         return true;
157 }
158
159
160