| United States-English |
|
|
|
![]() |
Common Desktop Environment: Advanced User's and System Administrator's Guide > Chapter 8 Introduction
to Actions and Data TypesIntroduction 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. Each of these icons runs an action when the icon is 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:
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:
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. 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.
The XWD data type, and its associated Open and Print actions, are explained in “How Data Types Connect Data Files to Actions”. 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 8-4 “Application (action) icon representing an action file”) 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:
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. 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.
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 Xwud action is called a command action because its definition contains the command (EXEC_STRING) to be run. The TYPE field in the action definition defines the action type. Initially, the Xwd Display icon appears in the Desktop_Tools application group. However, you can create additional copies of the action icon in any directory for which you have write permission. As long as the Xwud action definition is part of the database, any executable file you create named Xwud will be an action file representing that action, and its icon in File Manager or Application Manager can be used to run the action. An argument of a command is the thing, usually a file, that the command acts upon. Actions can be written to accept file arguments. For example, the EXEC_STRING of the Xwud action specifies that a file argument is required:
The term Arg stands for the word argument. The syntax Arg_1 means the first argument, and (File) means that the action treats that argument as a file. The easiest way for the user to provide a file argument is to drop a data file on the application icon. The desktop determines the path of the dropped file and substitutes it into the command line in place of the text between the % symbols (%(File)Arg_1"Xwd File To Display:"%). Thus, the command that gets executed is:
When the user double-clicks the application icon, the desktop determines from the EXEC_STRING that a file argument is required, and displays a dialog box prompting the user to enter a file name or path. In the case of the Xwud action, the prompt is:
The file name or path supplied by the user is used as the file argument. In addition to starting applications, actions are used throughout the desktop to create functionality in:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||