Revision: 22820
          http://sourceforge.net/p/bibdesk/svn/22820
Author:   hofman
Date:     2018-10-13 15:54:51 +0000 (Sat, 13 Oct 2018)
Log Message:
-----------
Declare scriptable app elements on item class, so they can be accessed from any 
tell block

Modified Paths:
--------------
    trunk/bibdesk/BDSKAppController+Scripting.h
    trunk/bibdesk/BDSKAppController+Scripting.m
    trunk/bibdesk/Scripting/BibDesk.sdef

Modified: trunk/bibdesk/BDSKAppController+Scripting.h
===================================================================
--- trunk/bibdesk/BDSKAppController+Scripting.h 2018-10-13 15:45:12 UTC (rev 
22819)
+++ trunk/bibdesk/BDSKAppController+Scripting.h 2018-10-13 15:54:51 UTC (rev 
22820)
@@ -61,6 +61,12 @@
 
 - (NSArray *)templateNames;
 
+- (BOOL)application:(NSApplication *)sender delegateHandlesKey:(NSString *)key;
+
+@end
+
+@interface NSObject (Scripting)
+
 - (BDSKTypeInfo *)valueInTypeInfosWithName:(NSString *)name;
 - (NSArray *)typeInfos;
 
@@ -73,7 +79,4 @@
 - (BDSKServerInfo *)valueInServerInfosWithName:(NSString *)name;
 - (NSArray *)serverInfos;
 
-- (BOOL)application:(NSApplication *)sender delegateHandlesKey:(NSString *)key;
-
-
 @end

Modified: trunk/bibdesk/BDSKAppController+Scripting.m
===================================================================
--- trunk/bibdesk/BDSKAppController+Scripting.m 2018-10-13 15:45:12 UTC (rev 
22819)
+++ trunk/bibdesk/BDSKAppController+Scripting.m 2018-10-13 15:54:51 UTC (rev 
22820)
@@ -111,6 +111,30 @@
     return [BDSKTemplate allStyleNamesForFormat:BDSKTemplateFormatRichText];
 }
 
+- (BOOL)application:(NSApplication *)sender delegateHandlesKey:(NSString *)key 
{
+    if ([key isEqualToString:@"papersFolder"] ||
+        [key isEqualToString:@"localFileFormat"] ||
+        [key isEqualToString:@"citeKeyFormat"] ||
+        [key isEqualToString:@"allTypes"] ||
+        [key isEqualToString:@"allFieldNames"] ||
+        [key isEqualToString:@"typeInfos"] ||
+        [key isEqualToString:@"fieldInfos"] ||
+        [key isEqualToString:@"macros"] ||
+        [key isEqualToString:@"scriptHooks"] ||
+        [key isEqualToString:@"templateNames"] ||
+        [key isEqualToString:@"plainTextTemplateNames"] ||
+        [key isEqualToString:@"richTextTemplateNames"] ||
+        [key isEqualToString:@"templates"] ||
+        [key isEqualToString:@"serverInfos"] ||
+        [key isEqualToString:@"clipboard"])
+    return YES;
+    return NO;
+}
+
+@end
+
+@implementation NSObject (Scripting)
+
 - (BDSKTypeInfo *)valueInTypeInfosWithName:(NSString *)name {
     return [[[BDSKTypeInfo alloc] initWithName:name] autorelease];
 }
@@ -159,24 +183,4 @@
     return [[BDSKSearchGroupServerManager sharedManager] servers];
 }
 
-- (BOOL)application:(NSApplication *)sender delegateHandlesKey:(NSString *)key 
{
-       if ([key isEqualToString:@"papersFolder"] ||
-        [key isEqualToString:@"localFileFormat"] ||
-        [key isEqualToString:@"citeKeyFormat"] ||
-               [key isEqualToString:@"allTypes"] ||
-        [key isEqualToString:@"allFieldNames"] ||
-        [key isEqualToString:@"typeInfos"] ||
-        [key isEqualToString:@"fieldInfos"] ||
-        [key isEqualToString:@"macros"] ||
-               [key isEqualToString:@"scriptHooks"] ||
-               [key isEqualToString:@"templateNames"] ||
-               [key isEqualToString:@"plainTextTemplateNames"] ||
-        [key isEqualToString:@"richTextTemplateNames"] ||
-        [key isEqualToString:@"templates"] ||
-        [key isEqualToString:@"serverInfos"] ||
-        [key isEqualToString:@"clipboard"])
-               return YES;
-       return NO;
-}
-
 @end

Modified: trunk/bibdesk/Scripting/BibDesk.sdef
===================================================================
--- trunk/bibdesk/Scripting/BibDesk.sdef        2018-10-13 15:45:12 UTC (rev 
22819)
+++ trunk/bibdesk/Scripting/BibDesk.sdef        2018-10-13 15:54:51 UTC (rev 
22820)
@@ -787,6 +787,27 @@
             </parameter>
         </command>
         
+        <class-extension extends="item" hidden="yes"
+            description="A scriptable object.">
+            <cocoa class="NSObject"/>
+            <element type="BibTeX type" access="r"
+                description="Infos for the BibTeX types.">
+                <cocoa key="typeInfos"/>
+            </element>
+            <element type="BibTeX field" access="r"
+                description="Infos for the BibTeX fields.">
+                <cocoa key="fieldInfos"/>
+            </element>
+            <element type="template" access="r"
+                description="Export templates.">
+                <cocoa key="templates"/>
+            </element>
+            <element type="search server" access="r"
+                description="Search server infos.">
+                <cocoa key="serverInfos"/>
+            </element>
+        </class-extension>
+
                <class-extension extends="application"
                        description="Bibdesk's top level scripting object.">
                        <cocoa class="BDSKApplication"/>

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

Reply via email to