Added Xft support in WINGs (for drawing antialiased fonts with transparency)
[wmaker-crm.git] / WINGs / configuration.c
blob92840c40b7a8ccfc9927bdf2404d71816d0f3a52
3 #include "WINGsP.h"
4 #include "wconfig.h"
6 #include <X11/Xlocale.h>
9 _WINGsConfiguration WINGsConfiguration;
13 #define SYSTEM_FONT "-*-helvetica-medium-r-normal-*-%d-*-*-*-*-*-*-*,-*-*-medium-r-*-*-%d-*-*-*-*-*-*-*"
15 #define BOLD_SYSTEM_FONT "-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-*-*,-*-*-bold-r-*-*-%d-*-*-*-*-*-*-*"
17 #define AASYSTEM_FONT "-*-arial-medium-r-normal-*-%d-*-*-*-*-*-*-*"
19 #define AABOLD_SYSTEM_FONT "-*-arial-bold-r-normal-*-%d-*-*-*-*-*-*-*"
21 #define FLOPPY_PATH "/floppy"
24 static unsigned
25 getButtonWithName(const char *name, unsigned defaultButton)
27 if (strncmp(name, "Button", 6)==0 && strlen(name)==7) {
28 switch (name[6]) {
29 case '1':
30 return Button1;
31 case '2':
32 return Button2;
33 case '3':
34 return Button3;
35 case '4':
36 return Button4;
37 case '5':
38 return Button5;
39 default:
40 break;
44 return defaultButton;
48 void
49 W_ReadConfigurations(void)
51 WMUserDefaults *defaults;
53 memset(&WINGsConfiguration, 0, sizeof(_WINGsConfiguration));
55 defaults = WMGetStandardUserDefaults();
57 if (defaults) {
58 char *buttonName;
59 unsigned button;
60 char *str;
62 WINGsConfiguration.systemFont =
63 WMGetUDStringForKey(defaults, "SystemFont");
65 WINGsConfiguration.boldSystemFont =
66 WMGetUDStringForKey(defaults, "BoldSystemFont");
68 WINGsConfiguration.aaSystemFont =
69 WMGetUDStringForKey(defaults, "AASystemFont");
71 WINGsConfiguration.aaBoldSystemFont =
72 WMGetUDStringForKey(defaults, "AABoldSystemFont");
74 #ifdef XFT
75 WINGsConfiguration.antialiasedText =
76 WMGetUDBoolForKey(defaults, "AntialiasedText");
77 #else
78 WINGsConfiguration.antialiasedText = False;
79 #endif
81 WINGsConfiguration.useMultiByte = False;
82 str = WMGetUDStringForKey(defaults, "MultiByteText");
83 if (str) {
84 if (strcasecmp(str, "YES") == 0) {
85 WINGsConfiguration.useMultiByte = True;
86 } else if (strcasecmp(str, "AUTO") == 0) {
87 char *locale;
89 /* if it's a multibyte language (japanese, chinese or korean)
90 * then set it to True */
91 locale = setlocale(LC_CTYPE, NULL);
92 if (locale != NULL
93 && (strncmp(locale, "ja", 2) == 0
94 || strncmp(locale, "zh", 2) == 0
95 || strncmp(locale, "ko", 2) == 0)) {
97 WINGsConfiguration.useMultiByte = True;
102 WINGsConfiguration.doubleClickDelay =
103 WMGetUDIntegerForKey(defaults, "DoubleClickTime");
105 WINGsConfiguration.floppyPath =
106 WMGetUDStringForKey(defaults, "FloppyPath");
108 buttonName = WMGetUDStringForKey(defaults, "MouseWheelUp");
109 if (buttonName) {
110 button = getButtonWithName(buttonName, Button4);
111 wfree(buttonName);
112 } else {
113 button = Button4;
115 WINGsConfiguration.mouseWheelUp = button;
117 buttonName = WMGetUDStringForKey(defaults, "MouseWheelDown");
118 if (buttonName) {
119 button = getButtonWithName(buttonName, Button5);
120 wfree(buttonName);
121 } else {
122 button = Button5;
124 WINGsConfiguration.mouseWheelDown = button;
126 if (WINGsConfiguration.mouseWheelDown==WINGsConfiguration.mouseWheelUp) {
127 WINGsConfiguration.mouseWheelUp = Button4;
128 WINGsConfiguration.mouseWheelDown = Button5;
131 WINGsConfiguration.defaultFontSize =
132 WMGetUDIntegerForKey(defaults, "DefaultFontSize");
136 if (!WINGsConfiguration.systemFont) {
137 WINGsConfiguration.systemFont = SYSTEM_FONT;
139 if (!WINGsConfiguration.boldSystemFont) {
140 WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT;
142 if (!WINGsConfiguration.aaSystemFont) {
143 WINGsConfiguration.aaSystemFont = AASYSTEM_FONT;
145 if (!WINGsConfiguration.aaBoldSystemFont) {
146 WINGsConfiguration.aaBoldSystemFont = AABOLD_SYSTEM_FONT;
148 if (!WINGsConfiguration.floppyPath) {
149 WINGsConfiguration.floppyPath = FLOPPY_PATH;
151 if (WINGsConfiguration.doubleClickDelay == 0) {
152 WINGsConfiguration.doubleClickDelay = 250;
154 if (WINGsConfiguration.mouseWheelUp == 0) {
155 WINGsConfiguration.mouseWheelUp = Button4;
157 if (WINGsConfiguration.mouseWheelDown == 0) {
158 WINGsConfiguration.mouseWheelDown = Button5;
160 if (WINGsConfiguration.defaultFontSize == 0) {
161 WINGsConfiguration.defaultFontSize = 12;