|
TOC | PREV | NEXT
//
// GIFPrefs.h
//
#import <AppKit/AppKit.h>
@interface GIFPrefs : NSObject
{
id delayField;
id disposalMatrix;
id loopField;
id loopMatrix;
id openBrowserSwitch;
id transField;
id folderField;
id window;
}
+ (GIFPrefs *)sharedDefaults;
- (void)loadDefaults:(id)sender;
- (void)ok:(id)sender;
- (void)orderFront:(id)sender;
- (void)restoreFactorySettings:(id)sender;
- (void)chooseDefaultFolder:(id)sender;
@end
#define DEF_DELAY @"Delay"
#define DEF_LOOP_METHOD @"LoopMethod"
#define DEF_LOOPS @"NumberLoops"
#define DEF_TRANS @"TransparentColor"
#define DEF_USE_BROWSER @"OpenInBrowser"
#define DEF_DISPOSAL @"DisposalMethod"
#define DEF_DIRECTORY @"CreationFolder"
//
// GifPrefs.m
//
#import "GIFPrefs.h"
#import "../GIFfun.h"
#import "../GifController.h"
@implementation GIFPrefs
+ (void)loadDictionary:(NSMutableDictionary *)registrationDict
{
[registrationDict setObject:@"20" forKey:DEF_DELAY];
[registrationDict setObject:@"2" forKey:DEF_LOOP_METHOD];
[registrationDict setObject:@"25" forKey:DEF_LOOPS];
[registrationDict setObject:@"" forKey:DEF_TRANS];
[registrationDict setObject:@"yes" forKey:DEF_USE_BROWSER];
[registrationDict setObject:@"0" forKey:DEF_DISPOSAL];
[registrationDict setObject:@"" forKey:DEF_DIRECTORY];
}
+ (void)initialize
{
NSMutableDictionary *registrationDict = [NSMutableDictionary dictionary];
[self loadDictionary:registrationDict];
[[NSUserDefaults standardUserDefaults] registerDefaults:registrationDict];
}
- init
{
[super init];
return self;
}
static GIFPrefs *unique = nil;
+ (GIFPrefs *)sharedDefaults
{
if (!unique) {
unique = [[self alloc]init];
}
return unique;
}
- (void)ok:(id)sender
{
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
[ud setInteger:[delayField intValue] forKey:DEF_DELAY];
[ud setInteger:[disposalMatrix selectedTag] forKey:DEF_DISPOSAL];
[ud setInteger:[loopField intValue] forKey:DEF_LOOPS];
[ud setInteger:[loopMatrix selectedTag] forKey:DEF_LOOP_METHOD];
[ud setBool:[openBrowserSwitch state] forKey:DEF_USE_BROWSER];
[ud setObject:[transField stringValue] forKey:DEF_TRANS];
[ud setObject:[folderField stringValue] forKey:DEF_DIRECTORY];
}
- (void)loadDefaults:(id)sender;
{
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
[delayField setIntValue:[ud integerForKey:DEF_DELAY]];
[disposalMatrix selectCellWithTag:[ud integerForKey:DEF_DISPOSAL]];
[loopField setIntValue:[ud integerForKey:DEF_LOOPS]];
[loopMatrix selectCellWithTag:[ud integerForKey:DEF_LOOP_METHOD]];
[openBrowserSwitch setState:[ud boolForKey:DEF_USE_BROWSER]];
[transField setStringValue:[ud stringForKey:DEF_TRANS]];
[folderField setStringValue:[ud stringForKey:DEF_DIRECTORY]];
}
- (void)orderFront:(id)sender
{
if (window == nil) [NSBundle loadNibNamed:@"GIFPrefs.nib" owner:self];
[self loadDefaults:self];
[window makeKeyAndOrderFront:self];
}
- (void)restoreFactorySettings:(id)sender
{
[delayField setIntValue:20];
[disposalMatrix selectCellWithTag:0];
[loopField setIntValue:25];
[loopMatrix selectCellWithTag:2];
[openBrowserSwitch setState:1];
[transField setStringValue:@""];
[folderField setStringValue:[[NSApp delegate]temporaryDirectory]];
[self ok:sender]; // and save them...
}
- (void)chooseDefaultFolder:(id)sender;
{
NSOpenPanel *op = [NSOpenPanel openPanel];
NSString *s = [[NSUserDefaults standardUserDefaults]stringForKey:DEF_DIRECTORY];
if (!s || [s isEqualToString:@""])
s = [[NSApp delegate]temporaryDirectory];
[op setTitle:CHOOSE_DIR];
[op setCanChooseDirectories:YES];
[op setDirectory:s];
if ([op runModal]) {
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
[folderField setStringValue:[op filename]];
[ud setObject:[folderField stringValue] forKey:DEF_DIRECTORY];
}
}
@end
TOC | PREV | NEXT
Created by Stone Design's Create on 4/30/1998
|
|