- Added support for antialiased text with multibyte languages too.
[wmaker-crm.git] / WINGs / configuration.c
blobb568c35a43c22df1cf280eac5eced21bb25477d7
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 XFTSYSTEM_FONT "-*-arial-medium-r-normal-*-%d-*-*-*-*-*-*-*"
19 #define XFTBOLD_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.antialiasedSystemFont =
69 WMGetUDStringForKey(defaults, "AntialiasedSystemFont");
71 WINGsConfiguration.antialiasedBoldSystemFont =
72 WMGetUDStringForKey(defaults, "AntialiasedBoldSystemFont");
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, "ru", 2) == 0
96 || strncmp(locale, "ko", 2) == 0)) {
98 WINGsConfiguration.useMultiByte = True;
103 WINGsConfiguration.doubleClickDelay =
104 WMGetUDIntegerForKey(defaults, "DoubleClickTime");
106 WINGsConfiguration.floppyPath =
107 WMGetUDStringForKey(defaults, "FloppyPath");
109 buttonName = WMGetUDStringForKey(defaults, "MouseWheelUp");
110 if (buttonName) {
111 button = getButtonWithName(buttonName, Button4);
112 wfree(buttonName);
113 } else {
114 button = Button4;
116 WINGsConfiguration.mouseWheelUp = button;
118 buttonName = WMGetUDStringForKey(defaults, "MouseWheelDown");
119 if (buttonName) {
120 button = getButtonWithName(buttonName, Button5);
121 wfree(buttonName);
122 } else {
123 button = Button5;
125 WINGsConfiguration.mouseWheelDown = button;
127 if (WINGsConfiguration.mouseWheelDown==WINGsConfiguration.mouseWheelUp) {
128 WINGsConfiguration.mouseWheelUp = Button4;
129 WINGsConfiguration.mouseWheelDown = Button5;
132 WINGsConfiguration.defaultFontSize =
133 WMGetUDIntegerForKey(defaults, "DefaultFontSize");
137 if (!WINGsConfiguration.systemFont) {
138 WINGsConfiguration.systemFont = SYSTEM_FONT;
140 if (!WINGsConfiguration.boldSystemFont) {
141 WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT;
143 if (!WINGsConfiguration.antialiasedSystemFont) {
144 WINGsConfiguration.antialiasedSystemFont = XFTSYSTEM_FONT;
146 if (!WINGsConfiguration.antialiasedBoldSystemFont) {
147 WINGsConfiguration.antialiasedBoldSystemFont = XFTBOLD_SYSTEM_FONT;
149 if (!WINGsConfiguration.floppyPath) {
150 WINGsConfiguration.floppyPath = FLOPPY_PATH;
152 if (WINGsConfiguration.doubleClickDelay == 0) {
153 WINGsConfiguration.doubleClickDelay = 250;
155 if (WINGsConfiguration.mouseWheelUp == 0) {
156 WINGsConfiguration.mouseWheelUp = Button4;
158 if (WINGsConfiguration.mouseWheelDown == 0) {
159 WINGsConfiguration.mouseWheelDown = Button5;
161 if (WINGsConfiguration.defaultFontSize == 0) {
162 WINGsConfiguration.defaultFontSize = 12;