551 lines
27 KiB
Plaintext
551 lines
27 KiB
Plaintext
<!-- $XConsortium: ch08.sgm /main/8 1996/09/08 19:33:24 rws $ -->
|
|
<!-- (c) Copyright 1995 Digital Equipment Corporation. -->
|
|
<!-- (c) Copyright 1995 Hewlett-Packard Company. -->
|
|
<!-- (c) Copyright 1995 International Business Machines Corp. -->
|
|
<!-- (c) Copyright 1995 Sun Microsystems, Inc. -->
|
|
<!-- (c) Copyright 1995 Novell, Inc. -->
|
|
<!-- (c) Copyright 1995 FUJITSU LIMITED. -->
|
|
<!-- (c) Copyright 1995 Hitachi. -->
|
|
<Chapter Id="SAG.IntAc.div.1">
|
|
<Title Id="SAG.IntAc.mkr.1">Introduction to Actions and Data Types</Title>
|
|
<Para><Emphasis><IndexTerm>
|
|
<Primary>actions</Primary>
|
|
<Secondary>introduction</Secondary>
|
|
</IndexTerm><IndexTerm>
|
|
<Primary>data types</Primary>
|
|
<Secondary>introduction</Secondary>
|
|
</IndexTerm>Actions</Emphasis> and <Emphasis>data types</Emphasis> 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.</Para>
|
|
<InformalTable Id="SAG.IntAc.itbl.1" Frame="All">
|
|
<TGroup Cols="1">
|
|
<ColSpec Colname="1" Colwidth="4.0 in">
|
|
<TBody>
|
|
<Row Rowsep="1">
|
|
<Entry><Para><!--Original XRef content: 'Introduction To Actions128'--><XRef Role="JumpText" Linkend="SAG.IntAc.div.3"></Para></Entry>
|
|
</Row>
|
|
<Row Rowsep="1">
|
|
<Entry><Para><!--Original XRef content: 'Introduction to Data Types135'--><XRef Role="JumpText" Linkend="SAG.IntAc.div.7"></Para></Entry>
|
|
</Row>
|
|
</TBody>
|
|
</TGroup>
|
|
</InformalTable>
|
|
<Para>This chapter introduces the concepts of actions and data types. It describes:</Para>
|
|
<ItemizedList Remap="Bullet1">
|
|
<ListItem>
|
|
<Para>Why you may want to create actions and data types for applications.</Para>
|
|
</ListItem>
|
|
<ListItem>
|
|
<Para>How actions and data types are related to each other.</Para>
|
|
</ListItem>
|
|
<ListItem>
|
|
<Para>How actions and data types are related to desktop printing.</Para>
|
|
</ListItem>
|
|
</ItemizedList>
|
|
<Sect1 Id="SAG.IntAc.div.2">
|
|
<Title>See Also</Title>
|
|
<Para>The procedures and rules for creating actions and data types are covered in
|
|
three chapters in this manual.</Para>
|
|
<ItemizedList Remap="Bullet1">
|
|
<ListItem>
|
|
<Para><!--Original XRef content: 'Chapter 9'--><XRef Role="ChapterNumber" Linkend="SAG.dtCrA.div.1"> explains how to create actions and data types using the desktop
|
|
application Create Action.</Para>
|
|
<Para>You can use Create Action to create actions and data types for most
|
|
applications without having to learn the syntax rules for their definitions.</Para>
|
|
</ListItem>
|
|
<ListItem>
|
|
<Para><!--Original XRef content: 'Chapter 10'--><XRef Role="ChapterNumber" Linkend="SAG.CrAct.div.1"> and
|
|
<!--Original XRef content: 'Chapter 11'--><XRef Role="ChapterNumber" Linkend="SAG.CrDT.div.1"> explain how to create actions and data types
|
|
manually by creating and editing configuration files.</Para>
|
|
<Para>It is necessary to create actions and data types manually when you want to
|
|
use advanced features not supported by Create Action.</Para>
|
|
</ListItem>
|
|
</ItemizedList>
|
|
</Sect1>
|
|
<Sect1 Id="SAG.IntAc.div.3">
|
|
<Title Id="SAG.IntAc.mkr.2">Introduction To Actions<IndexTerm><Primary>actions</Primary><Secondary>introduction</Secondary></IndexTerm></Title>
|
|
<Para>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.</Para>
|
|
<Para>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.</Para>
|
|
<Figure>
|
|
<Title>Uses for actions</Title>
|
|
<Graphic Entityref="SAG.IntAc.fig.1" Id="SAG.IntAc.grph.1"></Graphic>
|
|
</Figure>
|
|
<Para>For example, the Desktop_Tools application group in Application Manager
|
|
contains icons that start various utilities.</Para>
|
|
<Figure>
|
|
<Title>Action icons in the Desktop_Tools application group</Title>
|
|
<Graphic Entityref="SAG.IntAc.fig.2" Id="SAG.IntAc.grph.2"></Graphic>
|
|
</Figure>
|
|
<Para>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 <Filename>/usr/dt/appconfig/types/</Filename><Symbol Role="Variable">language</Symbol><Filename>/xclients.dt</Filename>:</Para>
|
|
<programlisting>ACTION Xwud
|
|
{
|
|
LABEL Xwd Display
|
|
TYPE COMMAND
|
|
EXEC_STRING /usr/bin/X11/xwud -noclick -in \
|
|
%(File)Arg_1“Xwd File To Display:“%
|
|
…
|
|
}
|
|
</ProgramListing>
|
|
<Para>The command in the action's <Filename>EXEC_STRING</Filename> is run when the user double-clicks
|
|
the icon.</Para>
|
|
<Para><IndexTerm>
|
|
<Primary>actions</Primary>
|
|
<Secondary>used by Front Panel</Secondary>
|
|
</IndexTerm><IndexTerm>
|
|
<Primary>Front Panel</Primary>
|
|
<Secondary>using actions</Secondary>
|
|
</IndexTerm>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
|
|
<Filename>/usr/dt/appconfig/types/</Filename><Symbol Role="Variable">language</Symbol><Filename>/dtwm.fp</Filename>:</Para>
|
|
<programlisting>CONTROL Term
|
|
{
|
|
ICON Fpterm
|
|
LABEL Terminal
|
|
PUSH_ACTION Dtterm
|
|
…
|
|
}
|
|
</ProgramListing>
|
|
<Para>The <Filename>PUSH_ACTION</Filename> field specifies the action to run when the user clicks the
|
|
control—in this case, an action named Dtterm.</Para>
|
|
<Para><IndexTerm>
|
|
<Primary>actions</Primary>
|
|
<Secondary>used in menus</Secondary>
|
|
</IndexTerm><IndexTerm>
|
|
<Primary>menus</Primary>
|
|
<Secondary>using actions</Secondary>
|
|
</IndexTerm>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<Filename>.xwd</Filename> or<Filename>.wd</Filename>) have an Open action that displays the screen image by
|
|
running the Xwud action.</Para>
|
|
<Figure>
|
|
<Title>Open action for files of data type XWD</Title>
|
|
<Graphic Entityref="SAG.IntAc.fig.3" Id="SAG.IntAc.grph.3"></Graphic>
|
|
</Figure>
|
|
<Para>The actions in the<IndexTerm>
|
|
<Primary>Selected menu</Primary>
|
|
</IndexTerm>
|
|
Selected menu are specified in the data type definition for
|
|
XWD files. The definition is located in the configuration file
|
|
<Filename>/usr/dt/appconfig/types/</Filename><Symbol Role="Variable">language</Symbol><Filename>/xclients.dt.</Filename></Para>
|
|
<programlisting>DATA_ATTRIBUTES XWD
|
|
{
|
|
ACTIONS Open,Print
|
|
ICON Dtxwd
|
|
…
|
|
}
|
|
</ProgramListing>
|
|
<Para>The XWD data type, and its associated Open and Print actions, are explained
|
|
in
|
|
<!--Original XRef content: '&xd2;How Data Types Connect Data Files to Actions&xd3; on page 136'--><XRef Role="SecTitleAndPageNum" Linkend="SAG.IntAc.div.9">.</Para>
|
|
<Sect2 Id="SAG.IntAc.div.4">
|
|
<Title>How Actions Create Icons for Applications<IndexTerm><Primary>actions</Primary><Secondary>creating icons for applications</Secondary></IndexTerm><IndexTerm><Primary>applications</Primary><Secondary>creating icons for</Secondary></IndexTerm><IndexTerm><Primary>icons</Primary><Secondary>for applications</Secondary></IndexTerm></Title>
|
|
<Para>Consider the Xwd Display icon in the Desktop_Tools application group.
|
|
Double-clicking this icon runs the X client <Command>xwud</Command>. However, this icon does not
|
|
directly represent the actual <Command>xwud</Command> executable <Filename>/usr/bin/X11/xwud</Filename>.</Para>
|
|
<Para>The icon labeled Xwd Display appears in the application group because there
|
|
is a file in that directory named <Command>Xwud</Command> (see
|
|
<!--Original XRef content: 'Figure 8‐4'--><XRef Role="CodeOrFigureOrTable" Linkend="SAG.IntAc.mkr.1">). This file represents an
|
|
underlying action with the same name—Xwud. In the action definition, the
|
|
action name is the name following the <Command>ACTION</Command> keyword:</Para>
|
|
<programlisting>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.
|
|
}
|
|
</ProgramListing>
|
|
<Para><IndexTerm>
|
|
<Primary>action file</Primary>
|
|
<Secondary>definition</Secondary>
|
|
</IndexTerm>The file is called an <Emphasis>action file</Emphasis> 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<IndexTerm>
|
|
<Primary>action icon</Primary>
|
|
</IndexTerm>
|
|
<Emphasis>action icon</Emphasis>, or<IndexTerm>
|
|
<Primary>application icon</Primary>
|
|
<Secondary>creating</Secondary>
|
|
</IndexTerm>
|
|
<Emphasis>application
|
|
icon</Emphasis>, because double-clicking it starts an application.</Para>
|
|
<Figure>
|
|
<Title Id="SAG.IntAc.mkr.3">Application (action) icon representing an action file</Title>
|
|
<Graphic Entityref="SAG.IntAc.fig.4" Id="SAG.IntAc.grph.4"></Graphic>
|
|
</Figure>
|
|
<Para>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.</Para>
|
|
<Para><IndexTerm>
|
|
<Primary>action file</Primary>
|
|
<Secondary>contents</Secondary>
|
|
</IndexTerm>The content of the action file is irrelevant; action files usually contain
|
|
comments describing their desktop function.</Para>
|
|
<Note>
|
|
<Para>The <Emphasis>action file</Emphasis> is not the same as the <Emphasis>action definition file</Emphasis>. The <Emphasis>action file</Emphasis> is
|
|
a file with the same name as the action. It is used to create the <Emphasis>application icon</Emphasis>
|
|
in File Manager or Application Manager. The <Emphasis>action definition file</Emphasis> is the file
|
|
named <Symbol Role="Variable">name</Symbol><Filename>.dt</Filename> containing the definition of the action.</Para>
|
|
</Note>
|
|
<Para>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.</Para>
|
|
<ItemizedList Remap="Bullet1">
|
|
<ListItem>
|
|
<Para>The <Filename>EXEC_STRING</Filename> field specifies the behavior of the application icon. In the
|
|
case of the Xwd Display icon, the <Filename>EXEC_STRING</Filename> specifies that the action
|
|
icon runs the <Command>xwud</Command> X client with certain command-line arguments.</Para>
|
|
</ListItem>
|
|
<ListItem>
|
|
<Para>The <Command>LABEL</Command> field specifies the label for the application icon.</Para>
|
|
</ListItem>
|
|
<ListItem>
|
|
<Para>The <Command>DESCRIPTION</Command> field describes the text displayed when the user requests
|
|
On Item help.</Para>
|
|
</ListItem>
|
|
<ListItem>
|
|
<Para>The Xwud application icon uses the default icon image for actions because
|
|
its action definition does contain an <Command>ICON</Command> field to specify a different image.</Para>
|
|
<Para>In contrast, the icon labeled Compress File uses a different icon image
|
|
because its underlying action definition contains an <Command>ICON</Command> field:</Para>
|
|
<Para>For example:</Para>
|
|
<programlisting>ACTION Compress
|
|
LABEL Compress File
|
|
ICON Dtcmprs
|
|
…
|
|
}
|
|
</Programlisting>
|
|
</ListItem>
|
|
</ItemizedList>
|
|
<Figure>
|
|
<Title>Icon image specified by the ICON field in the action definition</Title>
|
|
<Graphic Entityref="SAG.IntAc.fig.5" Id="SAG.IntAc.grph.5"></Graphic>
|
|
</Figure>
|
|
<Para>The Xwud action is called a <Symbol Role="Variable">command</Symbol> action because its definition contains the
|
|
command (<Filename>EXEC_STRING</Filename>) to be run. The <Command>TYPE</Command> field in the action definition
|
|
defines the action type.</Para>
|
|
<Para>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 <Command>Xwud</Command>
|
|
will be an action file representing that action, and its icon in File Manager or
|
|
Application Manager can be used to run the action.</Para>
|
|
</Sect2>
|
|
<Sect2 Id="SAG.IntAc.div.5">
|
|
<Title Id="SAG.IntAc.mkr.4">How Actions Use Data Files as Arguments<IndexTerm><Primary>actions</Primary><Secondary>file arguments</Secondary></IndexTerm><IndexTerm><Primary>arguments</Primary><Secondary>of actions</Secondary></IndexTerm></Title>
|
|
<Para>An<IndexTerm>
|
|
<Primary>arguments</Primary>
|
|
<Secondary>of actions</Secondary>
|
|
</IndexTerm>
|
|
<Symbol Role="Variable">argument</Symbol> of a command is the thing, usually a<IndexTerm>
|
|
<Primary>file argument</Primary>
|
|
<Secondary>used in actions</Secondary>
|
|
</IndexTerm>
|
|
file, that the command acts
|
|
upon. Actions can be written to accept file arguments.</Para>
|
|
<Para>For example, the <Filename>EXEC_STRING</Filename> of the Xwud action specifies that a file
|
|
argument is required:</Para>
|
|
<programlisting>EXEC_STRING /usr/bin/X11/xwud -noclick -in \
|
|
%(File)Arg_1“Xwd File To Display:“%
|
|
</ProgramListing>
|
|
<Para>The term <Command>Arg</Command> stands for the word <Symbol Role="Variable">argument.</Symbol> The syntax<IndexTerm>
|
|
<Primary>Arg_1 syntax</Primary>
|
|
</IndexTerm>
|
|
<Filename>Arg_1</Filename> means the first
|
|
argument, and <Filename>(File)</Filename> means that the action treats that argument as a file.</Para>
|
|
<Para><IndexTerm>
|
|
<Primary>application icon</Primary>
|
|
<Secondary>dropped files</Secondary>
|
|
</IndexTerm><IndexTerm>
|
|
<Primary>actions</Primary>
|
|
<Secondary>accepting dropped files</Secondary>
|
|
</IndexTerm><IndexTerm>
|
|
<Primary>application icon</Primary>
|
|
<Secondary>double-clicking</Secondary>
|
|
</IndexTerm>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 <Filename>%</Filename> symbols
|
|
(<ComputerOutput>%(File)Arg_1“Xwd File To Display:“%</ComputerOutput>). Thus, the command that gets
|
|
executed is:</Para>
|
|
<ProgramListing>/usr/bin/X11/xwud -noclick -in <Symbol Role="Variable">file_path</Symbol></ProgramListing>
|
|
<Para>When the user double-clicks the application icon, the desktop determines from
|
|
the <Filename>EXEC_STRING</Filename> 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:</Para>
|
|
<ProgramListing>Xwd File To Display:</ProgramListing>
|
|
<Para>The file name or path supplied by the user is used as the file argument.</Para>
|
|
</Sect2>
|
|
<Sect2 Id="SAG.IntAc.div.6">
|
|
<Title>Additional Uses for Actions<IndexTerm><Primary>actions</Primary><Secondary>uses</Secondary></IndexTerm></Title>
|
|
<Para>In addition to starting applications, actions are used throughout the desktop to
|
|
create functionality in:</Para>
|
|
<ItemizedList Remap="Bullet1">
|
|
<ListItem>
|
|
<Para>The Front Panel.</Para>
|
|
<Para>The definition for a Front Panel control includes fields that specify the
|
|
action that runs when the user clicks the control or drops a file on it. For
|
|
more information, see
|
|
<!--Original XRef content: '&xd2;Defining Front Panel Controls&xd3; on page 228'--><XRef Role="SecTitleAndPageNum" Linkend="SAG.FrPC.div.34">.</Para>
|
|
</ListItem>
|
|
<ListItem>
|
|
<Para>Menus.</Para>
|
|
<Para>The syntax for the Window and Workspace menu definitions allows you to
|
|
specify the action to be run by a menu item. For more information, see
|
|
<!--Original XRef content: '&xd2;Workspace Manager Menus&xd3; on page 246'--><XRef Role="SecTitleAndPageNum" Linkend="SAG.WMCnf.div.13"> and the <Filename MoreInfo="RefEntry">dtwmrc(4)</Filename> man page.</Para>
|
|
</ListItem>
|
|
<ListItem>
|
|
<Para>Communication between applications.</Para>
|
|
<Para>An application can be designed to send and receive information using a
|
|
special type of action called ToolTalk message (<Filename>TT_MSG</Filename>). <Filename>TT_MSG</Filename> actions are
|
|
described in the developer environment documentation for the desktop.</Para>
|
|
</ListItem>
|
|
</ItemizedList>
|
|
</Sect2>
|
|
</Sect1>
|
|
<Sect1 Id="SAG.IntAc.div.7">
|
|
<Title Id="SAG.IntAc.mkr.5">Introduction to Data Types<IndexTerm><Primary>data types</Primary><Secondary>introduction</Secondary></IndexTerm></Title>
|
|
<Para>When the user creates a new data file, the appearance and behavior of the file's
|
|
icon in File Manager varies depending on the type of data file the user has
|
|
created. This ability to create custom appearance and behavior for files and
|
|
directories is provided by the desktop's data typing mechanism.</Para>
|
|
<Sect2 Id="SAG.IntAc.div.8">
|
|
<Title>What Is a Data Type?<IndexTerm><Primary>Create Action</Primary><Secondary>data type creation</Secondary></IndexTerm><IndexTerm><Primary>data types</Primary><Secondary>created with Create Action</Secondary></IndexTerm></Title>
|
|
<Para>A data type is a construct that is defined within the desktop database. For
|
|
example, here is the definition of the XWD data type. The definition is in the
|
|
configuration file <Filename>/usr/dt/appconfig/types/</Filename><Symbol Role="Variable">language</Symbol><Filename>/xclients.dt</Filename>:</Para>
|
|
<programlisting>DATA_ATTRIBUTES XWD
|
|
{
|
|
ACTIONS Open,Print
|
|
ICON Dtxwd
|
|
NAME_TEMPLATE %s.xwd
|
|
MIME_TYPE application/octet-stream
|
|
SUNV3_TYPE xwd-file
|
|
DESCRIPTION This file contains a graphics image in the XWD \
|
|
format. These files are typically created by \
|
|
taking snapshots of windows using the XwdCapture \
|
|
action. Its data type is named XWD. XWD files \
|
|
have names ending with `.xwd' or `.wd'.
|
|
}
|
|
DATA_CRITERIA XWD1
|
|
{
|
|
DATA_ATTRIBUTES_NAME XWD
|
|
MODE f
|
|
NAME_PATTERN *.xwd
|
|
}
|
|
|
|
DATA_CRITERIA XWD2
|
|
{
|
|
DATA_ATTRIBUTES_NAME XWD
|
|
MODE f
|
|
NAME_PATTERN *.wd
|
|
}
|
|
</ProgramListing>
|
|
<Para>Every data type definition has two parts:</Para>
|
|
<InformalTable>
|
|
<TGroup Cols="2" colsep="0" rowsep="0">
|
|
<colspec colwidth="161*">
|
|
<colspec colwidth="367*">
|
|
<TBody>
|
|
<Row>
|
|
<Entry><Para><Filename>DATA_ATTRIBUTES</Filename></Para></Entry>
|
|
<Entry><Para>Describes the appearance and behavior of the data
|
|
type.</Para></Entry>
|
|
</Row>
|
|
<Row>
|
|
<Entry><Para><Filename>DATA_CRITERIA</Filename>,</Para></Entry>
|
|
<Entry><Para>Specifies the rules (naming or content) for categorizing
|
|
a file as belonging to that data type.</Para></Entry>
|
|
</Row>
|
|
</TBody>
|
|
</TGroup>
|
|
</InformalTable>
|
|
<Para>The <Filename>DATA_ATTRIBUTES_NAME</Filename> field connects the criteria to the attributes.</Para>
|
|
<Para>There can be multiple <Filename>DATA_CRITERIA</Filename> for a <Filename>DATA_ATTRIBUTE</Filename>. For example,
|
|
the XWD data type has two criteria to specify two different naming criteria
|
|
(<Filename>NAME_PATTERN</Filename>)—names ending with <Filename>.xwd</Filename> or <Filename>.wd</Filename>.</Para>
|
|
</Sect2>
|
|
<Sect2 Id="SAG.IntAc.div.9">
|
|
<Title Id="SAG.IntAc.mkr.6">How Data Types Connect Data Files to Actions<IndexTerm><Primary>data types</Primary><Secondary>relationship to actions</Secondary></IndexTerm><IndexTerm><Primary>actions</Primary><Secondary>relationship to data types</Secondary></IndexTerm></Title>
|
|
<Para>Consider the XWD data type. The user creates an XWD-type file by giving the
|
|
file one of two file-name suffixes (extensions): <Filename>.xwd</Filename> or<Filename>.wd</Filename>. The desktop uses
|
|
the file name as the <Emphasis>criteria</Emphasis> for designating a file as that type.</Para>
|
|
<Para>The XWD data type supplies each file of that data type with:</Para>
|
|
<ItemizedList Remap="Bullet1">
|
|
<ListItem>
|
|
<Para>A unique icon image that helps users recognize the data files.</Para>
|
|
</ListItem>
|
|
<ListItem>
|
|
<Para>On Item help that tells you about the data type.</Para>
|
|
</ListItem>
|
|
<ListItem>
|
|
<Para>A customized Selected menu in File Manager containing the actions Open
|
|
and Print. The Open action for XWD files runs the Xwud action.</Para>
|
|
</ListItem>
|
|
</ItemizedList>
|
|
<Sect3 Id="SAG.IntAc.div.10">
|
|
<Title>Running Actions from the Selected Menu<IndexTerm><Primary>Selected menu</Primary></IndexTerm></Title>
|
|
<Para>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.</Para>
|
|
<Para>The <Command>ACTIONS</Command> field in the data type definition specifies the commands added to
|
|
the bottom of the data type's Selected menu.</Para>
|
|
<programlisting>DATA_ATTRIBUTES XWD
|
|
{
|
|
ACTIONS Open,Print
|
|
…
|
|
}
|
|
</programlisting>
|
|
<Para><IndexTerm>
|
|
<Primary>Selected menu</Primary>
|
|
</IndexTerm>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.</Para>
|
|
<Figure>
|
|
<Title>The Selected menu for an XWD file</Title>
|
|
<Graphic Entityref="SAG.IntAc.fig.6" Id="SAG.IntAc.grph.6"></Graphic>
|
|
</Figure>
|
|
<Para>The<IndexTerm>
|
|
<Primary>Open action</Primary>
|
|
</IndexTerm>
|
|
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.</Para>
|
|
<Para>The ability to create a variety of Open actions that do different things uses two
|
|
features of action definitions:</Para>
|
|
<ItemizedList Remap="Bullet1">
|
|
<ListItem>
|
|
<Para>Action mapping.<IndexTerm><Primary>actions</Primary><Secondary>mapping</Secondary></IndexTerm><IndexTerm><Primary>MAP actions</Primary></IndexTerm>
|
|
</Para>
|
|
<Para>Action mapping lets you create an action that runs another action, rather
|
|
than directly running a command. For example, you can create an Open
|
|
action that maps to (runs) the Xwud action.</Para>
|
|
</ListItem>
|
|
<ListItem>
|
|
<Para>Data-type restrictions on an action.<IndexTerm><Primary>actions</Primary><Secondary>restricted by data type</Secondary></IndexTerm>
|
|
</Para>
|
|
<Para>Action definitions can include an <Filename>ARG_TYPE</Filename> field that limits the action to
|
|
certain data types. For example, you can specify that the Open action that
|
|
maps to the Xwud action applies only to files of data type XWD.</Para>
|
|
</ListItem>
|
|
</ItemizedList>
|
|
<Para>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
|
|
<Filename>/usr/dt/appconfig/types/<Symbol Role="Variable">language</Symbol>/xclients.dt</Filename>:</Para>
|
|
<programlisting>ACTION Open
|
|
{
|
|
LABEL Open
|
|
ARG_TYPE XWD
|
|
TYPE MAP
|
|
MAP_ACTION Xwud
|
|
}
|
|
</ProgramListing>
|
|
<Para>The <Command>TYPE</Command> field specifies that this is a map action; the <Filename>MAP_ACTION</Filename> field
|
|
specifies this action runs the Xwud action. The <Filename>ARG_TYPE</Filename> field specifies that
|
|
this action applies only to files whose data type is XWD.</Para>
|
|
<Para>Compare the previous definition of the Open action to the next definition,
|
|
which appears in the database file <Filename>/usr/dt/appconfig/types/<Symbol Role="Variable">language</Symbol>/dt.dt</Filename>:</Para>
|
|
<programlisting>ACTION Open
|
|
{
|
|
LABEL Open
|
|
ARG_TYPE BM
|
|
TYPE MAP
|
|
MAP_ACTION Dticon
|
|
}
|
|
</ProgramListing>
|
|
<Para>This definition applies to files of data type (<Filename>ARG_TYPE</Filename>) BM (bitmap files). The
|
|
definition maps the Open action to the Dticon action, which runs Icon Editor.</Para>
|
|
</Sect3>
|
|
<Sect3 Id="SAG.IntAc.div.11">
|
|
<Title><IndexTerm><Primary>data types</Primary><Secondary>double-click behavior</Secondary></IndexTerm>Defining the Double-Click Behavior of the Data Type</Title>
|
|
<Para>The data type's double-click behavior is defined by the first entry in the
|
|
<Command>ACTIONS</Command> 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.</Para>
|
|
</Sect3>
|
|
<Sect3 Id="SAG.IntAc.div.12">
|
|
<Title>Dropping a Data File on an Action Icon<IndexTerm><Primary>data types</Primary><Secondary>drop behavior</Secondary></IndexTerm></Title>
|
|
<Para>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
|
|
<!--Original XRef content: '&xd2;How Actions Use Data
|
|
Files as Arguments&xd3; on page 133'--><XRef Role="SecTitleAndPageNum" Linkend="SAG.IntAc.mkr.4">).</Para>
|
|
<Para>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 <Command>xwud</Command> X client
|
|
with that data file.</Para>
|
|
</Sect3>
|
|
</Sect2>
|
|
<Sect2 Id="SAG.IntAc.div.13">
|
|
<Title>Creating Desktop Printing for a Data Type<IndexTerm><Primary>data types</Primary><Secondary>printing</Secondary></IndexTerm><IndexTerm><Primary>printing</Primary><Secondary>configuring for data type</Secondary></IndexTerm></Title>
|
|
<Para>Desktop printing provides these ways to print a data file:</Para>
|
|
<ItemizedList Remap="Bullet1">
|
|
<ListItem>
|
|
<Para>Using the Print command, if available, in the File Manager Selected menu.</Para>
|
|
</ListItem>
|
|
<ListItem>
|
|
<Para>Dropping a data file on a desktop printer drop zone (the Front Panel Printer
|
|
control or a printer icon in Print Manager).</Para>
|
|
</ListItem>
|
|
</ItemizedList>
|
|
<Para>In addition to desktop printing, many applications provide a way to print from
|
|
within the application.</Para>
|
|
<Para>Desktop printing uses actions named Print. Print, like Open, is an action name
|
|
that is used for many different types of data. Therefore, Print actions use action
|
|
mapping and the <Filename>ARG_TYPE</Filename> field to customize printing for each data type.</Para>
|
|
<Para>For example, here is the Print action for the XWD data type. The definition is
|
|
located in <Filename>/usr/dt/appconfig/types/</Filename><Symbol Role="Variable">language</Symbol><Filename>/xclients.dt</Filename>:</Para>
|
|
<programlisting>ACTION Print
|
|
{
|
|
LABEL Print
|
|
ARG_TYPE XWD
|
|
TYPE MAP
|
|
MAP_ACTION NoPrint
|
|
}
|
|
</ProgramListing>
|
|
<Para>This Print action, specific to XWD files, is mapped to a NoPrint action. NoPrint
|
|
is a special action defined in <Filename>/usr/dt/appconfig/types/</Filename><Symbol Role="Variable">language</Symbol><Filename>/dt.dt</Filename>.
|
|
The<IndexTerm>
|
|
<Primary>NoPrint action</Primary>
|
|
</IndexTerm>
|
|
NoPrint action displays a dialog box telling the user that this data type
|
|
cannot be printed.</Para>
|
|
<Para>Compare the XWD Print action with the following Print action for PCL files:</Para>
|
|
<programlisting>ACTION Print
|
|
LABEL Print
|
|
ARG_TYPE PCL
|
|
TYPE MAP
|
|
MAP_ACTION PrintRaw
|
|
}
|
|
</ProgramListing>
|
|
<Para>The PrintRaw action, defined in the configuration file
|
|
<Filename>/usr/dt/appconfig/types/</Filename><Symbol Role="Variable">language</Symbol><Filename>/print.dt</Filename>, contains the command
|
|
line for printing the PCL files.</Para>
|
|
<programlisting>ACTION PrintRaw
|
|
{
|
|
TYPE COMMAND
|
|
WINDOW_TYPE NO_STDIO
|
|
EXEC_STRING /usr/dt/bin/dtlp -w %(File)Arg_1%
|
|
}
|
|
</ProgramListing>
|
|
</Sect2>
|
|
</Sect1>
|
|
</Chapter>
|
|
<!--fickle 1.14 mif-to-docbook 1.7 01/02/96 06:16:56-->
|