Пример #1
0
void
hackPathInTexture(WMPropList *texture, char *prefix)
{
    WMPropList *type;
    char *t;

    /* get texture type */
    type = WMGetFromPLArray(texture, 0);
    t = WMGetFromPLString(type);
    if (t == NULL)
        return;
    if (strcasecmp(t, "tpixmap")==0
        || strcasecmp(t, "spixmap")==0
        || strcasecmp(t, "mpixmap")==0
        || strcasecmp(t, "cpixmap")==0
        || strcasecmp(t, "tvgradient")==0
        || strcasecmp(t, "thgradient")==0
        || strcasecmp(t, "tdgradient")==0) {
        WMPropList *file;
        char buffer[4018];

        /* get pixmap file path */
        file = WMGetFromPLArray(texture, 1);
        sprintf(buffer, "%s/%s", prefix, WMGetFromPLString(file));
        /* replace path with full path */
        WMDeleteFromPLArray(texture, 1);
        WMInsertInPLArray(texture, 1, WMCreatePLString(buffer));
    } else if (strcasecmp(t, "bitmap") == 0) {
        WMPropList *file;
        char buffer[4018];

        /* get bitmap file path */
        file = WMGetFromPLArray(texture, 1);
        sprintf(buffer, "%s/%s", prefix, WMGetFromPLString(file));
        /* replace path with full path */
        WMDeleteFromPLArray(texture, 1);
        WMInsertInPLArray(texture, 1, WMCreatePLString(buffer));

        /* get mask file path */
        file = WMGetFromPLArray(texture, 2);
        sprintf(buffer, "%s/%s", prefix, WMGetFromPLString(file));
        /* replace path with full path */
        WMDeleteFromPLArray(texture, 2);
        WMInsertInPLArray(texture, 2, WMCreatePLString(buffer));
    }
}
Пример #2
0
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);
}