Solaris Common Desktop Environment: Advanced User's and System Administrator's Guide

Creating an Action Manually: General Steps

This section explains how to create a configuration file for an action definition.

Configuration Files for Actions

Configuration files containing action definitions must meet these requirements:

For information on modifying the actions/data types search path, see Setting the Value of a Search Path.

To Create an Action Manually

  1. Open an existing database file or create a new one.

    See the previous section, Configuration Files for Actions.

  2. Create the action definition using the syntax:

    	ACTION action_name
     	{
     		TYPE		action_type
     		action_field
     		…
     	}

    where:

    action_name—name used to run the action.

    action_type—COMMAND (default), MAP, or TT_MSG.

    action_field—one of the required or optional fields for this type of action. All fields consist of a keyword and a value.

    Many of the action fields are covered in this chapter. For more information, see the dtactionfile(4) man page.

  3. Save the file.

  4. If you want the action icon to have a unique image, create the icons for the action. The default location for icons is:

    • Personal icons: HomeDirectory/.dt/icons

  5. Double-click Reload Actions in the Desktop_Tools application group.

  6. Create an action file for the action. The action file creates an icon in File Manager or Application Manager that represents the action. (If the action is written to start an application, the icon is called an application icon.)

    To create the action file, create an executable file with the same name as action_name. You can put the file in any directory to which you have write permission. You can create as many action files as you like.

Example of Creating a COMMAND Action

The following steps create a personal action that starts a fax application on remote system AppServerA. The command for starting the fax application is:

/usr/fax/bin/faxcompose [filename]
  1. Create the file HomeDirectory/.dt/types/Fax.dt.

  2. Put the following action definition into the file:

    	ACTION FaxComposer
     	{
     		TYPE					COMMAND
     		ICON					fax
     		WINDOW_TYPE			NO_STDIO
     		EXEC_STRING			/usr/fax/bin/faxcompose -c %Arg_1%
     		EXEC_HOST     	 	AppServerA
     		DESCRIPTION    	Runs the fax composer
    	}

    The WINDOW_TYPE and EXEC_STRING fields describe the behavior of the action.

    WINDOW_TYPE—the NO_STDIO keyword specifies that the action does not have to run in a terminal emulator window.

    See Specifying the Window Support for the Action.

    EXEC_STRING—the syntax %Arg_1% accepts a dropped file. If the action icon is double-clicked, the action opens an empty fax composer window.

    See Building the Execution String for a COMMAND Action.

  3. Save the file.

  4. Use Icon Editor to create the following icon image files in the HomeDirectory/.dt/icons directory:

    • fax.m.pm, size 32 by 32 pixels

    • fax.t.pm, size 16 by 16 pixels

  5. Double-click Reload Actions in the Desktop_Tools application group.

  6. Create an executable file named FaxComposer in a directory to which you have write permission (for example, your home directory).

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

Graphic

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

Graphic

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:

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

To Modify an Existing Action Definition

You can modify any of the actions available on your system, including built-in actions.


Note –

Use caution when modifying the built-in action database. The built-in actions are designed to work well with the desktop applications.


  1. Locate the definition of the action you want to modify.

    The default locations for action definitions are:

    • Built-in actions: /usr/dt/appconfig/types/language

    • System-wide actions: /etc/dt/appconfig/types/language

    • Personal actions: HomeDirectory/.dt/types

      Your system might include additional locations. To see a list of the locations your system uses for actions, type the command:

      	dtsearchpath -v
      

      Your system uses the directories listed under DTDATABASESEARCHPATH.

  2. If necessary, copy the text of the action definition to a new or existing file in one of these directories:

    • System-wide actions: /etc/dt/appconfig/types/language

    • Personal actions: HomeDirectory/.dt/types

      You must copy built-in actions, since you should not edit files in the /usr/dt/appconfig/types/language directory.

  3. Edit the action definition.

  4. When you are done editing, save the file.

  5. Double-click Reload Actions in the Desktop_Tools application group.

Precedence in Action Definitions

When the user invokes an action, the system searches the database for a matching action name. When more than one action exists with that name, the system uses precedence rules to decide which one to use.