From 043a00c9343c477abab766c0cff0f3ba6e2cadc6 Mon Sep 17 00:00:00 2001 From: Ronald Wampler Date: Mon, 21 Nov 2016 15:47:26 -0500 Subject: [PATCH] Remove `OakShowSheetForWindow` wrapper (10.9) Also removed `OakSheetCallbackDelegate` since it's no longer used now. --- Frameworks/OakAppKit/src/OakAppKit.h | 1 - Frameworks/OakAppKit/src/OakAppKit.mm | 36 ------------------------- Frameworks/document/src/EncodingView.mm | 7 +++-- 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/Frameworks/OakAppKit/src/OakAppKit.h b/Frameworks/OakAppKit/src/OakAppKit.h index 6a395f7e0d..fa0214313b 100644 --- a/Frameworks/OakAppKit/src/OakAppKit.h +++ b/Frameworks/OakAppKit/src/OakAppKit.h @@ -4,7 +4,6 @@ PUBLIC extern NSString* const OakCursorDidHideNotification; PUBLIC BOOL OakIsAlternateKeyOrMouseEvent (NSUInteger flags = NSAlternateKeyMask, NSEvent* anEvent = [NSApp currentEvent]); -PUBLIC void OakShowSheetForWindow (NSWindow* sheet, NSWindow* window, void(^callback)(NSInteger)); PUBLIC extern NSUInteger const OakMoveMoveReturn; PUBLIC extern NSUInteger const OakMoveAcceptReturn; diff --git a/Frameworks/OakAppKit/src/OakAppKit.mm b/Frameworks/OakAppKit/src/OakAppKit.mm index 8a93d12914..61f7f184a3 100644 --- a/Frameworks/OakAppKit/src/OakAppKit.mm +++ b/Frameworks/OakAppKit/src/OakAppKit.mm @@ -22,42 +22,6 @@ BOOL OakIsAlternateKeyOrMouseEvent (NSUInteger flags, NSEvent* anEvent) return ([anEvent type] == NSLeftMouseUp || [anEvent type] == NSOtherMouseUp || [anEvent type] == NSKeyDown) && (([anEvent modifierFlags] & flags) == flags); } -@interface OakSheetCallbackDelegate : NSObject -@property (nonatomic, copy) void(^callback)(NSInteger); -@property (nonatomic) id retainedSelf; -@end - -@implementation OakSheetCallbackDelegate -- (id)initWithBlock:(void(^)(NSInteger))aBlock -{ - if(self = [super init]) - { - self.callback = aBlock; - self.retainedSelf = self; - } - return self; -} - -- (void)sheetDidEnd:(id)sheetOrAlert returnCode:(NSInteger)returnCode contextInfo:(void*)unused -{ - self.callback(returnCode); - self.retainedSelf = nil; -} -@end - -void OakShowSheetForWindow (NSWindow* sheet, NSWindow* window, void(^callback)(NSInteger)) -{ - if(!window) - { - callback([NSApp runModalForWindow:sheet]); - return; - } - - crash_reporter_info_t info(to_s([NSString stringWithFormat:@"sheet %@, window %@: title ‘%@’, is visible %s, is sheet %s, has sheet %s, delegate %@", sheet, window, window.title, BSTR(window.isVisible), BSTR(window.isSheet), BSTR(window.attachedSheet), window.delegate])); - OakSheetCallbackDelegate* delegate = [[OakSheetCallbackDelegate alloc] initWithBlock:callback]; - [NSApp beginSheet:sheet modalForWindow:window modalDelegate:delegate didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:NULL]; -} - // ====================== // = TableView Movement = // ====================== diff --git a/Frameworks/document/src/EncodingView.mm b/Frameworks/document/src/EncodingView.mm index 96a42dc088..efd453c9f5 100644 --- a/Frameworks/document/src/EncodingView.mm +++ b/Frameworks/document/src/EncodingView.mm @@ -1,6 +1,5 @@ #import "EncodingView.h" #import -#import #import #import #import @@ -236,7 +235,7 @@ - (id)initWithFirst:(char const*)firstPointer last:(char const*)lastPointer - (void)beginSheetModalForWindow:(NSWindow*)aWindow completionHandler:(void(^)(NSModalResponse))callback { [self.window layoutIfNeeded]; - OakShowSheetForWindow(self.window, aWindow, callback); + [aWindow beginSheet:self.window completionHandler:callback]; } - (BOOL)textView:(NSTextView*)aTextView doCommandBySelector:(SEL)aSelector @@ -314,14 +313,14 @@ - (void)cleanup - (IBAction)performOpenDocument:(id)sender { [self.window orderOut:self]; - [NSApp endSheet:self.window returnCode:NSRunStoppedResponse]; + [self.window.sheetParent endSheet:self.window returnCode:NSModalResponseOK]; [self cleanup]; } - (IBAction)performCancelOperation:(id)sender { [self.window orderOut:self]; - [NSApp endSheet:self.window returnCode:NSRunAbortedResponse]; + [self.window.sheetParent endSheet:self.window returnCode:NSModalResponseCancel]; [self cleanup]; } @end