1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 21:08:08 +01:00

- rewrote the font conversion routines to avoid the need to allocate memory

for font options while parsing the xlfd. now all processing is done using
  the original xlfd string only.
- removed memleaks introduced by previous commit.
This commit is contained in:
dan
2004-04-13 03:49:38 +00:00
parent 500d569c79
commit 6d02fe98f2
2 changed files with 950 additions and 810 deletions

View File

@@ -104,7 +104,7 @@ static char *theme_options[] = {
/* table of style related fonts */ /* table of style related fonts */
static char *font_styles[] = { static char *font_options[] = {
"ClipTitleFont", "ClipTitleFont",
"WindowTitleFont", "WindowTitleFont",
"MenuTitleFont", "MenuTitleFont",
@@ -115,7 +115,7 @@ static char *font_styles[] = {
NULL NULL
}; };
char *default_font = "sans:pixelsize=12"; #define DEFAULT_FONT "sans-serif:pixelsize=12"
char *ProgName; char *ProgName;
@@ -156,18 +156,18 @@ defaultsPathForDomain(char *domain)
gspath = getenv("GNUSTEP_USER_ROOT"); gspath = getenv("GNUSTEP_USER_ROOT");
if (gspath) { if (gspath) {
strcpy(path, gspath); strcpy(path, gspath);
strcat(path, "/"); strcat(path, "/");
} else { } else {
char *home; char *home;
home = getenv("HOME"); home = getenv("HOME");
if (!home) { if (!home) {
printf("%s:could not get HOME environment variable!\n", ProgName); printf("%s:could not get HOME environment variable!\n", ProgName);
exit(0); exit(0);
} }
strcpy(path, home); strcpy(path, home);
strcat(path, "/GNUstep/"); strcat(path, "/GNUstep/");
} }
strcat(path, DEFAULTS_DIR); strcat(path, DEFAULTS_DIR);
strcat(path, "/"); strcat(path, "/");
@@ -185,12 +185,12 @@ abortar(char *reason)
printf("%s: %s\n", ProgName, reason); printf("%s: %s\n", ProgName, reason);
if (ThemePath) { if (ThemePath) {
printf("Removing unfinished theme pack\n"); printf("Removing unfinished theme pack\n");
sprintf(buffer, "/bin/rm -fr \"%s\"", ThemePath); sprintf(buffer, "/bin/rm -fr \"%s\"", ThemePath);
if (system(buffer)!=0) { if (system(buffer)!=0) {
printf("%s: could not execute command %s\n", ProgName, buffer); printf("%s: could not execute command %s\n", ProgName, buffer);
} }
} }
exit(1); exit(1);
} }
@@ -205,51 +205,24 @@ wgethomedir()
struct passwd *user; struct passwd *user;
if (home) if (home)
return home; return home;
user = getpwuid(getuid()); user = getpwuid(getuid());
if (!user) { if (!user) {
char buffer[80]; char buffer[80];
sprintf(buffer, "could not get password entry for UID %i", getuid()); sprintf(buffer, "could not get password entry for UID %i", getuid());
perror(buffer); perror(buffer);
return "/"; return "/";
} }
if (!user->pw_dir) { if (!user->pw_dir) {
return "/"; return "/";
} else { } else {
return user->pw_dir; return user->pw_dir;
} }
} }
void*
mymalloc(int size)
{
void *tmp;
tmp = malloc(size);
if (!tmp) {
abortar("out of memory");
}
return tmp;
}
char*
mystrdup(char *str)
{
char *tmp;
tmp = mymalloc(strlen(str)+1);
strcpy(tmp, str);
return tmp;
}
static char* static char*
getuserhomedir(char *username) getuserhomedir(char *username)
{ {
@@ -257,22 +230,20 @@ getuserhomedir(char *username)
user = getpwnam(username); user = getpwnam(username);
if (!user) { if (!user) {
char buffer[100]; char buffer[100];
sprintf(buffer,"could not get password entry for user %s", username); sprintf(buffer,"could not get password entry for user %s", username);
perror(buffer); perror(buffer);
return NULL; return NULL;
} }
if (!user->pw_dir) { if (!user->pw_dir) {
return "/"; return "/";
} else { } else {
return user->pw_dir; return user->pw_dir;
} }
} }
char* char*
wexpandpath(char *path) wexpandpath(char *path)
{ {
@@ -283,77 +254,77 @@ wexpandpath(char *path)
memset(buffer, 0, PATH_MAX+2); memset(buffer, 0, PATH_MAX+2);
if (*path=='~') { if (*path=='~') {
char *home; char *home;
path++; path++;
if (*path=='/' || *path==0) { if (*path=='/' || *path==0) {
home = wgethomedir(); home = wgethomedir();
strcat(buffer, home); strcat(buffer, home);
} else { } else {
int j; int j;
j = 0; j = 0;
while (*path!=0 && *path!='/') { while (*path!=0 && *path!='/') {
buffer2[j++] = *path; buffer2[j++] = *path;
buffer2[j] = 0; buffer2[j] = 0;
path++; path++;
} }
home = getuserhomedir(buffer2); home = getuserhomedir(buffer2);
if (!home) if (!home)
return NULL; return NULL;
strcat(buffer, home); strcat(buffer, home);
} }
} }
i = strlen(buffer); i = strlen(buffer);
while (*path!=0) { while (*path!=0) {
char *tmp; char *tmp;
if (*path=='$') { if (*path=='$') {
int j = 0; int j = 0;
path++; path++;
/* expand $(HOME) or $HOME style environment variables */ /* expand $(HOME) or $HOME style environment variables */
if (*path=='(') { if (*path=='(') {
path++; path++;
while (*path!=0 && *path!=')') { while (*path!=0 && *path!=')') {
buffer2[j++] = *(path++); buffer2[j++] = *(path++);
buffer2[j] = 0; buffer2[j] = 0;
} }
if (*path==')') if (*path==')')
path++; path++;
tmp = getenv(buffer2); tmp = getenv(buffer2);
if (!tmp) { if (!tmp) {
buffer[i] = 0; buffer[i] = 0;
strcat(buffer, "$("); strcat(buffer, "$(");
strcat(buffer, buffer2); strcat(buffer, buffer2);
strcat(buffer, ")"); strcat(buffer, ")");
i += strlen(buffer2)+3; i += strlen(buffer2)+3;
} else { } else {
strcat(buffer, tmp); strcat(buffer, tmp);
i += strlen(tmp); i += strlen(tmp);
} }
} else { } else {
while (*path!=0 && *path!='/') { while (*path!=0 && *path!='/') {
buffer2[j++] = *(path++); buffer2[j++] = *(path++);
buffer2[j] = 0; buffer2[j] = 0;
} }
tmp = getenv(buffer2); tmp = getenv(buffer2);
if (!tmp) { if (!tmp) {
strcat(buffer, "$"); strcat(buffer, "$");
strcat(buffer, buffer2); strcat(buffer, buffer2);
i += strlen(buffer2)+1; i += strlen(buffer2)+1;
} else { } else {
strcat(buffer, tmp); strcat(buffer, tmp);
i += strlen(tmp); i += strlen(tmp);
} }
} }
} else { } else {
buffer[i++] = *path; buffer[i++] = *path;
path++; path++;
} }
} }
return mystrdup(buffer); return wstrdup(buffer);
} }
@@ -367,143 +338,236 @@ wfindfileinarray(WMPropList *paths, char *file)
char *fullpath; char *fullpath;
if (!file) if (!file)
return NULL; return NULL;
if (*file=='/' || *file=='~' || !paths || !WMIsPLArray(paths) if (*file=='/' || *file=='~' || !paths || !WMIsPLArray(paths)
|| WMGetPropListItemCount(paths)==0) { || WMGetPropListItemCount(paths)==0) {
if (access(file, R_OK)<0) { if (access(file, R_OK)<0) {
fullpath = wexpandpath(file); fullpath = wexpandpath(file);
if (!fullpath) if (!fullpath)
return NULL; return NULL;
if (access(fullpath, R_OK)<0) { if (access(fullpath, R_OK)<0) {
free(fullpath); free(fullpath);
return NULL; return NULL;
} else { } else {
return fullpath; return fullpath;
} }
} else { } else {
return mystrdup(file); return wstrdup(file);
} }
} }
flen = strlen(file); flen = strlen(file);
for (i=0; i < WMGetPropListItemCount(paths); i++) { for (i=0; i < WMGetPropListItemCount(paths); i++) {
WMPropList *tmp; WMPropList *tmp;
char *dir; char *dir;
tmp = WMGetFromPLArray(paths, i); tmp = WMGetFromPLArray(paths, i);
if (!WMIsPLString(tmp) || !(dir = WMGetFromPLString(tmp))) if (!WMIsPLString(tmp) || !(dir = WMGetFromPLString(tmp)))
continue; continue;
len = strlen(dir); len = strlen(dir);
path = mymalloc(len+flen+2); path = wmalloc(len+flen+2);
path = memcpy(path, dir, len); path = memcpy(path, dir, len);
path[len]=0; path[len]=0;
strcat(path, "/"); strcat(path, "/");
strcat(path, file); strcat(path, file);
/* expand tilde */ /* expand tilde */
fullpath = wexpandpath(path); fullpath = wexpandpath(path);
free(path); free(path);
if (fullpath) { if (fullpath) {
/* check if file is readable */ /* check if file is readable */
if (access(fullpath, R_OK)==0) { if (access(fullpath, R_OK)==0) {
return fullpath; return fullpath;
} }
free(fullpath); free(fullpath);
} }
} }
return NULL; return NULL;
} }
char*
capitalize(char *element) static Bool
isFontOption(char *option)
{ {
unsigned int first = 1; int i;
char *p;
char *b; for (i=0; font_options[i]!=NULL; i++) {
b = element; if (strcasecmp(option, font_options[i])==0) {
for (p = b; *p != 0; p++) return True;
{ }
if (isalpha(*p) && first) {
first = 0;
*p = toupper(*p);
}
else if (*p == '-' || *p == ' ') {
first = 1;
}
} }
return b;
return False;
} }
char*
getElementFromXLFD(const char *xlfd, int index) static int
countChar(char *str, char c)
{ {
const char *p = xlfd; int count = 0;
while (*p != 0) {
if (*p == '-' && --index == 0) { if (!str)
const char *end = strchr(p + 1, '-'); return 0;
char *buf;
size_t len; for (; *str!=0; str++) {
if (end == 0) end = p + strlen(p); if (*str == c) {
len = end - (p + 1); count++;
buf = wmalloc(len); }
memcpy(buf, p + 1, len);
buf[len] = 0;
return buf;
}
p++;
} }
return "*";
return count;
} }
typedef struct str {
char *str;
int len;
} str;
#define XLFD_TOKENS 14
static str*
getXLFDTokens(char *xlfd)
{
static str tokens[XLFD_TOKENS];
int i, len, size;
char *ptr;
if (!xlfd || countChar(xlfd, '-')<XLFD_TOKENS)
return NULL;
memset(tokens, 0, sizeof(str)*XLFD_TOKENS);
len = strlen(xlfd);
for (ptr=xlfd, i=0; i<XLFD_TOKENS && len>0; i++) {
size = strspn(ptr, "-");
ptr += size;
len -= size;
if (len <= 0)
break;
size = strcspn(ptr, "-");
if (size==0)
break;
tokens[i].str = ptr;
tokens[i].len = size;
ptr += size;
len -= size;
}
return tokens;
}
static int
strToInt(str *token)
{
int res=0, pos, c;
if (token->len==0 || token->str[0]=='*') {
return -1;
} else {
for (res=0, pos=0; pos<token->len; pos++) {
c = token->str[pos] - '0';
if (c<0 || c>9)
break;
res = res*10 + c;
}
}
return res;
}
static char*
mapSlantToName(str *slant)
{
if (slant->len==0 || slant->str[0]=='*')
return "roman";
switch(slant->str[0]) {
case 'i':
return "italic";
case 'o':
return "oblique";
case 'r':
default:
return "roman";
}
}
char* char*
xlfdToFc(char *xlfd) xlfdToFc(char *xlfd)
{ {
char *Fcname = NULL; str *tokens, *family, *weight, *slant;
char *name, buf[512];
int size, pixelsize;
char *family = getElementFromXLFD(xlfd, 2); tokens = getXLFDTokens(xlfd);
char *size = getElementFromXLFD(xlfd, 7); if (!tokens)
char *weight = getElementFromXLFD(xlfd, 3); return wstrdup(DEFAULT_FONT);
char *slant = getElementFromXLFD(xlfd, 4);
if (strcmp(family, "*") != 0) { family = &(tokens[1]);
Fcname = wstrconcat(Fcname, capitalize(family)); weight = &(tokens[2]);
} slant = &(tokens[3]);
if (strcmp(size, "*") != 0) {
Fcname = wstrconcat(Fcname, ":pixelsize=");
Fcname = wstrconcat(Fcname, size);
}
if (strcmp(weight, "*") != 0) {
Fcname = wstrconcat(Fcname, ":weight=");
Fcname = wstrconcat(Fcname, capitalize(weight));
}
if (strcmp(slant, "*") != 0) {
if (strcmp(slant, "i") == 0) {
Fcname = wstrconcat(Fcname, ":slant=");
Fcname = wstrconcat(Fcname, "Italic");
} else if (strcmp(slant, "o") == 0) {
Fcname = wstrconcat(Fcname, ":slant=");
Fcname = wstrconcat(Fcname, "Oblique");
} else if (strcmp(slant, "ri") == 0) {
Fcname = wstrconcat(Fcname, ":slant=");
Fcname = wstrconcat(Fcname, "Rev Italic");
} else if (strcmp(slant, "ro") == 0) {
Fcname = wstrconcat(Fcname, ":slant=");
Fcname = wstrconcat(Fcname, "Rev Oblique");
}
}
if (!Fcname)
Fcname = wstrdup(default_font);
wfree(family); if (family->len==0 || family->str[0]=='*')
wfree(size); return wstrdup(DEFAULT_FONT);
wfree(weight);
wfree(slant);
return Fcname; sprintf(buf, "%.*s", family->len, family->str);
name = wstrdup(buf);
pixelsize = strToInt(&tokens[6]);
size = strToInt(&tokens[7]);
if (size<=0 && pixelsize<=0) {
name = wstrappend(name, ":pixelsize=12");
} else if (pixelsize>0) {
/* if pixelsize is present size will be ignored so we skip it */
sprintf(buf, ":pixelsize=%d", pixelsize);
name = wstrappend(name, buf);
} else {
sprintf(buf, "-%d", size/10);
name = wstrappend(name, buf);
}
if (weight->len>0 && weight->str[0]!='*') {
sprintf(buf, ":weight=%.*s", weight->len, weight->str);
name = wstrappend(name, buf);
}
if (slant->len>0 && slant->str[0]!='*') {
sprintf(buf, ":slant=%s", mapSlantToName(slant));
name = wstrappend(name, buf);
}
name = wstrappend(name, ":xlfd=");
name = wstrappend(name, xlfd);
return name;
} }
/* return converted font (if conversion is needed) else the original font */
static char*
convertFont(char *font)
{
if (font[0]=='-') {
if (!strchr(font, ',')) {
return xlfdToFc(font);
} else {
wwarning("fontsets are not supported. replaced "
"with default %s", DEFAULT_FONT);
return wstrdup(DEFAULT_FONT);
}
} else {
return font;
}
}
void void
copyFile(char *dir, char *file) copyFile(char *dir, char *file)
{ {
@@ -511,7 +575,7 @@ copyFile(char *dir, char *file)
sprintf(buffer, "/bin/cp \"%s\" \"%s\"", file, dir); sprintf(buffer, "/bin/cp \"%s\" \"%s\"", file, dir);
if (system(buffer)!=0) { if (system(buffer)!=0) {
printf("%s: could not copy file %s\n", ProgName, file); printf("%s: could not copy file %s\n", ProgName, file);
} }
} }
@@ -523,10 +587,10 @@ findCopyFile(char *dir, char *file)
fullPath = wfindfileinarray(PixmapPath, file); fullPath = wfindfileinarray(PixmapPath, file);
if (!fullPath) { if (!fullPath) {
char buffer[4000]; char buffer[4000];
sprintf(buffer, "coould not find file %s", file); sprintf(buffer, "coould not find file %s", file);
abortar(buffer); abortar(buffer);
} }
copyFile(dir, fullPath); copyFile(dir, fullPath);
free(fullPath); free(fullPath);
@@ -542,94 +606,94 @@ makeThemePack(WMPropList *style, char *themeName)
int i; int i;
char *themeDir; char *themeDir;
themeDir = mymalloc(strlen(themeName)+50); themeDir = wmalloc(strlen(themeName)+50);
sprintf(themeDir, "%s.themed", themeName); sprintf(themeDir, "%s.themed", themeName);
ThemePath = themeDir; ThemePath = themeDir;
{ {
char *tmp; char *tmp;
tmp = mymalloc(strlen(themeDir)+20); tmp = wmalloc(strlen(themeDir)+20);
sprintf(tmp, "/bin/mkdir \"%s\"", themeDir); sprintf(tmp, "/bin/mkdir \"%s\"", themeDir);
if (system(tmp)!=0) { if (system(tmp)!=0) {
printf("%s: could not create directory %s. Probably there's already a theme with that name in this directory.\n", ProgName, themeDir); printf("%s: could not create directory %s. Probably there's already a theme with that name in this directory.\n", ProgName, themeDir);
exit(1); exit(1);
} }
free(tmp); free(tmp);
} }
keys = WMGetPLDictionaryKeys(style); keys = WMGetPLDictionaryKeys(style);
for (i = 0; i < WMGetPropListItemCount(keys); i++) { for (i = 0; i < WMGetPropListItemCount(keys); i++) {
key = WMGetFromPLArray(keys, i); key = WMGetFromPLArray(keys, i);
value = WMGetFromPLDictionary(style, key); value = WMGetFromPLDictionary(style, key);
if (value && WMIsPLArray(value) && WMGetPropListItemCount(value) > 2) { if (value && WMIsPLArray(value) && WMGetPropListItemCount(value) > 2) {
WMPropList *type; WMPropList *type;
char *t; char *t;
type = WMGetFromPLArray(value, 0); type = WMGetFromPLArray(value, 0);
t = WMGetFromPLString(type); t = WMGetFromPLString(type);
if (t == NULL) if (t == NULL)
continue; continue;
if (strcasecmp(t, "tpixmap")==0 if (strcasecmp(t, "tpixmap")==0
|| strcasecmp(t, "spixmap")==0 || strcasecmp(t, "spixmap")==0
|| strcasecmp(t, "cpixmap")==0 || strcasecmp(t, "cpixmap")==0
|| strcasecmp(t, "mpixmap")==0 || strcasecmp(t, "mpixmap")==0
|| strcasecmp(t, "tdgradient")==0 || strcasecmp(t, "tdgradient")==0
|| strcasecmp(t, "tvgradient")==0 || strcasecmp(t, "tvgradient")==0
|| strcasecmp(t, "thgradient")==0) { || strcasecmp(t, "thgradient")==0) {
WMPropList *file; WMPropList *file;
char *p; char *p;
char *newPath; char *newPath;
file = WMGetFromPLArray(value, 1); file = WMGetFromPLArray(value, 1);
p = strrchr(WMGetFromPLString(file), '/'); p = strrchr(WMGetFromPLString(file), '/');
if (p) { if (p) {
copyFile(themeDir, WMGetFromPLString(file)); copyFile(themeDir, WMGetFromPLString(file));
newPath = mystrdup(p+1); newPath = wstrdup(p+1);
WMDeleteFromPLArray(value, 1); WMDeleteFromPLArray(value, 1);
WMInsertInPLArray(value, 1, WMCreatePLString(newPath)); WMInsertInPLArray(value, 1, WMCreatePLString(newPath));
free(newPath); free(newPath);
} else { } else {
findCopyFile(themeDir, WMGetFromPLString(file)); findCopyFile(themeDir, WMGetFromPLString(file));
} }
} else if (strcasecmp(t, "bitmap")==0) { } else if (strcasecmp(t, "bitmap")==0) {
WMPropList *file; WMPropList *file;
char *p; char *p;
char *newPath; char *newPath;
file = WMGetFromPLArray(value, 1); file = WMGetFromPLArray(value, 1);
p = strrchr(WMGetFromPLString(file), '/'); p = strrchr(WMGetFromPLString(file), '/');
if (p) { if (p) {
copyFile(themeDir, WMGetFromPLString(file)); copyFile(themeDir, WMGetFromPLString(file));
newPath = mystrdup(p+1); newPath = wstrdup(p+1);
WMDeleteFromPLArray(value, 1); WMDeleteFromPLArray(value, 1);
WMInsertInPLArray(value, 1, WMCreatePLString(newPath)); WMInsertInPLArray(value, 1, WMCreatePLString(newPath));
free(newPath); free(newPath);
} else { } else {
findCopyFile(themeDir, WMGetFromPLString(file)); findCopyFile(themeDir, WMGetFromPLString(file));
} }
file = WMGetFromPLArray(value, 2); file = WMGetFromPLArray(value, 2);
p = strrchr(WMGetFromPLString(file), '/'); p = strrchr(WMGetFromPLString(file), '/');
if (p) { if (p) {
copyFile(themeDir, WMGetFromPLString(file)); copyFile(themeDir, WMGetFromPLString(file));
newPath = mystrdup(p+1); newPath = wstrdup(p+1);
WMDeleteFromPLArray(value, 2); WMDeleteFromPLArray(value, 2);
WMInsertInPLArray(value, 2, WMCreatePLString(newPath)); WMInsertInPLArray(value, 2, WMCreatePLString(newPath));
free(newPath); free(newPath);
} else { } else {
findCopyFile(themeDir, WMGetFromPLString(file)); findCopyFile(themeDir, WMGetFromPLString(file));
} }
} }
} }
} }
return themeDir; return themeDir;
@@ -641,43 +705,42 @@ main(int argc, char **argv)
{ {
WMPropList *prop, *style, *key, *val; WMPropList *prop, *style, *key, *val;
char *path; char *path;
int i, theme_too=0; int i, theme_too=0, make_pack=0;
int make_pack = 0;
char *style_file = NULL; char *style_file = NULL;
ProgName = argv[0]; ProgName = argv[0];
if (argc>1) { if (argc>1) {
for (i=1; i<argc; i++) { for (i=1; i<argc; i++) {
if (strcmp(argv[i], "-p")==0 if (strcmp(argv[i], "-p")==0
|| strcmp(argv[i], "--pack")==0) { || strcmp(argv[i], "--pack")==0) {
make_pack = 1; make_pack = 1;
theme_too = 1; theme_too = 1;
} else if (strcmp(argv[i], "-t")==0 } else if (strcmp(argv[i], "-t")==0
|| strcmp(argv[i], "--theme-options")==0) { || strcmp(argv[i], "--theme-options")==0) {
theme_too++; theme_too++;
} else if (strcmp(argv[i], "--help")==0) { } else if (strcmp(argv[i], "--help")==0) {
print_help(); print_help();
exit(0); exit(0);
} else if (strcmp(argv[i], "--version")==0) { } else if (strcmp(argv[i], "--version")==0) {
puts(PROG_VERSION); puts(PROG_VERSION);
exit(0); exit(0);
} else { } else {
if (style_file!=NULL) { if (style_file!=NULL) {
printf("%s: invalid argument '%s'\n", argv[0], printf("%s: invalid argument '%s'\n", argv[0],
style_file[0]=='-' ? style_file : argv[i]); style_file[0]=='-' ? style_file : argv[i]);
printf("Try '%s --help' for more information\n", argv[0]); printf("Try '%s --help' for more information\n", argv[0]);
exit(1); exit(1);
} }
style_file = argv[i]; style_file = argv[i];
} }
} }
} }
if (make_pack && !style_file) { if (make_pack && !style_file) {
printf("%s: you must supply a name for the theme pack\n", ProgName); printf("%s: you must supply a name for the theme pack\n", ProgName);
exit(1); exit(1);
} }
WMPLSetCaseSensitive(False); WMPLSetCaseSensitive(False);
@@ -686,58 +749,49 @@ main(int argc, char **argv)
prop = WMReadPropListFromFile(path); prop = WMReadPropListFromFile(path);
if (!prop) { if (!prop) {
printf("%s:could not load WindowMaker configuration file \"%s\".\n", printf("%s:could not load WindowMaker configuration file \"%s\".\n",
ProgName, path); ProgName, path);
exit(1); exit(1);
} }
/* get global value */ /* get global value */
path = globalDefaultsPathForDomain("WindowMaker"); path = globalDefaultsPathForDomain("WindowMaker");
val = WMReadPropListFromFile(path); val = WMReadPropListFromFile(path);
if (val) { if (val) {
WMMergePLDictionaries(val, prop, True); WMMergePLDictionaries(val, prop, True);
WMReleasePropList(prop); WMReleasePropList(prop);
prop = val; prop = val;
} }
style = WMCreatePLDictionary(NULL, NULL, NULL); style = WMCreatePLDictionary(NULL, NULL, NULL);
for (i=0; options[i]!=NULL; i++) { for (i=0; options[i]!=NULL; i++) {
key = WMCreatePLString(options[i]); key = WMCreatePLString(options[i]);
val = WMGetFromPLDictionary(prop, key); val = WMGetFromPLDictionary(prop, key);
if (val) { if (val) {
int j; WMRetainPropList(val);
char *str = WMGetFromPLString(key); if (isFontOption(options[i])) {
for (j = 0; font_styles[j]!=NULL; j++) { char *newfont, *oldfont;
if (strcasecmp(str, font_styles[j]) == 0) {
char *oldfont; oldfont = WMGetFromPLString(val);
oldfont = WMGetFromPLString(val); newfont = convertFont(oldfont);
if (oldfont[0] == '-') { /* font is a reference to old if conversion is not needed */
if (!strchr(oldfont, ',')) if (newfont != oldfont) {
{ WMReleasePropList(val);
char *newfont; val = WMCreatePLString(newfont);
newfont = xlfdToFc(oldfont); wfree(newfont);
val = WMCreatePLString(newfont); }
break; }
} else { WMPutInPLDictionary(style, key, val);
wwarning("fontsets are not supported. replaced with default %s", default_font); WMReleasePropList(val);
val = WMCreatePLString(default_font); }
break; WMReleasePropList(key);
}
} else {
break;
}
}
}
WMPutInPLDictionary(style, key, val);
}
} }
val = WMGetFromPLDictionary(prop, WMCreatePLString("PixmapPath")); val = WMGetFromPLDictionary(prop, WMCreatePLString("PixmapPath"));
if (val) if (val)
PixmapPath = val; PixmapPath = val;
if (theme_too) { if (theme_too) {
for (i=0; theme_options[i]!=NULL; i++) { for (i=0; theme_options[i]!=NULL; i++) {
@@ -750,21 +804,21 @@ main(int argc, char **argv)
} }
if (make_pack) { if (make_pack) {
char *path; char *path;
makeThemePack(style, style_file); makeThemePack(style, style_file);
path = mymalloc(strlen(ThemePath)+32); path = wmalloc(strlen(ThemePath)+32);
strcpy(path, ThemePath); strcpy(path, ThemePath);
strcat(path, "/style"); strcat(path, "/style");
WMWritePropListToFile(style, path, False); WMWritePropListToFile(style, path, False);
wfree(path); wfree(path);
} else { } else {
if (style_file) { if (style_file) {
WMWritePropListToFile(style, style_file, False); WMWritePropListToFile(style, style_file, False);
} else { } else {
puts(WMGetPropListDescription(style, True)); puts(WMGetPropListDescription(style, True));
} }
} }
exit(0); exit(0);
} }

File diff suppressed because it is too large Load Diff