From: ritsuka Date: Thu, 4 Dec 2014 20:01:48 +0000 (+0000) Subject: MacGui: merged the two browerFile methods. X-Git-Tag: 1.0.0~1713 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3748bca487db26b2bc411545c983a23f196407d0;p=handbrake MacGui: merged the two browerFile methods. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6582 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/macosx/Controller.h b/macosx/Controller.h index d72b1ece5..1cff14375 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -196,8 +196,6 @@ extern NSString *keyTitleTag; - (void) prepareJob; - (IBAction) browseFile: (id) sender; -- (void) browseFileDone: (NSSavePanel *) sheet - returnCode: (int) returnCode contextInfo: (void *) contextInfo; - (IBAction) showPicturePanel: (id) sender; - (IBAction) showPreviewWindow: (id) sender; diff --git a/macosx/Controller.m b/macosx/Controller.m index 39c8e432c..2c8685782 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1678,32 +1678,28 @@ NSString *keyTitleTag = @"keyTitleTag"; #pragma mark - #pragma mark New Output Destination -- (IBAction) browseFile: (id) sender +- (IBAction)browseFile:(id)sender { - /* Open a panel to let the user choose and update the text field */ + // Open a panel to let the user choose and update the text field NSSavePanel * panel = [NSSavePanel savePanel]; - /* We get the current file name and path from the destination field here */ - NSString* destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent]; + + // We get the current file name and path from the destination field here + NSString *destinationDirectory = fDstFile2Field.stringValue.stringByDeletingLastPathComponent; [panel setDirectoryURL:[NSURL fileURLWithPath:destinationDirectory]]; [panel setNameFieldStringValue:[[fDstFile2Field stringValue] lastPathComponent]]; + [panel beginSheetModalForWindow:fWindow completionHandler:^(NSInteger result) { - [self browseFileDone:panel returnCode:(int)result contextInfo:sender]; - }]; -} + if (result == NSFileHandlingPanelOKButton) + { + fDstFile2Field.stringValue = panel.URL.path; -- (void) browseFileDone: (NSSavePanel *) sheet - returnCode: (int) returnCode contextInfo: (void *) contextInfo -{ - if( returnCode == NSOKButton ) - { - [fDstFile2Field setStringValue: [[sheet URL] path]]; - /* Save this path to the prefs so that on next browse destination window it opens there */ - NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent]; - [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"]; - } + // Save this path to the prefs so that on next browse destination window it opens there + NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent]; + [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"]; + } + }]; } - #pragma mark - #pragma mark Main Window Control