|
NOTE: If you are not familiar with Tcl, you may want to postpone reading this section (and other sections in this book beginning with "Tcl:") until you have a chance to read B. Tcl (and perhaps some of the Tcl references recommended there).
An important reference for these examples, even if you are familiar with Tcl, is the GUI Tcl Library reference available online from Help>Manuals contents>Tornado API Reference. It describes the building blocks for the user interface (GUI) shared by the Tornado tools. |
||||||||||||||||||
All Tornado tools can be altered to your needs (and to your taste) by adding your own Tcl code. This section has a few examples of launcher customization.
When you consider modifications to the launcher, you may want to read related code in the standard form of the launcher. The Tcl code implementing the launcher is organized as follows (all file names below are relative to WIND_BASE):
When the launcher starts up, it looks for a file called .wind/launch.tcl in your home directory. If that file is present, its contents are read with the Tcl source command before the launcher puts up its initial display. Use this file to collect your custom modifications, or to incorporate shared customizations from a central repository of Tcl extensions at your site.
When you begin experimenting with any new system (or language), errors are to be expected. Any error messages from your launcher Tcl initialization code are captured by the launcher, and a summary of the error is displayed in a window similar to Figure 3-5.
To see the full Tcl error display, click on the Details button in the error display; click Continue to dismiss the display.
The examples in this section use the Tcl extensions summarized in Table 3-2. For detailed descriptions of these and other Tornado graphical building blocks in Tcl, see Help>Manuals contents>Tornado API Reference>GUI Tcl Library.
|
|||||||||||||||||||
|
|||||||||||||||||||
|
|||||||||||||||||||
Because the launcher has no direct command-line access to Tcl, it is not as convenient as other tools (such as WindSh or CrossWind) for experimentation with Tcl extensions. The following example makes things a little easier: it adds a command to the File menu that reloads the .wind/launch.tcl file. This avoids having to Quit the launcher and invoke it again, every time you change launcher customization.
# "Reinitialize" command for Launcher. # Adds item to File menu; calls Tcl "source" primitive directly. menuButtonCreate File "Re-Read Tcl" T { source ~/.wind/launch.tcl }
When you select the Quit command from the launcher File menu, the launcher displays the short form shown in Figure 3-6 to make sure you selected Quit intentionally.
This sort of safeguard is nearly universal in graphical applications, but some people find it annoying. If you would prefer to take your chances with an occasional unintended shutdown, for the sake of having the launcher obey you unquestioningly, this example may be of interest. It shows how to redefine the Quit command to shut down the launcher without first displaying a query.
To discover what procedure implements the Quit command, examine the launcher definitions in ${WIND_BASE}/host/resource/tcl/Launch.tcl. Searching there for the string "Quit" leads us to the following menuButtonCreate invocation, which shows that the procedure to redefine is called launchQuit:
menuButtonCreate File Quit Q {launchQuit}
The following redefinition of the launchQuit procedure eliminates the safeguard against leaving the launcher accidentally:
############################################################################## # launchQuit - abandon the launcher immediately # # This routine is a replacement for the launchQuit that comes with the # launcher; it runs when Quit is selected from the File menu in place of # the standard launchQuit, to avoid calling a confirmation dialog. # # SYNOPSIS: # launchQuit # # RETURNS: N/A # # ERRORS: N/A #
Because editing files is a common development activity, it may be useful to invoke an editor from the launcher. This example defines a File>Open command to run the editor specified by the EDITOR environment variable. The example is based on the file selector built into the noticePost Tcl extension.
The code in this example collects the launcher initialization (adding commands to the File menu, both for this example and for Example 3-1) in an initialization procedure<<FIXME: , as recommended in F.4 Tcl Coding Conventions>>. In the example, the launcher executes launchExtInit, which adds entries to the File menu. Of these two new entries, Open calls launchFileOpen, which in turn calls launchEdit if the user selects a file to open.
############################################################################## # # launchExtInit - collects personal launcher initialization # # This routine is invoked when the launcher begins executing, and collects # all the initialization (other than global and proc definitions) # defined in this file. # # SYNOPSIS: # launchExtInit # # RETURNS: N/A # # ERRORS: N/A #