static WEditMenu* buildSubmenu(_Panel *panel, WMPropList *pl) { WMScreen *scr = WMWidgetScreen(panel->parent); WEditMenu *menu; WEditMenuItem *item; char *title; WMPropList *tp, *bp; int i; tp = WMGetFromPLArray(pl, 0); title = WMGetFromPLString(tp); menu = WCreateEditMenu(scr, title); for (i = 1; i < WMGetPropListItemCount(pl); i++) { WMPropList *pi; pi = WMGetFromPLArray(pl, i); tp = WMGetFromPLArray(pi, 0); bp = WMGetFromPLArray(pi, 1); title = WMGetFromPLString(tp); if (!bp || WMIsPLArray(bp)) { /* it's a submenu */ WEditMenu *submenu; submenu = buildSubmenu(panel, pi); item = WAddMenuItemWithTitle(menu, title); WSetEditMenuSubmenu(menu, item, submenu); } else { ItemData *data; item = WAddMenuItemWithTitle(menu, title); data = parseCommand(pi); if (panel->markerPix[data->type]) WSetEditMenuItemImage(item, panel->markerPix[data->type]); WSetEditMenuItemData(item, data, (WMCallback*)freeItemData); } } WSetEditMenuAcceptsDrop(menu, True); WSetEditMenuDelegate(menu, &menuDelegate); WMRealizeWidget(menu); return menu; }
static WMPropList* getColor(WMPropList *texture) { WMPropList *value, *type; char *str; type = WMGetFromPLArray(texture, 0); if (!type) return NULL; value = NULL; str = WMGetFromPLString(type); if (strcasecmp(str, "solid")==0) { value = WMGetFromPLArray(texture, 1); } else if (strcasecmp(str, "dgradient")==0 || strcasecmp(str, "hgradient")==0 || strcasecmp(str, "vgradient")==0) { WMPropList *c1, *c2; int r1, g1, b1, r2, g2, b2; char buffer[32]; c1 = WMGetFromPLArray(texture, 1); c2 = WMGetFromPLArray(texture, 2); if (!dpy) { 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 = WMCreatePLString(buffer); } else { value = c1; } } else { XColor color1; XColor color2; XParseColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)), WMGetFromPLString(c1), &color1); XParseColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)), WMGetFromPLString(c2), &color2); sprintf(buffer, "#%02x%02x%02x", (color1.red+color2.red)>>9, (color1.green+color2.green)>>9, (color1.blue+color2.blue)>>9); value = WMCreatePLString(buffer); } } else if (strcasecmp(str, "mdgradient")==0
static int getBool(WMPropList *value) { char *val; if (!WMIsPLString(value)) return 0; if (!(val = WMGetFromPLString(value))) return 0; if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y' || val[0] == 'T' || val[0] == 't' || val[0] == '1')) || (strcasecmp(val, "YES") == 0 || strcasecmp(val, "TRUE") == 0)) { return 1; } else if ((val[1] == '\0' && (val[0] == 'n' || val[0] == 'N' || val[0] == 'F' || val[0] == 'f' || val[0] == '0')) || (strcasecmp(val, "NO") == 0 || strcasecmp(val, "FALSE") == 0)) { return 0; } else { wwarning(_("can't convert \"%s\" to boolean"), val); return 0; } }
char *wfindfileinarray(WMPropList *array, const char *file) { int i; char *path; int len, flen; char *fullpath; if (!file) return NULL; if (*file == '/' || *file == '~' || !array) { if (access(file, F_OK) < 0) { fullpath = wexpandpath(file); if (!fullpath) return NULL; if (access(fullpath, F_OK) < 0) { wfree(fullpath); return NULL; } else { return fullpath; } } else { return wstrdup(file); } } flen = strlen(file); for (i = 0; i < WMGetPropListItemCount(array); i++) { WMPropList *prop; char *p; prop = WMGetFromPLArray(array, i); if (!prop) continue; p = WMGetFromPLString(prop); len = strlen(p); path = wmalloc(len + flen + 2); path = memcpy(path, p, len); path[len] = 0; if (wstrlcat(path, "/", len + flen + 2) >= len + flen + 2 || wstrlcat(path, file, len + flen + 2) >= len + flen + 2) { wfree(path); return NULL; } /* expand tilde */ fullpath = wexpandpath(path); wfree(path); if (fullpath) { /* check if file exists */ if (access(fullpath, F_OK) == 0) { return fullpath; } wfree(fullpath); } } return NULL; }
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)); } }
/* * char *text; * WDMCheckPLString(pl, NULL, &text); */ Bool WDMCheckPLString(WMPropList * pl, void *def, void *target) { char **charptr_target = (char **)target; char *value = (char *)def; WDMDebug("WDMCheckPLString(%p, %p, %p)\n", (void *)pl, def, target); if (pl && WMIsPLString(pl)) { value = WMGetFromPLString(pl); } *charptr_target = value ? wstrdup(value) : value; return True; }
static void showData(_Panel *panel) { WMPropList *array, *val; int i; array = GetObjectForKey("IconPath"); if (!array || !WMIsPLArray(array)) { if (array) wwarning(_("bad value in option IconPath. Using default path list")); addPathToList(panel->icoL, -1, "~/pixmaps"); addPathToList(panel->icoL, -1, "~/GNUstep/Library/Icons"); addPathToList(panel->icoL, -1, "/usr/include/X11/pixmaps"); addPathToList(panel->icoL, -1, "/usr/local/share/WindowMaker/Icons"); addPathToList(panel->icoL, -1, "/usr/local/share/WindowMaker/Pixmaps"); addPathToList(panel->icoL, -1, "/usr/share/WindowMaker/Icons"); } else { for (i=0; i<WMGetPropListItemCount(array); i++) { val = WMGetFromPLArray(array, i); addPathToList(panel->icoL, -1, WMGetFromPLString(val)); } } array = GetObjectForKey("PixmapPath"); if (!array || !WMIsPLArray(array)) { if (array) wwarning(_("bad value in option PixmapPath. Using default path list")); addPathToList(panel->pixL, -1, "~/pixmaps"); addPathToList(panel->pixL, -1, "~/GNUstep/Library/WindowMaker/Pixmaps"); addPathToList(panel->pixL, -1, "/usr/local/share/WindowMaker/Pixmaps"); } else { for (i=0; i<WMGetPropListItemCount(array); i++) { val = WMGetFromPLArray(array, i); addPathToList(panel->pixL, -1, WMGetFromPLString(val)); } } }
/* * Bool bool; * WDMCheckPLBool(pl, True, &bool); */ Bool WDMCheckPLBool(WMPropList * pl, void *def, void *target) { Bool *bool_target = (Bool *) target; char *text = NULL; WDMDebug("WDMCheckPLBool(%p, %p, %p)\n", (void *)pl, def, target); *bool_target = (Bool)(intptr_t) def; if (pl && WMIsPLString(pl)) { text = WMGetFromPLString(pl); if (!strcasecmp(text, "yes")) { *bool_target = True; } else if (!strcasecmp(text, "no")) { *bool_target = False; } } return True; }
static Bool WDMCheckPLUInteger(WMPropList *pl, void *def, void *target) { unsigned int *int_target = (unsigned int *)target; unsigned int int_def = (unsigned int)def; char *text = NULL; char *endptr = NULL; WDMDebug("WDMCheckPLUInteger(%p, %p, %p)\n", (void*)pl, def, target); *int_target = int_def; if(pl && WMIsPLString(pl)) { text = WMGetFromPLString(pl); if(text != NULL) *int_target = strtoul(text, &endptr, 0); } return True; }
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); } } } }
void ParseWindowName(WMPropList *value, char **winstance, char **wclass, const char *where) { char *name; *winstance = *wclass = NULL; if (!WMIsPLString(value)) { wwarning(_("bad window name value in %s state info"), where); return; } name = WMGetFromPLString(value); if (!name || strlen(name) == 0) { wwarning(_("bad window name value in %s state info"), where); return; } UnescapeWM_CLASS(name, winstance, wclass); }
int main(int argc, char **argv) { WMPropList *prop, *style, *key, *val; char *path; int i, ch, theme_too = 0, make_pack = 0; char *style_file = NULL; struct option longopts[] = { { "pack", no_argument, NULL, 'p' }, { "theme-options", no_argument, NULL, 't' }, { "version", no_argument, NULL, 'v' }, { "help", no_argument, NULL, 'h' }, { NULL, 0, NULL, 0 } }; prog_name = argv[0]; while ((ch = getopt_long(argc, argv, "ptvh", 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 'p': make_pack = 1; theme_too = 1; break; case 't': theme_too = 1; case 0: break; default: print_help(0, 1); /* NOTREACHED */ } /* At most one non-option ARGV-element is accepted (the theme name) */ if (argc - optind > 1) print_help(0, 1); if (argc - optind == 1) style_file = argv[argc - 1]; if (make_pack && !style_file) { printf("%s: you must supply a name for the theme pack\n", prog_name); return 1; } WMPLSetCaseSensitive(False); path = wdefaultspathfordomain("WindowMaker"); prop = WMReadPropListFromFile(path); if (!prop) { printf("%s: could not load WindowMaker configuration file \"%s\".\n", prog_name, path); return 1; } /* get global value */ path = wglobaldefaultspathfordomain("WindowMaker"); val = WMReadPropListFromFile(path); if (val) { WMMergePLDictionaries(val, prop, True); WMReleasePropList(prop); prop = val; } style = WMCreatePLDictionary(NULL, NULL); for (i = 0; options[i] != NULL; i++) { key = WMCreatePLString(options[i]); val = WMGetFromPLDictionary(prop, key); if (val) { WMRetainPropList(val); if (isFontOption(options[i])) { char *newfont, *oldfont; oldfont = WMGetFromPLString(val); newfont = convertFont(oldfont, False); /* newfont is a reference to old if conversion is not needed */ if (newfont != oldfont) { WMReleasePropList(val); val = WMCreatePLString(newfont); wfree(newfont); } } WMPutInPLDictionary(style, key, val); WMReleasePropList(val); } WMReleasePropList(key); } val = WMGetFromPLDictionary(prop, WMCreatePLString("PixmapPath")); if (val) PixmapPath = val; if (theme_too) { for (i = 0; theme_options[i] != NULL; i++) { key = WMCreatePLString(theme_options[i]); val = WMGetFromPLDictionary(prop, key); if (val) WMPutInPLDictionary(style, key, val); } } if (make_pack) { char *path; makeThemePack(style, style_file); path = wmalloc(strlen(ThemePath) + 32); strcpy(path, ThemePath); strcat(path, "/style"); WMWritePropListToFile(style, path); wfree(path); } else { if (style_file) { WMWritePropListToFile(style, style_file); } else { puts(WMGetPropListDescription(style, True)); } } return 0; }
static ItemData *parseCommand(WMPropList * item) { ItemData *data = wmalloc(sizeof(ItemData)); WMPropList *p; char *command = NULL; char *parameter = NULL; char *shortcut = NULL; int i = 1; p = WMGetFromPLArray(item, i++); command = WMGetFromPLString(p); if (strcmp(command, "SHORTCUT") == 0) { p = WMGetFromPLArray(item, i++); shortcut = WMGetFromPLString(p); p = WMGetFromPLArray(item, i++); command = WMGetFromPLString(p); } p = WMGetFromPLArray(item, i++); if (p) parameter = WMGetFromPLString(p); if (strcmp(command, "EXEC") == 0 || strcmp(command, "SHEXEC") == 0) { data->type = ExecInfo; data->param.exec.command = wstrdup(parameter); if (shortcut) data->param.exec.shortcut = wstrdup(shortcut); } else if (strcmp(command, "OPEN_MENU") == 0) { char *p; /* * dir menu, menu file * dir WITH * |pipe */ p = parameter; while (isspace(*p) && *p) p++; if (*p == '|') { if (*(p + 1) == '|') { p++; data->param.pipe.cached = 0; } else { data->param.pipe.cached = 1; } data->type = PipeInfo; data->param.pipe.command = wtrimspace(p + 1); } else { char *s; p = wstrdup(p); s = strstr(p, "WITH"); if (s) { char **tokens; char **ctokens; int tokn; int i, j; data->type = DirectoryInfo; *s = '\0'; s += 5; while (*s && isspace(*s)) s++; data->param.directory.command = wstrdup(s); wtokensplit(p, &tokens, &tokn); wfree(p); ctokens = wmalloc(sizeof(char *) * tokn); for (i = 0, j = 0; i < tokn; i++) { if (strcmp(tokens[i], "-noext") == 0) { data->param.directory.stripExt = 1; } else { ctokens[j++] = tokens[i]; } } data->param.directory.directory = wtokenjoin(ctokens, j); wfree(ctokens); wtokenfree(tokens, tokn); } else { data->type = ExternalInfo; data->param.external.path = p; } } } else if (strcmp(command, "OPEN_PLMENU") == 0) { char *p; p = parameter; while (isspace(*p) && *p) p++; if (*p == '|') { if (*(p + 1) == '|') { p++; data->param.pipe.cached = 0; } else { data->param.pipe.cached = 1; } data->type = PLPipeInfo; data->param.pipe.command = wtrimspace(p + 1); } } else if (strcmp(command, "WORKSPACE_MENU") == 0) { data->type = WSMenuInfo; } else if (strcmp(command, "WINDOWS_MENU") == 0) { data->type = WWindowListInfo; } else { int cmd; if (strcmp(command, "ARRANGE_ICONS") == 0) { cmd = 0; } else if (strcmp(command, "HIDE_OTHERS") == 0) { cmd = 1; } else if (strcmp(command, "SHOW_ALL") == 0) { cmd = 2; } else if (strcmp(command, "EXIT") == 0) { cmd = 3; } else if (strcmp(command, "SHUTDOWN") == 0) { cmd = 4; } else if (strcmp(command, "RESTART") == 0) { if (parameter) { cmd = 6; } else { cmd = 5; } } else if (strcmp(command, "SAVE_SESSION") == 0) { cmd = 7; } else if (strcmp(command, "CLEAR_SESSION") == 0) { cmd = 8; } else if (strcmp(command, "REFRESH") == 0) { cmd = 9; } else if (strcmp(command, "INFO_PANEL") == 0) { cmd = 10; } else if (strcmp(command, "LEGAL_PANEL") == 0) { cmd = 11; } else { wwarning(_("unknown command '%s' in menu"), command); wfree(data); return NULL; } data->type = CommandInfo; data->param.command.command = cmd; if (shortcut) data->param.command.shortcut = wstrdup(shortcut); if (parameter) data->param.command.parameter = wstrdup(parameter); } return data; }
static void showData(_Panel * panel) { const char *gspath; char *menuPath, *labelText; char buf[1024]; WMPropList *pmenu; gspath = wusergnusteppath(); menuPath = wmalloc(strlen(gspath) + 32); strcpy(menuPath, gspath); strcat(menuPath, "/Defaults/WMRootMenu"); pmenu = WMReadPropListFromFile(menuPath); /* check if WMRootMenu references another file, and if so, if that file is in proplist format */ while (WMIsPLString(pmenu)) { char *path = NULL; path = wexpandpath(WMGetFromPLString(pmenu)); if (access(path, F_OK) < 0) path = wfindfile(DEF_CONFIG_PATHS, path); /* TODO: if needed, concatenate locale suffix to path. See getLocalizedMenuFile() in src/rootmenu.c. */ if (!path) break; if (access(path, W_OK) < 0) { snprintf(buf, 1024, _("The menu file \"%s\" referenced by " "WMRootMenu is read-only.\n" "You cannot use WPrefs to modify it."), path); WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent, _("Warning"), buf, _("OK"), NULL, NULL); panel->dontSave = True; wfree(path); return; } pmenu = WMReadPropListFromFile(path); menuPath = path; } if (!pmenu || !WMIsPLArray(pmenu)) { int res; res = WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent, _("Warning"), _("The menu file format currently in use is not supported\n" "by this tool. Do you want to discard the current menu\n" "to use this tool?"), _("Yes, Discard and Update"), _("No, Keep Current Menu"), NULL); if (res == WAPRDefault) { pmenu = getDefaultMenu(panel); if (!pmenu) { pmenu = WMCreatePLArray(WMCreatePLString("Applications"), NULL); } } else { panel->dontSave = True; return; } } panel->menuPath = menuPath; snprintf(buf, 1024, _("\n\nWhen saved, the menu will be written to the file\n\"%s\"."), menuPath); labelText = WMGetLabelText(panel->sections[NoInfo][0]); labelText = wstrconcat(labelText, buf); WMSetLabelText(panel->sections[NoInfo][0], labelText); wfree(labelText); buildMenuFromPL(panel, pmenu); WMReleasePropList(pmenu); }
static WEditMenu *buildSubmenu(_Panel * panel, WMPropList * pl) { WMScreen *scr = WMWidgetScreen(panel->parent); WEditMenu *menu; WEditMenuItem *item; char *title; WMPropList *tp, *bp; int i; tp = WMGetFromPLArray(pl, 0); title = WMGetFromPLString(tp); menu = WCreateEditMenu(scr, title); for (i = 1; i < WMGetPropListItemCount(pl); i++) { WMPropList *pi; pi = WMGetFromPLArray(pl, i); tp = WMGetFromPLArray(pi, 0); bp = WMGetFromPLArray(pi, 1); title = WMGetFromPLString(tp); if (!bp || WMIsPLArray(bp)) { /* it's a submenu */ WEditMenu *submenu; submenu = buildSubmenu(panel, pi); item = WAddMenuItemWithTitle(menu, title); WSetEditMenuSubmenu(menu, item, submenu); } else { ItemData *data; data = parseCommand(pi); if (data != NULL) { item = WAddMenuItemWithTitle(menu, title); if (panel->markerPix[data->type]) WSetEditMenuItemImage(item, panel->markerPix[data->type]); WSetEditMenuItemData(item, data, (WMCallback *) freeItemData); } else { char *buf = wmalloc(1024); snprintf(buf, 1024, _("Invalid menu command \"%s\" with label \"%s\" cleared"), WMGetFromPLString(WMGetFromPLArray(pi, 1)), WMGetFromPLString(WMGetFromPLArray(pi, 0))); WMRunAlertPanel(scr, panel->parent, _("Warning"), buf, _("OK"), NULL, NULL); wfree(buf); } } } WSetEditMenuAcceptsDrop(menu, True); WSetEditMenuDelegate(menu, &menuDelegate); WMRealizeWidget(menu); return menu; }
void wWorkspaceRestoreState(WScreen *scr) { WMPropList *parr, *pstr, *wks_state, *clip_state; int i, j; make_keys(); if (w_global.session_state == NULL) return; parr = WMGetFromPLDictionary(w_global.session_state, dWorkspaces); if (!parr) return; for (i = 0; i < WMIN(WMGetPropListItemCount(parr), MAX_WORKSPACES); i++) { wks_state = WMGetFromPLArray(parr, i); if (WMIsPLDictionary(wks_state)) pstr = WMGetFromPLDictionary(wks_state, dName); else pstr = wks_state; if (i >= w_global.workspace.count) wWorkspaceNew(scr); if (w_global.workspace.menu) { wfree(w_global.workspace.menu->entries[i + MC_WORKSPACE1]->text); w_global.workspace.menu->entries[i + MC_WORKSPACE1]->text = wstrdup(WMGetFromPLString(pstr)); w_global.workspace.menu->flags.realized = 0; } wfree(w_global.workspace.array[i]->name); w_global.workspace.array[i]->name = wstrdup(WMGetFromPLString(pstr)); if (!wPreferences.flags.noclip) { int added_omnipresent_icons = 0; clip_state = WMGetFromPLDictionary(wks_state, dClip); if (w_global.workspace.array[i]->clip) wDockDestroy(w_global.workspace.array[i]->clip); w_global.workspace.array[i]->clip = wDockRestoreState(scr, clip_state, WM_CLIP); if (i > 0) wDockHideIcons(w_global.workspace.array[i]->clip); /* We set the global icons here, because scr->workspaces[i]->clip * was not valid in wDockRestoreState(). * There we only set icon->omnipresent to know which icons we * need to set here. */ for (j = 0; j < w_global.workspace.array[i]->clip->max_icons; j++) { WAppIcon *aicon = w_global.workspace.array[i]->clip->icon_array[j]; int k; if (!aicon || !aicon->omnipresent) continue; aicon->omnipresent = 0; if (wClipMakeIconOmnipresent(aicon, True) != WO_SUCCESS) continue; if (i == 0) continue; /* Move this appicon from workspace i to workspace 0 */ w_global.workspace.array[i]->clip->icon_array[j] = NULL; w_global.workspace.array[i]->clip->icon_count--; added_omnipresent_icons++; /* If there are too many omnipresent appicons, we are in trouble */ assert(w_global.workspace.array[0]->clip->icon_count + added_omnipresent_icons <= w_global.workspace.array[0]->clip->max_icons); /* Find first free spot on workspace 0 */ for (k = 0; k < w_global.workspace.array[0]->clip->max_icons; k++) if (w_global.workspace.array[0]->clip->icon_array[k] == NULL) break; w_global.workspace.array[0]->clip->icon_array[k] = aicon; aicon->dock = w_global.workspace.array[0]->clip; } w_global.workspace.array[0]->clip->icon_count += added_omnipresent_icons; } WMPostNotificationName(WMNWorkspaceNameChanged, scr, (void *)(uintptr_t) i); } }
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); }