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

How Data Types Connect Data Files to Actions

Consider the XWD data type. The user creates an XWD-type file by giving the file one of two file-name suffixes (extensions): .xwd or.wd. The desktop uses the file name as the criteria for designating a file as that type.

The XWD data type supplies each file of that data type with:

Running Actions from the Selected Menu

The Selected menu in File Manager is active only when a file or directory is selected. The commands at the bottom of the Selected menu depend on the data type. For example, if an XWD file is selected, the Selected menu includes the items Open and Print.

The ACTIONS field in the data type definition specifies the commands added to the bottom of the data type's Selected menu.

DATA_ATTRIBUTES XWD { ACTIONS Open,Print … }

The contents of the Selected menu depends on the data type. However, many different data types provide an Open action—that is, when you select a file of that particular data type in File Manager and display the Selected menu, you see an Open command.

Figure 10–5 The Selected menu for an XWD file

Graphic

The Open action usually runs the application with which the data file is associated. For example, opening an XWD file runs the Xwud action, which in turn runs the xwud X client to display the screen image. In other words, for the XWD data type, the Open action is synonymous with the Xwud action. Likewise, opening a file of data type TEXTFILE runs the Text Editor, and opening a BM (bitmap) or PM (pixmap) file runs Icon Editor.

The ability to create a variety of Open actions that do different things uses two features of action definitions:

Here is the definition of the action that maps the Open action to the Xwud action for the XWD data type. It is located in the database configuration file /usr/dt/appconfig/types/C/xclients.dt.

ACTION Open
 {
 	LABEL				Open
 	ARG_TYPE			XWD
 	TYPE				MAP
 	MAP_ACTION		Xwud
 }

The TYPE field specifies that this is a map action; the MAP_ACTION field specifies this action runs the Xwud action. The ARG_TYPE field specifies that this action applies only to files whose data type is XWD.

Compare the previous definition of the Open action to the next definition, which appears in the database file /usr/dt/appconfig/types/C/dt.dt.

ACTION Open
 {
 	LABEL					Open
 	ARG_TYPE				BM
 	TYPE					MAP
 	MAP_ACTION			Dticon
 }

This definition applies to files of data type (ARG_TYPE) BM (bitmap files). The definition maps the Open action to the Dticon action, which runs Icon Editor.

Defining the Double-Click Behavior of the Data Type

The data type's double-click behavior is defined by the first entry in the ACTIONS field. For example, for the XWD data type, the double-click behavior is to run the Open action, which in turn runs the Xwud action.

Dropping a Data File on an Action Icon

When the user drops a data file on an action icon, the system runs the action using that data file as the argument for the action (see How Actions Use Data Files as Arguments).

For example, when an XWD data file is dropped on the Xwd Display icon, the Xwud action is run using the data file argument. This runs the xwud X client with that data file.