- Changed fallback font to 'sans serif:pixelsize=12'
[wmaker-crm.git] / WINGs / configuration.c
blobcb2dfb9643538d9e884f0d7a2b15a94c66936096
3 #include "WINGsP.h"
4 #include "wconfig.h"
6 #include <X11/Xlocale.h>
9 _WINGsConfiguration WINGsConfiguration;
13 #define SYSTEM_FONT "Trebuchet MS,Luxi Sans"
14 #define BOLD_SYSTEM_FONT "Trebuchet MS,Luxi Sans:bold"
15 #define DEFAULT_FONT_SIZE 12
17 #define FLOPPY_PATH "/floppy"
20 static unsigned
21 getButtonWithName(const char *name, unsigned defaultButton)
23 if (strncmp(name, "Button", 6)==0 && strlen(name)==7) {
24 switch (name[6]) {
25 case '1':
26 return Button1;
27 case '2':
28 return Button2;
29 case '3':
30 return Button3;
31 case '4':
32 return Button4;
33 case '5':
34 return Button5;
35 default:
36 break;
40 return defaultButton;
44 void
45 W_ReadConfigurations(void)
47 WMUserDefaults *defaults;
49 memset(&WINGsConfiguration, 0, sizeof(_WINGsConfiguration));
51 defaults = WMGetStandardUserDefaults();
53 if (defaults) {
54 char *buttonName;
55 unsigned button;
56 char *str;
58 WINGsConfiguration.systemFont =
59 WMGetUDStringForKey(defaults, "SystemFont");
61 WINGsConfiguration.boldSystemFont =
62 WMGetUDStringForKey(defaults, "BoldSystemFont");
64 WINGsConfiguration.antialiasedText =
65 WMGetUDBoolForKey(defaults, "AntialiasedText");
67 WINGsConfiguration.doubleClickDelay =
68 WMGetUDIntegerForKey(defaults, "DoubleClickTime");
70 WINGsConfiguration.floppyPath =
71 WMGetUDStringForKey(defaults, "FloppyPath");
73 buttonName = WMGetUDStringForKey(defaults, "MouseWheelUp");
74 if (buttonName) {
75 button = getButtonWithName(buttonName, Button4);
76 wfree(buttonName);
77 } else {
78 button = Button4;
80 WINGsConfiguration.mouseWheelUp = button;
82 buttonName = WMGetUDStringForKey(defaults, "MouseWheelDown");
83 if (buttonName) {
84 button = getButtonWithName(buttonName, Button5);
85 wfree(buttonName);
86 } else {
87 button = Button5;
89 WINGsConfiguration.mouseWheelDown = button;
91 if (WINGsConfiguration.mouseWheelDown==WINGsConfiguration.mouseWheelUp) {
92 WINGsConfiguration.mouseWheelUp = Button4;
93 WINGsConfiguration.mouseWheelDown = Button5;
96 WINGsConfiguration.defaultFontSize =
97 WMGetUDIntegerForKey(defaults, "DefaultFontSize");
100 if (!WINGsConfiguration.systemFont) {
101 WINGsConfiguration.systemFont = SYSTEM_FONT;
103 if (!WINGsConfiguration.boldSystemFont) {
104 WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT;
106 if (WINGsConfiguration.defaultFontSize == 0) {
107 WINGsConfiguration.defaultFontSize = DEFAULT_FONT_SIZE;
109 if (!WINGsConfiguration.floppyPath) {
110 WINGsConfiguration.floppyPath = FLOPPY_PATH;
112 if (WINGsConfiguration.doubleClickDelay == 0) {
113 WINGsConfiguration.doubleClickDelay = 250;
115 if (WINGsConfiguration.mouseWheelUp == 0) {
116 WINGsConfiguration.mouseWheelUp = Button4;
118 if (WINGsConfiguration.mouseWheelDown == 0) {
119 WINGsConfiguration.mouseWheelDown = Button5;