| 1 | /* |
|---|
| 2 | * $Id$ |
|---|
| 3 | * |
|---|
| 4 | * Copyright (C) 2005, 2006 Stephen F. Booth <me@sbooth.org> |
|---|
| 5 | * |
|---|
| 6 | * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | * it under the terms of the GNU General Public License as published by |
|---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | * (at your option) any later version. |
|---|
| 10 | * |
|---|
| 11 | * This program is distributed in the hope that it will be useful, |
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | * GNU General Public License for more details. |
|---|
| 15 | * |
|---|
| 16 | * You should have received a copy of the GNU General Public License |
|---|
| 17 | * along with this program; if not, write to the Free Software |
|---|
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | #import "PreferencesController.h" |
|---|
| 22 | |
|---|
| 23 | static PreferencesController *sharedPreferences = nil; |
|---|
| 24 | |
|---|
| 25 | @implementation PreferencesController |
|---|
| 26 | |
|---|
| 27 | + (void) initialize |
|---|
| 28 | { |
|---|
| 29 | NSMutableDictionary *initialValuesDictionary = [NSMutableDictionary dictionaryWithCapacity:40]; |
|---|
| 30 | NSColor *defaultColor = [NSColor colorWithCalibratedRed:1.0 green:(250.0/255.0) blue:(178.0/255.0) alpha:1.0]; |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | [initialValuesDictionary setObject:[NSNumber numberWithBool:YES] forKey:@"startupVersionCheck"]; |
|---|
| 34 | [initialValuesDictionary setObject:[NSNumber numberWithInt:4096] forKey:@"FLACPadding"]; |
|---|
| 35 | [initialValuesDictionary setObject:[NSArchiver archivedDataWithRootObject:defaultColor] forKey:@"multipleValuesMarkerColor"]; |
|---|
| 36 | [initialValuesDictionary setObject:NSLocalizedStringFromTable(@"<Multiple Values>", @"General", @"") forKey:@"multipleValuesDescription"]; |
|---|
| 37 | |
|---|
| 38 | /* [initialValuesDictionary setObject:nil forKey:@"FLACTag_TITLE"]; |
|---|
| 39 | [initialValuesDictionary setObject:nil forKey:@"FLACTag_ARTIST"]; |
|---|
| 40 | [initialValuesDictionary setObject:nil forKey:@"FLACTag_ALBUM"]; |
|---|
| 41 | [initialValuesDictionary setObject:nil forKey:@"FLACTag_YEAR"]; |
|---|
| 42 | [initialValuesDictionary setObject:nil forKey:@"FLACTag_GENRE"]; |
|---|
| 43 | [initialValuesDictionary setObject:nil forKey:@"FLACTag_COMPOSER"]; |
|---|
| 44 | [initialValuesDictionary setObject:nil forKey:@"FLACTag_MCN"]; |
|---|
| 45 | [initialValuesDictionary setObject:nil forKey:@"FLACTag_ISRC"]; |
|---|
| 46 | [initialValuesDictionary setObject:nil forKey:@"FLACTag_ENCODER"]; |
|---|
| 47 | [initialValuesDictionary setObject:nil forKey:@"FLACTag_DESCRIPTION"]; |
|---|
| 48 | [initialValuesDictionary setObject:nil forKey:@"FLACTag_TRACKNUMBER"]; |
|---|
| 49 | [initialValuesDictionary setObject:nil forKey:@"FLACTag_TRACKTOTAL"]; |
|---|
| 50 | [initialValuesDictionary setObject:nil forKey:@"FLACTag_DISCNUMBER"]; |
|---|
| 51 | [initialValuesDictionary setObject:nil forKey:@"FLACTag_DISCTOTAL"]; |
|---|
| 52 | [initialValuesDictionary setObject:nil forKey:@"FLACTag_COMPILATION"]; |
|---|
| 53 | [initialValuesDictionary setObject:nil forKey:@"FLACTag__CUSTOM"]; |
|---|
| 54 | |
|---|
| 55 | [initialValuesDictionary setObject:nil forKey:@"OggVorbisTag_TITLE"]; |
|---|
| 56 | [initialValuesDictionary setObject:nil forKey:@"OggVorbisTag_ARTIST"]; |
|---|
| 57 | [initialValuesDictionary setObject:nil forKey:@"OggVorbisTag_ALBUM"]; |
|---|
| 58 | [initialValuesDictionary setObject:nil forKey:@"OggVorbisTag_YEAR"]; |
|---|
| 59 | [initialValuesDictionary setObject:nil forKey:@"OggVorbisTag_GENRE"]; |
|---|
| 60 | [initialValuesDictionary setObject:nil forKey:@"OggVorbisTag_COMPOSER"]; |
|---|
| 61 | [initialValuesDictionary setObject:nil forKey:@"OggVorbisTag_MCN"]; |
|---|
| 62 | [initialValuesDictionary setObject:nil forKey:@"OggVorbisTag_ISRC"]; |
|---|
| 63 | [initialValuesDictionary setObject:nil forKey:@"OggVorbisTag_ENCODER"]; |
|---|
| 64 | [initialValuesDictionary setObject:nil forKey:@"OggVorbisTag_DESCRIPTION"]; |
|---|
| 65 | [initialValuesDictionary setObject:nil forKey:@"OggVorbisTag_TRACKNUMBER"]; |
|---|
| 66 | [initialValuesDictionary setObject:nil forKey:@"OggVorbisTag_TRACKTOTAL"]; |
|---|
| 67 | [initialValuesDictionary setObject:nil forKey:@"OggVorbisTag_DISCNUMBER"]; |
|---|
| 68 | [initialValuesDictionary setObject:nil forKey:@"OggVorbisTag_DISCTOTAL"]; |
|---|
| 69 | [initialValuesDictionary setObject:nil forKey:@"OggVorbisTag_COMPILATION"]; |
|---|
| 70 | [initialValuesDictionary setObject:nil forKey:@"OggVorbisTag__CUSTOM"];*/ |
|---|
| 71 | |
|---|
| 72 | [[NSUserDefaultsController sharedUserDefaultsController] setInitialValues:initialValuesDictionary]; |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | + (PreferencesController *) sharedPreferences |
|---|
| 76 | { |
|---|
| 77 | @synchronized(self) { |
|---|
| 78 | if(nil == sharedPreferences) { |
|---|
| 79 | sharedPreferences = [[self alloc] init]; |
|---|
| 80 | } |
|---|
| 81 | } |
|---|
| 82 | return sharedPreferences; |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | + (id) allocWithZone:(NSZone *)zone |
|---|
| 86 | { |
|---|
| 87 | @synchronized(self) { |
|---|
| 88 | if(nil == sharedPreferences) { |
|---|
| 89 | return [super allocWithZone:zone]; |
|---|
| 90 | } |
|---|
| 91 | } |
|---|
| 92 | return sharedPreferences; |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | - (id) init |
|---|
| 96 | { |
|---|
| 97 | if((self = [super initWithWindowNibName:@"Preferences"])) { |
|---|
| 98 | return self; |
|---|
| 99 | } |
|---|
| 100 | return nil; |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | - (id) copyWithZone:(NSZone *)zone { return self; } |
|---|
| 104 | - (id) retain { return self; } |
|---|
| 105 | - (unsigned) retainCount { return UINT_MAX; /* denotes an object that cannot be released */ } |
|---|
| 106 | - (void) release { /* do nothing */ } |
|---|
| 107 | - (id) autorelease { return self; } |
|---|
| 108 | |
|---|
| 109 | - (void) windowDidLoad |
|---|
| 110 | { |
|---|
| 111 | [self setShouldCascadeWindows:NO]; |
|---|
| 112 | [[self window] center]; |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | - (IBAction) revertToInitialValues:(id)sender |
|---|
| 116 | { |
|---|
| 117 | [[NSUserDefaultsController sharedUserDefaultsController] revertToInitialValues:self]; |
|---|
| 118 | } |
|---|
| 119 | @end |
|---|