]> icculus.org git repositories - dana/openbox.git/blob - src/main.cc
make strings in main.cc translatable
[dana/openbox.git] / src / main.cc
1 // -*- mode: C++; indent-tabs-mode: nil; -*-
2
3 #include "../version.h"
4
5 #ifdef    HAVE_CONFIG_H
6 #  include "../config.h"
7 #endif // HAVE_CONFIG_H
8
9 extern "C" {
10 #ifdef    HAVE_STDIO_H
11 #  include <stdio.h>
12 #endif // HAVE_STDIO_H
13
14 #ifdef HAVE_STDLIB_H
15 #  include <stdlib.h>
16 #endif // HAVE_STDLIB_H
17
18 #ifdef HAVE_STRING_H
19 #  include <string.h>
20 #endif // HAVE_STRING_H
21
22 #ifdef    HAVE_UNISTD_H
23 #include <sys/types.h>
24 #endif // HAVE_UNISTD_H
25
26 #ifdef    HAVE_SYS_PARAM_H
27 #  include <sys/param.h>
28 #endif // HAVE_SYS_PARAM_H
29 }
30
31 #include "gettext.h"
32 #define _(str) gettext(str)
33
34 #include <string>
35 using std::string;
36
37 #include "blackbox.hh"
38
39
40 static void showHelp(int exitval) {
41   // print program usage and command line options
42   printf(_("Openbox %s : (c) 2002 - 2002 Ben Jansens\n"),
43          OPENBOX_VERSION);
44   printf(_("  -display <string>  use display connection.\n\
45   -rc <string>       use alternate resource file.\n\
46   -menu <string>     use alternate menu file.\n\
47   -version           display version and exit.\n\
48   -help              display this help text and exit.\n\n"));
49
50   // some people have requested that we print out compile options
51   // as well
52   printf(_("Compile time options:\n\
53   Debugging:\t\t\t%s\n\
54   Shape:\t\t\t%s\n\
55   Xft:\t\t\t\t%s\n\
56   Xinerama:\t\t\t%s\n\
57   8bpp Ordered Dithering:\t%s\n\n"),
58 #ifdef    DEBUG
59          _("yes"),
60 #else // !DEBUG
61          _("no"),
62 #endif // DEBUG
63
64 #ifdef    SHAPE
65          _("yes"),
66 #else // !SHAPE
67          _("no"),
68 #endif // SHAPE
69
70 #ifdef    XFT
71          _("yes"),
72 #else // !XFT
73          _("no"),
74 #endif // XFT
75
76 #ifdef    XINERAMA
77          _("yes"),
78 #else // !XINERAMA
79          _("no"),
80 #endif // XINERAMA
81
82 #ifdef    ORDEREDPSEUDO
83          _("yes")
84 #else // !ORDEREDPSEUDO
85          _("no")
86 #endif // ORDEREDPSEUDO
87           );
88
89   ::exit(exitval);
90 }
91
92 int main(int argc, char **argv) {
93   char *session_display = (char *) 0;
94   char *rc_file = (char *) 0;
95   char *menu_file = (char *) 0;
96
97   for (int i = 1; i < argc; ++i) {
98     if (! strcmp(argv[i], "-rc")) {
99       // look for alternative rc file to use
100
101       if ((++i) >= argc) {
102         fprintf(stderr, _("error: '-rc' requires and argument\n"));
103
104         ::exit(1);
105       }
106
107       rc_file = argv[i];
108     } else if (! strcmp(argv[i], "-menu")) {
109       // look for alternative menu file to use
110
111       if ((++i) >= argc) {
112         fprintf(stderr, _("error: '-menu' requires and argument\n"));
113
114         ::exit(1);
115       }
116
117       menu_file = argv[i];
118     } else if (! strcmp(argv[i], "-display")) {
119       // check for -display option... to run on a display other than the one
120       // set by the environment variable DISPLAY
121
122       if ((++i) >= argc) {
123         fprintf(stderr, _("error: '-display' requires an argument\n"));
124
125         ::exit(1);
126       }
127
128       session_display = argv[i];
129       string dtmp = "DISPLAY=";
130       dtmp += session_display;
131
132       if (putenv(const_cast<char*>(dtmp.c_str()))) {
133         fprintf(stderr,
134                 _("warning: couldn't set environment variable 'DISPLAY'\n"));
135         perror("putenv()");
136       }
137     } else if (! strcmp(argv[i], "-version")) {
138       // print current version string
139       printf(_("Openbox %s : (c) 2002 - 2002 Ben Jansens\n"),
140              OPENBOX_VERSION);
141       printf("\n");
142
143       ::exit(0);
144     } else if (! strcmp(argv[i], "-help")) {
145       showHelp(0);
146     } else { // invalid command line option
147       showHelp(-1);
148     }
149   }
150
151 #ifdef    __EMX__
152   _chdir2(getenv("X11ROOT"));
153 #endif // __EMX__
154
155   Blackbox blackbox(argv, session_display, rc_file);
156   blackbox.eventLoop();
157
158   return(0);
159 }