Revision: 29002 http://sourceforge.net/p/bibdesk/svn/29002 Author: hofman Date: 2025-02-13 16:54:18 +0000 (Thu, 13 Feb 2025) Log Message: ----------- remove convenience methods for apple events to target an applescript, construct the apple events in the two places where they are needed
Modified Paths: -------------- trunk/bibdesk/BDSKScriptGroup.m trunk/bibdesk/BDSKScriptHook.m trunk/bibdesk/Base.lproj/TemplateDocument.xib trunk/bibdesk/NSAppleEventDescriptor_BDSKExtensions.h trunk/bibdesk/NSAppleEventDescriptor_BDSKExtensions.m Modified: trunk/bibdesk/BDSKScriptGroup.m =================================================================== --- trunk/bibdesk/BDSKScriptGroup.m 2025-02-11 10:32:36 UTC (rev 29001) +++ trunk/bibdesk/BDSKScriptGroup.m 2025-02-13 16:54:18 UTC (rev 29002) @@ -53,6 +53,10 @@ #import "BDSKMacroResolver.h" #import "NSObject_BDSKExtensions.h" +#define kASSubroutineEvent 'psbr' +#define kASAppleScriptSuite 'ascr' +#define keyASSubroutineName 'snam' + #define APPLESCRIPT_HANDLER_NAME @"main" #define BDSKScriptGroupRunLoopMode @"BDSKScriptGroupRunLoopMode" @@ -456,7 +460,10 @@ if (argsArray == nil) argsArray = [scriptArguments appleScriptArgumentsArray]; - NSAppleEventDescriptor *appleEvent = [NSAppleEventDescriptor appleEventWithHandler:APPLESCRIPT_HANDLER_NAME parameters:argsArray]; + NSAppleEventDescriptor *targetAddress = [NSAppleEventDescriptor descriptorWithProcessIdentifier:[[NSProcessInfo processInfo] processIdentifier]]; + NSAppleEventDescriptor *appleEvent = [NSAppleEventDescriptor appleEventWithEventClass:kASAppleScriptSuite eventID:kASSubroutineEvent targetDescriptor:targetAddress returnID:kAutoGenerateReturnID transactionID:kAnyTransactionID]; + [appleEvent setParamDescriptor:[argsArray aeDescriptorValue] forKeyword:keyDirectObject]; + [appleEvent setParamDescriptor:[APPLESCRIPT_HANDLER_NAME aeDescriptorValue] forKeyword:keyASSubroutineName]; [script executeWithAppleEvent:appleEvent completionHandler:^(NSAppleEventDescriptor *result1, NSError *error1){ if (result1 == nil && error1 && [argsArray count] == 0) { Modified: trunk/bibdesk/BDSKScriptHook.m =================================================================== --- trunk/bibdesk/BDSKScriptHook.m 2025-02-11 10:32:36 UTC (rev 29001) +++ trunk/bibdesk/BDSKScriptHook.m 2025-02-13 16:54:18 UTC (rev 29002) @@ -135,8 +135,11 @@ - (void)runWithPublications:(NSArray *)items completionHandler:(void (^)(BOOL cancelled))handler { BDSKPRECONDITION(script != nil); - NSAppleEventDescriptor *appleEvent = [NSAppleEventDescriptor appleEventWithEventClass:kBDSKBibdeskSuite eventID:kBDSKPerformBibdeskAction labelsAndParameters:keyDirectObject, items ?: [NSNull null], kBDSKPrepositionForScriptHook, self, 0]; - + NSAppleEventDescriptor *targetAddress = [NSAppleEventDescriptor descriptorWithProcessIdentifier:[[NSProcessInfo processInfo] processIdentifier]]; + NSAppleEventDescriptor *appleEvent = [NSAppleEventDescriptor appleEventWithEventClass:kBDSKBibdeskSuite eventID:kBDSKPerformBibdeskAction targetDescriptor:targetAddress returnID:kAutoGenerateReturnID transactionID:kAnyTransactionID]; + [appleEvent setParamDescriptor:[items ?: [NSNull null] aeDescriptorValue] forKeyword:keyDirectObject]; + [appleEvent setParamDescriptor:[self aeDescriptorValue] forKeyword:kBDSKPrepositionForScriptHook]; + if (scriptHooks == nil) scriptHooks = [[NSMutableDictionary alloc] init]; [scriptHooks setObject:self forKey:uniqueID]; Modified: trunk/bibdesk/Base.lproj/TemplateDocument.xib =================================================================== --- trunk/bibdesk/Base.lproj/TemplateDocument.xib 2025-02-11 10:32:36 UTC (rev 29001) +++ trunk/bibdesk/Base.lproj/TemplateDocument.xib 2025-02-13 16:54:18 UTC (rev 29002) @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19162" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> +<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> <dependencies> <deployment identifier="macosx"/> - <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19162"/> + <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19529"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> <objects> @@ -418,7 +418,7 @@ </view> </box> <textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="1542"> - <rect key="frame" x="18" y="510" width="57" height="14"/> + <rect key="frame" x="18" y="510" width="62" height="14"/> <textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Default type:" id="1901"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> @@ -426,7 +426,7 @@ </textFieldCell> </textField> <popUpButton horizontalHuggingPriority="750" verticalHuggingPriority="751" translatesAutoresizingMaskIntoConstraints="NO" id="1537"> - <rect key="frame" x="32" y="482" width="45" height="22"/> + <rect key="frame" x="32" y="482" width="50" height="22"/> <popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" controlSize="small" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" selectedItem="1541" id="1900"> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="smallSystem"/> @@ -443,9 +443,9 @@ </connections> </popUpButton> <scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZVm-ex-Jeo"> - <rect key="frame" x="20" y="177" width="53" height="301"/> + <rect key="frame" x="20" y="177" width="58" height="301"/> <clipView key="contentView" id="D7r-8N-QXM"> - <rect key="frame" x="1" y="1" width="51" height="299"/> + <rect key="frame" x="1" y="1" width="56" height="299"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" headerView="W7l-ga-thB" viewBased="YES" id="6Be-c7-qbI" customClass="BDSKTableView"> @@ -547,7 +547,7 @@ </subviews> </clipView> <scroller key="horizontalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="qw6-WF-LwA"> - <rect key="frame" x="1" y="284" width="51" height="16"/> + <rect key="frame" x="1" y="284" width="56" height="16"/> <autoresizingMask key="autoresizingMask"/> </scroller> <scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="vni-Rr-d7f"> @@ -560,13 +560,13 @@ </tableHeaderView> </scrollView> <box verticalCompressionResistancePriority="250" title="Item Template" translatesAutoresizingMaskIntoConstraints="NO" id="1556"> - <rect key="frame" x="73" y="303" width="744" height="94"/> + <rect key="frame" x="78" y="303" width="739" height="94"/> <view key="contentView" id="vaM-Fl-fT2"> - <rect key="frame" x="3" y="3" width="738" height="76"/> + <rect key="frame" x="3" y="3" width="733" height="76"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <tokenField horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="1558" customClass="BDSKTokenField"> - <rect key="frame" x="12" y="10" width="714" height="56"/> + <rect key="frame" x="12" y="10" width="709" height="56"/> <constraints> <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="22" id="bkY-kv-FEE"/> <constraint firstAttribute="height" priority="499" constant="56" id="bn0-3P-xsm"/> @@ -595,13 +595,13 @@ </view> </box> <box title="Options for field" translatesAutoresizingMaskIntoConstraints="NO" id="1559"> - <rect key="frame" x="73" y="173" width="744" height="126"/> + <rect key="frame" x="78" y="173" width="739" height="126"/> <view key="contentView" id="TSn-hs-oy2"> - <rect key="frame" x="3" y="3" width="738" height="108"/> + <rect key="frame" x="3" y="3" width="733" height="108"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <customView translatesAutoresizingMaskIntoConstraints="NO" id="cLa-yx-uut"> - <rect key="frame" x="4" y="6" width="730" height="96"/> + <rect key="frame" x="4" y="6" width="725" height="96"/> <constraints> <constraint firstAttribute="height" constant="96" id="ZSn-Gp-DmP"/> </constraints> @@ -623,15 +623,15 @@ </connections> </box> <box title="Available Fields" translatesAutoresizingMaskIntoConstraints="NO" id="1547"> - <rect key="frame" x="73" y="401" width="744" height="123"/> + <rect key="frame" x="78" y="401" width="739" height="123"/> <view key="contentView" id="fnr-QQ-bwY"> - <rect key="frame" x="3" y="3" width="738" height="105"/> + <rect key="frame" x="3" y="3" width="733" height="105"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasVerticalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1549"> - <rect key="frame" x="12" y="0.0" width="714" height="95"/> + <rect key="frame" x="12" y="0.0" width="709" height="95"/> <clipView key="contentView" autoresizesSubviews="NO" drawsBackground="NO" copiesOnScroll="NO" id="uAv-0P-sO3"> - <rect key="frame" x="0.0" y="0.0" width="714" height="95"/> + <rect key="frame" x="0.0" y="0.0" width="709" height="95"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <customView translatesAutoresizingMaskIntoConstraints="NO" id="1550" customClass="BDSKFlippedView"> @@ -777,7 +777,7 @@ </connections> </customView> <customView placeholderIntrinsicWidth="9" placeholderIntrinsicHeight="9" translatesAutoresizingMaskIntoConstraints="NO" id="hQX-jZ-Y2Y" customClass="BDSKResizeView"> - <rect key="frame" x="76" y="298" width="738" height="9"/> + <rect key="frame" x="81" y="298" width="733" height="9"/> <connections> <outlet property="constraint" destination="bn0-3P-xsm" id="BGv-oq-fab"/> </connections> @@ -1052,7 +1052,7 @@ <constraint firstAttribute="trailing" secondItem="1723" secondAttribute="trailing" constant="8" id="ZfN-1f-Ky8"/> <constraint firstItem="1726" firstAttribute="firstBaseline" secondItem="1727" secondAttribute="firstBaseline" id="fm7-pP-hBs"/> </constraints> - <point key="canvasLocation" x="-94.5" y="700"/> + <point key="canvasLocation" x="-95" y="700"/> </customView> <customView translatesAutoresizingMaskIntoConstraints="NO" id="1759" userLabel="LinkedFileView"> <rect key="frame" x="0.0" y="0.0" width="251" height="24"/> @@ -1263,7 +1263,7 @@ <constraint firstItem="1822" firstAttribute="leading" secondItem="1819" secondAttribute="trailing" constant="8" symbolic="YES" id="sgg-cJ-gfl"/> <constraint firstItem="1821" firstAttribute="firstBaseline" secondItem="1818" secondAttribute="firstBaseline" id="vam-8V-98N"/> </constraints> - <point key="canvasLocation" x="-4" y="992"/> + <point key="canvasLocation" x="-4.5" y="992"/> </customView> <customView translatesAutoresizingMaskIntoConstraints="NO" id="589" userLabel="FontOptionsView"> <rect key="frame" x="0.0" y="0.0" width="401" height="24"/> Modified: trunk/bibdesk/NSAppleEventDescriptor_BDSKExtensions.h =================================================================== --- trunk/bibdesk/NSAppleEventDescriptor_BDSKExtensions.h 2025-02-11 10:32:36 UTC (rev 29001) +++ trunk/bibdesk/NSAppleEventDescriptor_BDSKExtensions.h 2025-02-13 16:54:18 UTC (rev 29002) @@ -43,9 +43,6 @@ @property (nonatomic, readonly) id objCObjectValue; -+ (NSAppleEventDescriptor *)appleEventWithHandler:(NSString *)handlerName parameters:(NSArray *)arguments; -+ (NSAppleEventDescriptor *)appleEventWithEventClass:(AEEventClass)suiteID eventID:(AEEventID)eventID labelsAndParameters:(AEKeyword)keyword, ...; - @end @interface NSObject (BDSKNSAppleEventDescriptor) Modified: trunk/bibdesk/NSAppleEventDescriptor_BDSKExtensions.m =================================================================== --- trunk/bibdesk/NSAppleEventDescriptor_BDSKExtensions.m 2025-02-11 10:32:36 UTC (rev 29001) +++ trunk/bibdesk/NSAppleEventDescriptor_BDSKExtensions.m 2025-02-13 16:54:18 UTC (rev 29002) @@ -187,24 +187,6 @@ return self; } -+ (NSAppleEventDescriptor *)appleEventWithHandler:(NSString *)handlerName parameters:(NSArray *)arguments { - return [self appleEventWithEventClass:kASAppleScriptSuite eventID:kASSubroutineEvent labelsAndParameters:keyASSubroutineName, handlerName, keyDirectObject, arguments, 0U]; -} - -+ (NSAppleEventDescriptor *)appleEventWithEventClass:(AEEventClass)suiteID eventID:(AEEventID)eventID labelsAndParameters:(AEKeyword)keyword, ... { - int pid = [[NSProcessInfo processInfo] processIdentifier]; - NSAppleEventDescriptor *targetAddress = [NSAppleEventDescriptor descriptorWithDescriptorType:typeKernelProcessID bytes:&pid length:sizeof(pid)]; - NSAppleEventDescriptor *event = [NSAppleEventDescriptor appleEventWithEventClass:suiteID eventID:eventID targetDescriptor:targetAddress returnID:kAutoGenerateReturnID transactionID:kAnyTransactionID]; - va_list argList; - va_start(argList, keyword); - do { - id object = va_arg(argList, id); - [event setParamDescriptor:[object aeDescriptorValue] forKeyword:keyword]; - } while ((keyword = va_arg(argList, AEKeyword))); - va_end(argList); - return event; -} - @end #pragma mark - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit