static WMPropList* getDefaultMenu(_Panel *panel) { WMPropList *menu; char *menuPath, *gspath; gspath = wusergnusteppath(); menuPath = wmalloc(strlen(gspath)+128); sprintf(menuPath, "%s/Library/WindowMaker/plmenu", gspath); menu = WMReadPropListFromFile(menuPath); if (!menu) { char *buffer, *msg; msg = _("Could not open default menu from '%s'"); buffer = wmalloc(strlen(msg) + strlen(menuPath) + 10); sprintf(buffer, msg, menuPath); WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent, _("Error"), buffer, _("OK"), NULL, NULL); wfree(buffer); } wfree(menuPath); return menu; }
int main(int argc, char **argv) { char path[PATH_MAX]; WMPropList *key, *value, *dict; int 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; if (argc != 2) print_help(0, 1); key = WMCreatePLString(argv[1]); snprintf(path, sizeof(path), "%s", wdefaultspathfordomain(argv[0])); dict = WMReadPropListFromFile(path); if (dict == NULL) return 1; /* bad domain */ value = WMGetFromPLDictionary(dict, key); if (value == NULL) return 2; /* bad key */ printf("%s\n", WMGetPropListDescription(value, True)); return 0; }
WDMLoginConfig * LoadConfiguration(char *configFile) { char *filename = configFile ? configFile : DEF_WDMLOGIN_CONFIG; WMPropList *db; WDMLoginConfig *config = NULL; db = WMReadPropListFromFile(filename); if(db == NULL) WDMError("Cannot open config file. Using builtin defaults\n"); if(!WDMCheckPLDictionary(db, &wdmLogin_config, &config)) WDMError("Error parsing config file. Using builtin defaults\n"); if(db) WMReleasePropList(db); return config; }
static void showData(_Panel *panel) { char *gspath; char *menuPath; WMPropList *pmenu; gspath = wusergnusteppath(); menuPath = wmalloc(strlen(gspath)+32); strcpy(menuPath, gspath); strcat(menuPath, "/Defaults/WMRootMenu"); pmenu = WMReadPropListFromFile(menuPath); 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; buildMenuFromPL(panel, pmenu); WMReleasePropList(pmenu); }
static WMPropList *getDefaultMenu(_Panel * panel) { WMPropList *menu; static const char menuPath[] = WMAKER_RESOURCE_PATH "/plmenu"; menu = WMReadPropListFromFile(menuPath); if (!menu) { char *buffer, *msg; msg = _("Could not open default menu from '%s'"); buffer = wmalloc(strlen(msg) + strlen(menuPath) + 10); sprintf(buffer, msg, menuPath); WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent, _("Error"), buffer, _("OK"), NULL, NULL); wfree(buffer); } return menu; }
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); }
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; }
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; }
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); }