Revision: 24071
          http://sourceforge.net/p/bibdesk/svn/24071
Author:   hofman
Date:     2019-07-22 20:28:06 +0000 (Mon, 22 Jul 2019)
Log Message:
-----------
add NSAlert category defining a sheet method using a completion handler block

Modified Paths:
--------------
    trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj

Added Paths:
-----------
    trunk/bibdesk/NSAlert_BDSKExtensions.h
    trunk/bibdesk/NSAlert_BDSKExtensions.m

Modified: trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj
===================================================================
--- trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj     2019-07-22 06:30:25 UTC 
(rev 24070)
+++ trunk/bibdesk/Bibdesk.xcodeproj/project.pbxproj     2019-07-22 20:28:06 UTC 
(rev 24071)
@@ -644,6 +644,8 @@
                CEDD189921696373000E28D7 /* BDSKAutoFileCommand.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CEDD188B21696373000E28D7 /* 
BDSKAutoFileCommand.m */; };
                CEDED0952032450B003FA44D /* BDSKIUCrParser.m in Sources */ = 
{isa = PBXBuildFile; fileRef = CEDED0932032450B003FA44D /* BDSKIUCrParser.m */; 
};
                CEE09F1C216147E1009CE63D /* BDSKFieldInfo.m in Sources */ = 
{isa = PBXBuildFile; fileRef = CEE09F1A216147E1009CE63D /* BDSKFieldInfo.m */; 
};
+               CEE20D9422E64F6900A422FF /* NSAlert_BDSKExtensions.h in Headers 
*/ = {isa = PBXBuildFile; fileRef = CEE20D9222E64F6900A422FF /* 
NSAlert_BDSKExtensions.h */; };
+               CEE20D9522E64F6900A422FF /* NSAlert_BDSKExtensions.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = CEE20D9322E64F6900A422FF /* 
NSAlert_BDSKExtensions.m */; };
                CEE22B210BFB7DA8002B746B /* RelNotes.rtf in Resources */ = {isa 
= PBXBuildFile; fileRef = F994B8F607F5F65F00751DA1 /* RelNotes.rtf */; };
                CEE23BDC0BFBA775002B746B /* Scripts in Copy Files: Shared 
Support */ = {isa = PBXBuildFile; fileRef = CEE23BD50BFBA6D6002B746B /* Scripts 
*/; };
                CEE23BDD0BFBA781002B746B /* Templates in Copy Files: Shared 
Support */ = {isa = PBXBuildFile; fileRef = CE97A3B90A28F19A00CF2DF3 /* 
Templates */; };
@@ -1750,6 +1752,8 @@
                CEDED0932032450B003FA44D /* BDSKIUCrParser.m */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = 
BDSKIUCrParser.m; sourceTree = "<group>"; };
                CEE09F19216147E1009CE63D /* BDSKFieldInfo.h */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BDSKFieldInfo.h; 
sourceTree = "<group>"; };
                CEE09F1A216147E1009CE63D /* BDSKFieldInfo.m */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = 
BDSKFieldInfo.m; sourceTree = "<group>"; };
+               CEE20D9222E64F6900A422FF /* NSAlert_BDSKExtensions.h */ = {isa 
= PBXFileReference; lastKnownFileType = sourcecode.c.h; path = 
NSAlert_BDSKExtensions.h; sourceTree = "<group>"; };
+               CEE20D9322E64F6900A422FF /* NSAlert_BDSKExtensions.m */ = {isa 
= PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = 
NSAlert_BDSKExtensions.m; sourceTree = "<group>"; };
                CEE23BD50BFBA6D6002B746B /* Scripts */ = {isa = 
PBXFileReference; lastKnownFileType = folder; path = Scripts; sourceTree = 
"<group>"; };
                CEE50486104D662500636237 /* BDSKNotesSearchIndex.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= BDSKNotesSearchIndex.m; sourceTree = "<group>"; };
                CEE50488104D664200636237 /* BDSKNotesSearchIndex.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
BDSKNotesSearchIndex.h; sourceTree = "<group>"; };
@@ -2547,6 +2551,7 @@
                CE38FA7D091D210C00BCB69D /* AppKit Extensions */ = {
                        isa = PBXGroup;
                        children = (
+                               CEE20D9322E64F6900A422FF /* 
NSAlert_BDSKExtensions.m */,
                                CED76E2C1A17CCC000D1ACA4 /* 
NSAnimationContext_BDSKExtensions.m */,
                                F97BF0B8090AE7520063504B /* 
NSBezierPath_BDSKExtensions.m */,
                                CEF2EEE50F3462A900A7989E /* 
NSColor_BDSKExtensions.m */,
@@ -3231,6 +3236,7 @@
                                F9025F2E0969D66F008A551C /* 
CFString_BDSKExtensions.h */,
                                CE4476D92128907100DF38E1 /* 
DOMNode_BDSKExtensions.h */,
                                F9022C9B0758038000C3F701 /* html2tex.h */,
+                               CEE20D9222E64F6900A422FF /* 
NSAlert_BDSKExtensions.h */,
                                CED76E2B1A17CCC000D1ACA4 /* 
NSAnimationContext_BDSKExtensions.h */,
                                CE3011B70D5CC4D100C0B7FA /* 
NSAppleEventDescriptor_BDSKExtensions.h */,
                                F99BC25C095A5C7000E018C3 /* 
NSArray_BDSKExtensions.h */,
@@ -3598,6 +3604,7 @@
                                CE2A0A7822459A3100A8F31C /* BDSKSplitView.h in 
Headers */,
                                CE2A09DC224599B300A8F31C /* BDSKConverter.h in 
Headers */,
                                CE2A0A2C224599EF00A8F31C /* BDSKMainTableView.h 
in Headers */,
+                               CEE20D9422E64F6900A422FF /* 
NSAlert_BDSKExtensions.h in Headers */,
                                CE2A0AC522459A4B00A8F31C /* 
NSArray_BDSKExtensions.h in Headers */,
                                CE2A0ABB22459A4500A8F31C /* BibPref_Files.h in 
Headers */,
                                CE2A09FD224599E100A8F31C /* BDSKFilePathCell.h 
in Headers */,
@@ -4286,6 +4293,7 @@
                                F92F4E4F0788DEFC001B8F82 /* BibPref_Files.m in 
Sources */,
                                2730077E07CF20B500F2E485 /* 
BDSKBorderlessKeyWindow.m in Sources */,
                                2730077F07CF20B500F2E485 /* BDSKComplexString.m 
in Sources */,
+                               CEE20D9522E64F6900A422FF /* 
NSAlert_BDSKExtensions.m in Sources */,
                                2730078107CF20B500F2E485 /* 
BDSKComplexStringEditor.m in Sources */,
                                2730078307CF20B500F2E485 /* 
BDSKMacroWindowController.m in Sources */,
                                3D824AA907D099C300FB2F67 /* 
BDSKBackgroundView.m in Sources */,

Added: trunk/bibdesk/NSAlert_BDSKExtensions.h
===================================================================
--- trunk/bibdesk/NSAlert_BDSKExtensions.h                              (rev 0)
+++ trunk/bibdesk/NSAlert_BDSKExtensions.h      2019-07-22 20:28:06 UTC (rev 
24071)
@@ -0,0 +1,48 @@
+//
+//  NSAlert_BDSKExtensions.h
+//  BibDesk
+//
+//  Created by Christiaan Hofman on 22/07/2019.
+/*
+ This software is Copyright (c) 2019
+ Christiaan Hofman. All rights reserved.
+ 
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ 
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+ 
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+#if SDK_BEFORE(10_9)
+@interface NSAlert (BDSKMavericksDeclarations)
+- (void)beginSheetModalForWindow:(NSWindow *)window completionHandler:(void 
(^)(NSInteger result))handler;
+@end
+#endif
+
+@interface NSAlert (BDSKExtensions)
+@end

Added: trunk/bibdesk/NSAlert_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSAlert_BDSKExtensions.m                              (rev 0)
+++ trunk/bibdesk/NSAlert_BDSKExtensions.m      2019-07-22 20:28:06 UTC (rev 
24071)
@@ -0,0 +1,63 @@
+//
+//  NSAlert_BDSKExtensions.m
+//  BibDesk
+//
+//  Created by Christiaan Hofman on 22/07/2019.
+/*
+ This software is Copyright (c) 2019
+ Christiaan Hofman. All rights reserved.
+ 
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ 
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+ 
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "NSAlert_BDSKExtensions.h"
+#import "BDSKRuntime.h"
+
+@implementation NSAlert (BDSKExtensions)
+
+- (void)bdsk_didEndAlert:(NSAlert *)alert returnCode:(NSInteger)returnCode 
contextInfo:(void *)contextInfo {
+    if (contextInfo != NULL) {
+        void (^handler)(NSInteger) = (void(^)(NSInteger))contextInfo;
+        handler(returnCode);
+        Block_release(handler);
+    }
+}
+
+- (void)fallback_beginSheetModalForWindow:(NSWindow *)window 
completionHandler:(void (^)(NSInteger result))handler {
+    [self beginSheetModalForWindow:window
+                     modalDelegate:handler ? self : nil
+                    didEndSelector:handler ? 
@selector(bdsk_didEndAlert:returnCode:contextInfo:) : NULL
+                       contextInfo:handler ? Block_copy(handler) : NULL];
+}
+
++ (void)load {
+    BDSKAddInstanceMethodImplementationFromSelector(self, 
@selector(beginSheetModalForWindow:completionHandler:), 
@selector(fallback_beginSheetModalForWindow:completionHandler:));
+}
+
+@end

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to