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 FLOPPY_PATH "/floppy"
21 getButtonWithName(const char *name
, unsigned defaultButton
)
23 if (strncmp(name
, "Button", 6)==0 && strlen(name
)==7) {
46 missingOrInvalidXLFD(char *xlfd
)
58 if ((*ptr
=='d' || *ptr
=='i') && count
==0) {
64 } else if (*ptr
==',') {
71 if (xlfd
== WINGsConfiguration
.systemFont
) {
73 } else if (xlfd
== WINGsConfiguration
.boldSystemFont
) {
74 ptr
= "bold system font";
76 ptr
= "Unknown System Font";
78 wwarning(_("Invalid %s specification: '%s' (only %%d is allowed and "
79 "at most once for each font in a fontset)."), ptr
, xlfd
);
87 W_ReadConfigurations(void)
89 WMUserDefaults
*defaults
;
91 memset(&WINGsConfiguration
, 0, sizeof(_WINGsConfiguration
));
93 defaults
= WMGetStandardUserDefaults();
100 WINGsConfiguration
.systemFont
=
101 WMGetUDStringForKey(defaults
, "SystemFont");
103 WINGsConfiguration
.boldSystemFont
=
104 WMGetUDStringForKey(defaults
, "BoldSystemFont");
106 WINGsConfiguration
.antialiasedText
=
107 WMGetUDBoolForKey(defaults
, "AntialiasedText");
109 WINGsConfiguration
.useMultiByte
= False
;
110 str
= WMGetUDStringForKey(defaults
, "MultiByteText");
112 if (strcasecmp(str
, "YES") == 0) {
113 WINGsConfiguration
.useMultiByte
= True
;
114 } else if (strcasecmp(str
, "AUTO") == 0) {
117 /* if it's a multibyte language (japanese, chinese or korean)
118 * then set it to True */
119 locale
= setlocale(LC_CTYPE
, NULL
);
121 && (strncmp(locale
, "ja", 2) == 0
122 || strncmp(locale
, "zh", 2) == 0
123 || strncmp(locale
, "ru", 2) == 0
124 || strncmp(locale
, "ko", 2) == 0)) {
126 WINGsConfiguration
.useMultiByte
= True
;
131 WINGsConfiguration
.doubleClickDelay
=
132 WMGetUDIntegerForKey(defaults
, "DoubleClickTime");
134 WINGsConfiguration
.floppyPath
=
135 WMGetUDStringForKey(defaults
, "FloppyPath");
137 buttonName
= WMGetUDStringForKey(defaults
, "MouseWheelUp");
139 button
= getButtonWithName(buttonName
, Button4
);
144 WINGsConfiguration
.mouseWheelUp
= button
;
146 buttonName
= WMGetUDStringForKey(defaults
, "MouseWheelDown");
148 button
= getButtonWithName(buttonName
, Button5
);
153 WINGsConfiguration
.mouseWheelDown
= button
;
155 if (WINGsConfiguration
.mouseWheelDown
==WINGsConfiguration
.mouseWheelUp
) {
156 WINGsConfiguration
.mouseWheelUp
= Button4
;
157 WINGsConfiguration
.mouseWheelDown
= Button5
;
160 WINGsConfiguration
.defaultFontSize
=
161 WMGetUDIntegerForKey(defaults
, "DefaultFontSize");
164 if (missingOrInvalidXLFD(WINGsConfiguration
.systemFont
)) {
165 WINGsConfiguration
.systemFont
= SYSTEM_FONT
;
167 if (missingOrInvalidXLFD(WINGsConfiguration
.boldSystemFont
)) {
168 WINGsConfiguration
.boldSystemFont
= BOLD_SYSTEM_FONT
;
170 if (!WINGsConfiguration
.floppyPath
) {
171 WINGsConfiguration
.floppyPath
= FLOPPY_PATH
;
173 if (WINGsConfiguration
.doubleClickDelay
== 0) {
174 WINGsConfiguration
.doubleClickDelay
= 250;
176 if (WINGsConfiguration
.mouseWheelUp
== 0) {
177 WINGsConfiguration
.mouseWheelUp
= Button4
;
179 if (WINGsConfiguration
.mouseWheelDown
== 0) {
180 WINGsConfiguration
.mouseWheelDown
= Button5
;
182 if (WINGsConfiguration
.defaultFontSize
== 0) {
183 WINGsConfiguration
.defaultFontSize
= 12;