Files
wmaker/WINGs/configuration.c
T

123 lines
3.1 KiB
C
Raw Normal View History

1998-09-29 22:36:29 +00:00
#include "WINGsP.h"
#include "wconfig.h"
1998-09-29 22:36:29 +00:00
2000-06-20 23:27:37 +00:00
#include <X11/Xlocale.h>
1998-09-29 22:36:29 +00:00
_WINGsConfiguration WINGsConfiguration;
#define SYSTEM_FONT "Trebuchet MS,Luxi Sans"
#define BOLD_SYSTEM_FONT "Trebuchet MS,Luxi Sans:bold"
#define DEFAULT_FONT_SIZE 12
1998-09-29 22:36:29 +00:00
#define FLOPPY_PATH "/floppy"
1998-09-29 22:36:29 +00:00
2000-04-13 21:24:28 +00:00
static unsigned
getButtonWithName(const char *name, unsigned defaultButton)
{
if (strncmp(name, "Button", 6)==0 && strlen(name)==7) {
switch (name[6]) {
case '1':
return Button1;
case '2':
return Button2;
case '3':
return Button3;
case '4':
return Button4;
case '5':
return Button5;
default:
break;
}
}
return defaultButton;
}
1998-09-29 22:36:29 +00:00
void
W_ReadConfigurations(void)
{
WMUserDefaults *defaults;
memset(&WINGsConfiguration, 0, sizeof(_WINGsConfiguration));
defaults = WMGetStandardUserDefaults();
if (defaults) {
2000-04-13 21:24:28 +00:00
char *buttonName;
unsigned button;
WINGsConfiguration.systemFont =
WMGetUDStringForKey(defaults, "SystemFont");
1998-09-29 22:36:29 +00:00
WINGsConfiguration.boldSystemFont =
WMGetUDStringForKey(defaults, "BoldSystemFont");
WINGsConfiguration.antialiasedText =
WMGetUDBoolForKey(defaults, "AntialiasedText");
WINGsConfiguration.doubleClickDelay =
WMGetUDIntegerForKey(defaults, "DoubleClickTime");
WINGsConfiguration.floppyPath =
WMGetUDStringForKey(defaults, "FloppyPath");
2000-04-13 21:24:28 +00:00
buttonName = WMGetUDStringForKey(defaults, "MouseWheelUp");
if (buttonName) {
button = getButtonWithName(buttonName, Button4);
wfree(buttonName);
2000-04-13 21:24:28 +00:00
} else {
button = Button4;
}
WINGsConfiguration.mouseWheelUp = button;
buttonName = WMGetUDStringForKey(defaults, "MouseWheelDown");
if (buttonName) {
button = getButtonWithName(buttonName, Button5);
wfree(buttonName);
2000-04-13 21:24:28 +00:00
} else {
button = Button5;
}
WINGsConfiguration.mouseWheelDown = button;
if (WINGsConfiguration.mouseWheelDown==WINGsConfiguration.mouseWheelUp) {
WINGsConfiguration.mouseWheelUp = Button4;
WINGsConfiguration.mouseWheelDown = Button5;
}
WINGsConfiguration.defaultFontSize =
2000-04-13 21:24:28 +00:00
WMGetUDIntegerForKey(defaults, "DefaultFontSize");
1998-09-29 22:36:29 +00:00
}
2000-04-13 21:24:28 +00:00
if (!WINGsConfiguration.systemFont) {
WINGsConfiguration.systemFont = SYSTEM_FONT;
1998-09-29 22:36:29 +00:00
}
if (!WINGsConfiguration.boldSystemFont) {
WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT;
1998-09-29 22:36:29 +00:00
}
if (WINGsConfiguration.defaultFontSize == 0) {
WINGsConfiguration.defaultFontSize = DEFAULT_FONT_SIZE;
}
if (!WINGsConfiguration.floppyPath) {
WINGsConfiguration.floppyPath = FLOPPY_PATH;
}
1998-09-29 22:36:29 +00:00
if (WINGsConfiguration.doubleClickDelay == 0) {
WINGsConfiguration.doubleClickDelay = 250;
1998-09-29 22:36:29 +00:00
}
2000-04-13 21:24:28 +00:00
if (WINGsConfiguration.mouseWheelUp == 0) {
WINGsConfiguration.mouseWheelUp = Button4;
2000-04-13 21:24:28 +00:00
}
if (WINGsConfiguration.mouseWheelDown == 0) {
WINGsConfiguration.mouseWheelDown = Button5;
2000-04-13 21:24:28 +00:00
}
1999-10-27 22:32:12 +00:00
1998-09-29 22:36:29 +00:00
}