fookb: Use libdockapp instead of X resource manager for command line options.
This commit is contained in:
parent
0448b4965d
commit
bc767d15bb
|
@ -1,5 +1,5 @@
|
|||
bin_PROGRAMS = fookb
|
||||
fookb_SOURCES = fookb.c fookb.h globals.c images.c images.h opts.c opts.h \
|
||||
fookb_SOURCES = fookb.c fookb.h images.c images.h opts.h \
|
||||
params.c params.h sound.c sound.h
|
||||
dist_man_MANS = fookb.1x
|
||||
dist_pkgdata_DATA = 1.xpm 2.xpm 3.xpm 4.xpm rus.xpm lat.xpm boom.xpm \
|
||||
|
|
|
@ -11,9 +11,6 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
/* Command line parsing and X resource manager */
|
||||
#include <X11/Xresource.h>
|
||||
|
||||
/* XKB fun */
|
||||
#include <X11/XKBlib.h>
|
||||
|
||||
|
@ -25,6 +22,13 @@
|
|||
#include "sound.h"
|
||||
#include "opts.h"
|
||||
|
||||
char *icon1 = NULL;
|
||||
char *icon2 = NULL;
|
||||
char *icon3 = NULL;
|
||||
char *icon4 = NULL;
|
||||
char *iconboom = NULL;
|
||||
char *display = NULL;
|
||||
|
||||
#define sterror(x) (void)printf("Strange error, please report! %s:%d, %s\n",\
|
||||
__FILE__, __LINE__, x)
|
||||
|
||||
|
@ -34,13 +38,33 @@ int main(int argc, register char *argv[])
|
|||
int state = 0; /* We suppose that latin keyboard is the
|
||||
primal state FIXME */
|
||||
Pixmap pixmap;
|
||||
DAProgramOption options[] = {
|
||||
{NULL, "--icon1",
|
||||
"Icon to show for the 1st Xkb group",
|
||||
DOString, False, {&icon1}},
|
||||
{NULL, "--icon2",
|
||||
"Icon to show for the 2nd Xkb group",
|
||||
DOString, False, {&icon2}},
|
||||
{NULL, "--icon3",
|
||||
"Icon to show for the 3rd Xkb group",
|
||||
DOString, False, {&icon3}},
|
||||
{NULL, "--icon4",
|
||||
"Icon to show for the 4th Xkb group",
|
||||
DOString, False, {&icon4}},
|
||||
{NULL, "--iconboom",
|
||||
"Icon to show when Xkb system goes crazy",
|
||||
DOString, False, {&iconboom}},
|
||||
{"-d", "--display",
|
||||
"X display to use (normally not needed)",
|
||||
DOString, False, {&display}},
|
||||
};
|
||||
|
||||
|
||||
DAParseArguments(argc, argv, NULL, 0,
|
||||
DAParseArguments(argc, argv, options, 6,
|
||||
"XKB state indicator for Window Maker",
|
||||
PACKAGE_STRING);
|
||||
|
||||
DAOpenDisplay(NULL, argc, argv);
|
||||
DAOpenDisplay(display, argc, argv);
|
||||
read_images(DADisplay); /* Let's read icon images */
|
||||
DACreateIcon(PACKAGE_NAME, get_width(), get_height(), argc, argv);
|
||||
XSelectInput(DADisplay, DAWindow, ButtonPressMask);
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
/*
|
||||
* File: globals.c
|
||||
*
|
||||
* (c) 1998-2004 Alexey Vyskubov <alexey@mawhrin.net>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xresource.h>
|
||||
|
||||
char mydispname[256]; /* X display name */
|
||||
|
||||
XrmDatabase cmdlineDB; /* X resource database generated from
|
||||
command line */
|
||||
XrmDatabase finalDB; /* X resource database generated from
|
||||
app-defaults and X resource
|
||||
database */
|
104
fookb/opts.c
104
fookb/opts.c
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
* File: opts.c
|
||||
*
|
||||
* (c) 1998-2004 Alexey Vyskubov <alexey@mawhrin.net>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <X11/Xlib.h> /* X Window standard header */
|
||||
#include <X11/Xresource.h> /* X resource manager stuff */
|
||||
|
||||
#include "fookb.h"
|
||||
#include "opts.h"
|
||||
|
||||
static int tblentr = 6; /* There are 6 recognized
|
||||
options */
|
||||
static XrmOptionDescRec tbl[] = {
|
||||
{"-icon1", ".icon1",
|
||||
XrmoptionSepArg,
|
||||
(XPointer) NULL},
|
||||
{"-icon2", ".icon2",
|
||||
XrmoptionSepArg,
|
||||
(XPointer) NULL},
|
||||
{"-icon3", ".icon3",
|
||||
XrmoptionSepArg,
|
||||
(XPointer) NULL},
|
||||
{"-icon4", ".icon4",
|
||||
XrmoptionSepArg,
|
||||
(XPointer) NULL},
|
||||
{"-iconboom", ".iconBoom",
|
||||
XrmoptionSepArg,
|
||||
(XPointer) NULL},
|
||||
{"-display", ".display",
|
||||
XrmoptionSepArg,
|
||||
(XPointer) NULL}
|
||||
};
|
||||
|
||||
void ParseOptions(int *argc, register char *argv[])
|
||||
{
|
||||
XrmValue value;
|
||||
char *str_type[20];
|
||||
mydispname[0] = '\0';
|
||||
|
||||
XrmParseCommand(&cmdlineDB, tbl, tblentr, "fookb", argc, argv);
|
||||
|
||||
#ifdef DEBUG
|
||||
puts("Hereiam");
|
||||
#endif
|
||||
|
||||
if (1 != *argc) {
|
||||
puts("Fookb v 3.0");
|
||||
puts("\tUsage: fookb [options]");
|
||||
puts("Possible options:");
|
||||
puts("-icon1 xpm_file\t\tIcon to show for the 1st Xkb group");
|
||||
puts("-icon2 xpm_file\t\tIcon to show for the 2nd Xkb group");
|
||||
puts("-icon3 xpm_file\t\tIcon to show for the 3rd Xkb group");
|
||||
puts("-icon4 xpm_file\t\tIcon to show for the 4th Xkb group");
|
||||
puts("-iconboom xpm_file\tIcon to show when Xkb system goes crazy");
|
||||
puts("-display X_display\tX display to use (normally not needed)");
|
||||
puts("");
|
||||
puts("Command line parameters takes precedence over X resources or configuration file!");
|
||||
printf("Configuration file location: ");
|
||||
#ifdef WMAKER
|
||||
puts("~/GNUstep/Defaults/FOOkb");
|
||||
#else
|
||||
puts("~/.fookb");
|
||||
#endif
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* We should get display now -- we need it for access to other
|
||||
databases */
|
||||
if (XrmGetResource(cmdlineDB, "fookb.display", "Fookb.Display",
|
||||
str_type, &value) == True) {
|
||||
(void) strncpy(mydispname, value.addr, (size_t)value.size);
|
||||
#ifdef DEBUG
|
||||
puts(mydispname);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MoreOptions(Display *dpy)
|
||||
{
|
||||
|
||||
XrmDatabase servDB, appDB;
|
||||
|
||||
appDB = XrmGetFileDatabase
|
||||
("/usr/X11R6/lib/X11/app-defaults/Fookb");
|
||||
(void) XrmMergeDatabases(appDB, &finalDB); /* Fookb defaults file
|
||||
added into final
|
||||
database */
|
||||
|
||||
/* Let's look: does xrdb load server defautls? (As a property of
|
||||
root window.) */
|
||||
if (XResourceManagerString(dpy) != NULL) {
|
||||
servDB = XrmGetStringDatabase(XResourceManagerString(dpy));
|
||||
XrmMergeDatabases(servDB, &finalDB);
|
||||
}
|
||||
|
||||
}
|
21
fookb/opts.h
21
fookb/opts.h
|
@ -8,25 +8,6 @@
|
|||
#ifndef OPTS_H
|
||||
#define OPTS_H
|
||||
|
||||
/* X Window resource management */
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xresource.h>
|
||||
extern XrmDatabase cmdlineDB; /* Database for resources from command
|
||||
line */
|
||||
|
||||
extern XrmDatabase finalDB; /* Database for resources from other
|
||||
sources -- app-defaults and X
|
||||
Window resources */
|
||||
|
||||
void ParseOptions(int *argc, register char *argv[]); /* Parse
|
||||
command
|
||||
line
|
||||
options */
|
||||
|
||||
void MoreOptions(Display *dpy); /* Parse
|
||||
app-defaults
|
||||
and X
|
||||
resources
|
||||
database */
|
||||
extern char *icon1, *icon2, *icon3, *icon4, *iconboom, *display;
|
||||
|
||||
#endif /* OPTS_H */
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <string.h> /* strlen & strcat */
|
||||
#include <ctype.h> /* toupper */
|
||||
#include <stdlib.h>
|
||||
#include <WINGs/WUtil.h>
|
||||
#include "params.h"
|
||||
#include "opts.h"
|
||||
|
||||
|
@ -10,46 +11,24 @@
|
|||
|
||||
char *read_param(char *string)
|
||||
{
|
||||
XrmValue xvalue;
|
||||
|
||||
WMPropList *pl;
|
||||
WMPropList *value;
|
||||
WMPropList *tmp;
|
||||
char *path;
|
||||
char *newstring;
|
||||
char *newString;
|
||||
char *result;
|
||||
|
||||
/* Let's make lint happy */
|
||||
xvalue.size = 0;
|
||||
|
||||
newstring = wstrconcat("fookb.", string);
|
||||
newString = wstrconcat("Fookb.", string);
|
||||
newstring[6] = tolower((unsigned char)newstring[6]);
|
||||
newString[6] = toupper((unsigned char)newString[6]);
|
||||
|
||||
/* Command line parameters take precedence over all */
|
||||
|
||||
if (XrmGetResource(cmdlineDB,
|
||||
newstring,
|
||||
newString,
|
||||
str_type,
|
||||
&xvalue) == True) {
|
||||
result = (char *) malloc(xvalue.size + 1);
|
||||
if (NULL == result) {
|
||||
lputs("Not enough memory");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
strncpy(result, xvalue.addr, (size_t)xvalue.size);
|
||||
result[(int) xvalue.size + 1] = '\0';
|
||||
|
||||
wfree(newstring);
|
||||
wfree(newString);
|
||||
return result;
|
||||
}
|
||||
|
||||
wfree(newstring);
|
||||
wfree(newString);
|
||||
if (!strcmp(string, "Icon1") && icon1)
|
||||
return icon1;
|
||||
if (!strcmp(string, "Icon2") && icon2)
|
||||
return icon2;
|
||||
if (!strcmp(string, "Icon3") && icon3)
|
||||
return icon3;
|
||||
if (!strcmp(string, "Icon4") && icon4)
|
||||
return icon4;
|
||||
if (!strcmp(string, "IconBoom") && iconboom)
|
||||
return iconboom;
|
||||
|
||||
/*
|
||||
* Here we start the game with property lists.
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#ifndef PARAMS_H
|
||||
#define PARAMS_H
|
||||
|
||||
#include <WINGs/WUtil.h>
|
||||
|
||||
#ifdef WMAKER
|
||||
#define DEFAULTS_FILE "~/GNUstep/Defaults/FOOkb"
|
||||
|
@ -16,9 +15,6 @@
|
|||
#define DEFAULTS_FILE "~/.fookb"
|
||||
#endif /* WMAKER */
|
||||
|
||||
#include <X11/Xlib.h> /* X Window standard header */
|
||||
#include <X11/Xresource.h> /* X resource manager stuff */
|
||||
|
||||
char *read_param(char *);
|
||||
|
||||
#endif /* PARAMS_H */
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
extern XrmDatabase cmdlineDB; /* Database for resources from command
|
||||
line */
|
||||
|
||||
extern XrmDatabase finalDB; /* Database for resources from other
|
||||
sources -- app-defaults and X
|
||||
Window resources */
|
||||
|
Loading…
Reference in a new issue