| Line 39... |
Line 39... |
return @"TruePreviewPreferencesPanel";
|
return @"TruePreviewPreferencesPanel";
|
}
|
}
|
|
|
- (void)willBeDisplayed {
|
- (void)willBeDisplayed {
|
[super willBeDisplayed];
|
[super willBeDisplayed];
|
|
|
// build the list of accounts
|
// build the list of accounts
|
NSDictionary* theAccountDict = [[NSUserDefaults standardUserDefaults] objectForKey:@"TruePreviewAccountSettings"];
|
NSDictionary* theAccountDict = [[NSUserDefaults standardUserDefaults] objectForKey:@"TruePreviewAccountSettings"];
|
NSMutableArray* theAccounts = [NSMutableArray array];
|
NSMutableArray* theAccounts = [NSMutableArray array];
|
NSEnumerator* theEnum = [[[MailAccount remoteAccounts] valueForKey:@"displayName"] objectEnumerator];
|
NSEnumerator* theEnum = [[[NSClassFromString(@"MailAccount") remoteAccounts] valueForKey:@"displayName"] objectEnumerator];
|
NSString* theDisplayName = nil;
|
NSString* theDisplayName = nil;
|
|
|
while (theDisplayName = [theEnum nextObject]) {
|
while (theDisplayName = [theEnum nextObject]) {
|
NSMutableDictionary* theAccount = [[theAccountDict objectForKey:theDisplayName] mutableCopy];
|
NSMutableDictionary* theAccount = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
[theAccounts
|
theDisplayName, @"displayName",
|
addObject:((theAccount == nil)
|
[NSNumber numberWithInt:TRUEPREVIEW_DELAY_DEFAULT], @"delay",
|
? [NSMutableDictionary dictionaryWithObject:theDisplayName forKey:@"displayName"]
|
[NSNumber numberWithInt:TRUEPREVIEW_DELAY_DEFAULT], @"window",
|
: theAccount
|
[NSNumber numberWithInt:TRUEPREVIEW_DELAY_DEFAULT], @"scroll",
|
)
|
nil
|
];
|
];
|
|
|
|
[theAccount addEntriesFromDictionary:[theAccountDict objectForKey:theDisplayName]];
|
|
[theAccounts addObject:theAccount];
|
}
|
}
|
|
|
// watch the array for changes to save the user defaults
|
// watch the array for changes to save the user defaults
|
[theAccounts
|
[theAccounts
|
addObserver:self
|
addObserver:self
|
toObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [theAccounts count])]
|
toObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [theAccounts count])]
|
forKeyPath:@"custom"
|
forKeyPath:@"delay"
|
options:0
|
options:0
|
context:theAccounts
|
context:theAccounts
|
];
|
];
|
[theAccounts
|
[theAccounts
|
addObserver:self
|
addObserver:self
|
toObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [theAccounts count])]
|
toObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [theAccounts count])]
|
forKeyPath:@"delay"
|
forKeyPath:@"window"
|
options:0
|
options:0
|
context:theAccounts
|
context:theAccounts
|
];
|
];
|
|
[theAccounts
|
|
addObserver:self
|
|
toObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [theAccounts count])]
|
|
forKeyPath:@"scroll"
|
|
options:0
|
|
context:theAccounts
|
|
];
|
|
|
[fldAccountArrayController setContent:theAccounts];
|
[fldAccountArrayController setContent:theAccounts];
|
}
|
}
|
|
|
#pragma mark NSKeyValueObserving instance methods
|
#pragma mark NSKeyValueObserving instance methods
|
|
|
| Line 91... |
Line 101... |
while (theAccount = [theAccountEnum nextObject]) {
|
while (theAccount = [theAccountEnum nextObject]) {
|
[theAccountDict setObject:theAccount forKey:[theAccount objectForKey:@"displayName"]];
|
[theAccountDict setObject:theAccount forKey:[theAccount objectForKey:@"displayName"]];
|
}
|
}
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:theAccountDict forKey:@"TruePreviewAccountSettings"];
|
[[NSUserDefaults standardUserDefaults] setObject:theAccountDict forKey:@"TruePreviewAccountSettings"];
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
}
|
}
|
|
|
@end
|
@end
|
|
|
|
|