コード例 #1
0
void
hackPaths(WMPropList *style, char *prefix)
{
    WMPropList *keys;
    WMPropList *key;
    WMPropList *value;
    int i;


    keys = WMGetPLDictionaryKeys(style);

    for (i = 0; i < WMGetPropListItemCount(keys); i++) {
        key = WMGetFromPLArray(keys, i);

        value = WMGetFromPLDictionary(style, key);
        if (!value)
            continue;

        if (strcasecmp(WMGetFromPLString(key), "WorkspaceSpecificBack")==0) {
            if (WMIsPLArray(value)) {
                int j;
                WMPropList *texture;

                for (j = 0; j < WMGetPropListItemCount(value); j++) {
                    texture = WMGetFromPLArray(value, j);

                    if (texture && WMIsPLArray(texture)
                        && WMGetPropListItemCount(texture) > 2) {

                        hackPathInTexture(texture, prefix);
                    }
                }
            }
        } else {

            if (WMIsPLArray(value) && WMGetPropListItemCount(value) > 2) {

                hackPathInTexture(value, prefix);
            }
        }
    }

}
コード例 #2
0
ファイル: geticonset.c プロジェクト: awmaker/awmaker
int main(int argc, char **argv)
{
	WMPropList *window_name, *icon_key, *window_attrs, *icon_value;
	WMPropList *all_windows, *iconset, *keylist;
	char *path;
	int i, ch;

	struct option longopts[] = {
		{ "version",	no_argument,	NULL,		'v' },
		{ "help",	no_argument,	NULL,		'h' },
		{ NULL,		0,		NULL,		0 }
	};

	prog_name = argv[0];
	while ((ch = getopt_long(argc, argv, "hv", longopts, NULL)) != -1)
		switch(ch) {
			case 'v':
				printf("%s (Window Maker %s)\n", prog_name, VERSION);
				return 0;
				/* NOTREACHED */
			case 'h':
				print_help(1, 0);
				/* NOTREACHED */
			case 0:
				break;
			default:
				print_help(0, 1);
				/* NOTREACHED */
		}

	argc -= optind;
	argv += optind;

	path = wdefaultspathfordomain("WMWindowAttributes");

	all_windows = WMReadPropListFromFile(path);
	if (!all_windows) {
		printf("%s: could not load WindowMaker configuration file \"%s\".\n", prog_name, path);
		return 1;
	}

	iconset = WMCreatePLDictionary(NULL, NULL);

	keylist = WMGetPLDictionaryKeys(all_windows);
	icon_key = WMCreatePLString("Icon");

	for (i = 0; i < WMGetPropListItemCount(keylist); i++) {
		WMPropList *icondic;

		window_name = WMGetFromPLArray(keylist, i);
		if (!WMIsPLString(window_name))
			continue;

		window_attrs = WMGetFromPLDictionary(all_windows, window_name);
		if (window_attrs && WMIsPLDictionary(window_attrs)) {
			icon_value = WMGetFromPLDictionary(window_attrs, icon_key);
			if (icon_value) {
				icondic = WMCreatePLDictionary(icon_key, icon_value, NULL);
				WMPutInPLDictionary(iconset, window_name, icondic);
			}
		}
	}

	if (argc == 1) {
		WMWritePropListToFile(iconset, argv[0]);
	} else {
		puts(WMGetPropListDescription(iconset, True));
	}
	return 0;
}
コード例 #3
0
ファイル: getstyle.c プロジェクト: awmaker/awmaker
static void makeThemePack(WMPropList * style, const char *themeName)
{
	WMPropList *keys;
	WMPropList *key;
	WMPropList *value;
	int i;
	size_t themeNameLen;
	char *themeDir;
	const char *user_base;

	user_base = wusergnusteppath();
	if (user_base == NULL)
		return;
	themeNameLen = strlen(user_base) + sizeof(THEME_SUBPATH) + strlen(themeName) + sizeof(THEME_EXTDIR) + 1;
	themeDir = wmalloc(themeNameLen);
	snprintf(themeDir, themeNameLen,
	         "%s" THEME_SUBPATH "%s" THEME_EXTDIR,
	         user_base, themeName);
	ThemePath = themeDir;

	if (!wmkdirhier(themeDir)) {
		wwarning("Could not make theme dir %s\n", themeDir);
		return;
	}

	keys = WMGetPLDictionaryKeys(style);

	for (i = 0; i < WMGetPropListItemCount(keys); i++) {
		key = WMGetFromPLArray(keys, i);

		value = WMGetFromPLDictionary(style, key);
		if (value && WMIsPLArray(value) && WMGetPropListItemCount(value) > 2) {
			WMPropList *type;
			char *t;

			type = WMGetFromPLArray(value, 0);
			t = WMGetFromPLString(type);
			if (t == NULL)
				continue;

			if (strcasecmp(t, "tpixmap") == 0 ||
			    strcasecmp(t, "spixmap") == 0 ||
			    strcasecmp(t, "cpixmap") == 0 ||
			    strcasecmp(t, "mpixmap") == 0 ||
			    strcasecmp(t, "tdgradient") == 0 ||
			    strcasecmp(t, "tvgradient") == 0 ||
			    strcasecmp(t, "thgradient") == 0) {

				WMPropList *file;
				char *p;
				char *newPath;

				file = WMGetFromPLArray(value, 1);

				p = strrchr(WMGetFromPLString(file), '/');
				if (p) {
					newPath = wstrdup(p + 1);

					wcopy_file(themeDir, WMGetFromPLString(file), newPath);

					WMDeleteFromPLArray(value, 1);
					WMInsertInPLArray(value, 1, WMCreatePLString(newPath));
					free(newPath);
				} else {
					findCopyFile(themeDir, WMGetFromPLString(file));
				}
			} else if (strcasecmp(t, "bitmap") == 0) {

				WMPropList *file;
				char *p;
				char *newPath;

				file = WMGetFromPLArray(value, 1);

				p = strrchr(WMGetFromPLString(file), '/');
				if (p) {
					newPath = wstrdup(p + 1);

					wcopy_file(themeDir, WMGetFromPLString(file), newPath);

					WMDeleteFromPLArray(value, 1);
					WMInsertInPLArray(value, 1, WMCreatePLString(newPath));
					free(newPath);
				} else {
					findCopyFile(themeDir, WMGetFromPLString(file));
				}

				file = WMGetFromPLArray(value, 2);

				p = strrchr(WMGetFromPLString(file), '/');
				if (p) {
					newPath = wstrdup(p + 1);

					wcopy_file(themeDir, WMGetFromPLString(file), newPath);

					WMDeleteFromPLArray(value, 2);
					WMInsertInPLArray(value, 2, WMCreatePLString(newPath));
					free(newPath);
				} else {
					findCopyFile(themeDir, WMGetFromPLString(file));
				}
			}
		}
	}
	WMReleasePropList(keys);
}
コード例 #4
0
int
main(int argc, char **argv)
{
    WMPropList *window_name, *icon_key, *window_attrs, *icon_value;
    WMPropList *all_windows, *iconset, *keylist;
    int i;
    char *path = NULL;

    ProgName = argv[0];


    if (argc < 2) {
        printf("%s: missing argument\n", ProgName);
        printf("Try '%s --help' for more information\n", ProgName);
    }

    for (i = 1; i < argc; i++) {
        if (strcmp(argv[i], "-h")==0
            || strcmp(argv[i], "--help")==0) {
            print_help();
            exit(0);
        } else if (strcmp(argv[i], "--version")==0) {
            puts(PROG_VERSION);
            exit(0);
        } else {
            if (path) {
                printf("%s: invalid argument '%s'\n", ProgName, argv[i]);
                printf("Try '%s --help' for more information\n", ProgName);
                exit(1);
            }
            path = argv[i];
        }
    }

    path = defaultsPathForDomain("WMWindowAttributes");

    all_windows = WMReadPropListFromFile(path);
    if (!all_windows) {
        printf("%s:could not load WindowMaker configuration file \"%s\".\n",
               ProgName, path);
        exit(1);
    }

    iconset = WMReadPropListFromFile(argv[1]);
    if (!iconset) {
        printf("%s:could not load icon set file \"%s\".\n", ProgName, argv[1]);
        exit(1);
    }


    keylist = WMGetPLDictionaryKeys(iconset);
    icon_key = WMCreatePLString("Icon");

    for (i=0; i<WMGetPropListItemCount(keylist); i++) {
        window_name = WMGetFromPLArray(keylist, i);
        if (!WMIsPLString(window_name))
            continue;

        icon_value = WMGetFromPLDictionary(iconset, window_name);
        if (!icon_value || !WMIsPLDictionary(icon_value))
            continue;

        window_attrs = WMGetFromPLDictionary(all_windows, window_name);
        if (window_attrs) {
            if (WMIsPLDictionary(window_attrs)) {
                WMMergePLDictionaries(window_attrs, icon_value, True);
            }
        } else {
            WMPutInPLDictionary(all_windows, window_name, icon_value);
        }
    }

    WMWritePropListToFile(all_windows, path, True);

    exit(0);
}