diff options
author | fluxgen <fluxgen> | 2001-12-11 20:47:02 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2001-12-11 20:47:02 (GMT) |
commit | 18830ac9add80cbd3bf7369307d7e35a519dca9b (patch) | |
tree | 4759a5434a34ba317fe77bbf8b0ed9bb57bb6018 /src/main.cc | |
parent | 1523b48bff07dead084af3064ad11c79a9b25df0 (diff) | |
download | fluxbox_pavel-18830ac9add80cbd3bf7369307d7e35a519dca9b.zip fluxbox_pavel-18830ac9add80cbd3bf7369307d7e35a519dca9b.tar.bz2 |
Initial revision
Diffstat (limited to 'src/main.cc')
-rw-r--r-- | src/main.cc | 272 |
1 files changed, 272 insertions, 0 deletions
diff --git a/src/main.cc b/src/main.cc new file mode 100644 index 0000000..19ed631 --- /dev/null +++ b/src/main.cc | |||
@@ -0,0 +1,272 @@ | |||
1 | // main.cc for Blackbox - an X11 Window manager | ||
2 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) | ||
3 | // | ||
4 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | // copy of this software and associated documentation files (the "Software"), | ||
6 | // to deal in the Software without restriction, including without limitation | ||
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | // and/or sell copies of the Software, and to permit persons to whom the | ||
9 | // Software is furnished to do so, subject to the following conditions: | ||
10 | // | ||
11 | // The above copyright notice and this permission notice shall be included in | ||
12 | // all copies or substantial portions of the Software. | ||
13 | // | ||
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | // DEALINGS IN THE SOFTWARE. | ||
21 | |||
22 | // stupid macros needed to access some functions in version 2 of the GNU C | ||
23 | // library | ||
24 | #ifndef _GNU_SOURCE | ||
25 | #define _GNU_SOURCE | ||
26 | #endif // _GNU_SOURCE | ||
27 | |||
28 | #include "../version.h" | ||
29 | |||
30 | #ifdef HAVE_CONFIG_H | ||
31 | # include "../config.h" | ||
32 | #endif // HAVE_CONFIG_H | ||
33 | |||
34 | #include "i18n.hh" | ||
35 | #include "fluxbox.hh" | ||
36 | |||
37 | #ifdef HAVE_STDIO_H | ||
38 | # include <stdio.h> | ||
39 | #endif // HAVE_STDIO_H | ||
40 | |||
41 | #ifdef STDC_HEADERS | ||
42 | # include <stdlib.h> | ||
43 | # include <string.h> | ||
44 | #endif // STDC_HEADERS | ||
45 | |||
46 | #ifdef HAVE_UNISTD_H | ||
47 | #include <sys/types.h> | ||
48 | #endif // HAVE_UNISTD_H | ||
49 | |||
50 | #ifdef HAVE_SYS_PARAM_H | ||
51 | # include <sys/param.h> | ||
52 | #endif // HAVE_SYS_PARAM_H | ||
53 | |||
54 | #ifndef MAXPATHLEN | ||
55 | #define MAXPATHLEN 255 | ||
56 | #endif // MAXPATHLEN | ||
57 | |||
58 | #include <iostream> | ||
59 | using namespace std; | ||
60 | |||
61 | int main(int argc, char **argv) { | ||
62 | char *session_display = (char *) 0; | ||
63 | char *rc_file = (char *) 0; | ||
64 | |||
65 | NLSInit("blackbox.cat"); | ||
66 | I18n *i18n = I18n::instance(); | ||
67 | |||
68 | int i; | ||
69 | for (i = 1; i < argc; ++i) { | ||
70 | if (! strcmp(argv[i], "-rc")) { | ||
71 | // look for alternative rc file to use | ||
72 | |||
73 | if ((++i) >= argc) { | ||
74 | fprintf(stderr, | ||
75 | i18n->getMessage( | ||
76 | #ifdef NLS | ||
77 | mainSet, mainRCRequiresArg, | ||
78 | #else // !NLS | ||
79 | 0, 0, | ||
80 | #endif // NLS | ||
81 | "error: '-rc' requires and argument\n")); | ||
82 | |||
83 | ::exit(1); | ||
84 | } | ||
85 | |||
86 | rc_file = argv[i]; | ||
87 | } else if (! strcmp(argv[i], "-display")) { | ||
88 | // check for -display option... to run on a display other than the one | ||
89 | // set by the environment variable DISPLAY | ||
90 | |||
91 | if ((++i) >= argc) { | ||
92 | fprintf(stderr, | ||
93 | i18n->getMessage( | ||
94 | #ifdef NLS | ||
95 | mainSet, mainDISPLAYRequiresArg, | ||
96 | #else // !NLS | ||
97 | 0, 0, | ||
98 | #endif // NLS | ||
99 | "error: '-display' requires an argument\n")); | ||
100 | |||
101 | ::exit(1); | ||
102 | } | ||
103 | |||
104 | session_display = argv[i]; | ||
105 | char dtmp[MAXPATHLEN]; | ||
106 | sprintf(dtmp, "DISPLAY=%s", session_display); | ||
107 | |||
108 | if (putenv(dtmp)) { | ||
109 | fprintf(stderr, | ||
110 | i18n-> | ||
111 | getMessage( | ||
112 | #ifdef NLS | ||
113 | mainSet, mainWarnDisplaySet, | ||
114 | #else // !NLS | ||
115 | 0, 0, | ||
116 | #endif // NLS | ||
117 | "warning: couldn't set environment variable 'DISPLAY'\n")); | ||
118 | perror("putenv()"); | ||
119 | } | ||
120 | } else if (! strcmp(argv[i], "-version")) { | ||
121 | // print current version string | ||
122 | printf("Fluxbox %s : (c) 2001 Henrik Kinnunen \n\n", | ||
123 | __fluxbox_version); | ||
124 | |||
125 | ::exit(0); | ||
126 | } else if (! strcmp(argv[i], "-help")) { | ||
127 | // print program usage and command line options | ||
128 | printf(i18n-> | ||
129 | getMessage( | ||
130 | #ifdef NLS | ||
131 | mainSet, mainUsage, | ||
132 | #else // !NLS | ||
133 | 0, 0, | ||
134 | #endif // NLS | ||
135 | "Fluxbox %s : (c) 2001 Henrik Kinnunen\n\n" | ||
136 | " -display <string>\t\tuse display connection.\n" | ||
137 | " -rc <string>\t\t\tuse alternate resource file.\n" | ||
138 | " -version\t\t\tdisplay version and exit.\n" | ||
139 | " -help\t\t\t\tdisplay this help text and exit.\n\n"), | ||
140 | __fluxbox_version); | ||
141 | |||
142 | // some people have requested that we print out command line options | ||
143 | // as well | ||
144 | printf(i18n-> | ||
145 | getMessage( | ||
146 | #ifdef NLS | ||
147 | mainSet, mainCompileOptions, | ||
148 | #else // !NLS | ||
149 | 0, 0, | ||
150 | #endif // NLS | ||
151 | "Compile time options:\n" | ||
152 | " Debugging:\t\t\t%s\n" | ||
153 | " Interlacing:\t\t\t%s\n" | ||
154 | " Shape:\t\t\t%s\n" | ||
155 | " Slit:\t\t\t\t%s\n" | ||
156 | " 8bpp Ordered Dithering:\t%s\n\n"), | ||
157 | #ifdef DEBUG | ||
158 | i18n->getMessage( | ||
159 | #ifdef NLS | ||
160 | CommonSet, CommonYes, | ||
161 | #else // !NLS | ||
162 | 0, 0, | ||
163 | #endif // NLS | ||
164 | "yes"), | ||
165 | #else // !DEBUG | ||
166 | i18n->getMessage( | ||
167 | #ifdef NLS | ||
168 | CommonSet, CommonNo, | ||
169 | #else // !NLS | ||
170 | 0, 0, | ||
171 | #endif // NLS | ||
172 | "no"), | ||
173 | #endif // DEBUG | ||
174 | |||
175 | #ifdef INTERLACE | ||
176 | i18n->getMessage( | ||
177 | #ifdef NLS | ||
178 | CommonSet, CommonYes, | ||
179 | #else // !NLS | ||
180 | 0, 0, | ||
181 | #endif // NLS | ||
182 | "yes"), | ||
183 | #else // !INTERLACE | ||
184 | i18n->getMessage( | ||
185 | #ifdef NLS | ||
186 | CommonSet, CommonNo, | ||
187 | #else // !NLS | ||
188 | 0, 0, | ||
189 | #endif // NLS | ||
190 | "no"), | ||
191 | #endif // INTERLACE | ||
192 | |||
193 | #ifdef SHAPE | ||
194 | i18n->getMessage( | ||
195 | #ifdef NLS | ||
196 | CommonSet, CommonYes, | ||
197 | #else // !NLS | ||
198 | 0, 0, | ||
199 | #endif // NLS | ||
200 | "yes"), | ||
201 | #else // !SHAPE | ||
202 | i18n->getMessage( | ||
203 | #ifdef NLS | ||
204 | CommonSet, CommonNo, | ||
205 | #else // !NLS | ||
206 | 0, 0, | ||
207 | #endif // NLS | ||
208 | "no"), | ||
209 | #endif // SHAPE | ||
210 | |||
211 | #ifdef SLIT | ||
212 | i18n->getMessage( | ||
213 | #ifdef NLS | ||
214 | CommonSet, CommonYes, | ||
215 | #else // !NLS | ||
216 | 0, 0, | ||
217 | #endif // NLS | ||
218 | "yes"), | ||
219 | #else // !SLIT | ||
220 | i18n->getMessage( | ||
221 | #ifdef NLS | ||
222 | CommonSet, CommonNo, | ||
223 | #else // !NLS | ||
224 | 0, 0, | ||
225 | #endif // NLS | ||
226 | "no"), | ||
227 | #endif // SLIT | ||
228 | |||
229 | #ifdef ORDEREDPSEUDO | ||
230 | i18n->getMessage( | ||
231 | #ifdef NLS | ||
232 | CommonSet, CommonYes, | ||
233 | #else // !NLS | ||
234 | 0, 0, | ||
235 | #endif // NLS | ||
236 | "yes") | ||
237 | #else // !ORDEREDPSEUDO | ||
238 | i18n->getMessage( | ||
239 | #ifdef NLS | ||
240 | CommonSet, CommonNo, | ||
241 | #else // !NLS | ||
242 | 0, 0, | ||
243 | #endif // NLS | ||
244 | "no") | ||
245 | #endif // ORDEREDPSEUDO | ||
246 | |||
247 | ); | ||
248 | |||
249 | ::exit(0); | ||
250 | } | ||
251 | } | ||
252 | |||
253 | #ifdef __EMX__ | ||
254 | _chdir2(getenv("X11ROOT")); | ||
255 | #endif // __EMX__ | ||
256 | Fluxbox *fluxbox=0; | ||
257 | int exitcode=EXIT_SUCCESS; | ||
258 | try { | ||
259 | |||
260 | fluxbox = new Fluxbox(argc, argv, session_display, rc_file); | ||
261 | fluxbox->eventLoop(); | ||
262 | |||
263 | } catch (int _exitcode) { | ||
264 | exitcode=_exitcode; | ||
265 | } catch (...) { | ||
266 | cerr<<"Fluxbox: Unknown error."<<endl; | ||
267 | } | ||
268 | |||
269 | if (fluxbox) | ||
270 | delete fluxbox; | ||
271 | exit(exitcode); | ||
272 | } | ||