Remove .gitignore do nothing is ignored.
[synfig.git] / synfig-studio / trunk / 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::confirmation(const std::string &title, const std::string &primaryText,
53                 const std::string &secondaryText, const std::string &confirmPhrase,
54                 const std::string &cancelPhrase, Response dflt)
55 {
56         cout << title << ": " << primaryText << endl;
57         cout << secondaryText;
58
59         if (dflt == RESPONSE_OK)
60                 cout << "(" << confirmPhrase << "/" << cancelPhrase << ")" << endl;
61         else
62                 cout << "(" << cancelPhrase << "/" << confirmPhrase << ")" << endl;
63
64         string resp;
65         cin >> resp;
66
67         if (dflt == RESPONSE_OK)
68         {
69                 if (resp == cancelPhrase)
70                         return RESPONSE_CANCEL;
71                 return RESPONSE_OK;
72         }
73         if (resp == confirmPhrase)
74                 return RESPONSE_OK;
75         return RESPONSE_CANCEL;
76 }
77
78 UIInterface::Response
79 ConsoleUIInterface::yes_no(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::yes_no_cancel(const std::string &title, const std::string &message, Response dflt)
107 {
108         cout<<title<<": "<<message<<' ';
109         if(dflt==RESPONSE_NO)
110                 cout<<_("(no/yes)")<<endl;
111         else
112                 cout<<_("(yes/no)")<<endl;
113         string resp;
114         cin>>resp;
115
116         if(dflt==RESPONSE_NO)
117         {
118                 if(resp=="yes")
119                         return RESPONSE_YES;
120                 else
121                         return RESPONSE_NO;
122         }
123         else
124         {
125                 if(resp=="no")
126                         return RESPONSE_NO;
127                 else
128                         return RESPONSE_YES;
129         }
130 }
131
132 UIInterface::Response
133 ConsoleUIInterface::ok_cancel(const std::string &title, const std::string &message,Response dflt)
134 {
135         cout<<title<<": "<<message<<' ';
136         if(dflt==RESPONSE_CANCEL)
137                 cout<<_("(cancel/ok)")<<endl;
138         else
139                 cout<<_("(ok/cancel)")<<endl;
140         string resp;
141         cin>>resp;
142
143         if(dflt==RESPONSE_CANCEL)
144         {
145                 if(resp=="ok")
146                         return RESPONSE_OK;
147                 else
148                         return RESPONSE_CANCEL;
149         }
150         else
151         {
152                 if(resp=="cancel")
153                         return RESPONSE_CANCEL;
154                 else
155                         return RESPONSE_OK;
156         }
157 }
158
159 bool
160 ConsoleUIInterface::task(const std::string &task)
161 {
162         cout<<task<<endl;
163         return true;
164 }
165
166 bool
167 ConsoleUIInterface::error(const std::string &task)
168 {
169         cout<<_("error: ")<<task<<endl;
170         return true;
171 }
172
173 bool
174 ConsoleUIInterface::warning(const std::string &task)
175 {
176         cout<<_("warning: ")<<task<<endl;
177         return true;
178 }
179
180 bool
181 ConsoleUIInterface::amount_complete(int /*current*/, int /*total*/)
182 {
183         return true;
184 }
185
186
187