[Pkg-wmaker-commits] [fookb] 11/17: fookb: Use libdockapp instead of X resource manager for command line options.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Sun Sep 10 14:35:26 UTC 2017


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch upstream
in repository fookb.

commit 9785e30ede8880b83a3f2f2560bf8750dec6a3a9
Author: Doug Torrance <dtorrance at piedmont.edu>
Date:   Sat Sep 9 21:24:27 2017 -0400

    fookb: Use libdockapp instead of X resource manager for command line options.
---
 Makefile.am |   2 +-
 fookb.c     |  38 ++++++++++++++++++----
 globals.c   |  17 ----------
 opts.c      | 104 ------------------------------------------------------------
 opts.h      |  21 +-----------
 params.c    |  43 +++++++------------------
 params.h    |   4 ---
 xrmdb.h     |   7 ----
 8 files changed, 44 insertions(+), 192 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 4c1840f..82c1cd0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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 \
diff --git a/fookb.c b/fookb.c
index c6cf888..1aefbff 100644
--- a/fookb.c
+++ b/fookb.c
@@ -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;
-
-
-	DAParseArguments(argc, argv, NULL, 0,
+	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, 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);
diff --git a/globals.c b/globals.c
deleted file mode 100644
index 8283f83..0000000
--- a/globals.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * File: globals.c
- *
- * (c) 1998-2004 Alexey Vyskubov <alexey at 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 */
diff --git a/opts.c b/opts.c
deleted file mode 100644
index 2143518..0000000
--- a/opts.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * File: opts.c
- *
- * (c) 1998-2004 Alexey Vyskubov <alexey at 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);
-	}
-
-}
diff --git a/opts.h b/opts.h
index b077bde..871a78a 100644
--- a/opts.h
+++ b/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 */
diff --git a/params.c b/params.c
index c993f03..8501e04 100644
--- a/params.c
+++ b/params.c
@@ -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.
diff --git a/params.h b/params.h
index 5fdc73e..d97aa2c 100644
--- a/params.h
+++ b/params.h
@@ -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 */
diff --git a/xrmdb.h b/xrmdb.h
deleted file mode 100644
index d57d57e..0000000
--- a/xrmdb.h
+++ /dev/null
@@ -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 */
-

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/fookb.git



More information about the Pkg-wmaker-commits mailing list