From d9b15a23118ae2b87571d5ee76651c43e348dd91 Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Sat, 10 May 2014 23:42:51 -0500 Subject: [PATCH] WPrefs: WINGs font configuration This patch allows users to edit the two fonts (SystemFont and BoldSystemFont) used in WINGs widgets using WPrefs. Note that changes will not take effect for WINGs applications which are currently running. --- WPrefs.app/FontSimple.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/WPrefs.app/FontSimple.c b/WPrefs.app/FontSimple.c index a124a981..b6cdaf40 100644 --- a/WPrefs.app/FontSimple.c +++ b/WPrefs.app/FontSimple.c @@ -102,6 +102,8 @@ static const struct { "IconTitleFont", N_("Icon Title")}, { "ClipTitleFont", N_("Clip Title")}, { "LargeDisplayFont", N_("Desktop Caption")}, { + "SystemFont", N_("System Font")}, { + "BoldSystemFont", N_("Bold System Font")}, { NULL, NULL},}; static const char *standardSizes[] = { @@ -587,7 +589,19 @@ static void showData(_Panel * panel) if (ofont) wfree(ofont); - font = GetStringForKey(fontOptions[i].option); + if (strcmp(fontOptions[i].option, "SystemFont") == 0 || + strcmp(fontOptions[i].option, "BoldSystemFont") == 0) { + char *path; + WMUserDefaults *defaults; + + path = wdefaultspathfordomain("WMGLOBAL"); + defaults = WMGetDefaultsFromPath(path); + wfree(path); + font = WMGetUDStringForKey(defaults, + fontOptions[i].option); + } else { + font = GetStringForKey(fontOptions[i].option); + } if (font) font = wstrdup(font); WMSetMenuItemRepresentedObject(item, font); @@ -608,7 +622,21 @@ static void storeData(_Panel * panel) font = WMGetMenuItemRepresentedObject(item); if (font && *font) { - SetStringForKey(font, fontOptions[i].option); + if (strcmp(fontOptions[i].option, "SystemFont") == 0 || + strcmp(fontOptions[i].option, "BoldSystemFont") == 0) { + char *path; + WMUserDefaults *defaults; + + path = wdefaultspathfordomain("WMGLOBAL"); + defaults = WMGetDefaultsFromPath(path); + wfree(path); + WMSetUDStringForKey(defaults, + font, + fontOptions[i].option); + WMSaveUserDefaults(defaults); + } else { + SetStringForKey(font, fontOptions[i].option); + } } } }