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"
25 getButtonWithName(const char *name
, unsigned defaultButton
)
27 if (strncmp(name
, "Button", 6)==0 && strlen(name
)==7) {
49 missingOrInvalidXLFD(char *xlfd
)
61 if ((*ptr
=='d' || *ptr
=='i') && count
==0) {
67 } else if (*ptr
==',') {
74 if (xlfd
== WINGsConfiguration
.systemFont
) {
76 } else if (xlfd
== WINGsConfiguration
.boldSystemFont
) {
77 ptr
= "bold system font";
79 ptr
= "Unknown System Font";
81 wwarning(_("Invalid %s specification: '%s' (only %%d is allowed and "
82 "at most once for each font in a fontset)."), ptr
, xlfd
);
90 W_ReadConfigurations(void)
92 WMUserDefaults
*defaults
;
94 memset(&WINGsConfiguration
, 0, sizeof(_WINGsConfiguration
));
96 defaults
= WMGetStandardUserDefaults();
103 WINGsConfiguration
.systemFont
=
104 WMGetUDStringForKey(defaults
, "SystemFont");
106 WINGsConfiguration
.boldSystemFont
=
107 WMGetUDStringForKey(defaults
, "BoldSystemFont");
110 WINGsConfiguration
.antialiasedText
=
111 WMGetUDBoolForKey(defaults
, "AntialiasedText");
113 WINGsConfiguration
.antialiasedText
= False
;
116 WINGsConfiguration
.useMultiByte
= False
;
117 str
= WMGetUDStringForKey(defaults
, "MultiByteText");
119 if (strcasecmp(str
, "YES") == 0) {
120 WINGsConfiguration
.useMultiByte
= True
;
121 } else if (strcasecmp(str
, "AUTO") == 0) {
124 /* if it's a multibyte language (japanese, chinese or korean)
125 * then set it to True */
126 locale
= setlocale(LC_CTYPE
, NULL
);
128 && (strncmp(locale
, "ja", 2) == 0
129 || strncmp(locale
, "zh", 2) == 0
130 || strncmp(locale
, "ru", 2) == 0
131 || strncmp(locale
, "ko", 2) == 0)) {
133 WINGsConfiguration
.useMultiByte
= True
;
138 WINGsConfiguration
.doubleClickDelay
=
139 WMGetUDIntegerForKey(defaults
, "DoubleClickTime");
141 WINGsConfiguration
.floppyPath
=
142 WMGetUDStringForKey(defaults
, "FloppyPath");
144 buttonName
= WMGetUDStringForKey(defaults
, "MouseWheelUp");
146 button
= getButtonWithName(buttonName
, Button4
);
151 WINGsConfiguration
.mouseWheelUp
= button
;
153 buttonName
= WMGetUDStringForKey(defaults
, "MouseWheelDown");
155 button
= getButtonWithName(buttonName
, Button5
);
160 WINGsConfiguration
.mouseWheelDown
= button
;
162 if (WINGsConfiguration
.mouseWheelDown
==WINGsConfiguration
.mouseWheelUp
) {
163 WINGsConfiguration
.mouseWheelUp
= Button4
;
164 WINGsConfiguration
.mouseWheelDown
= Button5
;
167 WINGsConfiguration
.defaultFontSize
=
168 WMGetUDIntegerForKey(defaults
, "DefaultFontSize");
171 if (missingOrInvalidXLFD(WINGsConfiguration
.systemFont
)) {
172 WINGsConfiguration
.systemFont
= SYSTEM_FONT
;
174 if (missingOrInvalidXLFD(WINGsConfiguration
.boldSystemFont
)) {
175 WINGsConfiguration
.boldSystemFont
= BOLD_SYSTEM_FONT
;
177 if (!WINGsConfiguration
.floppyPath
) {
178 WINGsConfiguration
.floppyPath
= FLOPPY_PATH
;
180 if (WINGsConfiguration
.doubleClickDelay
== 0) {
181 WINGsConfiguration
.doubleClickDelay
= 250;
183 if (WINGsConfiguration
.mouseWheelUp
== 0) {
184 WINGsConfiguration
.mouseWheelUp
= Button4
;
186 if (WINGsConfiguration
.mouseWheelDown
== 0) {
187 WINGsConfiguration
.mouseWheelDown
= Button5
;
189 if (WINGsConfiguration
.defaultFontSize
== 0) {
190 WINGsConfiguration
.defaultFontSize
= 12;