diff --git a/macosx/Controller.m b/macosx/Controller.m index 3e1eb7ca5..9b72d4c03 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1231,10 +1231,9 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy - (void) urlSheetDidEnd: (URLSheetWindowController *) controller url: (NSString *) urlString returnCode: (NSInteger) returnCode { - if (returnCode != 1) - return; + if (returnCode == 1) + [self performSelectorOnMainThread: @selector(openURL:) withObject: urlString waitUntilDone: NO]; - [self performSelectorOnMainThread: @selector(openURL:) withObject: urlString waitUntilDone: NO]; [controller release]; } diff --git a/macosx/URLSheetWindowController.m b/macosx/URLSheetWindowController.m index 7714f674e..696fef3ef 100644 --- a/macosx/URLSheetWindowController.m +++ b/macosx/URLSheetWindowController.m @@ -25,9 +25,15 @@ #import "URLSheetWindowController.h" #import "Controller.h" +@interface URLSheetWindowController (Private) + +- (BOOL) updateOpenButtonForURL: (NSString *) string; + +@end + @implementation URLSheetWindowController -NSString * urlString = @""; +NSString * urlString = nil; - (id) initWithController: (Controller *) controller { @@ -42,8 +48,13 @@ NSString * urlString = @""; { [fLabelField setStringValue: NSLocalizedString(@"Internet address of torrent file:", "URL sheet label")]; - [fTextField setStringValue: urlString]; - [fTextField selectText: self]; + if (urlString) + { + [fTextField setStringValue: urlString]; + [fTextField selectText: self]; + + [self updateOpenButtonForURL: urlString]; + } [fOpenButton setTitle: NSLocalizedString(@"Open", "URL sheet button")]; [fCancelButton setTitle: NSLocalizedString(@"Cancel", "URL sheet button")]; @@ -57,8 +68,6 @@ NSString * urlString = @""; NSRect cancelFrame = [fCancelButton frame]; cancelFrame.size.width += 10.0; - - if (NSWidth(openFrame) > NSWidth(cancelFrame)) cancelFrame.size.width = NSWidth(openFrame); else @@ -92,13 +101,22 @@ NSString * urlString = @""; - (void) sheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo { - urlString = [fTextField stringValue]; + [urlString release]; + urlString = [[fTextField stringValue] retain]; [fController urlSheetDidEnd: self url: urlString returnCode: returnCode]; } - (void) controlTextDidChange: (NSNotification *) notification { - NSString * string = [fTextField stringValue]; + [self updateOpenButtonForURL: [fTextField stringValue]]; +} + +@end + +@implementation URLSheetWindowController (Private) + +- (BOOL) updateOpenButtonForURL: (NSString *) string +{ BOOL enable = YES; if ([string isEqualToString: @""]) enable = NO;