Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
12.  Creating Actions Manually Creating an Action Manually: General Steps Example of Creating a COMMAND Action  Previous   Contents   Next 
   
 

Example of Creating a MAP Action

Suppose most of the files you fax are created with Text Editor and are of data type TEXTFILE (files named *.txt).

These steps add a ``Fax'' menu item to the data type's Selected menu.

  1. Open the file HomeDirectory/.dt/types/Fax.dt that was created in the previous example.

  2. Add this map action definition to the file:

    	ACTION Fax
     	{
     		ARG_TYPE			TEXTFILE
     		TYPE				MAP
     		MAP_ACTION		FaxComposer
     	} 
  3. Save the file.

  4. Copy the data attributes definition for TEXTFILE from /usr/dt/appconfig/types/language/dtpad.dt to a new file HomeDirectory/.dt/types/textfile.dt. Add the Fax action to the ACTIONS field.

    	DATA_ATTRIBUTES TEXTFILE
     	{
     		ACTIONS			Open,Print,Fax
     		ICON				Dtpenpd
     		...
     	}
  5. Save the file.

  6. Open Application Manager and double-click Reload Actions in the Desktop_Tools application group.

To Reload the Actions/Data Types Database

In order for new or edited action definitions to take effect, the desktop must reread the database.

  • Open the Desktop_Tools application group and double-click Reload Actions.

  • Or, execute the command:

    	dtaction ReloadActions

    ReloadActions is the name of the action whose icon is labeled ``Reload Actions.''

    The actions database is also reread when the user:

    • Logs in

    • Restarts the Workspace Manager

    • Saves an action in the Create Action window by choosing Save from the File menu

Creating an Action File (Icon) for an Action

An action file is a file created to provide a visual representation of the action in File Manager or Application Manager.

Figure 12-1 Action files (action icons) in Application Manager

Since an action file's icon represents an action, it is sometimes called an action icon. If the underlying action starts an application, the action file icon is called an application icon.

Double-clicking the action icon runs the action. The action icon may also be a drop zone.

To Create an Action File (Action Icon)

  • Create an executable file with the same name as the action name. The content of the file does not matter.

For example, if the action definition is:

ACTION  MyFavoriteApp
 {
 	EXEC_STRING				Mfa -file %Arg_1%
 	DESCRIPTION				Runs MyFavoriteApp
 	ICON						Mfapp
 }

then the action file would be an executable file named MyFavoriteApp. In File Manager and Application Manager, the MyFavoriteApp file would use the icon image Mfapp.size.type. Double-clicking MyFavoriteApp's icon would run the action's execution string, and the icon's On Item help would be the contents of the DESCRIPTION field ("runs MyFavoriteApp").

Action Labels

If the action definition includes the LABEL field, the action file will be labeled in File Manager and Application Manager with the contents of this field rather than the file name (action_name). For example, if the action definition includes:

ACTION  MyFavoriteApp
 {
 	LABEL      Favorite Application
 	...
 }

then the action icon will be labeled ``Favorite Application.''

Specifying the Icon Image Used by an Action

Use the ICON field to specify the icon used in File Manager and Application Manager for the action icons created for the action.

If you do not specify an icon, the system uses the default action icon image files /usr/dt/appconfig/icons/language/Dtactn.*.

Figure 12-2 Default action icon image

The default action icon can be changed using the resource:

*actionIcon:    icon_file_name

where icon_file_name can be a base name or absolute path.

The value of the ICON field can be:

  • A base file name

    The base file name is the name of the file containing the icon image minus the file-name suffixes for size (m and t) and image type (bm and pm). For example, if files are named GameIcon.m.pm and GameIcon.t.pm, use GameIcon.

    If you use the base file name, the icon files must be placed in a directory on the icon search path:

    • Personal icons: HomeDirectory/.dt/icons

    • System-wide icons: /etc/dt/appconfig/icons/language

  • An absolute path to the icon file, including the full file name

    You should use the absolute path only if the icon file is not located on the icon search path. For example, if icon file GameIcon.m.pm is placed in the directory /doc/projects, which is not on the icon search path, the value of the ICON field would be /doc/projects/GameIcon.m.pm.

    Table 12-1 lists icon sizes you should create and the corresponding file names.

Table 12-1 Icon Names and Sizes for Action Icons

Size in Pixels

Bitmap Name

Pixmap Name

48 by 48

name.l.bm

name.l.pm

32 by 32

name.m.bm

name.m.pm

16 by 16

name.t.bm

name.t.pm

 
 
 
  Previous   Contents   Next