StepTalk Application Scripting Bundle
Contents
Application Extensions
Scripts
Creating a scriptable application
StepTalk provideas a bundle that allows users to 'script' applications. In other words, for example, users can:
- extend the behaviour of application by adding their own functionality
- automate tasks in the application
- create a batch task
The Application Scripting bundle is installed together with StepTalk.
Application Extensions
The bundle provides a scripting menu and a scripts panel to the application. With scripting menu one can open scripts panel, open transcript window or execute selected text as script.
The scripts panel lists all application-specific scripts with their localised name and description.
Scripts
Application is looking for scripts in:
- applications resource directory (ApplicationName.app/Resources/Scripts)
- application specific scripts in all GNUstep Library directories (*/Library/StepTalk/Scripts/ApplicationName)
- shared scriptins in all GNUstep Library directories (*/Library/StepTalk/Scripts/Shared)
- resource directories of all bundles loaded by the application (BundleName.bundle/Resources/Scripts)
(*) can be any of GNUstep System, Local, Network or user home path Script Metafile
Each script may have accopmpaining file containing information about script. This information file is optional, has extension .stinfo and its name is script name with that extension. For example if script name is insertDate.st then information file is insertDate.st.stinfo. File may contain:
- script name that will be shown to the user (localizable)
- script description (localizable)
- scripting language used for script -- overrides language guess based on file extension
The file is dictionary property list. Kes are:
Name - Name of a script that is shown to the user.
Description - Description of a script.
Language - Scripting language name used in script. This value overrides language guess based on script file extension.
Example:
{
Default = {
Name = "Some name";
Description = "Some description";
};
English = {
Name = "Some name in english";
Description = "Some description in english";
};
French = {
Name = "Some name in french";
Description = "Some description in french";
}
}
Creating a scriptable application
1. Think of objects you want to provide for scripting.
2. Make classes available in ScriptingInfo.plist:
{
STClasses =
{
MessageComposition,
InternetAddress
};
}
Add this line to your makefile:
MyApp_RESOURCE_FILES = ScriptingInfo.plist
3. Include bundle loading code
Copy files STScriptingSupport.h and STScriptingSupport.m from ApplicationScripting/Support directory to your project and add the following line to your makefile:
MyApp_OBJC_FILES += STScriptingSupport.m
4. Make scripting available to the user
#import "STScriptingSupport.h"
...
if([NSApp isScriptingSupported])
{
[menu addItemWithTitle: @"Scripting"
action: NULL
keyEquivalent: @""];
[menu setSubmenu: [NSApp scriptingMenu]
forItem: [menu itemWithTitle:@"Scripting"]];
}
...