mirror of
https://github.com/gryf/wmaker.git
synced 2026-02-02 22:25:48 +01:00
- Finished moving to the new proplist handling code in WINGs.
- Also tested the backward compatibility ability of the WINGs proplist code which seems to work quite well. Starting with this moment, Window Maker no longer needs libPropList and is now using the better and much more robust proplist code from WINGs. Also the WINGs based proplist code is actively maintained while the old libPropList code is practically dead and flawed by the fact that it borrowed concepts from the UserDefaults which conflicted with the retain/release mechanism, making some problems that libPropList had, practically unsolvable without a complete redesign (which can be found in the more robust WINGs code).
This commit is contained in:
@@ -18,40 +18,39 @@ INCLUDES = $(DFLAGS) -I$(top_srcdir)/WINGs -I$(top_srcdir)/wrlib \
|
||||
# X_EXTRA_LIBS is for libproplist in systems that need -lsocket
|
||||
# remove after we require lPL 0.10.2 which automatically resolves its
|
||||
# library dependancies using the libPropList.la file
|
||||
liblist= @LIBRARY_SEARCH_PATH@ @LIBPL@ @X_EXTRA_LIBS@
|
||||
liblist= @LIBRARY_SEARCH_PATH@ @X_EXTRA_LIBS@
|
||||
|
||||
wdwrite_LDADD = $(liblist)
|
||||
wdwrite_LDADD = $(top_builddir)/WINGs/libWUtil.a $(liblist)
|
||||
|
||||
wdread_LDADD = $(liblist)
|
||||
wdread_LDADD = $(top_builddir)/WINGs/libWUtil.a $(liblist)
|
||||
|
||||
wxcopy_LDADD = @XLFLAGS@ @XLIBS@
|
||||
|
||||
wxpaste_LDADD = @XLFLAGS@ @XLIBS@
|
||||
|
||||
getstyle_LDADD = $(liblist)
|
||||
getstyle_LDADD = $(top_builddir)/WINGs/libWUtil.a $(liblist)
|
||||
|
||||
setstyle_LDADD = @XLFLAGS@ @XLIBS@ $(liblist)
|
||||
setstyle_LDADD = \
|
||||
$(top_builddir)/WINGs/libWUtil.a \
|
||||
@XLFLAGS@ @XLIBS@ $(liblist)
|
||||
|
||||
seticons_LDADD= $(liblist)
|
||||
seticons_LDADD= $(top_builddir)/WINGs/libWUtil.a $(liblist)
|
||||
|
||||
geticonset_LDADD= $(liblist)
|
||||
geticonset_LDADD= $(top_builddir)/WINGs/libWUtil.a $(liblist)
|
||||
|
||||
wmagnify_LDADD = \
|
||||
$(top_builddir)/WINGs/libWINGs.a \
|
||||
$(top_builddir)/wrlib/libwraster.la \
|
||||
@LIBPL@ \
|
||||
@DLLIBS@
|
||||
|
||||
wmsetup_LDADD = \
|
||||
$(top_builddir)/WINGs/libWINGs.a \
|
||||
$(top_builddir)/wrlib/libwraster.la \
|
||||
@LIBPL@ \
|
||||
@DLLIBS@
|
||||
|
||||
wmsetbg_LDADD = \
|
||||
$(top_builddir)/WINGs/libWINGs.a \
|
||||
$(top_builddir)/wrlib/libwraster.la \
|
||||
@LIBPL@ \
|
||||
@DLLIBS@
|
||||
|
||||
CLEANFILES = wmaker.inst wmchlocale
|
||||
|
||||
@@ -25,9 +25,10 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <proplist.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <WINGs/WUtil.h>
|
||||
|
||||
#include "../src/wconfig.h"
|
||||
|
||||
|
||||
@@ -77,9 +78,8 @@ print_help()
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
proplist_t window_name, icon_key, window_attrs, icon_value;
|
||||
proplist_t all_windows, iconset;
|
||||
proplist_t keylist;
|
||||
WMPropList *window_name, *icon_key, *window_attrs, *icon_value;
|
||||
WMPropList *all_windows, *iconset, *keylist;
|
||||
char *path;
|
||||
int i;
|
||||
|
||||
@@ -99,46 +99,43 @@ main(int argc, char **argv)
|
||||
|
||||
path = defaultsPathForDomain("WMWindowAttributes");
|
||||
|
||||
all_windows = PLGetProplistWithPath(path);
|
||||
all_windows = WMReadPropListFromFile(path);
|
||||
if (!all_windows) {
|
||||
printf("%s:could not load WindowMaker configuration file \"%s\".\n",
|
||||
ProgName, path);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
iconset = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
|
||||
iconset = WMCreatePLDictionary(NULL, NULL, NULL);
|
||||
|
||||
keylist = PLGetAllDictionaryKeys(all_windows);
|
||||
icon_key = PLMakeString("Icon");
|
||||
keylist = WMGetPLDictionaryKeys(all_windows);
|
||||
icon_key = WMCreatePLString("Icon");
|
||||
|
||||
for (i=0; i<PLGetNumberOfElements(keylist); i++) {
|
||||
proplist_t icondic;
|
||||
for (i=0; i<WMGetPropListItemCount(keylist); i++) {
|
||||
WMPropList *icondic;
|
||||
|
||||
window_name = PLGetArrayElement(keylist, i);
|
||||
if (!PLIsString(window_name))
|
||||
window_name = WMGetFromPLArray(keylist, i);
|
||||
if (!WMIsPLString(window_name))
|
||||
continue;
|
||||
|
||||
window_attrs = PLGetDictionaryEntry(all_windows, window_name);
|
||||
if (window_attrs && PLIsDictionary(window_attrs)) {
|
||||
icon_value = PLGetDictionaryEntry(window_attrs, icon_key);
|
||||
window_attrs = WMGetFromPLDictionary(all_windows, window_name);
|
||||
if (window_attrs && WMIsPLDictionary(window_attrs)) {
|
||||
icon_value = WMGetFromPLDictionary(window_attrs, icon_key);
|
||||
if (icon_value) {
|
||||
|
||||
icondic = PLMakeDictionaryFromEntries(icon_key, icon_value,
|
||||
icondic = WMCreatePLDictionary(icon_key, icon_value,
|
||||
NULL);
|
||||
|
||||
PLInsertDictionaryEntry(iconset, window_name, icondic);
|
||||
WMPutInPLDictionary(iconset, window_name, icondic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (argc==2) {
|
||||
proplist_t val;
|
||||
val = PLMakeString(argv[1]);
|
||||
PLSetFilename(iconset, val);
|
||||
PLSave(iconset, NO);
|
||||
WMWritePropListToFile(iconset, argv[1], False);
|
||||
} else {
|
||||
puts(PLGetDescriptionIndent(iconset, 0));
|
||||
puts(WMGetPropListDescription(iconset, True));
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
161
util/getstyle.c
161
util/getstyle.c
@@ -27,13 +27,13 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <proplist.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <pwd.h>
|
||||
#include <limits.h>
|
||||
#include <assert.h>
|
||||
#include <WINGs/WUtil.h>
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 1024
|
||||
@@ -106,7 +106,7 @@ static char *theme_options[] = {
|
||||
|
||||
char *ProgName;
|
||||
|
||||
proplist_t PixmapPath = NULL;
|
||||
WMPropList *PixmapPath = NULL;
|
||||
|
||||
char *ThemePath = NULL;
|
||||
|
||||
@@ -164,21 +164,6 @@ defaultsPathForDomain(char *domain)
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
StringCompareHook(proplist_t pl1, proplist_t pl2)
|
||||
{
|
||||
char *str1, *str2;
|
||||
|
||||
str1 = PLGetString(pl1);
|
||||
str2 = PLGetString(pl2);
|
||||
|
||||
if (strcasecmp(str1, str2)==0)
|
||||
return YES;
|
||||
else
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
abortar(char *reason)
|
||||
{
|
||||
@@ -226,7 +211,7 @@ wgethomedir()
|
||||
|
||||
|
||||
void*
|
||||
wmalloc(int size)
|
||||
mymalloc(int size)
|
||||
{
|
||||
void *tmp;
|
||||
|
||||
@@ -240,11 +225,11 @@ wmalloc(int size)
|
||||
|
||||
|
||||
char*
|
||||
wstrdup(char *str)
|
||||
mystrdup(char *str)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
tmp = wmalloc(strlen(str)+1);
|
||||
tmp = mymalloc(strlen(str)+1);
|
||||
|
||||
strcpy(tmp, str);
|
||||
|
||||
@@ -355,13 +340,13 @@ wexpandpath(char *path)
|
||||
}
|
||||
}
|
||||
|
||||
return wstrdup(buffer);
|
||||
return mystrdup(buffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
char*
|
||||
wfindfileinarray(proplist_t paths, char *file)
|
||||
wfindfileinarray(WMPropList *paths, char *file)
|
||||
{
|
||||
int i;
|
||||
char *path;
|
||||
@@ -371,8 +356,8 @@ wfindfileinarray(proplist_t paths, char *file)
|
||||
if (!file)
|
||||
return NULL;
|
||||
|
||||
if (*file=='/' || *file=='~' || !paths || !PLIsArray(paths)
|
||||
|| PLGetNumberOfElements(paths)==0) {
|
||||
if (*file=='/' || *file=='~' || !paths || !WMIsPLArray(paths)
|
||||
|| WMGetPropListItemCount(paths)==0) {
|
||||
if (access(file, R_OK)<0) {
|
||||
fullpath = wexpandpath(file);
|
||||
if (!fullpath)
|
||||
@@ -385,21 +370,21 @@ wfindfileinarray(proplist_t paths, char *file)
|
||||
return fullpath;
|
||||
}
|
||||
} else {
|
||||
return wstrdup(file);
|
||||
return mystrdup(file);
|
||||
}
|
||||
}
|
||||
|
||||
flen = strlen(file);
|
||||
for (i=0; i < PLGetNumberOfElements(paths); i++) {
|
||||
proplist_t tmp;
|
||||
for (i=0; i < WMGetPropListItemCount(paths); i++) {
|
||||
WMPropList *tmp;
|
||||
char *dir;
|
||||
|
||||
tmp = PLGetArrayElement(paths, i);
|
||||
if (!PLIsString(tmp) || !(dir = PLGetString(tmp)))
|
||||
tmp = WMGetFromPLArray(paths, i);
|
||||
if (!WMIsPLString(tmp) || !(dir = WMGetFromPLString(tmp)))
|
||||
continue;
|
||||
|
||||
len = strlen(dir);
|
||||
path = wmalloc(len+flen+2);
|
||||
path = mymalloc(len+flen+2);
|
||||
path = memcpy(path, dir, len);
|
||||
path[len]=0;
|
||||
strcat(path, "/");
|
||||
@@ -451,21 +436,21 @@ findCopyFile(char *dir, char *file)
|
||||
|
||||
|
||||
char*
|
||||
makeThemePack(proplist_t style, char *themeName)
|
||||
makeThemePack(WMPropList *style, char *themeName)
|
||||
{
|
||||
proplist_t keys;
|
||||
proplist_t key;
|
||||
proplist_t value;
|
||||
WMPropList *keys;
|
||||
WMPropList *key;
|
||||
WMPropList *value;
|
||||
int i;
|
||||
char *themeDir;
|
||||
|
||||
themeDir = wmalloc(strlen(themeName)+50);
|
||||
themeDir = mymalloc(strlen(themeName)+50);
|
||||
sprintf(themeDir, "%s.themed", themeName);
|
||||
ThemePath = themeDir;
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
tmp = wmalloc(strlen(themeDir)+20);
|
||||
tmp = mymalloc(strlen(themeDir)+20);
|
||||
sprintf(tmp, "/bin/mkdir \"%s\"", themeDir);
|
||||
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);
|
||||
@@ -473,18 +458,18 @@ makeThemePack(proplist_t style, char *themeName)
|
||||
}
|
||||
free(tmp);
|
||||
}
|
||||
keys = PLGetAllDictionaryKeys(style);
|
||||
keys = WMGetPLDictionaryKeys(style);
|
||||
|
||||
for (i = 0; i < PLGetNumberOfElements(keys); i++) {
|
||||
key = PLGetArrayElement(keys, i);
|
||||
for (i = 0; i < WMGetPropListItemCount(keys); i++) {
|
||||
key = WMGetFromPLArray(keys, i);
|
||||
|
||||
value = PLGetDictionaryEntry(style, key);
|
||||
if (value && PLIsArray(value) && PLGetNumberOfElements(value) > 2) {
|
||||
proplist_t type;
|
||||
value = WMGetFromPLDictionary(style, key);
|
||||
if (value && WMIsPLArray(value) && WMGetPropListItemCount(value) > 2) {
|
||||
WMPropList *type;
|
||||
char *t;
|
||||
|
||||
type = PLGetArrayElement(value, 0);
|
||||
t = PLGetString(type);
|
||||
type = WMGetFromPLArray(value, 0);
|
||||
t = WMGetFromPLString(type);
|
||||
if (t == NULL)
|
||||
continue;
|
||||
|
||||
@@ -495,55 +480,55 @@ makeThemePack(proplist_t style, char *themeName)
|
||||
|| strcasecmp(t, "tdgradient")==0
|
||||
|| strcasecmp(t, "tvgradient")==0
|
||||
|| strcasecmp(t, "thgradient")==0) {
|
||||
proplist_t file;
|
||||
WMPropList *file;
|
||||
char *p;
|
||||
char *newPath;
|
||||
|
||||
file = PLGetArrayElement(value, 1);
|
||||
file = WMGetFromPLArray(value, 1);
|
||||
|
||||
p = strrchr(PLGetString(file), '/');
|
||||
p = strrchr(WMGetFromPLString(file), '/');
|
||||
if (p) {
|
||||
copyFile(themeDir, PLGetString(file));
|
||||
copyFile(themeDir, WMGetFromPLString(file));
|
||||
|
||||
newPath = wstrdup(p+1);
|
||||
PLRemoveArrayElement(value, 1);
|
||||
PLInsertArrayElement(value, PLMakeString(newPath), 1);
|
||||
newPath = mystrdup(p+1);
|
||||
WMDeleteFromPLArray(value, 1);
|
||||
WMInsertInPLArray(value, 1, WMCreatePLString(newPath));
|
||||
free(newPath);
|
||||
} else {
|
||||
findCopyFile(themeDir, PLGetString(file));
|
||||
findCopyFile(themeDir, WMGetFromPLString(file));
|
||||
}
|
||||
} else if (strcasecmp(t, "bitmap")==0) {
|
||||
proplist_t file;
|
||||
WMPropList *file;
|
||||
char *p;
|
||||
char *newPath;
|
||||
|
||||
file = PLGetArrayElement(value, 1);
|
||||
file = WMGetFromPLArray(value, 1);
|
||||
|
||||
p = strrchr(PLGetString(file), '/');
|
||||
p = strrchr(WMGetFromPLString(file), '/');
|
||||
if (p) {
|
||||
copyFile(themeDir, PLGetString(file));
|
||||
copyFile(themeDir, WMGetFromPLString(file));
|
||||
|
||||
newPath = wstrdup(p+1);
|
||||
PLRemoveArrayElement(value, 1);
|
||||
PLInsertArrayElement(value, PLMakeString(newPath), 1);
|
||||
newPath = mystrdup(p+1);
|
||||
WMDeleteFromPLArray(value, 1);
|
||||
WMInsertInPLArray(value, 1, WMCreatePLString(newPath));
|
||||
free(newPath);
|
||||
} else {
|
||||
findCopyFile(themeDir, PLGetString(file));
|
||||
findCopyFile(themeDir, WMGetFromPLString(file));
|
||||
}
|
||||
|
||||
|
||||
file = PLGetArrayElement(value, 2);
|
||||
file = WMGetFromPLArray(value, 2);
|
||||
|
||||
p = strrchr(PLGetString(file), '/');
|
||||
p = strrchr(WMGetFromPLString(file), '/');
|
||||
if (p) {
|
||||
copyFile(themeDir, PLGetString(file));
|
||||
copyFile(themeDir, WMGetFromPLString(file));
|
||||
|
||||
newPath = wstrdup(p+1);
|
||||
PLRemoveArrayElement(value, 2);
|
||||
PLInsertArrayElement(value, PLMakeString(newPath), 2);
|
||||
newPath = mystrdup(p+1);
|
||||
WMDeleteFromPLArray(value, 2);
|
||||
WMInsertInPLArray(value, 2, WMCreatePLString(newPath));
|
||||
free(newPath);
|
||||
} else {
|
||||
findCopyFile(themeDir, PLGetString(file));
|
||||
findCopyFile(themeDir, WMGetFromPLString(file));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -556,7 +541,7 @@ makeThemePack(proplist_t style, char *themeName)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
proplist_t prop, style, key, val;
|
||||
WMPropList *prop, *style, *key, *val;
|
||||
char *path;
|
||||
int i, theme_too=0;
|
||||
int make_pack = 0;
|
||||
@@ -597,11 +582,11 @@ main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
PLSetStringCmpHook(StringCompareHook);
|
||||
WMPLSetCaseSensitive(False);
|
||||
|
||||
path = defaultsPathForDomain("WindowMaker");
|
||||
|
||||
prop = PLGetProplistWithPath(path);
|
||||
prop = WMReadPropListFromFile(path);
|
||||
if (!prop) {
|
||||
printf("%s:could not load WindowMaker configuration file \"%s\".\n",
|
||||
ProgName, path);
|
||||
@@ -610,36 +595,36 @@ main(int argc, char **argv)
|
||||
|
||||
/* get global value */
|
||||
path = globalDefaultsPathForDomain("WindowMaker");
|
||||
val = PLGetProplistWithPath(path);
|
||||
val = WMReadPropListFromFile(path);
|
||||
if (val) {
|
||||
PLMergeDictionaries(val, prop);
|
||||
PLRelease(prop);
|
||||
WMMergePLDictionaries(val, prop);
|
||||
WMReleasePropList(prop);
|
||||
prop = val;
|
||||
}
|
||||
|
||||
style = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
|
||||
style = WMCreatePLDictionary(NULL, NULL, NULL);
|
||||
|
||||
|
||||
for (i=0; options[i]!=NULL; i++) {
|
||||
key = PLMakeString(options[i]);
|
||||
key = WMCreatePLString(options[i]);
|
||||
|
||||
val = PLGetDictionaryEntry(prop, key);
|
||||
val = WMGetFromPLDictionary(prop, key);
|
||||
if (val)
|
||||
PLInsertDictionaryEntry(style, key, val);
|
||||
WMPutInPLDictionary(style, key, val);
|
||||
}
|
||||
|
||||
val = PLGetDictionaryEntry(prop, PLMakeString("PixmapPath"));
|
||||
val = WMGetFromPLDictionary(prop, WMCreatePLString("PixmapPath"));
|
||||
if (val)
|
||||
PixmapPath = val;
|
||||
|
||||
if (theme_too) {
|
||||
for (i=0; theme_options[i]!=NULL; i++) {
|
||||
key = PLMakeString(theme_options[i]);
|
||||
key = WMCreatePLString(theme_options[i]);
|
||||
|
||||
val = PLGetDictionaryEntry(prop, key);
|
||||
val = WMGetFromPLDictionary(prop, key);
|
||||
if (val)
|
||||
PLInsertDictionaryEntry(style, key, val);
|
||||
}
|
||||
WMPutInPLDictionary(style, key, val);
|
||||
}
|
||||
}
|
||||
|
||||
if (make_pack) {
|
||||
@@ -647,18 +632,16 @@ main(int argc, char **argv)
|
||||
|
||||
makeThemePack(style, style_file);
|
||||
|
||||
path = wmalloc(strlen(ThemePath)+32);
|
||||
path = mymalloc(strlen(ThemePath)+32);
|
||||
strcpy(path, ThemePath);
|
||||
strcat(path, "/style");
|
||||
PLSetFilename(style, PLMakeString(path));
|
||||
PLSave(style, NO);
|
||||
WMWritePropListToFile(style, path, False);
|
||||
wfree(path);
|
||||
} else {
|
||||
if (style_file) {
|
||||
val = PLMakeString(style_file);
|
||||
PLSetFilename(style, val);
|
||||
PLSave(style, NO);
|
||||
WMWritePropListToFile(style, style_file, False);
|
||||
} else {
|
||||
puts(PLGetDescriptionIndent(style, 0));
|
||||
puts(WMGetPropListDescription(style, True));
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
|
||||
@@ -25,9 +25,8 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <proplist.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <WINGs/WUtil.h>
|
||||
|
||||
#include "../src/wconfig.h"
|
||||
|
||||
@@ -77,9 +76,8 @@ print_help()
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
proplist_t window_name, icon_key, window_attrs, icon_value;
|
||||
proplist_t all_windows, iconset;
|
||||
proplist_t keylist;
|
||||
WMPropList *window_name, *icon_key, *window_attrs, *icon_value;
|
||||
WMPropList *all_windows, *iconset, *keylist;
|
||||
int i;
|
||||
char *path = NULL;
|
||||
|
||||
@@ -111,43 +109,43 @@ main(int argc, char **argv)
|
||||
|
||||
path = defaultsPathForDomain("WMWindowAttributes");
|
||||
|
||||
all_windows = PLGetProplistWithPath(path);
|
||||
all_windows = WMReadPropListFromFile(path);
|
||||
if (!all_windows) {
|
||||
printf("%s:could not load WindowMaker configuration file \"%s\".\n",
|
||||
ProgName, path);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
iconset = PLGetProplistWithPath(argv[1]);
|
||||
iconset = WMReadPropListFromFile(argv[1]);
|
||||
if (!iconset) {
|
||||
printf("%s:could not load icon set file \"%s\".\n", ProgName, argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
keylist = PLGetAllDictionaryKeys(iconset);
|
||||
icon_key = PLMakeString("Icon");
|
||||
keylist = WMGetPLDictionaryKeys(iconset);
|
||||
icon_key = WMCreatePLString("Icon");
|
||||
|
||||
for (i=0; i<PLGetNumberOfElements(keylist); i++) {
|
||||
window_name = PLGetArrayElement(keylist, i);
|
||||
if (!PLIsString(window_name))
|
||||
for (i=0; i<WMGetPropListItemCount(keylist); i++) {
|
||||
window_name = WMGetFromPLArray(keylist, i);
|
||||
if (!WMIsPLString(window_name))
|
||||
continue;
|
||||
|
||||
icon_value = PLGetDictionaryEntry(iconset, window_name);
|
||||
if (!icon_value || !PLIsDictionary(icon_value))
|
||||
icon_value = WMGetFromPLDictionary(iconset, window_name);
|
||||
if (!icon_value || !WMIsPLDictionary(icon_value))
|
||||
continue;
|
||||
|
||||
window_attrs = PLGetDictionaryEntry(all_windows, window_name);
|
||||
window_attrs = WMGetFromPLDictionary(all_windows, window_name);
|
||||
if (window_attrs) {
|
||||
if (PLIsDictionary(window_attrs)) {
|
||||
PLMergeDictionaries(window_attrs, icon_value);
|
||||
if (WMIsPLDictionary(window_attrs)) {
|
||||
WMMergePLDictionaries(window_attrs, icon_value);
|
||||
}
|
||||
} else {
|
||||
PLInsertDictionaryEntry(all_windows, window_name, icon_value);
|
||||
WMPutInPLDictionary(all_windows, window_name, icon_value);
|
||||
}
|
||||
}
|
||||
|
||||
PLSave(all_windows, YES);
|
||||
WMWritePropListToFile(all_windows, path, True);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
198
util/setstyle.c
198
util/setstyle.c
@@ -25,13 +25,13 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <proplist.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <WINGs/WUtil.h>
|
||||
|
||||
|
||||
|
||||
#include "../src/wconfig.h"
|
||||
|
||||
@@ -76,7 +76,7 @@ Display *dpy;
|
||||
|
||||
|
||||
|
||||
proplist_t readBlackBoxStyle(char *path);
|
||||
WMPropList *readBlackBoxStyle(char *path);
|
||||
|
||||
|
||||
|
||||
@@ -112,14 +112,14 @@ defaultsPathForDomain(char *domain)
|
||||
|
||||
|
||||
void
|
||||
hackPathInTexture(proplist_t texture, char *prefix)
|
||||
hackPathInTexture(WMPropList *texture, char *prefix)
|
||||
{
|
||||
proplist_t type;
|
||||
WMPropList *type;
|
||||
char *t;
|
||||
|
||||
/* get texture type */
|
||||
type = PLGetArrayElement(texture, 0);
|
||||
t = PLGetString(type);
|
||||
type = WMGetFromPLArray(texture, 0);
|
||||
t = WMGetFromPLString(type);
|
||||
if (t == NULL)
|
||||
return;
|
||||
if (strcasecmp(t, "tpixmap")==0
|
||||
@@ -129,64 +129,64 @@ hackPathInTexture(proplist_t texture, char *prefix)
|
||||
|| strcasecmp(t, "tvgradient")==0
|
||||
|| strcasecmp(t, "thgradient")==0
|
||||
|| strcasecmp(t, "tdgradient")==0) {
|
||||
proplist_t file;
|
||||
WMPropList *file;
|
||||
char buffer[4018];
|
||||
|
||||
/* get pixmap file path */
|
||||
file = PLGetArrayElement(texture, 1);
|
||||
sprintf(buffer, "%s/%s", prefix, PLGetString(file));
|
||||
file = WMGetFromPLArray(texture, 1);
|
||||
sprintf(buffer, "%s/%s", prefix, WMGetFromPLString(file));
|
||||
/* replace path with full path */
|
||||
PLRemoveArrayElement(texture, 1);
|
||||
PLInsertArrayElement(texture, PLMakeString(buffer), 1);
|
||||
WMDeleteFromPLArray(texture, 1);
|
||||
WMInsertInPLArray(texture, 1, WMCreatePLString(buffer));
|
||||
} else if (strcasecmp(t, "bitmap") == 0) {
|
||||
proplist_t file;
|
||||
WMPropList *file;
|
||||
char buffer[4018];
|
||||
|
||||
/* get bitmap file path */
|
||||
file = PLGetArrayElement(texture, 1);
|
||||
sprintf(buffer, "%s/%s", prefix, PLGetString(file));
|
||||
file = WMGetFromPLArray(texture, 1);
|
||||
sprintf(buffer, "%s/%s", prefix, WMGetFromPLString(file));
|
||||
/* replace path with full path */
|
||||
PLRemoveArrayElement(texture, 1);
|
||||
PLInsertArrayElement(texture, PLMakeString(buffer), 1);
|
||||
WMDeleteFromPLArray(texture, 1);
|
||||
WMInsertInPLArray(texture, 1, WMCreatePLString(buffer));
|
||||
|
||||
/* get mask file path */
|
||||
file = PLGetArrayElement(texture, 2);
|
||||
sprintf(buffer, "%s/%s", prefix, PLGetString(file));
|
||||
file = WMGetFromPLArray(texture, 2);
|
||||
sprintf(buffer, "%s/%s", prefix, WMGetFromPLString(file));
|
||||
/* replace path with full path */
|
||||
PLRemoveArrayElement(texture, 2);
|
||||
PLInsertArrayElement(texture, PLMakeString(buffer), 2);
|
||||
WMDeleteFromPLArray(texture, 2);
|
||||
WMInsertInPLArray(texture, 2, WMCreatePLString(buffer));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
hackPaths(proplist_t style, char *prefix)
|
||||
hackPaths(WMPropList *style, char *prefix)
|
||||
{
|
||||
proplist_t keys;
|
||||
proplist_t key;
|
||||
proplist_t value;
|
||||
WMPropList *keys;
|
||||
WMPropList *key;
|
||||
WMPropList *value;
|
||||
int i;
|
||||
|
||||
|
||||
keys = PLGetAllDictionaryKeys(style);
|
||||
keys = WMGetPLDictionaryKeys(style);
|
||||
|
||||
for (i = 0; i < PLGetNumberOfElements(keys); i++) {
|
||||
key = PLGetArrayElement(keys, i);
|
||||
for (i = 0; i < WMGetPropListItemCount(keys); i++) {
|
||||
key = WMGetFromPLArray(keys, i);
|
||||
|
||||
value = PLGetDictionaryEntry(style, key);
|
||||
value = WMGetFromPLDictionary(style, key);
|
||||
if (!value)
|
||||
continue;
|
||||
|
||||
if (strcasecmp(PLGetString(key), "WorkspaceSpecificBack")==0) {
|
||||
if (PLIsArray(value)) {
|
||||
if (strcasecmp(WMGetFromPLString(key), "WorkspaceSpecificBack")==0) {
|
||||
if (WMIsPLArray(value)) {
|
||||
int j;
|
||||
proplist_t texture;
|
||||
WMPropList *texture;
|
||||
|
||||
for (j = 0; j < PLGetNumberOfElements(value); j++) {
|
||||
texture = PLGetArrayElement(value, j);
|
||||
for (j = 0; j < WMGetPropListItemCount(value); j++) {
|
||||
texture = WMGetFromPLArray(value, j);
|
||||
|
||||
if (texture && PLIsArray(texture)
|
||||
&& PLGetNumberOfElements(texture) > 2) {
|
||||
if (texture && WMIsPLArray(texture)
|
||||
&& WMGetPropListItemCount(texture) > 2) {
|
||||
|
||||
hackPathInTexture(texture, prefix);
|
||||
}
|
||||
@@ -194,7 +194,7 @@ hackPaths(proplist_t style, char *prefix)
|
||||
}
|
||||
} else {
|
||||
|
||||
if (PLIsArray(value) && PLGetNumberOfElements(value) > 2) {
|
||||
if (WMIsPLArray(value) && WMGetPropListItemCount(value) > 2) {
|
||||
|
||||
hackPathInTexture(value, prefix);
|
||||
}
|
||||
@@ -204,36 +204,36 @@ hackPaths(proplist_t style, char *prefix)
|
||||
}
|
||||
|
||||
|
||||
static proplist_t
|
||||
getColor(proplist_t texture)
|
||||
static WMPropList*
|
||||
getColor(WMPropList *texture)
|
||||
{
|
||||
proplist_t value, type;
|
||||
WMPropList *value, *type;
|
||||
char *str;
|
||||
|
||||
type = PLGetArrayElement(texture, 0);
|
||||
type = WMGetFromPLArray(texture, 0);
|
||||
if (!type)
|
||||
return NULL;
|
||||
|
||||
value = NULL;
|
||||
|
||||
str = PLGetString(type);
|
||||
str = WMGetFromPLString(type);
|
||||
if (strcasecmp(str, "solid")==0) {
|
||||
value = PLGetArrayElement(texture, 1);
|
||||
value = WMGetFromPLArray(texture, 1);
|
||||
} else if (strcasecmp(str, "dgradient")==0
|
||||
|| strcasecmp(str, "hgradient")==0
|
||||
|| strcasecmp(str, "vgradient")==0) {
|
||||
proplist_t c1, c2;
|
||||
WMPropList *c1, *c2;
|
||||
int r1, g1, b1, r2, g2, b2;
|
||||
char buffer[32];
|
||||
|
||||
c1 = PLGetArrayElement(texture, 1);
|
||||
c2 = PLGetArrayElement(texture, 2);
|
||||
c1 = WMGetFromPLArray(texture, 1);
|
||||
c2 = WMGetFromPLArray(texture, 2);
|
||||
if (!dpy) {
|
||||
if (sscanf(PLGetString(c1), "#%2x%2x%2x", &r1, &g1, &b1)==3
|
||||
&& sscanf(PLGetString(c2), "#%2x%2x%2x", &r2, &g2, &b2)==3) {
|
||||
if (sscanf(WMGetFromPLString(c1), "#%2x%2x%2x", &r1, &g1, &b1)==3
|
||||
&& sscanf(WMGetFromPLString(c2), "#%2x%2x%2x", &r2, &g2, &b2)==3) {
|
||||
sprintf(buffer, "#%02x%02x%02x", (r1+r2)/2, (g1+g2)/2,
|
||||
(b1+b2)/2);
|
||||
value = PLMakeString(buffer);
|
||||
value = WMCreatePLString(buffer);
|
||||
} else {
|
||||
value = c1;
|
||||
}
|
||||
@@ -242,27 +242,27 @@ getColor(proplist_t texture)
|
||||
XColor color2;
|
||||
|
||||
XParseColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)),
|
||||
PLGetString(c1), &color1);
|
||||
WMGetFromPLString(c1), &color1);
|
||||
XParseColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)),
|
||||
PLGetString(c2), &color2);
|
||||
WMGetFromPLString(c2), &color2);
|
||||
|
||||
sprintf(buffer, "#%02x%02x%02x",
|
||||
(color1.red+color2.red)>>9,
|
||||
(color1.green+color2.green)>>9,
|
||||
(color1.blue+color2.blue)>>9);
|
||||
value = PLMakeString(buffer);
|
||||
value = WMCreatePLString(buffer);
|
||||
}
|
||||
} else if (strcasecmp(str, "mdgradient")==0
|
||||
|| strcasecmp(str, "mhgradient")==0
|
||||
|| strcasecmp(str, "mvgradient")==0) {
|
||||
|
||||
value = PLGetArrayElement(texture, 1);
|
||||
value = WMGetFromPLArray(texture, 1);
|
||||
|
||||
} else if (strcasecmp(str, "tpixmap")==0
|
||||
|| strcasecmp(str, "cpixmap")==0
|
||||
|| strcasecmp(str, "spixmap")==0) {
|
||||
|
||||
value = PLGetArrayElement(texture, 2);
|
||||
value = WMGetFromPLArray(texture, 2);
|
||||
}
|
||||
|
||||
return value;
|
||||
@@ -277,28 +277,26 @@ getColor(proplist_t texture)
|
||||
* IconTitleBack
|
||||
*/
|
||||
void
|
||||
hackStyle(proplist_t style)
|
||||
hackStyle(WMPropList *style)
|
||||
{
|
||||
proplist_t keys;
|
||||
proplist_t tmp;
|
||||
WMPropList *keys, *tmp;
|
||||
int foundIconTitle = 0, foundResizebarBack = 0;
|
||||
int i;
|
||||
int foundIconTitle = 0;
|
||||
int foundResizebarBack = 0;
|
||||
|
||||
keys = PLGetAllDictionaryKeys(style);
|
||||
keys = WMGetPLDictionaryKeys(style);
|
||||
|
||||
for (i = 0; i < PLGetNumberOfElements(keys); i++) {
|
||||
for (i = 0; i < WMGetPropListItemCount(keys); i++) {
|
||||
char *str;
|
||||
|
||||
tmp = PLGetArrayElement(keys, i);
|
||||
str = PLGetString(tmp);
|
||||
tmp = WMGetFromPLArray(keys, i);
|
||||
str = WMGetFromPLString(tmp);
|
||||
if (str) {
|
||||
int j, found;
|
||||
|
||||
if (ignoreFonts) {
|
||||
for (j = 0, found = 0; FontOptions[j]!=NULL; j++) {
|
||||
if (strcasecmp(str, FontOptions[j])==0) {
|
||||
PLRemoveDictionaryEntry(style, tmp);
|
||||
WMRemoveFromPLDictionary(style, tmp);
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
@@ -309,7 +307,7 @@ hackStyle(proplist_t style)
|
||||
if (ignoreCursors) {
|
||||
for (j = 0, found = 0; CursorOptions[j] != NULL; j++) {
|
||||
if (strcasecmp(str, CursorOptions[j]) == 0) {
|
||||
PLRemoveDictionaryEntry(style, tmp);
|
||||
WMRemoveFromPLDictionary(style, tmp);
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
@@ -329,20 +327,20 @@ hackStyle(proplist_t style)
|
||||
|
||||
if (!foundIconTitle) {
|
||||
/* set the default values */
|
||||
tmp = PLGetDictionaryEntry(style, PLMakeString("FTitleColor"));
|
||||
tmp = WMGetFromPLDictionary(style, WMCreatePLString("FTitleColor"));
|
||||
if (tmp) {
|
||||
PLInsertDictionaryEntry(style, PLMakeString("IconTitleColor"),
|
||||
WMPutInPLDictionary(style, WMCreatePLString("IconTitleColor"),
|
||||
tmp);
|
||||
}
|
||||
|
||||
tmp = PLGetDictionaryEntry(style, PLMakeString("FTitleBack"));
|
||||
tmp = WMGetFromPLDictionary(style, WMCreatePLString("FTitleBack"));
|
||||
if (tmp) {
|
||||
proplist_t value;
|
||||
WMPropList *value;
|
||||
|
||||
value = getColor(tmp);
|
||||
|
||||
if (value) {
|
||||
PLInsertDictionaryEntry(style, PLMakeString("IconTitleBack"),
|
||||
WMPutInPLDictionary(style, WMCreatePLString("IconTitleBack"),
|
||||
value);
|
||||
}
|
||||
}
|
||||
@@ -350,46 +348,31 @@ hackStyle(proplist_t style)
|
||||
|
||||
if (!foundResizebarBack) {
|
||||
/* set the default values */
|
||||
tmp = PLGetDictionaryEntry(style, PLMakeString("UTitleBack"));
|
||||
tmp = WMGetFromPLDictionary(style, WMCreatePLString("UTitleBack"));
|
||||
if (tmp) {
|
||||
proplist_t value;
|
||||
WMPropList *value;
|
||||
|
||||
value = getColor(tmp);
|
||||
|
||||
if (value) {
|
||||
proplist_t t;
|
||||
WMPropList *t;
|
||||
|
||||
t = PLMakeArrayFromElements(PLMakeString("solid"), value,
|
||||
t = WMCreatePLArray(WMCreatePLString("solid"), value,
|
||||
NULL);
|
||||
PLInsertDictionaryEntry(style, PLMakeString("ResizebarBack"),
|
||||
WMPutInPLDictionary(style, WMCreatePLString("ResizebarBack"),
|
||||
t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!PLGetDictionaryEntry(style, PLMakeString("MenuStyle"))) {
|
||||
PLInsertDictionaryEntry(style, PLMakeString("MenuStyle"),
|
||||
PLMakeString("normal"));
|
||||
if (!WMGetFromPLDictionary(style, WMCreatePLString("MenuStyle"))) {
|
||||
WMPutInPLDictionary(style, WMCreatePLString("MenuStyle"),
|
||||
WMCreatePLString("normal"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
StringCompareHook(proplist_t pl1, proplist_t pl2)
|
||||
{
|
||||
char *str1, *str2;
|
||||
|
||||
str1 = PLGetString(pl1);
|
||||
str2 = PLGetString(pl2);
|
||||
|
||||
if (strcasecmp(str1, str2)==0)
|
||||
return YES;
|
||||
else
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
print_help()
|
||||
{
|
||||
@@ -418,7 +401,7 @@ print_help()
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
proplist_t prop, style;
|
||||
WMPropList *prop, *style;
|
||||
char *path;
|
||||
char *file = NULL;
|
||||
struct stat statbuf;
|
||||
@@ -479,11 +462,11 @@ main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
PLSetStringCmpHook(StringCompareHook);
|
||||
WMPLSetCaseSensitive(False);
|
||||
|
||||
path = defaultsPathForDomain("WindowMaker");
|
||||
|
||||
prop = PLGetProplistWithPath(path);
|
||||
prop = WMReadPropListFromFile(path);
|
||||
if (!prop) {
|
||||
perror(path);
|
||||
printf("%s:could not load WindowMaker configuration file.\n",
|
||||
@@ -536,7 +519,7 @@ main(int argc, char **argv)
|
||||
|
||||
strcat(buffer, "/style");
|
||||
|
||||
style = PLGetProplistWithPath(buffer);
|
||||
style = WMReadPropListFromFile(buffer);
|
||||
if (!style) {
|
||||
perror(buffer);
|
||||
printf("%s:could not load style file.\n", ProgName);
|
||||
@@ -548,7 +531,7 @@ main(int argc, char **argv)
|
||||
} else {
|
||||
/* normal style file */
|
||||
|
||||
style = PLGetProplistWithPath(file);
|
||||
style = WMReadPropListFromFile(file);
|
||||
if (!style) {
|
||||
perror(file);
|
||||
printf("%s:could not load style file.\n", ProgName);
|
||||
@@ -557,7 +540,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (!PLIsDictionary(style)) {
|
||||
if (!WMIsPLDictionary(style)) {
|
||||
printf("%s: '%s' is not a style file/theme\n", ProgName, file);
|
||||
exit(1);
|
||||
}
|
||||
@@ -566,13 +549,13 @@ main(int argc, char **argv)
|
||||
|
||||
if (ignoreCount > 0) {
|
||||
for (i = 0; i < ignoreCount; i++) {
|
||||
PLRemoveDictionaryEntry(style, PLMakeString(ignoreList[i]));
|
||||
WMRemoveFromPLDictionary(style, WMCreatePLString(ignoreList[i]));
|
||||
}
|
||||
}
|
||||
|
||||
PLMergeDictionaries(prop, style);
|
||||
WMMergePLDictionaries(prop, style);
|
||||
|
||||
PLSave(prop, YES);
|
||||
WMWritePropListToFile(prop, path, True);
|
||||
{
|
||||
XEvent ev;
|
||||
|
||||
@@ -609,14 +592,13 @@ getToken(char *str, int i, char *buf)
|
||||
}
|
||||
|
||||
|
||||
proplist_t
|
||||
static WMPropList*
|
||||
readBlackBoxStyle(char *path)
|
||||
{
|
||||
FILE *f;
|
||||
char buffer[128], char token[128];
|
||||
proplist_t style;
|
||||
proplist_t p;
|
||||
|
||||
WMPropList *style, *p;
|
||||
|
||||
f = fopen(path, "r");
|
||||
if (!f) {
|
||||
perror(path);
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <proplist.h>
|
||||
#include <WINGs/WUtil.h>
|
||||
|
||||
#include <pwd.h>
|
||||
|
||||
|
||||
@@ -83,7 +84,7 @@ void help()
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char path[256];
|
||||
proplist_t key, value, dict;
|
||||
WMPropList *key, *value, *dict;
|
||||
char *gsdir;
|
||||
int i;
|
||||
|
||||
@@ -105,7 +106,7 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
key = PLMakeString(argv[2]);
|
||||
key = WMCreatePLString(argv[2]);
|
||||
|
||||
gsdir = getenv("GNUSTEP_USER_ROOT");
|
||||
if (gsdir) {
|
||||
@@ -119,12 +120,12 @@ int main(int argc, char **argv)
|
||||
strcat(path, "/");
|
||||
strcat(path, argv[1]);
|
||||
|
||||
if ((dict = PLGetProplistWithPath(path)) == NULL)
|
||||
if ((dict = WMReadPropListFromFile(path)) == NULL)
|
||||
return 1; /* bad domain */
|
||||
if ((value = PLGetDictionaryEntry(dict, key)) == NULL)
|
||||
if ((value = WMGetFromPLDictionary(dict, key)) == NULL)
|
||||
return 2; /* bad key */
|
||||
|
||||
printf("%s\n", PLGetString(value));
|
||||
printf("%s\n", WMGetFromPLString(value));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,8 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <proplist.h>
|
||||
#include <WINGs/WUtil.h>
|
||||
|
||||
#include <pwd.h>
|
||||
|
||||
|
||||
@@ -81,8 +82,8 @@ void help()
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char path[256];
|
||||
proplist_t dom, key, value, dict;
|
||||
char *path;
|
||||
WMPropList *dom, *key, *value, *dict;
|
||||
char *gsdir;
|
||||
int i;
|
||||
|
||||
@@ -104,36 +105,35 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
dom = PLMakeString(argv[1]);
|
||||
key = PLMakeString(argv[2]);
|
||||
value = PLGetProplistWithDescription(argv[3]);
|
||||
dom = WMCreatePLString(argv[1]);
|
||||
key = WMCreatePLString(argv[2]);
|
||||
value = WMCreatePropListFromDescription(argv[3]);
|
||||
if (!value) {
|
||||
printf("%s:syntax error in value \"%s\"", ProgName, argv[3]);
|
||||
exit(1);
|
||||
}
|
||||
gsdir = getenv("GNUSTEP_USER_ROOT");
|
||||
if (gsdir) {
|
||||
strcpy(path, gsdir);
|
||||
path = wstrdup(gsdir);
|
||||
} else {
|
||||
strcpy(path, gethomedir());
|
||||
strcat(path, "/GNUstep");
|
||||
path = wstrdup(gethomedir());
|
||||
path = wstrappend(path, "/GNUstep");
|
||||
}
|
||||
strcat(path, "/");
|
||||
strcat(path, DEFAULTS_DIR);
|
||||
strcat(path, "/");
|
||||
strcat(path, argv[1]);
|
||||
path = wstrappend(path, "/");
|
||||
path = wstrappend(path, DEFAULTS_DIR);
|
||||
path = wstrappend(path, "/");
|
||||
path = wstrappend(path, argv[1]);
|
||||
|
||||
dict = PLGetProplistWithPath(path);
|
||||
dict = WMReadPropListFromFile(path);
|
||||
if (!dict) {
|
||||
dict = PLMakeDictionaryFromEntries(key, value, NULL);
|
||||
PLSetFilename(dict, PLMakeString(path));
|
||||
dict = WMCreatePLDictionary(key, value, NULL);
|
||||
} else {
|
||||
PLRemoveDictionaryEntry(dict, key);
|
||||
PLInsertDictionaryEntry(dict, key, value);
|
||||
WMPutInPLDictionary(dict, key, value);
|
||||
}
|
||||
|
||||
PLSave(dict, YES);
|
||||
|
||||
|
||||
WMWritePropListToFile(dict, path, True);
|
||||
wfree(path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
116
util/wmsetbg.c
116
util/wmsetbg.c
@@ -49,7 +49,6 @@
|
||||
#include <WINGs/WINGs.h>
|
||||
#include <wraster.h>
|
||||
|
||||
#include <proplist.h>
|
||||
|
||||
#define PROG_VERSION "wmsetbg (Window Maker) 2.7"
|
||||
|
||||
@@ -121,27 +120,27 @@ BackgroundTexture*
|
||||
parseTexture(RContext *rc, char *text)
|
||||
{
|
||||
BackgroundTexture *texture = NULL;
|
||||
proplist_t texarray;
|
||||
proplist_t val;
|
||||
WMPropList *texarray;
|
||||
WMPropList *val;
|
||||
int count;
|
||||
char *tmp;
|
||||
char *type;
|
||||
|
||||
#define GETSTRORGOTO(val, str, i, label) \
|
||||
val = PLGetArrayElement(texarray, i);\
|
||||
if (!PLIsString(val)) {\
|
||||
val = WMGetFromPLArray(texarray, i);\
|
||||
if (!WMIsPLString(val)) {\
|
||||
wwarning("could not parse texture %s", text);\
|
||||
goto label;\
|
||||
}\
|
||||
str = PLGetString(val)
|
||||
str = WMGetFromPLString(val)
|
||||
|
||||
texarray = PLGetProplistWithDescription(text);
|
||||
if (!texarray || !PLIsArray(texarray)
|
||||
|| (count = PLGetNumberOfElements(texarray)) < 2) {
|
||||
texarray = WMCreatePropListFromDescription(text);
|
||||
if (!texarray || !WMIsPLArray(texarray)
|
||||
|| (count = WMGetPropListItemCount(texarray)) < 2) {
|
||||
|
||||
wwarning("could not parse texture %s", text);
|
||||
if (texarray)
|
||||
PLRelease(texarray);
|
||||
WMReleasePropList(texarray);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -263,8 +262,8 @@ parseTexture(RContext *rc, char *text)
|
||||
memset(colors, 0, sizeof(RColor*)*(count-1));
|
||||
|
||||
for (i = 2; i < count; i++) {
|
||||
val = PLGetArrayElement(texarray, i);
|
||||
if (!PLIsString(val)) {
|
||||
val = WMGetFromPLArray(texarray, i);
|
||||
if (!WMIsPLString(val)) {
|
||||
wwarning("could not parse texture %s", text);
|
||||
|
||||
for (j = 0; colors[j]!=NULL; j++)
|
||||
@@ -272,7 +271,7 @@ parseTexture(RContext *rc, char *text)
|
||||
wfree(colors);
|
||||
goto error;
|
||||
}
|
||||
tmp = PLGetString(val);
|
||||
tmp = WMGetFromPLString(val);
|
||||
|
||||
if (!XParseColor(dpy, DefaultColormap(dpy, scr), tmp, &color)) {
|
||||
wwarning("could not parse color %s in texture %s",
|
||||
@@ -687,7 +686,7 @@ error:
|
||||
if (texture)
|
||||
wfree(texture);
|
||||
if (texarray)
|
||||
PLRelease(texarray);
|
||||
WMReleasePropList(texarray);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -1032,30 +1031,28 @@ globalDefaultsPathForDomain(char *domain)
|
||||
}
|
||||
|
||||
|
||||
proplist_t
|
||||
static WMPropList*
|
||||
getValueForKey(char *domain, char *keyName)
|
||||
{
|
||||
char *path;
|
||||
proplist_t key;
|
||||
proplist_t d;
|
||||
proplist_t val;
|
||||
WMPropList *key, *val, *d;
|
||||
|
||||
key = PLMakeString(keyName);
|
||||
key = WMCreatePLString(keyName);
|
||||
|
||||
/* try to find PixmapPath in user defaults */
|
||||
path = wdefaultspathfordomain(domain);
|
||||
d = PLGetProplistWithPath(path);
|
||||
d = WMReadPropListFromFile(path);
|
||||
if (!d) {
|
||||
wwarning("could not open domain file %s", path);
|
||||
}
|
||||
wfree(path);
|
||||
|
||||
if (d && !PLIsDictionary(d)) {
|
||||
PLRelease(d);
|
||||
if (d && !WMIsPLDictionary(d)) {
|
||||
WMReleasePropList(d);
|
||||
d = NULL;
|
||||
}
|
||||
if (d) {
|
||||
val = PLGetDictionaryEntry(d, key);
|
||||
val = WMGetFromPLDictionary(d, key);
|
||||
} else {
|
||||
val = NULL;
|
||||
}
|
||||
@@ -1066,16 +1063,16 @@ getValueForKey(char *domain, char *keyName)
|
||||
wwarning("could not locate file for domain %s", domain);
|
||||
d = NULL;
|
||||
} else {
|
||||
d = PLGetProplistWithPath(path);
|
||||
d = WMReadPropListFromFile(path);
|
||||
wfree(path);
|
||||
}
|
||||
|
||||
if (d && !PLIsDictionary(d)) {
|
||||
PLRelease(d);
|
||||
if (d && !WMIsPLDictionary(d)) {
|
||||
WMReleasePropList(d);
|
||||
d = NULL;
|
||||
}
|
||||
if (d) {
|
||||
val = PLGetDictionaryEntry(d, key);
|
||||
val = WMGetFromPLDictionary(d, key);
|
||||
|
||||
} else {
|
||||
val = NULL;
|
||||
@@ -1083,11 +1080,11 @@ getValueForKey(char *domain, char *keyName)
|
||||
}
|
||||
|
||||
if (val)
|
||||
PLRetain(val);
|
||||
WMRetainPropList(val);
|
||||
|
||||
PLRelease(key);
|
||||
WMReleasePropList(key);
|
||||
if (d)
|
||||
PLRelease(d);
|
||||
WMReleasePropList(d);
|
||||
|
||||
return val;
|
||||
}
|
||||
@@ -1097,50 +1094,50 @@ getValueForKey(char *domain, char *keyName)
|
||||
char*
|
||||
getPixmapPath(char *domain)
|
||||
{
|
||||
proplist_t val;
|
||||
WMPropList *val;
|
||||
char *ptr, *data;
|
||||
int len, i, count;
|
||||
|
||||
val = getValueForKey(domain, "PixmapPath");
|
||||
|
||||
if (!val || !PLIsArray(val)) {
|
||||
if (!val || !WMIsPLArray(val)) {
|
||||
if (val)
|
||||
PLRelease(val);
|
||||
WMReleasePropList(val);
|
||||
return wstrdup("");
|
||||
}
|
||||
|
||||
count = PLGetNumberOfElements(val);
|
||||
count = WMGetPropListItemCount(val);
|
||||
len = 0;
|
||||
for (i=0; i<count; i++) {
|
||||
proplist_t v;
|
||||
WMPropList *v;
|
||||
|
||||
v = PLGetArrayElement(val, i);
|
||||
if (!v || !PLIsString(v)) {
|
||||
v = WMGetFromPLArray(val, i);
|
||||
if (!v || !WMIsPLString(v)) {
|
||||
continue;
|
||||
}
|
||||
len += strlen(PLGetString(v))+1;
|
||||
len += strlen(WMGetFromPLString(v))+1;
|
||||
}
|
||||
|
||||
ptr = data = wmalloc(len+1);
|
||||
*ptr = 0;
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
proplist_t v;
|
||||
WMPropList *v;
|
||||
|
||||
v = PLGetArrayElement(val, i);
|
||||
if (!v || !PLIsString(v)) {
|
||||
v = WMGetFromPLArray(val, i);
|
||||
if (!v || !WMIsPLString(v)) {
|
||||
continue;
|
||||
}
|
||||
strcpy(ptr, PLGetString(v));
|
||||
strcpy(ptr, WMGetFromPLString(v));
|
||||
|
||||
ptr += strlen(PLGetString(v));
|
||||
ptr += strlen(WMGetFromPLString(v));
|
||||
*ptr = ':';
|
||||
ptr++;
|
||||
}
|
||||
if (i>0)
|
||||
ptr--; *(ptr--) = 0;
|
||||
|
||||
PLRelease(val);
|
||||
WMReleasePropList(val);
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -1216,12 +1213,11 @@ P(" --help show this help and exit");
|
||||
void
|
||||
changeTextureForWorkspace(char *domain, char *texture, int workspace)
|
||||
{
|
||||
proplist_t array;
|
||||
proplist_t val;
|
||||
WMPropList *array, *val;
|
||||
char *value;
|
||||
int j;
|
||||
|
||||
val = PLGetProplistWithDescription(texture);
|
||||
val = WMCreatePropListFromDescription(texture);
|
||||
if (!val) {
|
||||
wwarning("could not parse texture %s", texture);
|
||||
return;
|
||||
@@ -1230,25 +1226,25 @@ changeTextureForWorkspace(char *domain, char *texture, int workspace)
|
||||
array = getValueForKey("WindowMaker", "WorkspaceSpecificBack");
|
||||
|
||||
if (!array) {
|
||||
array = PLMakeArrayFromElements(NULL, NULL);
|
||||
array = WMCreatePLArray(NULL, NULL);
|
||||
}
|
||||
|
||||
j = PLGetNumberOfElements(array);
|
||||
j = WMGetPropListItemCount(array);
|
||||
if (workspace >= j) {
|
||||
proplist_t empty;
|
||||
WMPropList *empty;
|
||||
|
||||
empty = PLMakeArrayFromElements(NULL, NULL);
|
||||
empty = WMCreatePLArray(NULL, NULL);
|
||||
|
||||
while (j++ < workspace-1) {
|
||||
PLAppendArrayElement(array, empty);
|
||||
WMAddToPLArray(array, empty);
|
||||
}
|
||||
PLAppendArrayElement(array, val);
|
||||
WMAddToPLArray(array, val);
|
||||
} else {
|
||||
PLRemoveArrayElement(array, workspace);
|
||||
PLInsertArrayElement(array, val, workspace);
|
||||
WMDeleteFromPLArray(array, workspace);
|
||||
WMInsertInPLArray(array, workspace, val);
|
||||
}
|
||||
|
||||
value = PLGetDescription(array);
|
||||
value = WMGetPropListDescription(array, False);
|
||||
updateDomain(domain, "WorkspaceSpecificBack", value);
|
||||
}
|
||||
|
||||
@@ -1391,15 +1387,15 @@ main(int argc, char **argv)
|
||||
|
||||
PixmapPath = getPixmapPath(domain);
|
||||
if (!smooth) {
|
||||
proplist_t val;
|
||||
WMPropList *val;
|
||||
#if 0 /* some problem with Alpha... TODO: check if its right */
|
||||
val = PLGetDictionaryEntry(domain,
|
||||
PLMakeString("SmoothWorkspaceBack"));
|
||||
val = WMGetFromPLDictionary(domain,
|
||||
WMCreatePLString("SmoothWorkspaceBack"));
|
||||
#else
|
||||
val = getValueForKey(domain, "SmoothWorkspaceBack");
|
||||
#endif
|
||||
|
||||
if (val && PLIsString(val) && strcasecmp(PLGetString(val), "YES")==0)
|
||||
if (val && WMIsPLString(val) && strcasecmp(WMGetFromPLString(val), "YES")==0)
|
||||
smooth = True;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user