#948 - when processing the blocklist, don't block the gui (Leopard-only)

This commit is contained in:
Mitchell Livingston 2008-05-16 00:25:09 +00:00
parent f0b7932b90
commit 788ccd60d3
1 changed files with 29 additions and 20 deletions

View File

@ -34,6 +34,7 @@
- (id) initWithPrefsController: (PrefsController *) prefsController; - (id) initWithPrefsController: (PrefsController *) prefsController;
- (void) startDownload; - (void) startDownload;
- (void) finishDownloadSuccess;
- (void) updateProcessString; - (void) updateProcessString;
- (void) failureSheetClosed: (NSAlert *) alert returnCode: (int) code contextInfo: (void *) info; - (void) failureSheetClosed: (NSAlert *) alert returnCode: (int) code contextInfo: (void *) info;
@ -108,28 +109,10 @@
- (void) downloadDidFinish: (NSURLDownload *) download - (void) downloadDidFinish: (NSURLDownload *) download
{ {
//change to indeterminate while processing
[fProgressBar setIndeterminate: YES];
[fProgressBar startAnimation: self];
[fTextField setStringValue: [NSLocalizedString(@"Processing blocklist", "Blocklist -> message") stringByAppendingEllipsis]];
[fButton setEnabled: NO];
[fStatusWindow display]; //force window to be updated
//process data
tr_blocklistSetContent([fPrefsController handle], [DESTINATION UTF8String]);
//delete downloaded file
if ([NSApp isOnLeopardOrBetter]) if ([NSApp isOnLeopardOrBetter])
[[NSFileManager defaultManager] removeItemAtPath: DESTINATION error: NULL]; [self performSelectorInBackground: @selector(finishDownloadSuccess) withObject: nil];
else else
[[NSFileManager defaultManager] removeFileAtPath: DESTINATION handler: nil]; [self finishDownloadSuccess];
[fPrefsController updateBlocklistFields];
[NSApp endSheet: fStatusWindow];
[fStatusWindow orderOut: self];
[self release];
} }
@end @end
@ -159,6 +142,32 @@
[fDownload setDestination: DESTINATION allowOverwrite: YES]; [fDownload setDestination: DESTINATION allowOverwrite: YES];
} }
- (void) finishDownloadSuccess
{
//change to indeterminate while processing
[fProgressBar setIndeterminate: YES];
[fProgressBar startAnimation: self];
[fTextField setStringValue: [NSLocalizedString(@"Processing blocklist", "Blocklist -> message") stringByAppendingEllipsis]];
[fButton setEnabled: NO];
[fStatusWindow display]; //force window to be updated
//process data
tr_blocklistSetContent([fPrefsController handle], [DESTINATION UTF8String]);
//delete downloaded file
if ([NSApp isOnLeopardOrBetter])
[[NSFileManager defaultManager] removeItemAtPath: DESTINATION error: NULL];
else
[[NSFileManager defaultManager] removeFileAtPath: DESTINATION handler: nil];
[fPrefsController updateBlocklistFields];
[NSApp endSheet: fStatusWindow];
[fStatusWindow orderOut: self];
[self release];
}
- (void) updateProcessString - (void) updateProcessString
{ {
NSString * string = NSLocalizedString(@"Downloading blocklist", "Blocklist -> message"); NSString * string = NSLocalizedString(@"Downloading blocklist", "Blocklist -> message");