Update German translation
[wmaker-crm.git] / WINGs / configuration.c
blob8b3d81845f2c4f99665e518eba1b214e02435c98
2 #include "WINGsP.h"
3 #include "wconfig.h"
5 #include <X11/Xlocale.h>
7 _WINGsConfiguration WINGsConfiguration;
9 #define SYSTEM_FONT "Trebuchet MS,Luxi Sans"
10 #define BOLD_SYSTEM_FONT "Trebuchet MS,Luxi Sans:bold"
11 #define DEFAULT_FONT_SIZE 12
13 #define FLOPPY_PATH "/floppy"
15 static unsigned getButtonWithName(const char *name, unsigned defaultButton)
17 if (strncmp(name, "Button", 6) == 0 && strlen(name) == 7) {
18 switch (name[6]) {
19 case '1':
20 return Button1;
21 case '2':
22 return Button2;
23 case '3':
24 return Button3;
25 case '4':
26 return Button4;
27 case '5':
28 return Button5;
29 default:
30 break;
34 return defaultButton;
37 void W_ReadConfigurations(void)
39 WMUserDefaults *defaults;
41 memset(&WINGsConfiguration, 0, sizeof(_WINGsConfiguration));
43 defaults = WMGetStandardUserDefaults();
45 if (defaults) {
46 char *buttonName;
47 unsigned button;
49 WINGsConfiguration.systemFont = WMGetUDStringForKey(defaults, "SystemFont");
51 WINGsConfiguration.boldSystemFont = WMGetUDStringForKey(defaults, "BoldSystemFont");
53 WINGsConfiguration.antialiasedText = WMGetUDBoolForKey(defaults, "AntialiasedText");
55 WINGsConfiguration.doubleClickDelay = WMGetUDIntegerForKey(defaults, "DoubleClickTime");
57 WINGsConfiguration.floppyPath = WMGetUDStringForKey(defaults, "FloppyPath");
59 buttonName = WMGetUDStringForKey(defaults, "MouseWheelUp");
60 if (buttonName) {
61 button = getButtonWithName(buttonName, Button4);
62 wfree(buttonName);
63 } else {
64 button = Button4;
66 WINGsConfiguration.mouseWheelUp = button;
68 buttonName = WMGetUDStringForKey(defaults, "MouseWheelDown");
69 if (buttonName) {
70 button = getButtonWithName(buttonName, Button5);
71 wfree(buttonName);
72 } else {
73 button = Button5;
75 WINGsConfiguration.mouseWheelDown = button;
77 if (WINGsConfiguration.mouseWheelDown == WINGsConfiguration.mouseWheelUp) {
78 WINGsConfiguration.mouseWheelUp = Button4;
79 WINGsConfiguration.mouseWheelDown = Button5;
82 WINGsConfiguration.defaultFontSize = WMGetUDIntegerForKey(defaults, "DefaultFontSize");
85 if (!WINGsConfiguration.systemFont) {
86 WINGsConfiguration.systemFont = SYSTEM_FONT;
88 if (!WINGsConfiguration.boldSystemFont) {
89 WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT;
91 if (WINGsConfiguration.defaultFontSize == 0) {
92 WINGsConfiguration.defaultFontSize = DEFAULT_FONT_SIZE;
94 if (!WINGsConfiguration.floppyPath) {
95 WINGsConfiguration.floppyPath = FLOPPY_PATH;
97 if (WINGsConfiguration.doubleClickDelay == 0) {
98 WINGsConfiguration.doubleClickDelay = 250;
100 if (WINGsConfiguration.mouseWheelUp == 0) {
101 WINGsConfiguration.mouseWheelUp = Button4;
103 if (WINGsConfiguration.mouseWheelDown == 0) {
104 WINGsConfiguration.mouseWheelDown = Button5;