Change to the linux kernel coding style
[wmaker-crm.git] / WINGs / configuration.c
Commit [+]AuthorDateLineData
9d2e6ef9 scottc1998-09-29 22:36:29 +00001
9d2e6ef9 scottc1998-09-29 22:36:29 +00002#include "WINGsP.h"
17f26077 dan2002-10-09 05:14:28 +00003#include "wconfig.h"
9d2e6ef9 scottc1998-09-29 22:36:29 +00004
c49ad9ca kojima2000-06-20 23:27:37 +00005#include <X11/Xlocale.h>
6
9d2e6ef9 scottc1998-09-29 22:36:29 +00007_WINGsConfiguration WINGsConfiguration;
8
d08691d5 dan2004-10-22 22:27:11 +00009#define SYSTEM_FONT "Trebuchet MS,Luxi Sans"
10#define BOLD_SYSTEM_FONT "Trebuchet MS,Luxi Sans:bold"
11#define DEFAULT_FONT_SIZE 12
9d2e6ef9 scottc1998-09-29 22:36:29 +000012
0ae1ecc0 dan2000-05-10 12:30:34 +000013#define FLOPPY_PATH "/floppy"
14
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020015static unsigned getButtonWithName(const char *name, unsigned defaultButton)
5c761670 dan2000-04-13 21:24:28 +000016{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020017 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;
31 }
32 }
33
34 return defaultButton;
5c761670 dan2000-04-13 21:24:28 +000035}
9d2e6ef9 scottc1998-09-29 22:36:29 +000036
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020037void W_ReadConfigurations(void)
9d2e6ef9 scottc1998-09-29 22:36:29 +000038{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020039 WMUserDefaults *defaults;
40
41 memset(&WINGsConfiguration, 0, sizeof(_WINGsConfiguration));
42
43 defaults = WMGetStandardUserDefaults();
44
45 if (defaults) {
46 char *buttonName;
47 unsigned button;
48
49 WINGsConfiguration.systemFont = WMGetUDStringForKey(defaults, "SystemFont");
50
51 WINGsConfiguration.boldSystemFont = WMGetUDStringForKey(defaults, "BoldSystemFont");
52
53 WINGsConfiguration.antialiasedText = WMGetUDBoolForKey(defaults, "AntialiasedText");
54
55 WINGsConfiguration.doubleClickDelay = WMGetUDIntegerForKey(defaults, "DoubleClickTime");
56
57 WINGsConfiguration.floppyPath = WMGetUDStringForKey(defaults, "FloppyPath");
58
59 buttonName = WMGetUDStringForKey(defaults, "MouseWheelUp");
60 if (buttonName) {
61 button = getButtonWithName(buttonName, Button4);
62 wfree(buttonName);
63 } else {
64 button = Button4;
65 }
66 WINGsConfiguration.mouseWheelUp = button;
67
68 buttonName = WMGetUDStringForKey(defaults, "MouseWheelDown");
69 if (buttonName) {
70 button = getButtonWithName(buttonName, Button5);
71 wfree(buttonName);
72 } else {
73 button = Button5;
74 }
75 WINGsConfiguration.mouseWheelDown = button;
76
77 if (WINGsConfiguration.mouseWheelDown == WINGsConfiguration.mouseWheelUp) {
78 WINGsConfiguration.mouseWheelUp = Button4;
79 WINGsConfiguration.mouseWheelDown = Button5;
80 }
81
82 WINGsConfiguration.defaultFontSize = WMGetUDIntegerForKey(defaults, "DefaultFontSize");
83 }
84
85 if (!WINGsConfiguration.systemFont) {
86 WINGsConfiguration.systemFont = SYSTEM_FONT;
87 }
88 if (!WINGsConfiguration.boldSystemFont) {
89 WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT;
90 }
91 if (WINGsConfiguration.defaultFontSize == 0) {
92 WINGsConfiguration.defaultFontSize = DEFAULT_FONT_SIZE;
93 }
94 if (!WINGsConfiguration.floppyPath) {
95 WINGsConfiguration.floppyPath = FLOPPY_PATH;
96 }
97 if (WINGsConfiguration.doubleClickDelay == 0) {
98 WINGsConfiguration.doubleClickDelay = 250;
99 }
100 if (WINGsConfiguration.mouseWheelUp == 0) {
101 WINGsConfiguration.mouseWheelUp = Button4;
102 }
103 if (WINGsConfiguration.mouseWheelDown == 0) {
104 WINGsConfiguration.mouseWheelDown = Button5;
105 }
94f4483d kojima1999-10-27 22:32:12 +0000106
9d2e6ef9 scottc1998-09-29 22:36:29 +0000107}