Creating an Action for Multiple Dropped Files
To accept multiple dropped file arguments and execute a command line in the form:
command file 1 file 2 ... |
use the syntax:
%Args% |
Examples
This execution string executes a script named Checkout for multiple files:
EXEC_STRING /usr/local/bin/Checkout \ %Arg_1"Check out what file?"% %Args%
This execution string executes lp -oraw with multiple files:
EXEC_STRING lp -oraw %Arg_1"File to print:"% %Args%
Windowing Support and Terminal Emulators for COMMAND Actions
There are several ways that COMMAND actions support windows on the desktop.
If the application has its own window, the action can be written to provide no additional window support. This option is also used when an action runs a command that requires no direct user input and has no output.
If the application must run in a terminal emulator window, the action can be written to open a window and then run the application. There are several terminal options.
Specifying the Window Support for the Action
Use the WINDOW_TYPE field to specify the type of windowing support required by the action as shown in Table 12-2.
Table 12-2 WINDOW_TYPE Field and Windowing Support Provided
Windowing Support Provided | |
---|---|
None. Use NO_STDIO if the application has its own window, or if the command has no visible output. | |
Permanent terminal emulator window. The action opens a terminal window that remains open until the user explicitly closes it. The user can enter data into the window. Use with commands that take some input, produce some output, then terminate (for example, ls directory). | |
Temporary terminal emulator window. The action opens a terminal window that closes as soon as the command is completed. Use with full-screen commands (for example, vi). |
Specifying Command-Line Options for the Terminal Emulator
Use the TERM_OPTS field in the action definition to specify command-line options for the terminal emulator.
For example, the following action prompts for the execution host:
ACTION OpenTermOnSystemUserChooses { WINDOW_TYPE PERM_TERMINAL EXEC_HOST %(String)"Remote terminal on:"% TERM_OPTS -title %(String)"Window title:"% EXEC_STRING $SHELL } |
Specifying a Different Default Terminal Emulator
The default terminal emulator used by actions is dtterm. You can change this to another terminal emulator. The default terminal emulator is used when the action does not explicitly specify a terminal emulator to use.
The terminal emulator used by actions must have these command-line options:
-title window_title
-e command
Two resources determine the default terminal emulator used by actions:
The localTerminal resource specifies the terminal emulator used by local applications.
*localTerminal: terminal
For example:
*localTerminal: xterm
The remoteTerminal resource specifies the terminal emulator used by remote applications.
*remoteTerminal: host:terminal [,host:terminal...]
For example:
*remoteTerminal: sysibm1:/usr/bin/xterm,syshp2:/usr/bin/yterm
Restricting Actions to Certain Arguments
Restricting an action to a particular type of argument refines the action. For example, you should restrict an action that invokes a viewer for PostScript files to only PostScript file arguments; with the restriction, the action will return an error dialog if a non-PostScript file is specified.
You can restrict actions based on:
The data type of the file argument.
The number of file arguments--for example, no arguments versus one or more arguments. This provides different drop and double-click behavior for the action icon.
The read/write mode of the argument.
Restricting an Action to a Specified Data Type
Use the ARG_TYPE field to specify the data types for which the action is valid. Use the data attribute name.
You can enter a list of data types; separate the entries with commas.
For example, the following action definition assumes a GIF data type has been created.
ACTION Open_Gif { TYPE COMMAND LABEL "Display Gif" WINDOW_TYPE NO_STDIO ARG_TYPE Gif ICON xgif DESCRIPTION Displays gif files EXEC_STRING xgif } |