Initial mouse wheel code.
[wmaker-crm.git] / WINGs / configuration.c
blob7d9bb1f7e48950b842c504824e382b45db9a7517
3 #include "WINGsP.h"
5 #include <proplist.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-*-*-*-*-*-*-*"
17 static unsigned
18 getButtonWithName(const char *name, unsigned defaultButton)
20 if (strncmp(name, "Button", 6)==0 && strlen(name)==7) {
21 switch (name[6]) {
22 case '1':
23 return Button1;
24 case '2':
25 return Button2;
26 case '3':
27 return Button3;
28 case '4':
29 return Button4;
30 case '5':
31 return Button5;
32 default:
33 break;
37 return defaultButton;
41 void
42 W_ReadConfigurations(void)
44 WMUserDefaults *defaults;
46 memset(&WINGsConfiguration, 0, sizeof(_WINGsConfiguration));
48 defaults = WMGetStandardUserDefaults();
50 if (defaults) {
51 char *buttonName;
52 unsigned button;
54 WINGsConfiguration.systemFont =
55 WMGetUDStringForKey(defaults, "SystemFont");
57 WINGsConfiguration.boldSystemFont =
58 WMGetUDStringForKey(defaults, "BoldSystemFont");
60 WINGsConfiguration.useMultiByte =
61 WMGetUDBoolForKey(defaults, "MultiByteText");
63 WINGsConfiguration.doubleClickDelay =
64 WMGetUDIntegerForKey(defaults, "DoubleClickTime");
66 buttonName = WMGetUDStringForKey(defaults, "MouseWheelUp");
67 if (buttonName) {
68 button = getButtonWithName(buttonName, Button4);
69 free(buttonName);
70 } else {
71 button = Button4;
73 WINGsConfiguration.mouseWheelUp = button;
75 buttonName = WMGetUDStringForKey(defaults, "MouseWheelDown");
76 if (buttonName) {
77 button = getButtonWithName(buttonName, Button5);
78 free(buttonName);
79 } else {
80 button = Button5;
82 WINGsConfiguration.mouseWheelDown = button;
84 if (WINGsConfiguration.mouseWheelDown==WINGsConfiguration.mouseWheelUp) {
85 WINGsConfiguration.mouseWheelUp = Button4;
86 WINGsConfiguration.mouseWheelDown = Button5;
89 WINGsConfiguration.defaultFontSize =
90 WMGetUDIntegerForKey(defaults, "DefaultFontSize");
94 if (!WINGsConfiguration.systemFont) {
95 WINGsConfiguration.systemFont = SYSTEM_FONT;
97 if (!WINGsConfiguration.boldSystemFont) {
98 WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT;
100 if (WINGsConfiguration.doubleClickDelay == 0) {
101 WINGsConfiguration.doubleClickDelay = 250;
103 if (WINGsConfiguration.mouseWheelUp == 0) {
104 WINGsConfiguration.mouseWheelUp = Button4;
106 if (WINGsConfiguration.mouseWheelDown == 0) {
107 WINGsConfiguration.mouseWheelDown = Button5;
109 if (WINGsConfiguration.defaultFontSize == 0) {
110 WINGsConfiguration.defaultFontSize = 12;