cdesktopenv/cde/programs/ttsnoop/ttChooser_stubs.C.src

674 lines
20 KiB
Plaintext

/*** DTB_USER_CODE_START vvv Add file header below vvv ***/
//%% (c) Copyright 1993, 1994 Hewlett-Packard Company
//%% (c) Copyright 1993, 1994 International Business Machines Corp.
//%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
//%% (c) Copyright 1993, 1994 Novell, Inc.
//%% $XConsortium: ttChooser_stubs.C.src /main/3 1995/11/06 17:14:10 rswiston $
/*** DTB_USER_CODE_END ^^^ Add file header above ^^^ ***/
/*
* File: ttChooser_stubs.c
* Contains: Module callbacks and connection functions
*
* This file was generated by dtcodegen, from module ttChooser
*
* Any text may be added between the DTB_USER_CODE_START and
* DTB_USER_CODE_END comments (even non-C code). Descriptive comments
* are provided only as an aid.
*
* ** EDIT ONLY WITHIN SECTIONS MARKED WITH DTB_USER_CODE COMMENTS. **
* ** ALL OTHER MODIFICATIONS WILL BE OVERWRITTEN. DO NOT MODIFY OR **
* ** DELETE THE GENERATED COMMENTS! **
*/
#include <stdint.h>
#include <stdio.h>
#include <Xm/Xm.h>
#include "dtb_utils.h"
#include "ttChooser_ui.h"
/*
* Header files for cross-module connections
*/
#include "ttsnoop_ui.h"
/**************************************************************************
*** DTB_USER_CODE_START
***
*** All necessary header files have been included.
***
*** Add include files, types, macros, externs, and user functions here.
***/
#include <stdio.h>
#include <sstream>
#include <Xm/TextF.h>
#include <Xm/List.h>
#include "DtTt.h"
void
_DtTtChooserSet(
_DtTtChooserAction choice,
void * entity
)
{
DtbTtChooserChooserInfo instance = &dtb_tt_chooser_chooser;
if (! instance->initialized) {
dtb_tt_chooser_chooser_initialize(
instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin );
}
char *okString;
char *title;
char *valueLabel;
char *valuesLabel;
switch (choice) {
case _DtTtChooserNone:
return;
case _DtTtChooserMessageOpen:
okString = "Open";
title = "Open Tt_message";
break;
case _DtTtChooserMessageCreateStandard:
okString = "Create";
title = "Create Standard Tt_message";
break;
case _DtTtChooserMessageOpSet:
okString = "Set";
title = "tt_message_op_set";
break;
case _DtTtChooserMessageHandlerSet:
okString = "Set";
title = "tt_message_handler_set";
break;
case _DtTtChooserMessageDestroy:
okString = "Destroy";
title = "tt_message_destroy";
break;
case _DtTtChooserPatternOpen:
okString = "Open";
title = "Open Tt_pattern";
break;
case _DtTtChooserPatternOpAdd:
okString = "Add";
title = "tt_pattern_op_add";
break;
case _DtTtChooserPatternSenderAdd:
okString = "Add";
title = "tt_pattern_sender_add";
break;
case _DtTtChooserPatternDestroy:
okString = "Destroy";
title = "tt_pattern_destroy";
break;
case _DtTtChooserDtSessionQuit:
okString = "Quit";
title = "ttdt_session_quit";
break;
case _DtTtChooserDtFileDeleted:
okString = "Send";
title = "ttdt_file_event(,TTDT_DELETED)";
break;
case _DtTtChooserDtFileModified:
okString = "Send";
title = "ttdt_file_event(,TTDT_MODIFIED)";
break;
case _DtTtChooserDtFileReverted:
okString = "Send";
title = "ttdt_file_event(,TTDT_REVERTED)";
break;
case _DtTtChooserDtFileMoved:
okString = "Send";
title = "ttdt_file_event(,TTDT_MOVED)";
break;
case _DtTtChooserDtFileSaved:
okString = "Send";
title = "ttdt_file_event(,TTDT_SAVED)";
break;
case _DtTtChooserDtFileQuit:
okString = "Quit";
title = "ttdt_file_quit";
break;
case _DtTtChooserProcidSetDefault:
okString = "Set";
title = "tt_default_procid_set";
break;
case _DtTtChooserProcidSuspend:
okString = "Remove";
title = "XtRemoveInput";
break;
case _DtTtChooserProcidResume:
okString = "Add";
title = "XtAppAddInput";
break;
case _DtTtChooserDtProcidClose:
okString = "Close";
title = "ttdt_close";
break;
}
DtTtType type;
switch (choice) {
case _DtTtChooserNone:
return;
case _DtTtChooserMessageOpSet:
case _DtTtChooserPatternOpAdd:
case _DtTtChooserMessageCreateStandard:
valueLabel = "Op:";
valuesLabel = "Standard Op";
type = DTTT_OP;
break;
case _DtTtChooserMessageOpen:
case _DtTtChooserMessageDestroy:
valueLabel = "Tt_message:";
valuesLabel = "Tt_message";
type = DTTT_MESSAGE;
break;
case _DtTtChooserPatternOpen:
case _DtTtChooserPatternDestroy:
valueLabel = "Tt_pattern:";
valuesLabel = "Tt_pattern";
type = DTTT_PATTERN;
break;
case _DtTtChooserDtSessionQuit:
valueLabel = "Tt_pattern *:";
valuesLabel = "Desktop-joined session";
type = DTTT_DTSESSION;
break;
case _DtTtChooserDtFileDeleted:
case _DtTtChooserDtFileModified:
case _DtTtChooserDtFileReverted:
case _DtTtChooserDtFileMoved:
case _DtTtChooserDtFileSaved:
case _DtTtChooserDtFileQuit:
valueLabel = "Tt_pattern *:";
valuesLabel = "Desktop-joined file";
type = DTTT_DTFILE;
break;
case _DtTtChooserMessageHandlerSet:
case _DtTtChooserPatternSenderAdd:
case _DtTtChooserProcidSetDefault:
case _DtTtChooserProcidSuspend:
case _DtTtChooserProcidResume:
case _DtTtChooserDtProcidClose:
valueLabel = "Procid:";
valuesLabel = "Procid";
type = DTTT_PROCID;
break;
}
DtTtSetLabel( instance->chooserOkButton, okString );
DtTtSetLabel( instance->chooserText_label, valueLabel );
int itemCount;
XmString *items = _DtTtChoices( type, &itemCount );
XtVaSetValues( instance->chooserList,
XmNitemCount, itemCount,
XmNitems, items,
NULL );
XmListDeselectAllItems( instance->chooserList );
XmTextFieldSetString( instance->chooserText, 0 );
XtVaSetValues( instance->chooser, XmNtitle, title, NULL );
std::ostringstream valuesStream;
valuesStream << itemCount << " " << valuesLabel;
if (itemCount != 1) valuesStream << "s";
valuesStream << ends;
DtTtSetLabel( instance->chooserList_label, valuesStream.str().c_str() );
// Remember dialog mode, entity
XtVaSetValues( instance->chooserOkButton, XmNuserData, choice, NULL );
XtVaSetValues( instance->chooserCancelButton, XmNuserData, entity, NULL );
XtManageChild( instance->chooser_shellform );
}
/*** DTB_USER_CODE_END
***
*** End of user code section
***
**************************************************************************/
void
ttChooser_chooserCancelButton_CB1(
Widget widget,
XtPointer clientData,
XtPointer callData
)
{
/*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
/*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
if (!(instance->initialized))
{
dtb_tt_chooser_chooser_initialize(instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin);
}
XtUnmanageChild(instance->chooser_shellform);
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
}
void
choiceSelected(
Widget widget,
XtPointer clientData,
XtPointer callData
)
{
/*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
/*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
XmListCallbackStruct *info = (XmListCallbackStruct *)callData;
int choice;
XtVaGetValues( instance->chooserOkButton, XmNuserData, &choice, NULL );
DtTtType type;
Boolean isString = False;
switch ((_DtTtChooserAction)choice) {
case _DtTtChooserNone:
return;
case _DtTtChooserMessageOpSet:
case _DtTtChooserPatternOpAdd:
case _DtTtChooserMessageCreateStandard:
isString = True;
type = DTTT_OP;
break;
case _DtTtChooserMessageOpen:
case _DtTtChooserMessageDestroy:
type = DTTT_MESSAGE;
break;
case _DtTtChooserPatternOpen:
case _DtTtChooserPatternDestroy:
type = DTTT_PATTERN;
break;
case _DtTtChooserDtSessionQuit:
type = DTTT_DTSESSION;
break;
case _DtTtChooserDtFileDeleted:
case _DtTtChooserDtFileModified:
case _DtTtChooserDtFileReverted:
case _DtTtChooserDtFileMoved:
case _DtTtChooserDtFileSaved:
case _DtTtChooserDtFileQuit:
type = DTTT_DTFILE;
break;
case _DtTtChooserMessageHandlerSet:
case _DtTtChooserPatternSenderAdd:
case _DtTtChooserProcidSetDefault:
case _DtTtChooserProcidSuspend:
case _DtTtChooserProcidResume:
case _DtTtChooserDtProcidClose:
isString = True;
type = DTTT_PROCID;
break;
}
void *entity = DtTtNth( type, info->item_position - 1 );
std::ostringstream entityName;
if (isString) {
entityName << (char *)entity << ends;
} else {
entityName << entity << ends;
}
XmTextFieldSetString( instance->chooserText, const_cast<char *>(entityName.str().c_str()) );
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
}
void
choiceOkayed(
Widget widget,
XtPointer clientData,
XtPointer callData
)
{
/*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
/*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
char *text = XmTextFieldGetString( instance->chooserText );
int ival;
XtVaGetValues( instance->chooserOkButton, XmNuserData, &ival, NULL );
_DtTtChooserAction choice = (_DtTtChooserAction)ival;
Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
switch (choice) {
int ival, fd;
Tt_message msg;
Tt_pattern pat;
Tt_pattern *pats;
Tt_status status;
char *func, *procid;
XtPointer xtPtr;
XtInputId id;
Widget newWidget;
case _DtTtChooserNone:
return;
case _DtTtChooserMessageCreateStandard:
msg = tttk_message_create( text );
status = DtTtSetLabel( label, "tt_message_create()", msg );
if (tt_is_err( status )) {
break;
}
DtTtCreated( DTTT_MESSAGE, msg );
newWidget = DtTtMessageWidgetCreate(
dtb_ttsnoop_ttsnoop_win.ttsnoopWin, msg,
DtTtMessageWidgetUpdate );
status = tt_ptr_error( newWidget );
if (tt_is_err( status )) {
return;
}
XRaiseWindow( XtDisplay( newWidget ), XtWindow( newWidget ));
XtUnmanageChild( instance->chooser_shellform );
break;
case _DtTtChooserMessageOpSet:
XtVaGetValues( instance->chooserCancelButton,
XmNuserData, &xtPtr, NULL );
_DtTtMessageUpdate( (Tt_message)xtPtr, choice, text );
XtUnmanageChild( instance->chooser_shellform );
break;
case _DtTtChooserPatternOpAdd:
XtVaGetValues( instance->chooserCancelButton,
XmNuserData, &xtPtr, NULL );
_DtTtPatternUpdate( (Tt_pattern)xtPtr, choice, text );
XtUnmanageChild( instance->chooser_shellform );
break;
case _DtTtChooserMessageHandlerSet:
XtVaGetValues( instance->chooserCancelButton,
XmNuserData, &xtPtr, NULL );
_DtTtMessageUpdate( (Tt_message)xtPtr, choice, text );
XtUnmanageChild( instance->chooser_shellform );
break;
case _DtTtChooserPatternSenderAdd:
XtVaGetValues( instance->chooserCancelButton,
XmNuserData, &xtPtr, NULL );
_DtTtPatternUpdate( (Tt_pattern)xtPtr, choice, text );
XtUnmanageChild( instance->chooser_shellform );
break;
case _DtTtChooserMessageOpen:
case _DtTtChooserMessageDestroy:
if (text == 0) {
return;
}
ival = 0;
sscanf( text, "%i", &ival );
msg = (Tt_message) (intptr_t) ival;
if (DtTtIndex( DTTT_MESSAGE, msg ) < 0) {
return;
}
if (choice == _DtTtChooserMessageOpen) {
Widget newWidget = DtTtMessageWidgetCreate(
dtb_ttsnoop_ttsnoop_win.ttsnoopWin,
msg, DtTtMessageWidgetUpdate );
Tt_status status = tt_ptr_error( newWidget );
if (tt_is_err( status )) {
return;
}
XRaiseWindow( XtDisplay( newWidget ), XtWindow( newWidget ));
} else {
Widget msgWidget = DtTtMessageWidget( msg );
Tt_status status = tttk_message_destroy( msg );
if (status == TT_WRN_STOPPED) {
DtTtSetLabel( label, "tttk_message_destroy()",
status );
return;
}
DtTtDestroyed( DTTT_MESSAGE, msg );
if (msgWidget != 0) {
XtDestroyWidget( msgWidget );
}
_DtTtChooserSet( _DtTtChooserMessageDestroy );
}
break;
case _DtTtChooserPatternOpen:
case _DtTtChooserPatternDestroy:
if (text == 0) {
return;
}
ival = 0;
sscanf( text, "%i", &ival );
pat = (Tt_pattern) (intptr_t) ival;
if (DtTtIndex( DTTT_PATTERN, pat ) < 0) {
return;
}
if (choice == _DtTtChooserPatternOpen) {
Widget newWidget = DtTtPatternWidgetCreate(
dtb_ttsnoop_ttsnoop_win.ttsnoopWin,
pat, 0 );
Tt_status status = tt_ptr_error( newWidget );
if (tt_is_err( status )) {
return;
}
XRaiseWindow( XtDisplay( newWidget ), XtWindow( newWidget ));
} else {
Widget patWidget = DtTtPatternWidget( pat );
Tt_status status = tt_pattern_destroy( pat );
if (status == TT_WRN_STOPPED) {
DtTtSetLabel( label, "tt_pattern_destroy()",
status );
return;
}
DtTtDestroyed( DTTT_PATTERN, pat );
if (patWidget != 0) {
XtDestroyWidget( patWidget );
}
_DtTtChooserSet( _DtTtChooserPatternDestroy );
}
break;
case _DtTtChooserDtSessionQuit:
if (text == 0) {
return;
}
ival = 0;
sscanf( text, "%i", &ival );
pats = (Tt_pattern *) (intptr_t) ival;
if (DtTtIndex( DTTT_DTSESSION, pats ) < 0) {
return;
}
text = (char *)tt_pattern_user( *pats, _DtTtPatsNameKey );
if (tt_is_err( tt_ptr_error( text )) || text == 0) {
return;
}
status = ttdt_session_quit( text, pats, 1 );
DtTtSetLabel( label, "ttdt_session_quit()", status );
if (status == TT_OK) {
DtTtDestroyed( DTTT_DTSESSION, pats );
}
XtUnmanageChild( instance->chooser_shellform );
break;
case _DtTtChooserDtFileDeleted:
case _DtTtChooserDtFileModified:
case _DtTtChooserDtFileReverted:
case _DtTtChooserDtFileMoved:
case _DtTtChooserDtFileSaved:
case _DtTtChooserDtFileQuit:
if (text == 0) {
return;
}
ival = 0;
sscanf( text, "%i", &ival );
pats = (Tt_pattern *) (intptr_t) ival;
if (DtTtIndex( DTTT_DTFILE, pats ) < 0) {
return;
}
switch ((_DtTtChooserAction)choice) {
case _DtTtChooserDtFileModified:
status = ttdt_file_event( 0, TTDT_MODIFIED, pats, 1 );
func = "ttdt_file_event(,TTDT_MODIFIED)";
break;
case _DtTtChooserDtFileReverted:
status = ttdt_file_event( 0, TTDT_REVERTED, pats, 1 );
func = "ttdt_file_event(,TTDT_REVERTED)";
break;
case _DtTtChooserDtFileSaved:
status = ttdt_file_event( 0, TTDT_SAVED, pats, 1 );
func = "ttdt_file_event(,TTDT_SAVED)";
break;
case _DtTtChooserDtFileQuit:
status = ttdt_file_quit( pats, 1 );
func = "ttdt_file_quit()";
if (status == TT_OK) {
DtTtDestroyed( DTTT_DTFILE, pats );
}
break;
}
DtTtSetLabel( label, func, status );
XtUnmanageChild( instance->chooser_shellform );
case _DtTtChooserProcidSetDefault:
status = tt_default_procid_set( text );
DtTtSetLabel( label, "tt_default_procid_set()", status );
XtUnmanageChild( instance->chooser_shellform );
break;
case _DtTtChooserProcidSuspend:
ival = DtTtIndex( DTTT_PROCID, text );
if (ival < 0) {
return;
}
id = (XtInputId)DtTtNthClientDatum( DTTT_PROCID, ival );
if (id != 0) {
XtRemoveInput( id );
DtTtSetLabel( label, "XtRemoveInput()" );
}
XtUnmanageChild( instance->chooser_shellform );
break;
case _DtTtChooserProcidResume:
ival = DtTtIndex( DTTT_PROCID, text );
if (ival < 0) {
return;
}
fd = tt_procid_fd( text );
if (tt_is_err( tt_int_error( fd ))) {
return;
}
id = XtAppAddInput( XtWidgetToApplicationContext( label ),
fd, (XtPointer)XtInputReadMask,
tttk_Xt_input_handler, text );
DtTtSetLabel( label, "XtAppAddInput()", (int)id );
if (id != 0) {
DtTtNthClientDatumSet( DTTT_PROCID, ival, (void *)id );
}
XtUnmanageChild( instance->chooser_shellform );
break;
case _DtTtChooserDtProcidClose:
status = ttdt_close( text, 0, 1 );
DtTtSetLabel( label, "ttdt_close()", status );
ival = DtTtIndex( DTTT_PROCID, text );
if (ival < 0) {
return;
}
id = (XtInputId)DtTtNthClientDatum( DTTT_PROCID, ival );
if (id != 0) {
XtRemoveInput( id );
}
DtTtDestroyed( DTTT_PROCID, text );
XtUnmanageChild( instance->chooser_shellform );
break;
}
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
}
void
ttChooserHelp(
Widget widget,
XtPointer clientData,
XtPointer callData
)
{
/*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
/*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
/*** DTB_USER_CODE_START vvv Add C code below vvv ***/
DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
int ival;
XtVaGetValues( instance->chooserOkButton, XmNuserData, &ival, NULL );
_DtTtChooserAction choice = (_DtTtChooserAction)ival;
Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
switch (choice) {
char *op;
case _DtTtChooserNone:
return;
case _DtTtChooserMessageOpSet:
case _DtTtChooserMessageCreateStandard:
case _DtTtChooserPatternOpAdd:
op = XmTextFieldGetString( instance->chooserText );
if (op != 0) {
_DtMan( label, op );
}
if (choice == _DtTtChooserMessageOpSet) {
_DtMan( label, "tt_message_op_set" );
} else {
_DtMan( label, "tt_pattern_op_add" );
}
break;
case _DtTtChooserMessageOpen:
_DtMan( label, "tt_message_print" );
break;
case _DtTtChooserMessageHandlerSet:
_DtMan( label, "tt_message_handler_set" );
break;
case _DtTtChooserMessageDestroy:
_DtMan( label, "tt_message_destroy" );
break;
case _DtTtChooserPatternOpen:
_DtMan( label, "tt_pattern_print" );
break;
case _DtTtChooserPatternSenderAdd:
_DtMan( label, "tt_pattern_sender_add" );
break;
case _DtTtChooserPatternDestroy:
_DtMan( label, "tt_pattern_destroy" );
break;
case _DtTtChooserDtSessionQuit:
_DtMan( label, "ttdt_session_quit" );
break;
case _DtTtChooserDtFileDeleted:
case _DtTtChooserDtFileModified:
case _DtTtChooserDtFileReverted:
case _DtTtChooserDtFileMoved:
case _DtTtChooserDtFileSaved:
_DtMan( label, "ttdt_file_event" );
break;
case _DtTtChooserDtFileQuit:
_DtMan( label, "ttdt_file_quit" );
break;
case _DtTtChooserProcidSetDefault:
_DtMan( label, "tt_default_procid_set" );
break;
case _DtTtChooserProcidSuspend:
_DtMan( label, "XtRemoveInput" );
break;
case _DtTtChooserProcidResume:
_DtMan( label, "XtAppAddInput" );
break;
case _DtTtChooserDtProcidClose:
_DtMan( label, "ttdt_close" );
break;
}
/*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
}
/**************************************************************************
*** DTB_USER_CODE_START
***
*** All automatically-generated data and functions have been defined.
***
*** Add new functions here, or at the top of the file.
***/
/*** DTB_USER_CODE_END
***
*** End of user code section
***
**************************************************************************/