Files
cdesktop/cde/doc/C/guides/progGuide/ch01.sgm

555 lines
30 KiB
Plaintext

<!-- Fragment document type declaration subset:
ArborText, Inc., 1988-1995, v.4001
<!DOCTYPE DOCBOOK [
<!ENTITY PG.BIntg.fig.1 SYSTEM "./progGuide/graphics/NoPrint.eps" NDATA eps>
<!ENTITY PG.BIntg.fig.2 SYSTEM "./progGuide/graphics/package.eps" NDATA eps>
<!ENTITY PG.BIntg.fig.3 SYSTEM "./progGuide/graphics/approot.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.1 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.1.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.2 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.2.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.3 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.3.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.4 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.4.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.5 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.5.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.6 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.6.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.7 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.7.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.8 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.8.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.9 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.9.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.10 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.10.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.11 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.11.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.12 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.12.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.13 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.13.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.14 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.14.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.15 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.15.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.16 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.16.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.17 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.17.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.18 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.18.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.19 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.19.eps" NDATA eps>
<!ENTITY PG.dndPG.fig.20 SYSTEM "./progGuide/graphics/PG.dndPG.iFrame.20.eps" NDATA eps>
<!ENTITY PG.widgs.fig.1 SYSTEM "./progGuide/graphics/PG.widgs.iFrame.1.eps" NDATA eps>
<!ENTITY PG.widgs.fig.2 SYSTEM "./progGuide/graphics/ComboBox.rs" NDATA eps>
<!ENTITY PG.widgs.fig.3 SYSTEM "./progGuide/graphics/MenuButton2.rs" NDATA eps>
<!ENTITY PG.calmg.fig.1 SYSTEM "./progGuide/graphics/PG.calmg.iFrame.1.eps" NDATA eps>
<!ENTITY PG.calmg.fig.2 SYSTEM "./progGuide/graphics/PG.calmg.iFrame.2.eps" NDATA eps>
<!ENTITY PG.basc1.fig.1 SYSTEM "./progGuide/graphics/NoPrint.eps" NDATA eps>
<!ENTITY PG.basic.fig.1 SYSTEM "./progGuide/graphics/NoPrint.eps" NDATA eps>
<!ENTITY PG.basic.fig.2 SYSTEM "./progGuide/graphics/package.eps" NDATA eps>
<!ENTITY PG.basic.fig.3 SYSTEM "./progGuide/graphics/approot.eps" NDATA eps>
<!ENTITY Copyr SYSTEM "./progGuide/copyright.sgm">
<!ENTITY Pref SYSTEM "./progGuide/preface.sgm">
<!ENTITY prtI SYSTEM "./progGuide/part1.sgm">
<!ENTITY prt2 SYSTEM "./progGuide/part2.sgm">
<!ENTITY fonts SYSTEM "./progGuide/ch02.sgm">
<!ENTITY msgs SYSTEM "./progGuide/ch03.sgm">
<!ENTITY smgr SYSTEM "./progGuide/ch04.sgm">
<!ENTITY dndPG SYSTEM "./progGuide/ch05.sgm">
<!ENTITY prt3 SYSTEM "./progGuide/part3.sgm">
<!ENTITY wsmgr SYSTEM "./progGuide/ch06.sgm">
<!ENTITY widgs SYSTEM "./progGuide/ch07.sgm">
<!ENTITY aIII SYSTEM "./progGuide/ch08.sgm">
<!ENTITY datat SYSTEM "./progGuide/ch09.sgm">
<!ENTITY calmg SYSTEM "./progGuide/ch10.sgm">
<!ENTITY gloss SYSTEM "./progGuide/glossary.sgm">
]>
-->
<!-- $XConsortium: ch01.sgm /main/8 1996/09/08 19:36:07 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="PG.basc1.div.1">
<title id="PG.basc1.mkr.1">Basic Application Integration</title>
<para>Basic application integration is a set of highly recommended tasks
you should perform.<indexterm><primary>basic integration</primary><secondary>definition</secondary></indexterm></para>
<informaltable id="PG.basc1.itbl.1" frame="All">
<tgroup cols="1">
<colspec colname="1" colwidth="4.0 in">
<tbody>
<row rowsep="1">
<entry><para><!--Original XRef content: 'Basic Integration Features3'--><xref
role="JumpText" linkend="PG.basc1.mkr.2"></para></entry></row>
<row rowsep="1">
<entry><para><!--Original XRef content: 'Basic Integration Tasks5'--><xref
role="JumpText" linkend="PG.basc1.mkr.3"></para></entry></row>
<row rowsep="1">
<entry><para><!--Original XRef content: 'Complete Print Integration6'--><xref
role="JumpText" linkend="PG.basc1.mkr.6"></para></entry></row>
<row rowsep="1">
<entry><para><!--Original XRef content: 'Partial Print Integration10'--><xref
role="JumpText" linkend="PG.basc1.mkr.8"></para></entry></row>
<row rowsep="1">
<entry><para><!--Original XRef content: 'Nonintegrated Printing13'--><xref
role="JumpText" linkend="PG.basc1.mkr.9"></para></entry></row></tbody></tgroup>
</informaltable>
<para>Basic integration does not involve extensive use of the desktop application
programmer's interface (API). Therefore, it does not provide other interaction
with the desktop, such as drag and drop, session management, ToolTalk&reg;
messaging, and programmatic access to the actions and data typing database.
</para>
<para>A few of the integration tasks covered in this chapter require source
code modification. They are optional, and are discussed here because they
are closely related to basic integration tasks.</para>
<sect1 id="PG.basc1.div.2">
<title id="PG.basc1.mkr.2">Basic Integration Features</title>
<para>Basic application integration provides these features for end users:
</para>
<itemizedlist remap="Bullet1"><listitem><para>A graphical way to locate and
start your application on the desktop</para>
<para>Your application will provide a desktop<indexterm><primary>registration
package</primary></indexterm> <symbol role="Variable">registration package</symbol>, and your installation script will automatically register your
application.</para>
<para>Registration creates an application group at the top level of Application
Manager. The application group contains an icon the user double-clicks to
start the application.<indexterm><primary>registration</primary><secondary>definition</secondary></indexterm></para>
</listitem><listitem><para>The ability to recognize and manipulate your application's
data files</para>
<para>Your application will provide data types for its data files.</para>
<para>Data typing configures data files to use a unique icon to help users
identify them. The data files also have meaningful desktop behavior. For
example, the user can start your application by double-clicking a data file;
dropping a data file on a desktop printer drop zone prints the file using
the appropriate print command.<indexterm><primary>data type</primary><secondary>purpose of</secondary></indexterm></para>
</listitem><listitem><para>Easy font and color selection using Style Manager<indexterm>
<primary>Style Manager</primary><secondary>integrating with</secondary></indexterm></para>
<para>Your application will change interface fonts and background, foreground,
and shadow colors dynamically.</para>
<para>The desktop defines general interface font and color resources that
are used if no corresponding application-specific resources exist.<indexterm>
<primary>fonts</primary><secondary>getting from Style Manager</secondary>
</indexterm><indexterm><primary>colors</primary><secondary>getting from Style
Manager</secondary></indexterm></para>
</listitem></itemizedlist>
<para>Basic integration provides these advantages to system administrators:<indexterm>
<primary>basic integration</primary><secondary>advantages</secondary></indexterm></para>
<itemizedlist remap="Bullet1"><listitem><para>Easy installation and registration
</para>
<para>Upon installation, the application is automatically registered. The
system administrator has little or no additional work to do.</para>
</listitem><listitem><para>Easy ongoing administration</para>
<para>All the desktop's configuration files are gathered in one location.
Furthermore, the application can easily be unregistered if, for example,
the administrator wants to update it or to move it to a different application
server.</para>
</listitem></itemizedlist>
<sect2 id="PG.basc1.div.3">
<title>Organization of Basic Integration Information</title>
<para>Most of the tasks involved in basic integration are also performed by
system administrators who are integrating an existing application into the
desktop. Therefore, most basic integration documentation is located in the
chapter &ldquo;Registering an Application&rdquo; in the <emphasis>Common
Desktop Environment: Advanced User's and System Administrator's Guide</emphasis>.
</para>
<para>This chapter guides you to that information and contains additional
information specific to application programmers.</para>
</sect2>
</sect1>
<sect1 id="PG.basc1.div.4">
<title id="PG.basc1.mkr.3">Basic Integration Tasks</title>
<para>These are the general tasks involved in basic integration:</para>
<itemizedlist remap="Bullet1"><listitem><para>Modify any application resources
that set fonts and colors. This allows users to change the application's
interface fonts and colors using Style Manager.<indexterm><primary>basic integration</primary><secondary>summary of tasks</secondary></indexterm></para>
<para>See the section on modifying font and color resources in the chapter
&ldquo;Registering an Application&rdquo; in the <emphasis>Common Desktop
Environment: Advanced User's and System Administrator's Guide</emphasis>.
</para>
</listitem><listitem><para>Create the registration package for your application.
</para>
<para>See the text, <!--Original XRef content: '&xd2;Creating a Registration
Package for Your Application'--><xref role="SectionTitle" linkend="PG.basc1.mkr.11">
and &ldquo;Registering an Application&rdquo; in the <emphasis>Common Desktop
Environment: Advanced User's and System Administrator's Guide .</emphasis></para>
</listitem><listitem><para>Modify your application's installation script to
install the registration package files and perform the registration procedure.
</para>
<para id="pg.basc1.mkr.4">See the section on registering the application using <command>dtappintegrate</command> in the chapter &ldquo;Registering an Application&rdquo;
in the <emphasis>Common Desktop Environment: Advanced User's and System Administrator's
Guide</emphasis>.<indexterm><primary>data types</primary><secondary>printing</secondary></indexterm><indexterm><primary>registration package</primary>
<secondary>providing printing</secondary></indexterm><indexterm><primary>printing integration</primary></indexterm></para>
</listitem><listitem><para>Print application data files on networked and local
printers. The desktop printer model provides a graphical way for users to
print and is built on top of the native networking capabilities of the UNIX <command>lp</command> service.</para>
</listitem></itemizedlist>
<sect2 id="PG.basc1.div.5">
<title id="PG.basc1.mkr.5">Levels of Printing Integration<indexterm><primary>printing integration</primary></indexterm><indexterm><primary>basic integration</primary><secondary>printing</secondary></indexterm></title>
<para>The printing functionality available to the user depends on the level
of integration you use. There are three levels of integration:<indexterm>
<primary>print integration</primary><secondary>levels</secondary></indexterm></para>
<itemizedlist remap="Bullet1"><listitem><para>Complete integration. See <!--Original
XRef content: '&xd2;Complete Print Integration&xd3; on page&numsp;6'--><xref
role="SecTitleAndPageNum" linkend="PG.basc1.mkr.6">.</para>
<para>You should do complete integration if you have the ability to modify
the application's source code.</para>
<para>When you do complete print integration, users can print data files on
various printers by dropping them on printer drop zones (the Front Panel
Printer control and printer icons in Print Manager). Certain other desktop
behaviors are also implemented (see <!--Original XRef content: '&xd2;Desktop
Printing Environment
Variables&xd3; on page&numsp;6'--><xref role="SecTitleAndPageNum" linkend="PG.basc1.mkr.7">).
</para>
</listitem><listitem><para>Partial integration. See <!--Original XRef content:
'&xd2;Partial Print Integration&xd3; on page&numsp;10'--><xref role="SecTitleAndPageNum"
linkend="PG.basc1.mkr.8">.</para>
<para>You should do partial integration if you do not have the ability to
modify the application's source code, but you do have the ability to invoke
printing via an action.</para>
<para>When you do partial integration, your application provides a subset
of full- integration functionality. For example, by using the <command>LPDEST</command> environment variable, your application's printing mechanism will
obtain the print destination from the drop zone.</para>
</listitem><listitem><para>No integration. See <!--Original XRef content:
'&xd2;Nonintegrated Printing&xd3; on page&numsp;13'--><xref role="SecTitleAndPageNum"
linkend="PG.basc1.mkr.9">.</para>
<para>If an application can not supply a print action for its data files,
you should configure the data files to display an error dialog box when users
drop the files on printer drop zones.</para>
</listitem></itemizedlist>
</sect2>
<sect2 id="PG.basc1.div.6">
<title id="PG.basc1.mkr.6">Complete Print Integration<indexterm><primary>print integration</primary><secondary>complete</secondary></indexterm></title>
<para>To do complete print integration, your application must:</para>
<itemizedlist remap="Bullet1"><listitem><para>Provide a Print action</para>
</listitem><listitem><para>Use (dereference) the four desktop printing environment
variables</para>
</listitem></itemizedlist>
<sect3 id="PG.basc1.div.7">
<title id="PG.basc1.mkr.7">Desktop Printing Environment Variables<indexterm>
<primary>print integration</primary><secondary>environment variables</secondary>
</indexterm><indexterm><primary>environment variables,printing</primary>
</indexterm></title>
<para>To have fully integrated printing, your application must dereference
the following four environment variables. The <command>LPDEST</command> variable
is particularly important. It provides the ability for the user to choose
the print destination by using a particular printer drop zone.</para>
<informaltable>
<tgroup cols="2" colsep="0" rowsep="0">
<?PubTbl tgroup dispwid="6.58in">
<colspec align="left" colwidth="188*">
<colspec align="left" colwidth="355*">
<thead>
<row><entry align="left" valign="bottom"><para>Printing Variable</para></entry>
<entry align="left" valign="bottom"><para>Description</para></entry></row>
</thead>
<tbody>
<row>
<entry align="left" valign="top"><para><command>LPDEST</command><indexterm>
<primary>LPDEST variable</primary></indexterm></para></entry>
<entry align="left" valign="top"><para>Uses the specified value as the printer
destination for the file. If the variable is not set, the default printing
device for your application should be used.<indexterm><primary>print integration</primary><secondary>specifying destination printer</secondary></indexterm></para></entry>
</row>
<row>
<entry align="left" valign="top"><para><command>DTPRINTUSERFILENAME</command><indexterm>
<primary>DTPRINTUSERFILENAME variable</primary></indexterm></para></entry>
<entry align="left" valign="top"><para>Specifies the name of the file as it
should appear in the Print dialog or print output. If the variable is not
set, the actual file name should be used.<indexterm><primary>print integration</primary><secondary>specifying file name</secondary></indexterm></para></entry>
</row>
<row>
<entry align="left" valign="top"><para><command>DTPRINTSILENT</command><indexterm>
<primary>DTPRINTSILENT variable</primary></indexterm></para></entry>
<entry align="left" valign="top"><para>Specifies whether to display a Print
dialog box. When the variable is set to True, the Print dialog should not
be displayed. If the variable is not set, the dialog box should be displayed.<indexterm>
<primary>print integration</primary><secondary>printing without Print dialog
box</secondary></indexterm><indexterm><primary>Print dialog box</primary>
</indexterm></para></entry></row>
<row>
<entry align="left" valign="top"><para><command>DTPRINTFILEREMOVE</command><indexterm>
<primary>DTPRINTFILEREMOVE variable</primary></indexterm></para></entry>
<entry align="left" valign="top"><para>When the variable is set to True, the
file should be removed after it is printed. This functionality is intended
for temporary files that don't need to be retained after printing is complete.
If the variable is not set, the file should not be removed.<indexterm><primary>print integration</primary><secondary>removing temporary files</secondary>
</indexterm></para></entry></row></tbody></tgroup></informaltable>
</sect3>
<sect3 id="pg.basc1.div.8">
<title>A Fully Integrated Print Action<indexterm><primary>print actions</primary></indexterm></title>
<para>The Print action is part of the registration package, provided in a
configuration file, <symbol role="Variable">app_root</symbol><filename>/dt/appconfig/types/language/</filename><symbol role="Variable">name</symbol><filename>.dt</filename>.
</para>
<para>If your print action executes a program that dereferences the four environment
variables indicated in <!--Original XRef content: '&xd2;Desktop Printing
Environment Variables'--><xref role="SectionTitle" linkend="pg.basc1.mkr.7">,
then your data type is fully integrated. The Print action must be written
to be specific for the application's data type and should accept only a single
file.</para>
<para>For example, the following print action is specific for a data type
named <command>ThisAppData</command>:</para>
<programlisting>Print
{
ARG_TYPE ThisAppData
EXEC_STRING <symbol role="Variable">print_command</symbol> -file %(file)Arg_1%
}</programlisting>
<para>If your application handles the Print ToolTalk request, then your print
action could send a variant of it with the following actions. (If any of
the four environment variables are not set, the corresponding message argument
will be null. When the message argument is null, refer to &ldquo;Desktop
Printing Environment Variables&ldquo; for the default interpretation.)</para>
<programlisting>ACTION Print
{
ARG_TYPE ThisAppData
ARG_CLASS FILE
ARG_COUNT 1
TYPE TT_MSG
TT_CLASS TT_REQUEST
TT_SCOPE TT_SESSION
TT_OPERATION Print
TT_FILE %Arg_1%
TT_ARG0_MODE TT_IN
TT_ARG0_VTYPE %Arg_1%
TT_ARG1_MODE TT_IN
TT_ARG1_VTYPE LPDEST
TT_ARG1_VALUE $LPDEST
TT_ARG2_MODE TT_IN
TT_ARG2_VTYPE DTPRINTUSERFILENAME
TT_ARG2_VALUE $DTPRINTUSERFILENAME
TT_ARG3_MODE TT_IN
TT_ARG3_VTYPE DTPRINTSILENT
TT_ARG3_VALUE $DTPRINTSILENT
TT_ARG4_MODE TT_IN
TT_ARG4_VTYPE DTPRINTFILEREMOVE
TT_ARG4_VALUE $DTPRINTFILEREMOVE
}
ACTION Print
{
ARG_TYPE ThisAppData
ARG_CLASS BUFFER
ARG_COUNT 1
TYPE TT_MSG
TT_CLASS TT_REQUEST
TT_SCOPE TT_SESSION
TT_OPERATION Print
TT_ARG0_MODE TT_IN
TT_ARG0_VTYPE %Arg_1%
TT_ARG0_VALUE %Arg_1%
TT_ARG1_MODE TT_IN
TT_ARG1_VTYPE LPDEST
TT_ARG1_VALUE $LPDEST
TT_ARG2_MODE TT_IN
TT_ARG2_VTYPE DTPRINTUSERFILENAME
TT_ARG2_VALUE $DTPRINTUSERFILENAME
TT_ARG3_MODE TT_IN
TT_ARG3_VTYPE DTPRINTSILENT
TT_ARG3_VALUE $DTPRINTSILENT
TT_ARG4_MODE TT_IN
TT_ARG4_VTYPE DTPRINTFILEREMOVE
TT_ARG4_VALUE false
}</programlisting>
</sect3>
<sect3 id="PG.basc1.div.9">
<title>Creating Print Actions for Filtered Data or Data Ready to Print<indexterm>
<primary>print filters</primary></indexterm><indexterm><primary>filters,print</primary></indexterm><indexterm><primary>print actions</primary></indexterm></title>
<para>The desktop print utility <filename>/usr/dt/dtlp</filename> provides
functionality on top of the <command>lp</command> subsystem. It gathers <command>lp</command> print options and prints the specified file.</para>
<para>Your application can use <command>dtlp</command> if either of the following
conditions are true:</para>
<itemizedlist remap="Bullet1"><listitem><para>The data files do not need to
be processed before they are sent to a printer.</para>
</listitem><listitem><para><emphasis>Or</emphasis>, your application provides
a filter for converting its data files to a ready-to-print form.</para>
</listitem></itemizedlist>
<para>If your application's data files do not meet either of these conditions, you must
provide an entry point into the application's printing system. Your application
can then use the X Print Service to print the data file. For example,
</para>
<programlisting>
Print
{
ARG_TYPE ThisAppData
EXEC_STRING app_name -print %Arg_1%
}
</programlisting>
<para>Note that the <command>dtlp</command> services are intended for printing
through the action system (as opposed to printing through the application).
For detailed information about <command>dtlp</command>, see the <filename moreinfo="RefEntry">dtlp</filename>(1) reference page.</para>
<para>If the file is ready to print, the Print action runs <command>dtlp</command>
in the <command>EXEC_STRING.</command> For example:</para>
<programlisting>Print
{
ARG_TYPE ThisAppData
EXEC_STRING dtlp %Arg_1%
}</programlisting>
<para>If the application provides a conversion filter, the filter must be
run before running <filename>dtlp.</filename> For example:</para>
<programlisting>Print
{
ARG_TYPE MyAppData
EXEC_STRING /bin/sh `cat %Arg_1%| <symbol role="Variable">filter_name</symbol> | dtlp`
}</programlisting>
<para>where <symbol role="Variable">filter_name</symbol> is the name of the
print filter.</para>
</sect3>
</sect2>
<sect2 id="PG.basc1.div.10">
<title id="PG.basc1.mkr.8">Partial Print Integration<indexterm><primary>print integration</primary><secondary>partial</secondary></indexterm></title>
<para>To do partial print integration, your application must provide:</para>
<itemizedlist remap="Bullet1"><listitem><para>A Print action</para>
</listitem><listitem><para>The extent to which printing is integrated depends
on which, if any, of the printing environment variables are handled by the
action.</para>
</listitem></itemizedlist>
<para>If your application's data files are not in a ready-to-print state, you must provide
an entry point into the printing system. Then the application can use the X Print Service
to print the data files.
</para>
<sect3 id="pg.basc1.div.11">
<title>Providing the Print Command for Partial Integration<indexterm><primary>print command line</primary><secondary>partial integration</secondary></indexterm></title>
<para>To provide partial print integration, your application must provide
a print command line of the form:</para>
<programlisting><symbol role="Variable">print_command</symbol> [<symbol role="Variable">options</symbol>] -file <symbol role="Variable">filename</symbol></programlisting>
<para>where <symbol role="Variable">options</symbol> provides a mechanism
for dereferencing none, some, or all of the printing environment variables
(see <!--Original XRef content: '&xd2;Desktop Printing
Environment Variables&xd--><!--3;
on page&numsp;6'--><xref role="SecTitleAndPageNum" linkend="pg.basc1.mkr.7">).
</para>
<para>The simplest form of this print command line omits
options.</para>
<programlisting><symbol role="Variable">print_command</symbol> -file <symbol role="Variable">filename</symbol></programlisting>
<para>This command line lets users print your application's data files using
the desktop printer drop zones. However, printing destination is not set
by the drop zone. In addition, other print behaviors set by the environment
variables are not implemented. For example, the desktop may not be able to
direct silent printing or remove temporary files.</para>
<para>If your print command line provides additional command-line options that correspond to the desktop printing
environment variables, you can provide additional integration.</para>
<para>For example, the following command line provides the ability to dereference
<command>LPDEST</command>:</para>
<programlisting><symbol role="Variable">print_command</symbol> [-d <symbol role="Variable">destination</symbol>] [-file <symbol role="Variable">filename</symbol>]</programlisting>
<para>where:</para>
<para><symbol role="Variable">destination</symbol> is the destination printer.
</para>
<para>The next print command line provides options for dereferencing all four
variables:</para>
<programlisting><symbol role="Variable">print_command</symbol> [-d <symbol role="Variable">destination</symbol>] [-u <symbol role="Variable">user_file_name</symbol>] [-s] [-e] -file <symbol role="Variable">filename</symbol></programlisting>
<para>where:</para>
<informaltable>
<tgroup cols="2" colsep="0" rowsep="0">
<colspec align="left" colwidth="100*">
<colspec align="left" colwidth="356*">
<tbody>
<row>
<entry><para><symbol role="Variable">user_file_name</symbol></para></entry>
<entry><para>The file name as seen by the user.</para></entry></row>
<row>
<entry><para><filename>-s</filename></para></entry>
<entry><para>Printing is silent (no Print dialog box is displayed).</para></entry>
</row>
<row>
<entry><para><filename>-e</filename></para></entry>
<entry><para>The file is removed after it is printed.</para></entry></row>
</tbody></tgroup></informaltable>
<para>The dereferencing occurs in the action definition. See the section,
<!--Original XRef content: '&xd2;Desktop
Printing Environment Variables&xd--><!--3; on page&numsp;6'--><xref role="SecTitleAndPageNum"
linkend="pg.basc1.mkr.7"> for more information.</para>
</sect3>
<sect3 id="pg.basc1.div.11a">
<title>Turning Environment Variables into Command Line Switches</title>
<para>If your action is not capable of dereferencing the four environment
variables, but it is capable of taking corresponding command line options,
this subsection explains how to turn the environment variable values into
command line options.</para>
<para>For example, this is a simple Print action that deferences <command>LPDEST</command>:</para>
<programlisting>Print
{
ARG_TYPE <symbol role="Variable">data_type</symbol>
EXEC_STRING <symbol role="Variable">print_command</symbol> -d $LPDEST -file %(file)Arg_1%
}</programlisting>
<para>However, this Print action may create unpredictable behavior if <command>LPDEST</command> is not set.</para>
<para>One way to create a Print action that provides proper behavior when
variables are not set is to create a shell script that is used by the Print
action.</para>
<para>For example, the following action and the script it uses properly handle
all four environment variables:</para>
<programlisting>Print
ARG_TYPE <symbol role="Variable">data_type</symbol>
EXEC_STRING <symbol role="Variable">app_root</symbol>/bin/envprint %(File)Arg_1%
}</programlisting>
<para>The contents of the <command>envprint</command> script follows:<indexterm>
<primary>print integration</primary><secondary>script for</secondary></indexterm></para>
<programlisting>#!/bin/sh
# envprint - sample print script
DEST=&rdquo;&rdquo;
USERFILENAME=&rdquo;&rdquo;
REMOVE=&rdquo;&rdquo;
SILENT=&rdquo;&rdquo;
if [ $LPDEST ]; then
DEST=&rdquo;-d $LPDEST&rdquo;
fi
if [ $DTPRINTUSERFILENAME ]; then
USERFILENAME=&rdquo;-u $DTPRINTUSERFILENAME&rdquo;
fi
DTPRINTFILEREMOVE=echo $DTPRINTFILEREMOVE | tr &ldquo;[:upper:]&rdquo;
&ldquo;[:lower:]&rdquo;`
if [ &ldquo;$DTPRINTFILEREMOVE&rdquo; = &ldquo;true&rdquo; ]; then
REMOVE=&rdquo;-e&rdquo;
fi
DTPRINTSILENT=`echo $DTPRINTSILENT | tr &ldquo;[:upper:]&rdquo; &ldquo;[:lower:]&rdquo;`
if [ &ldquo;$DTPRINTSILENT&rdquo; = &ldquo;true&rdquo; ]; then
SILENT=&rdquo;-s&rdquo;
fi
<symbol role="Variable">print_command</symbol> $DEST $USERFILENAME $REMOVE $SILENT -file $1
</programlisting>
</sect3>
</sect2>
<sect2 id="PG.basc1.div.12">
<title id="PG.basc1.mkr.9">Nonintegrated Printing<indexterm><primary>print
integration</primary><secondary>using NoPrint action</secondary></indexterm></title>
<para>If your application does not integrate printing with the desktop, users
must open your application to properly print data files.</para>
<para>Nevertheless, you should provide a Print action that runs when users
drop your application's data files on a printer drop zone. Otherwise, the
desktop may assume that the file contains text data, and the print output
will be garbled.</para>
<para>The desktop provides a print action for this purpose named NoPrint.
The NoPrint action displays a dialog box telling users that the data files
cannot be printed using the printer drop zones.</para>
<para>The<indexterm><primary>NoPrint action</primary></indexterm> NoPrint
action displays the<indexterm><primary>Unable to Print dialog box</primary>
</indexterm> Unable to Print dialog box shown in <!--Original XRef content:
'Figure&numsp;1&hyphen;1'--><xref role="CodeOrFigureOrTable" linkend="PG.basc1.mkr.10">.
</para>
<figure>
<title id="PG.basc1.mkr.10">Dialog box displayed by the built-in NoPrint action</title>
<graphic id="PG.basc1.grph.1" entityref="PG.basc1.fig.1"></graphic>
</figure>
<para>To use the Unable to Print dialog box, create a print action specific
to your data type that maps to the NoPrint action. For example, suppose the
data type for your application is:</para>
<programlisting>DATA_ATTRIBUTES MySpreadSheet_Data1
{
&mdash;
}</programlisting>
<para>The following Print action maps to the NoPrint for this data type:</para>
<programlisting>ACTION Print
{
ARG_TYPE MySpreadSheet_Data1
TYPE MAP
MAP_ACTION NoPrint
}</programlisting>
</sect2>
<sect2 id="PG.basc1.div.13">
<title id="PG.basc1.mkr.11">Creating a Registration Package for Your Application<indexterm>
<primary>registration package</primary><secondary>creating</secondary></indexterm><indexterm>
<primary>basic integration</primary><secondary>registration package</secondary>
</indexterm></title>
<para>The desktop registration package you create for an application should
become part of the application's installation package. The procedures for
creating a registration package are also performed by system administrators
integrating existing applications into the desktop. These procedures are
documented in the chapter &ldquo;Registering an Application&rdquo; in the <emphasis>Common Desktop Environment: Advanced User's and System Administrator's Guide</emphasis>.</para>
</sect2>
</sect1>
</chapter>
<!--fickle 1.14 mif-to-docbook 1.7 01/02/96 09:54:57-->
<?Pub Caret>
<?Pub *0000030451>