Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-studio / tags / synfigstudio_0_61_07_rc3 / 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 #endif
37
38 /* === U S I N G =========================================================== */
39
40 using namespace std;
41 using namespace etl;
42 using namespace synfig;
43 using namespace synfigapp;
44
45 /* === M A C R O S ========================================================= */
46
47 /* === M E T H O D S ======================================================= */
48
49 UIInterface::Response
50 ConsoleUIInterface::yes_no(const std::string &title, const std::string &message,Response dflt)
51 {
52         cout<<title<<": "<<message<<' ';
53         if(dflt==RESPONSE_NO)
54                 cout<<_("(no/yes)")<<endl;
55         else
56                 cout<<_("(yes/no)")<<endl;
57         string resp;
58         cin>>resp;
59
60         if(dflt==RESPONSE_NO)
61         {
62                 if(resp=="yes")
63                         return RESPONSE_YES;
64                 else
65                         return RESPONSE_NO;
66         }
67         else
68         {
69                 if(resp=="no")
70                         return RESPONSE_NO;
71                 else
72                         return RESPONSE_YES;
73         }
74 }
75
76 UIInterface::Response
77 ConsoleUIInterface::yes_no_cancel(const string &title, const string &message,Response dflt)
78 {
79         cout<<title<<": "<<message<<' ';
80         if(dflt==RESPONSE_NO)
81                 cout<<_("(no/yes)")<<endl;
82         else
83                 cout<<_("(yes/no)")<<endl;
84         string resp;
85         cin>>resp;
86
87         if(dflt==RESPONSE_NO)
88         {
89                 if(resp=="yes")
90                         return RESPONSE_YES;
91                 else
92                         return RESPONSE_NO;
93         }
94         else
95         {
96                 if(resp=="no")
97                         return RESPONSE_NO;
98                 else
99                         return RESPONSE_YES;
100         }
101 }
102
103 UIInterface::Response
104 ConsoleUIInterface::ok_cancel(const std::string &title, const std::string &message,Response dflt)
105 {
106         cout<<title<<": "<<message<<' ';
107         if(dflt==RESPONSE_CANCEL)
108                 cout<<_("(cancel/ok)")<<endl;
109         else
110                 cout<<_("(ok/cancel)")<<endl;
111         string resp;
112         cin>>resp;
113
114         if(dflt==RESPONSE_CANCEL)
115         {
116                 if(resp=="ok")
117                         return RESPONSE_OK;
118                 else
119                         return RESPONSE_CANCEL;
120         }
121         else
122         {
123                 if(resp=="cancel")
124                         return RESPONSE_CANCEL;
125                 else
126                         return RESPONSE_OK;
127         }
128 }
129
130 bool
131 ConsoleUIInterface::task(const std::string &task)
132 {
133         cout<<task<<endl;
134         return true;
135 }
136
137 bool
138 ConsoleUIInterface::error(const std::string &task)
139 {
140         cout<<_("error: ")<<task<<endl;
141         return true;
142 }
143
144 bool
145 ConsoleUIInterface::warning(const std::string &task)
146 {
147         cout<<_("warning: ")<<task<<endl;
148         return true;
149 }
150
151 bool
152 ConsoleUIInterface::amount_complete(int /*current*/, int /*total*/)
153 {
154         return true;
155 }
156
157
158