Skip to content

Commit bc767d1

Browse files
d-torrancecrmafra
authored andcommitted
fookb: Use libdockapp instead of X resource manager for command line options.
1 parent 0448b49 commit bc767d1

File tree

8 files changed

+44
-192
lines changed

8 files changed

+44
-192
lines changed

fookb/Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
bin_PROGRAMS = fookb
2-
fookb_SOURCES = fookb.c fookb.h globals.c images.c images.h opts.c opts.h \
2+
fookb_SOURCES = fookb.c fookb.h images.c images.h opts.h \
33
params.c params.h sound.c sound.h
44
dist_man_MANS = fookb.1x
55
dist_pkgdata_DATA = 1.xpm 2.xpm 3.xpm 4.xpm rus.xpm lat.xpm boom.xpm \

fookb/fookb.c

+31-7
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
#include <X11/Xlib.h>
1212
#include <X11/Xutil.h>
1313

14-
/* Command line parsing and X resource manager */
15-
#include <X11/Xresource.h>
16-
1714
/* XKB fun */
1815
#include <X11/XKBlib.h>
1916

@@ -25,6 +22,13 @@
2522
#include "sound.h"
2623
#include "opts.h"
2724

25+
char *icon1 = NULL;
26+
char *icon2 = NULL;
27+
char *icon3 = NULL;
28+
char *icon4 = NULL;
29+
char *iconboom = NULL;
30+
char *display = NULL;
31+
2832
#define sterror(x) (void)printf("Strange error, please report! %s:%d, %s\n",\
2933
__FILE__, __LINE__, x)
3034

@@ -34,13 +38,33 @@ int main(int argc, register char *argv[])
3438
int state = 0; /* We suppose that latin keyboard is the
3539
primal state FIXME */
3640
Pixmap pixmap;
37-
38-
39-
DAParseArguments(argc, argv, NULL, 0,
41+
DAProgramOption options[] = {
42+
{NULL, "--icon1",
43+
"Icon to show for the 1st Xkb group",
44+
DOString, False, {&icon1}},
45+
{NULL, "--icon2",
46+
"Icon to show for the 2nd Xkb group",
47+
DOString, False, {&icon2}},
48+
{NULL, "--icon3",
49+
"Icon to show for the 3rd Xkb group",
50+
DOString, False, {&icon3}},
51+
{NULL, "--icon4",
52+
"Icon to show for the 4th Xkb group",
53+
DOString, False, {&icon4}},
54+
{NULL, "--iconboom",
55+
"Icon to show when Xkb system goes crazy",
56+
DOString, False, {&iconboom}},
57+
{"-d", "--display",
58+
"X display to use (normally not needed)",
59+
DOString, False, {&display}},
60+
};
61+
62+
63+
DAParseArguments(argc, argv, options, 6,
4064
"XKB state indicator for Window Maker",
4165
PACKAGE_STRING);
4266

43-
DAOpenDisplay(NULL, argc, argv);
67+
DAOpenDisplay(display, argc, argv);
4468
read_images(DADisplay); /* Let's read icon images */
4569
DACreateIcon(PACKAGE_NAME, get_width(), get_height(), argc, argv);
4670
XSelectInput(DADisplay, DAWindow, ButtonPressMask);

fookb/globals.c

-17
This file was deleted.

fookb/opts.c

-104
This file was deleted.

fookb/opts.h

+1-20
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,6 @@
88
#ifndef OPTS_H
99
#define OPTS_H
1010

11-
/* X Window resource management */
12-
#include <X11/Xlib.h>
13-
#include <X11/Xresource.h>
14-
extern XrmDatabase cmdlineDB; /* Database for resources from command
15-
line */
16-
17-
extern XrmDatabase finalDB; /* Database for resources from other
18-
sources -- app-defaults and X
19-
Window resources */
20-
21-
void ParseOptions(int *argc, register char *argv[]); /* Parse
22-
command
23-
line
24-
options */
25-
26-
void MoreOptions(Display *dpy); /* Parse
27-
app-defaults
28-
and X
29-
resources
30-
database */
11+
extern char *icon1, *icon2, *icon3, *icon4, *iconboom, *display;
3112

3213
#endif /* OPTS_H */

fookb/params.c

+11-32
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <string.h> /* strlen & strcat */
33
#include <ctype.h> /* toupper */
44
#include <stdlib.h>
5+
#include <WINGs/WUtil.h>
56
#include "params.h"
67
#include "opts.h"
78

@@ -10,46 +11,24 @@
1011

1112
char *read_param(char *string)
1213
{
13-
XrmValue xvalue;
14-
1514
WMPropList *pl;
1615
WMPropList *value;
1716
WMPropList *tmp;
1817
char *path;
19-
char *newstring;
20-
char *newString;
2118
char *result;
2219

23-
/* Let's make lint happy */
24-
xvalue.size = 0;
25-
26-
newstring = wstrconcat("fookb.", string);
27-
newString = wstrconcat("Fookb.", string);
28-
newstring[6] = tolower((unsigned char)newstring[6]);
29-
newString[6] = toupper((unsigned char)newString[6]);
30-
3120
/* Command line parameters take precedence over all */
3221

33-
if (XrmGetResource(cmdlineDB,
34-
newstring,
35-
newString,
36-
str_type,
37-
&xvalue) == True) {
38-
result = (char *) malloc(xvalue.size + 1);
39-
if (NULL == result) {
40-
lputs("Not enough memory");
41-
exit(EXIT_FAILURE);
42-
}
43-
strncpy(result, xvalue.addr, (size_t)xvalue.size);
44-
result[(int) xvalue.size + 1] = '\0';
45-
46-
wfree(newstring);
47-
wfree(newString);
48-
return result;
49-
}
50-
51-
wfree(newstring);
52-
wfree(newString);
22+
if (!strcmp(string, "Icon1") && icon1)
23+
return icon1;
24+
if (!strcmp(string, "Icon2") && icon2)
25+
return icon2;
26+
if (!strcmp(string, "Icon3") && icon3)
27+
return icon3;
28+
if (!strcmp(string, "Icon4") && icon4)
29+
return icon4;
30+
if (!strcmp(string, "IconBoom") && iconboom)
31+
return iconboom;
5332

5433
/*
5534
* Here we start the game with property lists.

fookb/params.h

-4
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,13 @@
88
#ifndef PARAMS_H
99
#define PARAMS_H
1010

11-
#include <WINGs/WUtil.h>
1211

1312
#ifdef WMAKER
1413
#define DEFAULTS_FILE "~/GNUstep/Defaults/FOOkb"
1514
#else
1615
#define DEFAULTS_FILE "~/.fookb"
1716
#endif /* WMAKER */
1817

19-
#include <X11/Xlib.h> /* X Window standard header */
20-
#include <X11/Xresource.h> /* X resource manager stuff */
21-
2218
char *read_param(char *);
2319

2420
#endif /* PARAMS_H */

fookb/xrmdb.h

-7
This file was deleted.

0 commit comments

Comments
 (0)