changed API to better reflect behavior

This commit is contained in:
michael starke
2017-05-22 18:10:56 +02:00
parent e8185480f1
commit 69f66f3dd3
3 changed files with 8 additions and 8 deletions

View File

@@ -145,7 +145,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
NSView *contentView = self.window.contentView; NSView *contentView = self.window.contentView;
NSView *oldSubView = nil; NSView *oldSubView = nil;
if(contentView.subviews.count == 1) { if(contentView.subviews.count == 1) {
oldSubView = contentView.subviews[0]; oldSubView = contentView.subviews.firstObject;
} }
if(oldSubView == newContentView) { if(oldSubView == newContentView) {
return; // View is already present return; // View is already present
@@ -165,7 +165,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
[contentView layout]; [contentView layout];
[viewController updateResponderChain]; [viewController updateResponderChain];
[self.window makeFirstResponder:[viewController reconmendedFirstResponder]]; [self.window makeFirstResponder:viewController.reconmendedFirstResponder];
} }
#pragma mark MPDocument notifications #pragma mark MPDocument notifications
@@ -253,9 +253,9 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
[self.document saveDocument:sender]; [self.document saveDocument:sender];
} }
- (void)saveDocumentAs:(id)sender { - (void)saveDocumentAs:(id)sender {
MPDocument *document = [self document]; MPDocument *document = self.document;
if(document.compositeKey) { if(document.compositeKey) {
[[self document] saveDocumentAs:sender]; [self.document saveDocumentAs:sender];
return; return;
} }
/* we need to make sure that a password is set */ /* we need to make sure that a password is set */
@@ -315,7 +315,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
self.fixAutotypeWindowController = [[MPFixAutotypeWindowController alloc] init]; self.fixAutotypeWindowController = [[MPFixAutotypeWindowController alloc] init];
} }
[self.document addWindowController:self.fixAutotypeWindowController]; [self.document addWindowController:self.fixAutotypeWindowController];
[[self.fixAutotypeWindowController window] makeKeyAndOrderFront:sender]; [self.fixAutotypeWindowController.window makeKeyAndOrderFront:sender];
} }
- (void)showPasswordInput { - (void)showPasswordInput {
@@ -324,7 +324,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
} }
[self _setContentViewController:self.passwordInputController]; [self _setContentViewController:self.passwordInputController];
__weak MPDocumentWindowController *welf = self; __weak MPDocumentWindowController *welf = self;
[self.passwordInputController requestPassword:^BOOL(NSString *password, NSURL *keyURL, NSError *__autoreleasing *error) { [self.passwordInputController requestPasswordWithCompletionHandler:^BOOL(NSString *password, NSURL *keyURL, NSError *__autoreleasing *error) {
return [((MPDocument *)welf.document) unlockWithPassword:password keyFileURL:keyURL error:error]; return [((MPDocument *)welf.document) unlockWithPassword:password keyFileURL:keyURL error:error];
}]; }];
} }

View File

@@ -14,6 +14,6 @@
typedef BOOL (^passwordInputCompletionBlock)(NSString *password, NSURL *keyURL, NSError *__autoreleasing*error); typedef BOOL (^passwordInputCompletionBlock)(NSString *password, NSURL *keyURL, NSError *__autoreleasing*error);
- (void)requestPassword:(passwordInputCompletionBlock)completionHandler; - (void)requestPasswordWithCompletionHandler:(passwordInputCompletionBlock)completionHandler;
@end @end

View File

@@ -66,7 +66,7 @@
return self.passwordTextField; return self.passwordTextField;
} }
- (void)requestPassword:(passwordInputCompletionBlock)completionHandler { - (void)requestPasswordWithCompletionHandler:(passwordInputCompletionBlock)completionHandler {
self.completionHandler = completionHandler; self.completionHandler = completionHandler;
[self _reset]; [self _reset];
} }