Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

New Acorn filter stuff.

  • Loading branch information...
commit d6c2b3c723841455e116d30097efa8a19f5cb5d6 1 parent eb006c5
@ccgus authored
View
14 plugins/acornplugin/ACPlugin.h
@@ -30,6 +30,7 @@ enum {
@protocol ACBitmapTool;
@protocol ACImageIOProvider;
@protocol ACImageFilter;
+@protocol ACLayer;
@protocol ACPluginManager
@@ -90,6 +91,19 @@ enum {
*/
- (NSNumber*)worksOnShapeLayers:(id)userObject;
+
+/*
+ How about a more general type of "do you work on this type of layer" question:
+
+ return [NSNumber numberWithBool:YES];
+
+ NSNumber is used to be friendly with scripting languages.
+
+ Added in version 3.5
+
+ */
+- (NSNumber*)validateForLayer:(id<ACLayer>)layer;
+
@end
View
45 plugins/acornplugin/JSEnablerPlugIn.m
@@ -13,6 +13,7 @@
#define ACScriptSuperMenuTitleKey @"ACScriptSuperMenuTitle"
#define ACShortcutKeyKey @"ACShortcutKey"
#define ACShortcutMaskKey @"ACShortcutMask"
+#define ACIsActionKey @"ACIsAction"
@interface JSEnablerPlugIn (SuperSecret)
- (void)findJSCocoaScriptsForPluginManager:(id<ACPluginManager>)pluginManager;
@@ -50,12 +51,13 @@ - (NSDictionary*)propertiesFromScriptAtPath:(NSString*)path {
[s replaceOccurrencesOfString:@"\r" withString:@"\n" options:0 range:NSMakeRange(0, [s length])];
NSMutableDictionary *d = [NSMutableDictionary dictionary];
- NSString *menuTitle = 0x00;
+ NSString *menuTitle = nil;
NSString *shortcutKey = @"";
NSString *superMenuTitle = nil;
- int shortcutMask = 0x00;
+ int shortcutMask = 0;
NSEnumerator *enumerator = [[s componentsSeparatedByString:@"\n"] objectEnumerator];
NSString *line;
+ BOOL isAction = NO;
while ((line = [enumerator nextObject])) {
@@ -83,6 +85,14 @@ - (NSDictionary*)propertiesFromScriptAtPath:(NSString*)path {
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
}
}
+ else if ([line hasPrefix:ACIsActionKey]) {
+ int eqIdx = [line rangeOfString:@"="].location;
+ if (eqIdx != NSNotFound && [line length] > eqIdx + 1) {
+ NSString *val = [[line substringFromIndex:eqIdx+1]
+ stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+ isAction = [val boolValue];
+ }
+ }
else if ([line hasPrefix:ACShortcutMaskKey]) {
int eqIdx = [line rangeOfString:@"="].location;
if (eqIdx != NSNotFound && [line length] > eqIdx + 1) {
@@ -121,6 +131,7 @@ - (NSDictionary*)propertiesFromScriptAtPath:(NSString*)path {
}
[d setObject:[NSNumber numberWithInt:shortcutMask] forKey:ACShortcutMaskKey];
+ [d setObject:[NSNumber numberWithBool:isAction] forKey:ACIsActionKey];
return d;
}
@@ -155,13 +166,25 @@ - (void)findJSCocoaScriptsForPluginManager:(id<ACPluginManager>)pluginManager {
NSUInteger shortcutMask = [[scriptProperties objectForKey:ACShortcutMaskKey] unsignedIntegerValue];
- [pluginManager addFilterMenuTitle:menuTitle
- withSuperMenuTitle:superMenuTitle
- target:self
- action:@selector(executeScriptForImage:scriptPath:)
- keyEquivalent:shortcutKey
- keyEquivalentModifierMask:shortcutMask
- userObject:[pluginDir stringByAppendingPathComponent:fileName]];
+ if ([[scriptProperties objectForKey:ACIsActionKey] boolValue]) {
+ [pluginManager addActionMenuTitle:menuTitle
+ withSuperMenuTitle:superMenuTitle
+ target:self
+ action:@selector(executeScriptForImage:scriptPath:)
+ keyEquivalent:shortcutKey
+ keyEquivalentModifierMask:shortcutMask
+ userObject:[pluginDir stringByAppendingPathComponent:fileName]];
+ }
+ else {
+
+ [pluginManager addFilterMenuTitle:menuTitle
+ withSuperMenuTitle:superMenuTitle
+ target:self
+ action:@selector(executeScriptForImage:scriptPath:)
+ keyEquivalent:shortcutKey
+ keyEquivalentModifierMask:shortcutMask
+ userObject:[pluginDir stringByAppendingPathComponent:fileName]];
+ }
}
}
@@ -214,6 +237,10 @@ - (NSNumber*)worksOnShapeLayers:(id)userObject {
return [NSNumber numberWithBool:YES];
}
+- (NSNumber*)validateForLayer:(id)userObject {
+ return [NSNumber numberWithBool:YES];
+}
+
@end
View
6 plugins/acornplugin/jsenabler.xcodeproj/project.pbxproj
@@ -631,8 +631,9 @@
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
PREBINDING = NO;
- SDKROOT = macosx10.6;
+ SDKROOT = macosx10.7;
};
name = Debug;
};
@@ -646,8 +647,9 @@
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
PREBINDING = NO;
- SDKROOT = macosx10.6;
+ SDKROOT = macosx10.7;
};
name = Release;
};
Please sign in to comment.
Something went wrong with that request. Please try again.