added preliminary X Input Methods support
[wmaker-crm.git] / WINGs / configuration.c
blobebc4fc8d33aacb7e50f4cd0bec10d827ee954e5d
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;
57 WINGsConfiguration.systemFont =
58 WMGetUDStringForKey(defaults, "SystemFont");
60 WINGsConfiguration.boldSystemFont =
61 WMGetUDStringForKey(defaults, "BoldSystemFont");
63 WINGsConfiguration.antialiasedText =
64 WMGetUDBoolForKey(defaults, "AntialiasedText");
66 WINGsConfiguration.doubleClickDelay =
67 WMGetUDIntegerForKey(defaults, "DoubleClickTime");
69 WINGsConfiguration.floppyPath =
70 WMGetUDStringForKey(defaults, "FloppyPath");
72 buttonName = WMGetUDStringForKey(defaults, "MouseWheelUp");
73 if (buttonName) {
74 button = getButtonWithName(buttonName, Button4);
75 wfree(buttonName);
76 } else {
77 button = Button4;
79 WINGsConfiguration.mouseWheelUp = button;
81 buttonName = WMGetUDStringForKey(defaults, "MouseWheelDown");
82 if (buttonName) {
83 button = getButtonWithName(buttonName, Button5);
84 wfree(buttonName);
85 } else {
86 button = Button5;
88 WINGsConfiguration.mouseWheelDown = button;
90 if (WINGsConfiguration.mouseWheelDown==WINGsConfiguration.mouseWheelUp) {
91 WINGsConfiguration.mouseWheelUp = Button4;
92 WINGsConfiguration.mouseWheelDown = Button5;
95 WINGsConfiguration.defaultFontSize =
96 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.defaultFontSize == 0) {
106 WINGsConfiguration.defaultFontSize = DEFAULT_FONT_SIZE;
108 if (!WINGsConfiguration.floppyPath) {
109 WINGsConfiguration.floppyPath = FLOPPY_PATH;
111 if (WINGsConfiguration.doubleClickDelay == 0) {
112 WINGsConfiguration.doubleClickDelay = 250;
114 if (WINGsConfiguration.mouseWheelUp == 0) {
115 WINGsConfiguration.mouseWheelUp = Button4;
117 if (WINGsConfiguration.mouseWheelDown == 0) {
118 WINGsConfiguration.mouseWheelDown = Button5;