- Finished moving to the new proplist handling code in WINGs.
[wmaker-crm.git] / WINGs / configuration.c
blobc835427b38caa0d9ef334f2365d88b10ca281812
3 #include "WINGsP.h"
5 #include <X11/Xlocale.h>
8 _WINGsConfiguration WINGsConfiguration;
12 #define SYSTEM_FONT "-*-helvetica-medium-r-normal-*-%d-*-*-*-*-*-*-*,-*-*-medium-r-*-*-%d-*-*-*-*-*-*-*"
14 #define BOLD_SYSTEM_FONT "-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-*-*,-*-*-bold-r-*-*-%d-*-*-*-*-*-*-*"
16 #define FLOPPY_PATH "/floppy"
19 static unsigned
20 getButtonWithName(const char *name, unsigned defaultButton)
22 if (strncmp(name, "Button", 6)==0 && strlen(name)==7) {
23 switch (name[6]) {
24 case '1':
25 return Button1;
26 case '2':
27 return Button2;
28 case '3':
29 return Button3;
30 case '4':
31 return Button4;
32 case '5':
33 return Button5;
34 default:
35 break;
39 return defaultButton;
43 void
44 W_ReadConfigurations(void)
46 WMUserDefaults *defaults;
48 memset(&WINGsConfiguration, 0, sizeof(_WINGsConfiguration));
50 defaults = WMGetStandardUserDefaults();
52 if (defaults) {
53 char *buttonName;
54 unsigned button;
55 char *str;
57 WINGsConfiguration.systemFont =
58 WMGetUDStringForKey(defaults, "SystemFont");
60 WINGsConfiguration.boldSystemFont =
61 WMGetUDStringForKey(defaults, "BoldSystemFont");
63 WINGsConfiguration.useMultiByte = False;
64 str = WMGetUDStringForKey(defaults, "MultiByteText");
65 if (str) {
66 if (strcasecmp(str, "YES") == 0) {
67 WINGsConfiguration.useMultiByte = True;
68 } else if (strcasecmp(str, "AUTO") == 0) {
69 char *locale;
71 /* if it's a multibyte language (japanese, chinese or korean)
72 * then set it to True */
73 locale = setlocale(LC_CTYPE, NULL);
74 if (locale != NULL
75 && (strncmp(locale, "ja", 2) == 0
76 || strncmp(locale, "zh", 2) == 0
77 || strncmp(locale, "ko", 2) == 0)) {
79 WINGsConfiguration.useMultiByte = True;
84 WINGsConfiguration.doubleClickDelay =
85 WMGetUDIntegerForKey(defaults, "DoubleClickTime");
87 WINGsConfiguration.floppyPath =
88 WMGetUDStringForKey(defaults, "FloppyPath");
90 buttonName = WMGetUDStringForKey(defaults, "MouseWheelUp");
91 if (buttonName) {
92 button = getButtonWithName(buttonName, Button4);
93 wfree(buttonName);
94 } else {
95 button = Button4;
97 WINGsConfiguration.mouseWheelUp = button;
99 buttonName = WMGetUDStringForKey(defaults, "MouseWheelDown");
100 if (buttonName) {
101 button = getButtonWithName(buttonName, Button5);
102 wfree(buttonName);
103 } else {
104 button = Button5;
106 WINGsConfiguration.mouseWheelDown = button;
108 if (WINGsConfiguration.mouseWheelDown==WINGsConfiguration.mouseWheelUp) {
109 WINGsConfiguration.mouseWheelUp = Button4;
110 WINGsConfiguration.mouseWheelDown = Button5;
113 WINGsConfiguration.defaultFontSize =
114 WMGetUDIntegerForKey(defaults, "DefaultFontSize");
118 if (!WINGsConfiguration.systemFont) {
119 WINGsConfiguration.systemFont = SYSTEM_FONT;
121 if (!WINGsConfiguration.boldSystemFont) {
122 WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT;
124 if (!WINGsConfiguration.floppyPath) {
125 WINGsConfiguration.floppyPath = FLOPPY_PATH;
127 if (WINGsConfiguration.doubleClickDelay == 0) {
128 WINGsConfiguration.doubleClickDelay = 250;
130 if (WINGsConfiguration.mouseWheelUp == 0) {
131 WINGsConfiguration.mouseWheelUp = Button4;
133 if (WINGsConfiguration.mouseWheelDown == 0) {
134 WINGsConfiguration.mouseWheelDown = Button5;
136 if (WINGsConfiguration.defaultFontSize == 0) {
137 WINGsConfiguration.defaultFontSize = 12;