Initial revision
[wmaker-crm.git] / WPrefs.app / main.c
blob53421a3af024e1d254988027dffbef1395cb19be
1 /*
2 * WPrefs - WindowMaker Preferences Program
3 *
4 * Copyright (c) 1998 Alfredo K. Kojima
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 * USA.
22 #include "WPrefs.h"
24 #include <X11/Xlocale.h>
27 extern void Initialize(WMScreen *scr);
31 void
32 wAbort(Bool foo)
34 exit(1);
38 static BOOL
39 stringCompareHook(proplist_t pl1, proplist_t pl2)
41 char *str1, *str2;
43 str1 = PLGetString(pl1);
44 str2 = PLGetString(pl2);
46 if (strcasecmp(str1, str2)==0)
47 return YES;
48 else
49 return NO;
53 static void
54 print_help(char *progname)
56 printf(_("usage: %s [options]\n"), progname);
57 puts(_("options:"));
58 puts(_(" -display <display> display to be used"));
59 puts(_(" -version print version number and exit"));
63 int
64 main(int argc, char **argv)
66 Display *dpy;
67 WMScreen *scr;
68 char *locale;
69 int i;
70 char *display_name="";
72 WMInitializeApplication("WPrefs", &argc, argv);
74 if (argc>1) {
75 for (i=1; i<argc; i++) {
76 if (strcmp(argv[i], "-version")==0) {
77 printf("WPrefs %s\n", WVERSION);
78 exit(0);
79 } else if (strcmp(argv[i], "-display")==0) {
80 i++;
81 if (i>=argc) {
82 wwarning(_("too few arguments for %s"), argv[i-1]);
83 exit(0);
85 display_name = argv[i];
86 } else {
87 print_help(argv[0]);
88 exit(0);
93 locale = getenv("LANG");
94 setlocale(LC_ALL, "");
96 #ifdef I18N
97 if (getenv("NLSPATH"))
98 bindtextdomain("WPrefs", getenv("NLSPATH"));
99 else
100 bindtextdomain("WPrefs", NLSDIR);
101 textdomain("WPrefs");
103 if (!XSupportsLocale()) {
104 wwarning(_("X server does not support locale"));
106 if (XSetLocaleModifiers("") == NULL) {
107 wwarning(_("cannot set locale modifiers"));
109 #endif
111 dpy = XOpenDisplay(display_name);
112 if (!dpy) {
113 wfatal(_("could not open display %s"), XDisplayName(display_name));
114 exit(0);
116 #if 0
117 XSynchronize(dpy, 1);
118 #endif
119 scr = WMCreateScreen(dpy, DefaultScreen(dpy));
120 if (!scr) {
121 wfatal(_("could not initialize application"));
122 exit(0);
125 PLSetStringCmpHook(stringCompareHook);
127 Initialize(scr);
129 while (1) {
130 XEvent event;
132 WMNextEvent(dpy, &event);
133 WMHandleEvent(&event);