/*
 * Simple default handler.
 * M. J. Hawley
 * mike@media-lab.mit.edu
 * Copyright (c) November 1991, MIT Media Laboratory.
 */
#import "DefaultHandler.h"
#import <defaults/defaults.h>
#import <appkit/Application.h>

extern id NXApp;

@implementation DefaultHandler

#define appname [NXApp appName]

char TmpDir[1024] = "/tmp";
char ArchiveFormat[1024] = ".tar.Z";
char EyeOffset[1024] = "";
char FirstUsed[1024] = "";
char Cube[1024] = "";
char Axes[1024] = "";

static NXDefaultsVector Defaults = {
/*
    {"TmpDir",  TmpDir},
    {"ArchiveFormat",  ArchiveFormat},
    {"FirstUsed",  FirstUsed},
*/
    {"EyeOffset",  EyeOffset},
    {"Cube",  Cube},
    {"Axes",  Axes},
    {NULL}
};

char *
deflt(char *s){
    return (char *)NXGetDefaultValue(appname,s);
}

+ loadDefaults {
    char *s;
#define l(x,xs) s = deflt(xs); if (s && *s) strcpy(x,s)
/*
    l(TmpDir,"TmpDir");
    l(ArchiveFormat,"ArchiveFormat");
    l(FirstUsed,"FirstUsed");
*/
	l(EyeOffset,"EyeOffset");
    l(Cube,"Cube");
	l(Axes,"Axes");
	return self;
}

+ initialize {
    NXRegisterDefaults(appname, Defaults);
    [self loadDefaults];
    return self;
}

- writeDefaults:sender {
    NXWriteDefaults(appname, Defaults);
    return self;
}

- free {
    [self writeDefaults:self];
    [super free];
    return self;
}
@end
