Avoid icon change to default on winspector save
[wmaker-crm.git] / WINGs / configuration.c
blobc354ebc945a7f0414be105fd059bbeb26ee10ded
2 #include "WINGsP.h"
3 #include "wconfig.h"
5 #include <X11/Xlocale.h>
7 _WINGsConfiguration WINGsConfiguration;
9 #define SYSTEM_FONT "Trebuchet MS,sans serif"
10 #define BOLD_SYSTEM_FONT "Trebuchet MS,sans serif: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;
40 Bool aaIsSet = False;
42 memset(&WINGsConfiguration, 0, sizeof(_WINGsConfiguration));
44 defaults = WMGetStandardUserDefaults();
46 if (defaults) {
47 char *buttonName;
48 WMPropList *val;
49 unsigned button;
51 WINGsConfiguration.systemFont = WMGetUDStringForKey(defaults, "SystemFont");
53 WINGsConfiguration.boldSystemFont = WMGetUDStringForKey(defaults, "BoldSystemFont");
55 val = WMGetUDObjectForKey(defaults, "AntialiasedText");
56 if (val && WMIsPLString(val) && WMGetFromPLString(val)) {
57 aaIsSet = True;
58 WINGsConfiguration.antialiasedText =
59 WMGetUDBoolForKey(defaults, "AntialiasedText");
62 WINGsConfiguration.doubleClickDelay = WMGetUDIntegerForKey(defaults, "DoubleClickTime");
64 WINGsConfiguration.floppyPath = WMGetUDStringForKey(defaults, "FloppyPath");
66 buttonName = WMGetUDStringForKey(defaults, "MouseWheelUp");
67 if (buttonName) {
68 button = getButtonWithName(buttonName, Button4);
69 wfree(buttonName);
70 } else {
71 button = Button4;
73 WINGsConfiguration.mouseWheelUp = button;
75 buttonName = WMGetUDStringForKey(defaults, "MouseWheelDown");
76 if (buttonName) {
77 button = getButtonWithName(buttonName, Button5);
78 wfree(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 = WMGetUDIntegerForKey(defaults, "DefaultFontSize");
92 if (!WINGsConfiguration.systemFont) {
93 WINGsConfiguration.systemFont = SYSTEM_FONT;
95 if (!WINGsConfiguration.boldSystemFont) {
96 WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT;
98 if (WINGsConfiguration.defaultFontSize == 0) {
99 WINGsConfiguration.defaultFontSize = DEFAULT_FONT_SIZE;
101 if (!aaIsSet) {
102 WINGsConfiguration.antialiasedText = True;
104 if (!WINGsConfiguration.floppyPath) {
105 WINGsConfiguration.floppyPath = FLOPPY_PATH;
107 if (WINGsConfiguration.doubleClickDelay == 0) {
108 WINGsConfiguration.doubleClickDelay = 250;
110 if (WINGsConfiguration.mouseWheelUp == 0) {
111 WINGsConfiguration.mouseWheelUp = Button4;
113 if (WINGsConfiguration.mouseWheelDown == 0) {
114 WINGsConfiguration.mouseWheelDown = Button5;