diff options
author | rathnor <rathnor> | 2004-06-07 11:46:05 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2004-06-07 11:46:05 (GMT) |
commit | fff4456dee29e675d7f2ed3490db39bcb7e10e53 (patch) | |
tree | 2d2dbf386551773cbdc8231b2a93b493187bd733 /src/main.cc | |
parent | 073065ac56b388db1169108d44f37d32f1d19c67 (diff) | |
download | fluxbox_pavel-fff4456dee29e675d7f2ed3490db39bcb7e10e53.zip fluxbox_pavel-fff4456dee29e675d7f2ed3490db39bcb7e10e53.tar.bz2 |
update NLS string handling...
Diffstat (limited to 'src/main.cc')
-rw-r--r-- | src/main.cc | 92 |
1 files changed, 48 insertions, 44 deletions
diff --git a/src/main.cc b/src/main.cc index 9f3d816..68bb62f 100644 --- a/src/main.cc +++ b/src/main.cc | |||
@@ -20,14 +20,14 @@ | |||
20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21 | // DEALINGS IN THE SOFTWARE. | 21 | // DEALINGS IN THE SOFTWARE. |
22 | 22 | ||
23 | // $Id: main.cc,v 1.29 2004/02/28 10:32:06 fluxgen Exp $ | 23 | // $Id: main.cc,v 1.30 2004/06/07 11:46:04 rathnor Exp $ |
24 | 24 | ||
25 | #include "fluxbox.hh" | 25 | #include "fluxbox.hh" |
26 | #include "I18n.hh" | ||
27 | #include "version.h" | 26 | #include "version.h" |
28 | #include "defaults.hh" | 27 | #include "defaults.hh" |
29 | 28 | ||
30 | #include "FbTk/Theme.hh" | 29 | #include "FbTk/Theme.hh" |
30 | #include "FbTk/I18n.hh" | ||
31 | 31 | ||
32 | #ifdef HAVE_CONFIG_H | 32 | #ifdef HAVE_CONFIG_H |
33 | #include "config.h" | 33 | #include "config.h" |
@@ -48,26 +48,31 @@ | |||
48 | 48 | ||
49 | using namespace std; | 49 | using namespace std; |
50 | void showInfo(ostream &ostr) { | 50 | void showInfo(ostream &ostr) { |
51 | ostr<<"Fluxbox version: "<<__fluxbox_version<<endl; | 51 | _FB_USES_NLS; |
52 | ostr<<_FBTEXT(Common, FluxboxVersion, "Fluxbox version", "Fluxbox version heading")<<": "<<__fluxbox_version<<endl; | ||
52 | #if defined(__DATE__) && defined(__TIME__) | 53 | #if defined(__DATE__) && defined(__TIME__) |
53 | ostr<<"Compiled: "<<__DATE__<<" "<<__TIME__<<endl; | 54 | ostr<<_FBTEXT(Common, Compiled, "Compiled", "Time fluxbox was compiled")<<": "<<__DATE__<<" "<<__TIME__<<endl; |
54 | #endif | 55 | #endif |
55 | #ifdef __fluxbox_compiler | 56 | #ifdef __fluxbox_compiler |
56 | ostr<<"Compiler: "<<__fluxbox_compiler<<endl; | 57 | ostr<<_FBTEXT(Common, Compiler, "Compiler", "Compiler used to build fluxbox")<<": "<<__fluxbox_compiler<<endl; |
57 | #endif // __fluxbox_compiler | 58 | #endif // __fluxbox_compiler |
58 | #ifdef __fluxbox_compiler_version | 59 | #ifdef __fluxbox_compiler_version |
59 | ostr<<"Compiler version: "<<__fluxbox_compiler_version<<endl; | 60 | ostr<<_FBTEXT(Common, CompilerVersion, "Compiler version", "Compiler version used to build fluxbox")<<": "<<__fluxbox_compiler_version<<endl; |
60 | #endif // __fluxbox_compiler_version | 61 | #endif // __fluxbox_compiler_version |
61 | 62 | ||
62 | ostr<<endl<<"Defaults:"<<endl; | 63 | ostr<<endl<<_FBTEXT(Common, Defaults, "Defaults", "Default values compiled in")<<":"<<endl; |
63 | ostr<<" menu: "<<DEFAULTMENU<<endl; | 64 | |
64 | ostr<<" style: "<<DEFAULTSTYLE<<endl; | 65 | ostr<<_FBTEXT(Common, DefaultMenuFile, " menu", "default menu file (right aligned - make sure same width as other default values)")<<": "<<DEFAULTMENU<<endl; |
66 | ostr<<_FBTEXT(Common, DefaultStyle, " style", "default style (right aligned - make sure same width as other default values)")<<": "<<DEFAULTSTYLE<<endl; | ||
65 | 67 | ||
66 | ostr<<" keys: "<<DEFAULTKEYSFILE<<endl; | 68 | ostr<<_FBTEXT(Common, DefaultKeyFile, " keys", "default key file (right aligned - make sure same width as other default values)")<<": "<<DEFAULTKEYSFILE<<endl; |
67 | ostr<<" init: "<<DEFAULT_INITFILE<<endl; | 69 | ostr<<_FBTEXT(Common, DefaultInitFile, " init", "default init file (right aligned - make sure same width as other default values)")<<": "<<DEFAULT_INITFILE<<endl; |
68 | 70 | ||
69 | const char NOT[] = "-"; | 71 | const char NOT[] = "-"; |
70 | ostr<<endl<<"Compiled options ("<<NOT<<" => disabled): "<<endl<< | 72 | ostr<<endl<< |
73 | _FBTEXT(Common, CompiledOptions, "Compiled options", "Options used when compiled") | ||
74 | <<" ("<<NOT<<" => "<< | ||
75 | _FBTEXT(Common, Disabled, "disabled", "option is turned off")<<"): "<<endl<< | ||
71 | #ifndef DEBUG | 76 | #ifndef DEBUG |
72 | NOT<< | 77 | NOT<< |
73 | #endif // DEBUG | 78 | #endif // DEBUG |
@@ -141,8 +146,8 @@ int main(int argc, char **argv) { | |||
141 | std::string rc_file; | 146 | std::string rc_file; |
142 | std::string log_filename; | 147 | std::string log_filename; |
143 | 148 | ||
144 | NLSInit("fluxbox.cat"); | 149 | FbTk::NLSInit("fluxbox.cat"); |
145 | I18n &i18n = *I18n::instance(); | 150 | _FB_USES_NLS; |
146 | 151 | ||
147 | int i; | 152 | int i; |
148 | for (i = 1; i < argc; ++i) { | 153 | for (i = 1; i < argc; ++i) { |
@@ -150,9 +155,8 @@ int main(int argc, char **argv) { | |||
150 | // look for alternative rc file to use | 155 | // look for alternative rc file to use |
151 | 156 | ||
152 | if ((++i) >= argc) { | 157 | if ((++i) >= argc) { |
153 | fprintf(stderr, | 158 | cerr<<_FBTEXT(main, RCRequiresArg, |
154 | i18n.getMessage(FBNLS::mainSet, FBNLS::mainRCRequiresArg, | 159 | "error: '-rc' requires an argument", "the -rc option requires a file argument")<<endl;; |
155 | "error: '-rc' requires and argument\n")); | ||
156 | exit(1); | 160 | exit(1); |
157 | } | 161 | } |
158 | 162 | ||
@@ -162,19 +166,18 @@ int main(int argc, char **argv) { | |||
162 | // set by the environment variable DISPLAY | 166 | // set by the environment variable DISPLAY |
163 | 167 | ||
164 | if ((++i) >= argc) { | 168 | if ((++i) >= argc) { |
165 | fprintf(stderr, | 169 | cerr<<_FBTEXT(main, DISPLAYRequiresArg, |
166 | i18n.getMessage(FBNLS::mainSet, FBNLS::mainDISPLAYRequiresArg, | 170 | "error: '-display' requires an argument", |
167 | "error: '-display' requires an argument\n")); | 171 | "")<<endl; |
168 | exit(1); | 172 | exit(1); |
169 | } | 173 | } |
170 | 174 | ||
171 | session_display = argv[i]; | 175 | session_display = argv[i]; |
172 | std::string display_env = "DISPLAY=" + session_display; | 176 | std::string display_env = "DISPLAY=" + session_display; |
173 | if (putenv(const_cast<char *>(display_env.c_str()))) { | 177 | if (putenv(const_cast<char *>(display_env.c_str()))) { |
174 | fprintf(stderr, | 178 | cerr<<_FBTEXT(main, WarnDisplaySet, |
175 | i18n. | 179 | "warning: couldn't set environment variable 'DISPLAY'", |
176 | getMessage(FBNLS::mainSet, FBNLS::mainWarnDisplaySet, | 180 | "")<<endl; |
177 | "warning: couldn't set environment variable 'DISPLAY'\n")); | ||
178 | perror("putenv()"); | 181 | perror("putenv()"); |
179 | } | 182 | } |
180 | } else if (strcmp(argv[i], "-version") == 0 || strcmp(argv[i], "-v") == 0) { | 183 | } else if (strcmp(argv[i], "-version") == 0 || strcmp(argv[i], "-v") == 0) { |
@@ -183,22 +186,23 @@ int main(int argc, char **argv) { | |||
183 | exit(0); | 186 | exit(0); |
184 | } else if (strcmp(argv[i], "-log") == 0 ) { | 187 | } else if (strcmp(argv[i], "-log") == 0 ) { |
185 | if (i + 1 >= argc) { | 188 | if (i + 1 >= argc) { |
186 | cerr<<"error: '-log' needs an argument"<<endl; | 189 | cerr<<_FBTEXT(main, LOGRequiresArg, "error: '-log' needs an argument", "")<<endl; |
187 | exit(1); | 190 | exit(1); |
188 | } | 191 | } |
189 | log_filename = argv[++i]; | 192 | log_filename = argv[++i]; |
190 | } else if (strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "-h") == 0) { | 193 | } else if (strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "-h") == 0) { |
191 | // print program usage and command line options | 194 | // print program usage and command line options |
192 | printf(i18n. | 195 | printf(_FBTEXT(main, Usage, |
193 | getMessage(FBNLS::mainSet, FBNLS::mainUsage, | 196 | "Fluxbox %s : (c) %s Henrik Kinnunen\n" |
194 | "Fluxbox %s : (c) %s Henrik Kinnunen\n" | 197 | "Website: http://www.fluxbox.org/ \n\n" |
195 | "Website: http://www.fluxbox.org/ \n\n" | 198 | "\t-display <string>\t\tuse display connection.\n" |
196 | " -display <string>\t\tuse display connection.\n" | 199 | "\t-rc <string>\t\t\tuse alternate resource file.\n" |
197 | " -rc <string>\t\t\tuse alternate resource file.\n" | 200 | "\t-version\t\t\tdisplay version and exit.\n" |
198 | " -version\t\t\tdisplay version and exit.\n" | 201 | "\t-info\t\t\t\tdisplay some useful information.\n" |
199 | " -info\t\t\t\tdisplay some useful information.\n" | 202 | "\t-log <filename>\t\t\tlog output to file.\n" |
200 | "\t-log <filename>\t\t\tlog output to file.\n" | 203 | "\t-help\t\t\t\tdisplay this help text and exit.\n\n", |
201 | " -help\t\t\t\tdisplay this help text and exit.\n\n"), | 204 | |
205 | "Main usage string. Please lay it out nicely. There is one %s that is given the version"), | ||
202 | __fluxbox_version, "2001-2004"); | 206 | __fluxbox_version, "2001-2004"); |
203 | exit(0); | 207 | exit(0); |
204 | } else if (strcmp(argv[i], "-info") == 0 || strcmp(argv[i], "-i") == 0) { | 208 | } else if (strcmp(argv[i], "-info") == 0 || strcmp(argv[i], "-i") == 0) { |
@@ -222,9 +226,9 @@ int main(int argc, char **argv) { | |||
222 | 226 | ||
223 | // setup log file | 227 | // setup log file |
224 | if (log_file) { | 228 | if (log_file) { |
225 | cerr<<"Loggin to: "<<log_filename<<endl; | 229 | cerr<<_FBTEXT(main, LoggingTo, "Logging to", "Logging to a file")<<": "<<log_filename<<endl; |
226 | log_file<<"------------------------------------------"<<endl; | 230 | log_file<<"------------------------------------------"<<endl; |
227 | log_file<<"Logfile: "<<log_filename<<endl; | 231 | log_file<<_FBTEXT(main, LogFile, "Log File", "")<<": "<<log_filename<<endl; |
228 | showInfo(log_file); | 232 | showInfo(log_file); |
229 | log_file<<"------------------------------------------"<<endl; | 233 | log_file<<"------------------------------------------"<<endl; |
230 | // setup log to use cout and cerr stream | 234 | // setup log to use cout and cerr stream |
@@ -240,19 +244,19 @@ int main(int argc, char **argv) { | |||
240 | exitcode = EXIT_SUCCESS; | 244 | exitcode = EXIT_SUCCESS; |
241 | 245 | ||
242 | } catch (std::out_of_range &oor) { | 246 | } catch (std::out_of_range &oor) { |
243 | cerr<<"Fluxbox: Out of range: "<<oor.what()<<endl; | 247 | cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorOutOfRange, "Out of range", "Error message")<<": "<<oor.what()<<endl; |
244 | } catch (std::runtime_error &re) { | 248 | } catch (std::runtime_error &re) { |
245 | cerr<<"Fluxbox: Runtime error: "<<re.what()<<endl; | 249 | cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorRuntime, "Runtime error", "Error message")<<": "<<re.what()<<endl; |
246 | } catch (std::bad_cast &bc) { | 250 | } catch (std::bad_cast &bc) { |
247 | cerr<<"Fluxbox: Bad cast: "<<bc.what()<<endl; | 251 | cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorBadCast, "Bad cast", "Error message")<<": "<<bc.what()<<endl; |
248 | } catch (std::bad_alloc &ba) { | 252 | } catch (std::bad_alloc &ba) { |
249 | cerr<<"Fluxbox: Bad Alloc: "<<ba.what()<<endl; | 253 | cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorBadAlloc, "Bad Alloc", "Error message")<<": "<<ba.what()<<endl; |
250 | } catch (std::exception &e) { | 254 | } catch (std::exception &e) { |
251 | cerr<<"Fluxbox: Standard exception: "<<e.what()<<endl; | 255 | cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorStandardException, "Standard Exception", "Error message")<<": "<<e.what()<<endl; |
252 | } catch (std::string error_str) { | 256 | } catch (std::string error_str) { |
253 | cerr<<"Error: "<<error_str<<endl; | 257 | cerr<<_FBTEXT(Common, Error, "Error", "Error message header")<<": "<<error_str<<endl; |
254 | } catch (...) { | 258 | } catch (...) { |
255 | cerr<<"Fluxbox: Unknown error."<<endl; | 259 | cerr<<"Fluxbox: "<<_FBTEXT(main, ErrorUnknown, "Unknown error", "Error message")<<"."<<endl; |
256 | abort(); | 260 | abort(); |
257 | } | 261 | } |
258 | // destroy fluxbox | 262 | // destroy fluxbox |