Skip to content

Commit

Permalink
Remove OakShowSheetForWindow wrapper (10.9)
Browse files Browse the repository at this point in the history
Also removed `OakSheetCallbackDelegate` since it's no longer used now.
  • Loading branch information
rdwampler authored and sorbits committed May 31, 2017
1 parent 30891b1 commit 043a00c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 41 deletions.
1 change: 0 additions & 1 deletion Frameworks/OakAppKit/src/OakAppKit.h
Expand Up @@ -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;
Expand Down
36 changes: 0 additions & 36 deletions Frameworks/OakAppKit/src/OakAppKit.mm
Expand Up @@ -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 =
// ======================
Expand Down
7 changes: 3 additions & 4 deletions Frameworks/document/src/EncodingView.mm
@@ -1,6 +1,5 @@
#import "EncodingView.h"
#import <OakFoundation/NSString Additions.h>
#import <OakAppKit/OakAppKit.h>
#import <OakAppKit/OakEncodingPopUpButton.h>
#import <OakAppKit/OakUIConstructionFunctions.h>
#import <text/hexdump.h>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 043a00c

Please sign in to comment.