-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATAppDelegate.m
More file actions
48 lines (40 loc) · 1.58 KB
/
ATAppDelegate.m
File metadata and controls
48 lines (40 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#import "ATAppDelegate.h"
#import "ATMailDocument.h"
@implementation ATAppDelegate
- (IBAction)newMailSpool:(id)sender
{
[window makeKeyAndOrderFront:nil];
}
- (IBAction)selectSavingFolder:(id)sender
{
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
[oPanel setCanChooseDirectories:YES];
[oPanel beginSheetForDirectory:nil file:nil types:nil modalForWindow:window modalDelegate:self didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:) contextInfo:nil];
}
- (void)openPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
if (returnCode == NSOKButton)
{
NSString *aPath = [[sheet directory] stringByAppendingPathComponent:mailSpoolName];
aPath = [aPath stringByAppendingPathExtension:ATMaillDocumentType];
[self setValue:aPath forKey:@"savingPath"];
}
}
- (IBAction)openNewMailSpool:(id)sender
{
NSError *anError = nil;
ATMailDocument *aDocument = [[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:NO error:&anError];
[aDocument writeToURL:[NSURL fileURLWithPath:savingPath] ofType:ATMaillDocumentType error:&anError];
[aDocument close];
[[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:[NSURL fileURLWithPath:savingPath] display:YES error:&anError];
[window orderOut:nil];
}
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
{
return NO;
}
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
return [[NSDocumentController sharedDocumentController] hasMessageDownloadingDocument] ? NSTerminateCancel : NSTerminateNow;
}
@end