Close the app when the main window is closed. Terminate all in progress downloads when the app is closed.

This commit is contained in:
Paul Chote
2010-11-25 12:52:43 +13:00
parent 2fe7e10750
commit 77a35fd132
5 changed files with 35 additions and 87 deletions

View File

@@ -185,4 +185,29 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
{
NSLog(@"%@",dictionary);
}
#pragma mark Application delegates
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
{
return YES;
}
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
// Todo: show a sheet if downloads are in progress
return NSTerminateNow;
}
- (void)applicationWillTerminate:(NSNotification *)aNotification
{
// Cancel all in-progress downloads
for (NSString *key in downloads)
{
Download *d = [downloads objectForKey:key];
if ([[d status] isEqualToString:@"DOWNLOADING"])
[d cancel];
}
}
@end