Made the floppy path in the file panel be configurable via the FloppyPath
[wmaker-crm.git] / WINGs / configuration.c
blob3df6d5bcad20f7e5fad13b12f866fc072e5c1811
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-*-*-*-*-*-*-*"
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;
56 WINGsConfiguration.systemFont =
57 WMGetUDStringForKey(defaults, "SystemFont");
59 WINGsConfiguration.boldSystemFont =
60 WMGetUDStringForKey(defaults, "BoldSystemFont");
62 WINGsConfiguration.useMultiByte =
63 WMGetUDBoolForKey(defaults, "MultiByteText");
65 WINGsConfiguration.doubleClickDelay =
66 WMGetUDIntegerForKey(defaults, "DoubleClickTime");
68 WINGsConfiguration.floppyPath =
69 WMGetUDStringForKey(defaults, "FloppyPath");
71 buttonName = WMGetUDStringForKey(defaults, "MouseWheelUp");
72 if (buttonName) {
73 button = getButtonWithName(buttonName, Button4);
74 free(buttonName);
75 } else {
76 button = Button4;
78 WINGsConfiguration.mouseWheelUp = button;
80 buttonName = WMGetUDStringForKey(defaults, "MouseWheelDown");
81 if (buttonName) {
82 button = getButtonWithName(buttonName, Button5);
83 free(buttonName);
84 } else {
85 button = Button5;
87 WINGsConfiguration.mouseWheelDown = button;
89 if (WINGsConfiguration.mouseWheelDown==WINGsConfiguration.mouseWheelUp) {
90 WINGsConfiguration.mouseWheelUp = Button4;
91 WINGsConfiguration.mouseWheelDown = Button5;
94 WINGsConfiguration.defaultFontSize =
95 WMGetUDIntegerForKey(defaults, "DefaultFontSize");
99 if (!WINGsConfiguration.systemFont) {
100 WINGsConfiguration.systemFont = SYSTEM_FONT;
102 if (!WINGsConfiguration.boldSystemFont) {
103 WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT;
105 if (!WINGsConfiguration.floppyPath) {
106 WINGsConfiguration.floppyPath = FLOPPY_PATH;
108 if (WINGsConfiguration.doubleClickDelay == 0) {
109 WINGsConfiguration.doubleClickDelay = 250;
111 if (WINGsConfiguration.mouseWheelUp == 0) {
112 WINGsConfiguration.mouseWheelUp = Button4;
114 if (WINGsConfiguration.mouseWheelDown == 0) {
115 WINGsConfiguration.mouseWheelDown = Button5;
117 if (WINGsConfiguration.defaultFontSize == 0) {
118 WINGsConfiguration.defaultFontSize = 12;