Common Desktop Environment: ToolTalk Messaging Overview

Optional Tasks ToolTalk-aware Editor Applications Can Perform

In addition to the tasks described in the section "Tasks ToolTalk-aware Editor Applications Need to Perform" editor applications can also perform other optional tasks such as tasks that use desktop file interfaces to coordinate with other editors. This section provides examples of some of the ToolTalk code you need to include in your editor application so that it can perform these optional tasks.


Note -

The code snippets used in this section are taken from the CoEditor.C file. This file contains specific commands for editor applications. See Appendix B, The CoEd Demonstration Program for the detailed source code.


Requesting Modify, Revert, or Save Operations

The following code snippet asks a file whether it has any changes pending:

// Does the file have any changes pending?
_modifiedByOther = ttdt_Get_Modified( _contract, _file, TT_BOTH,
                     10 * timeOutFactor );

The following code snippet reverts a file to its last version:

// Revert file to last version 
status = ttdt_Revert(_contract, _file, TT_BOTH,
              10 * timeOutFactor );

The following code snippet saves pending changes to a file:

// Save pending changes 
status = ttdt_Save( _contract, _file, TT_BOTH,
             10 * timeOutFactor );

Notifying When a File Is Modified, Reverted, or Saved

The following code snippet announces to interested tools that your application has changes pending for the file:

// File has been modified 
ttdt_file_event( _contract, TTDT_MODIFIED, _filePats, 1 );

The following code snippet announces to interested tools that your application has reverted the file to its last saved version:

// File has been reverted to last version 
ttdt_file_event( _contract, TTDT_REVERTED, _filePats, 1 );

The following code snippet announces to interested tools that your application has saved its pending changes for the file.

// File has been saved 
ttdt_file_event( _contract, TTDT_SAVED, _filePats, 1 );

Quitting a File

The following code snippet unregisters interest in ToolTalk events about a file and destroys the patterns.

// Unregister interest in ToolTalk events and destroy patterns 
status = ttdt_file_quit( _filePats, 1 );
    _filePats = 0;