Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
  Previous   Contents   Next 
   
 
Chapter 10

Introduction to Actions and Data Types

Actions and data types are powerful components for integrating applications into the desktop. They provide a way to create a user interface for starting applications and manipulating their data files.

This chapter introduces the concepts of actions and data types. It describes:

  • Why you may want to create actions and data types for applications.

  • How actions and data types are related to each other.

  • How actions and data types are related to desktop printing.

The procedures and rules for creating actions and data types are covered in three chapters in this manual.

Introduction To Actions

Actions are instructions written that automate desktop tasks such as running applications and opening data files. Actions work much like application macros or programming functions. Each action has a name that is used to run the action.

Once you define an action, it can be used to adapt the desktop user interface so that tasks are easier to do. The desktop provides the ability to attach user interface components such as icons, Front Panel controls, and menu items to actions.

For example, the Desktop_Tools application group in Application Manager contains icons that start various utilities.

Figure 10-1 Action icons in the Desktop_Tools application group

Each of these icons runs an action when double-clicked. For example, here's a portion of the definition of the action that runs when the user double-clicks the icon labeled Xwd Display. The action is defined in the configuration file /usr/dt/appconfig/types/language/xclients.dt:

ACTION Xwud
 {
 	LABEL				Xwd Display
 	TYPE				COMMAND
 	EXEC_STRING		/usr/bin/X11/xwud -noclick -in \
 							%(File)Arg_1"Xwd File To Display:"%
 	...
 }

The command in the action's EXEC_STRING is run when the user double-clicks the icon.

The Front Panel also uses actions. For example, here's a portion of the definition of the control labeled Terminal in the Personal Applications subpanel. The control is defined in the configuration file /usr/dt/appconfig/types/language/dtwm.fp:

CONTROL Term
 {
 	ICON				Fpterm
 	LABEL				Terminal
 	PUSH_ACTION		Dtterm
 	...
 }

The PUSH_ACTION field specifies the action to run when the user clicks the control--in this case, an action named Dtterm.

Another common use for actions is in menus. Data files usually have actions in their Selected menu in File Manager. For example, XWD files (files with names ending in.xwd or.wd) have an Open action that displays the screen image by running the Xwud action.

Figure 10-2 Open action for files of data type XWD

The actions in the Selected menu are specified in the data type definition for XWD files. The definition is located in the configuration file /usr/dt/appconfig/types/language/xclients.dt.

DATA_ATTRIBUTES XWD
 {
 	ACTIONS				Open,Print
 	ICON				Dtxwd
 	...
}

The XWD data type, and its associated Open and Print actions, are explained in "How Data Types Connect Data Files to Actions".

How Actions Create Icons for Applications

Consider the Xwd Display icon in the Desktop_Tools application group. Double-clicking this icon runs the X client xwud. However, this icon does not directly represent the actual xwud executable /usr/bin/X11/xwud.

The icon labeled Xwd Display appears in the application group because there is a file in that directory named Xwud (see Figure 10-3). This file represents an underlying action with the same name--Xwud. In the action definition, the action name is the name following the ACTION keyword:

ACTION Xwud
 {
 LABEL               Xwd Display
 TYPE                COMMAND
 WINDOW_TYPE         NO_STDIO
 EXEC_STRING         /usr/bin/X11/xwud -noclick -in \
                     %(File)Arg_1"Xwd File To Display:"%
 DESCRIPTION         The Xwd Display (Xwud) XwdDisplay action \
                     displays an xwd file that was created using the \
                     Xwd Capture (Xwd) action. It uses \
                     the xwud command.
 }

The file is called an action file because it represents an action. A file is an action file when it is an executable file with the same name as an action. Its icon in Application Manager (or File Manager) is called an action icon, or application icon, because double-clicking it starts an application.

Figure 10-3 Application (action) icon representing an action file

When Application Manager detects an executable file, it looks through the actions database to see if there are any actions whose names match the file name. If a match is found, Application Manager knows that the file is an action file.

The content of the action file is irrelevant; action files usually contain comments describing their desktop function.


Note - The action file is not the same as the action definition file. The action file is a file with the same name as the action. It is used to create the application icon in File Manager or Application Manager. The action definition file is the file named name.dt containing the definition of the action.


Once the desktop determines that a file is an action file, the underlying action definition is used to define the appearance and behavior of the action file.

  • The EXEC_STRING field specifies the behavior of the application icon. In the case of the Xwd Display icon, the EXEC_STRING specifies that the action icon runs the xwud X client with certain command-line arguments.

  • The LABEL field specifies the label for the application icon.

  • The DESCRIPTION field describes the text displayed when the user requests On Item help.

  • The Xwud application icon uses the default icon image for actions because its action definition does contain an ICON field to specify a different image.

    In contrast, the icon labeled Compress File uses a different icon image because its underlying action definition contains an ICON field:

    For example:

    ACTION Compress
    {
    	LABEL			Compress File  	
    	ICON			Dtcmprs  
    	...  
    }

Figure 10-4 Icon image specified by the ICON field in the action definition

 
 
 
  Previous   Contents   Next