2 * WPrefs - Window Maker Preferences Program
4 * Copyright (c) 1998-2003 Alfredo K. Kojima
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,
27 #include <X11/Xlocale.h>
33 char *NOptionValueChanged
= "NOptionValueChanged";
35 extern void Initialize(WMScreen
*scr
);
42 void (*handler
)(void*);
43 } DeadHandlers
[MAX_DEATHS
];
46 static pid_t DeadChildren
[MAX_DEATHS
];
47 static int DeadChildrenCount
= 0;
57 print_help(char *progname
)
59 printf(_("usage: %s [options]\n"), progname
);
61 puts(_(" -display <display> display to be used"));
62 puts(_(" --version print version number and exit"));
63 puts(_(" --help print this message and exit"));
69 handleDeadChild(int sig
)
74 pid
= waitpid(-1, &status
, WNOHANG
);
76 DeadChildren
[DeadChildrenCount
++] = pid
;
82 AddDeadChildHandler(pid_t pid
, void (*handler
)(void*), void *data
)
86 for (i
= 0; i
< MAX_DEATHS
; i
++) {
87 if (DeadHandlers
[i
].pid
== 0) {
88 DeadHandlers
[i
].pid
= pid
;
89 DeadHandlers
[i
].handler
= handler
;
90 DeadHandlers
[i
].data
= data
;
94 assert(i
!=MAX_DEATHS
);
99 main(int argc
, char **argv
)
105 char *display_name
="";
109 memset(DeadHandlers
, 0, sizeof(DeadHandlers
));
111 WMInitializeApplication("WPrefs", &argc
, argv
);
114 for (i
=1; i
<argc
; i
++) {
115 if (strcmp(argv
[i
], "-version")==0
116 || strcmp(argv
[i
], "--version")==0) {
117 printf("WPrefs (Window Maker) %s\n", WVERSION
);
119 } else if (strcmp(argv
[i
], "-display")==0) {
122 wwarning(_("too few arguments for %s"), argv
[i
-1]);
125 display_name
= argv
[i
];
133 locale
= getenv("LANG");
134 setlocale(LC_ALL
, "");
137 if (getenv("NLSPATH"))
138 bindtextdomain("WPrefs", getenv("NLSPATH"));
140 bindtextdomain("WPrefs", LOCALEDIR
);
141 textdomain("WPrefs");
143 if (!XSupportsLocale()) {
144 wwarning(_("X server does not support locale"));
146 if (XSetLocaleModifiers("") == NULL
) {
147 wwarning(_("cannot set locale modifiers"));
151 dpy
= XOpenDisplay(display_name
);
153 wfatal(_("could not open display %s"), XDisplayName(display_name
));
157 XSynchronize(dpy
, 1);
159 scr
= WMCreateScreen(dpy
, DefaultScreen(dpy
));
161 wfatal(_("could not initialize application"));
165 WMPLSetCaseSensitive(False
);
172 WMNextEvent(dpy
, &event
);
174 while (DeadChildrenCount
-- > 0) {
177 for (i
=0; i
<MAX_DEATHS
; i
++) {
178 if (DeadChildren
[i
] == DeadHandlers
[i
].pid
) {
179 (*DeadHandlers
[i
].handler
)(DeadHandlers
[i
].data
);
180 DeadHandlers
[i
].pid
= 0;
185 WMHandleEvent(&event
);