1 /*** DTB_USER_CODE_START vvv Add file header below vvv ***/
2 //%% (c) Copyright 1993, 1994 Hewlett-Packard Company
3 //%% (c) Copyright 1993, 1994 International Business Machines Corp.
4 //%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
5 //%% (c) Copyright 1993, 1994 Novell, Inc.
6 //%% $XConsortium: ttChooser_stubs.C.src /main/3 1995/11/06 17:14:10 rswiston $
7 /*** DTB_USER_CODE_END ^^^ Add file header above ^^^ ***/
10 * File: ttChooser_stubs.c
11 * Contains: Module callbacks and connection functions
13 * This file was generated by dtcodegen, from module ttChooser
15 * Any text may be added between the DTB_USER_CODE_START and
16 * DTB_USER_CODE_END comments (even non-C code). Descriptive comments
17 * are provided only as an aid.
19 * ** EDIT ONLY WITHIN SECTIONS MARKED WITH DTB_USER_CODE COMMENTS. **
20 * ** ALL OTHER MODIFICATIONS WILL BE OVERWRITTEN. DO NOT MODIFY OR **
21 * ** DELETE THE GENERATED COMMENTS! **
27 #include "dtb_utils.h"
28 #include "ttChooser_ui.h"
31 * Header files for cross-module connections
33 #include "ttsnoop_ui.h"
36 /**************************************************************************
37 *** DTB_USER_CODE_START
39 *** All necessary header files have been included.
41 *** Add include files, types, macros, externs, and user functions here.
46 #if defined(linux) || defined(CSRG_BASED) || defined(sun)
49 #include <strstream.h>
58 _DtTtChooserAction choice,
62 DtbTtChooserChooserInfo instance = &dtb_tt_chooser_chooser;
63 if (! instance->initialized) {
64 dtb_tt_chooser_chooser_initialize(
65 instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin );
72 case _DtTtChooserNone:
74 case _DtTtChooserMessageOpen:
76 title = "Open Tt_message";
78 case _DtTtChooserMessageCreateStandard:
80 title = "Create Standard Tt_message";
82 case _DtTtChooserMessageOpSet:
84 title = "tt_message_op_set";
86 case _DtTtChooserMessageHandlerSet:
88 title = "tt_message_handler_set";
90 case _DtTtChooserMessageDestroy:
92 title = "tt_message_destroy";
94 case _DtTtChooserPatternOpen:
96 title = "Open Tt_pattern";
98 case _DtTtChooserPatternOpAdd:
100 title = "tt_pattern_op_add";
102 case _DtTtChooserPatternSenderAdd:
104 title = "tt_pattern_sender_add";
106 case _DtTtChooserPatternDestroy:
107 okString = "Destroy";
108 title = "tt_pattern_destroy";
110 case _DtTtChooserDtSessionQuit:
112 title = "ttdt_session_quit";
114 case _DtTtChooserDtFileDeleted:
116 title = "ttdt_file_event(,TTDT_DELETED)";
118 case _DtTtChooserDtFileModified:
120 title = "ttdt_file_event(,TTDT_MODIFIED)";
122 case _DtTtChooserDtFileReverted:
124 title = "ttdt_file_event(,TTDT_REVERTED)";
126 case _DtTtChooserDtFileMoved:
128 title = "ttdt_file_event(,TTDT_MOVED)";
130 case _DtTtChooserDtFileSaved:
132 title = "ttdt_file_event(,TTDT_SAVED)";
134 case _DtTtChooserDtFileQuit:
136 title = "ttdt_file_quit";
138 case _DtTtChooserProcidSetDefault:
140 title = "tt_default_procid_set";
142 case _DtTtChooserProcidSuspend:
144 title = "XtRemoveInput";
146 case _DtTtChooserProcidResume:
148 title = "XtAppAddInput";
150 case _DtTtChooserDtProcidClose:
152 title = "ttdt_close";
157 case _DtTtChooserNone:
159 case _DtTtChooserMessageOpSet:
160 case _DtTtChooserPatternOpAdd:
161 case _DtTtChooserMessageCreateStandard:
163 valuesLabel = "Standard Op";
166 case _DtTtChooserMessageOpen:
167 case _DtTtChooserMessageDestroy:
168 valueLabel = "Tt_message:";
169 valuesLabel = "Tt_message";
172 case _DtTtChooserPatternOpen:
173 case _DtTtChooserPatternDestroy:
174 valueLabel = "Tt_pattern:";
175 valuesLabel = "Tt_pattern";
178 case _DtTtChooserDtSessionQuit:
179 valueLabel = "Tt_pattern *:";
180 valuesLabel = "Desktop-joined session";
181 type = DTTT_DTSESSION;
183 case _DtTtChooserDtFileDeleted:
184 case _DtTtChooserDtFileModified:
185 case _DtTtChooserDtFileReverted:
186 case _DtTtChooserDtFileMoved:
187 case _DtTtChooserDtFileSaved:
188 case _DtTtChooserDtFileQuit:
189 valueLabel = "Tt_pattern *:";
190 valuesLabel = "Desktop-joined file";
193 case _DtTtChooserMessageHandlerSet:
194 case _DtTtChooserPatternSenderAdd:
195 case _DtTtChooserProcidSetDefault:
196 case _DtTtChooserProcidSuspend:
197 case _DtTtChooserProcidResume:
198 case _DtTtChooserDtProcidClose:
199 valueLabel = "Procid:";
200 valuesLabel = "Procid";
204 DtTtSetLabel( instance->chooserOkButton, okString );
205 DtTtSetLabel( instance->chooserText_label, valueLabel );
208 XmString *items = _DtTtChoices( type, &itemCount );
209 XtVaSetValues( instance->chooserList,
210 XmNitemCount, itemCount,
213 XmListDeselectAllItems( instance->chooserList );
214 XmTextFieldSetString( instance->chooserText, 0 );
215 XtVaSetValues( instance->chooser, XmNtitle, title, NULL );
217 std::ostrstream valuesStream;
218 valuesStream << itemCount << " " << valuesLabel;
219 if (itemCount != 1) valuesStream << "s";
220 valuesStream << ends;
221 DtTtSetLabel( instance->chooserList_label, valuesStream.str() );
222 delete valuesStream.str();
224 // Remember dialog mode, entity
225 XtVaSetValues( instance->chooserOkButton, XmNuserData, choice, NULL );
226 XtVaSetValues( instance->chooserCancelButton, XmNuserData, entity, NULL );
228 XtManageChild( instance->chooser_shellform );
231 /*** DTB_USER_CODE_END
233 *** End of user code section
235 **************************************************************************/
240 ttChooser_chooserCancelButton_CB1(
242 XtPointer clientData,
246 /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
247 /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
249 DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
251 if (!(instance->initialized))
253 dtb_tt_chooser_chooser_initialize(instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin);
255 XtUnmanageChild(instance->chooser_shellform);
257 /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
258 /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
265 XtPointer clientData,
269 /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
270 /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
272 /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
273 DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
274 XmListCallbackStruct *info = (XmListCallbackStruct *)callData;
276 XtVaGetValues( instance->chooserOkButton, XmNuserData, &choice, NULL );
278 Boolean isString = False;
279 switch ((_DtTtChooserAction)choice) {
280 case _DtTtChooserNone:
282 case _DtTtChooserMessageOpSet:
283 case _DtTtChooserPatternOpAdd:
284 case _DtTtChooserMessageCreateStandard:
288 case _DtTtChooserMessageOpen:
289 case _DtTtChooserMessageDestroy:
292 case _DtTtChooserPatternOpen:
293 case _DtTtChooserPatternDestroy:
296 case _DtTtChooserDtSessionQuit:
297 type = DTTT_DTSESSION;
299 case _DtTtChooserDtFileDeleted:
300 case _DtTtChooserDtFileModified:
301 case _DtTtChooserDtFileReverted:
302 case _DtTtChooserDtFileMoved:
303 case _DtTtChooserDtFileSaved:
304 case _DtTtChooserDtFileQuit:
307 case _DtTtChooserMessageHandlerSet:
308 case _DtTtChooserPatternSenderAdd:
309 case _DtTtChooserProcidSetDefault:
310 case _DtTtChooserProcidSuspend:
311 case _DtTtChooserProcidResume:
312 case _DtTtChooserDtProcidClose:
317 void *entity = DtTtNth( type, info->item_position - 1 );
318 std::ostrstream entityName;
320 entityName << (char *)entity << ends;
322 entityName << entity << ends;
324 XmTextFieldSetString( instance->chooserText, entityName.str() );
325 delete entityName.str();
326 /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
333 XtPointer clientData,
337 /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
338 /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
340 /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
341 DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
342 char *text = XmTextFieldGetString( instance->chooserText );
344 XtVaGetValues( instance->chooserOkButton, XmNuserData, &ival, NULL );
345 _DtTtChooserAction choice = (_DtTtChooserAction)ival;
346 Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
357 case _DtTtChooserNone:
359 case _DtTtChooserMessageCreateStandard:
360 msg = tttk_message_create( text );
361 status = DtTtSetLabel( label, "tt_message_create()", msg );
362 if (tt_is_err( status )) {
365 DtTtCreated( DTTT_MESSAGE, msg );
366 newWidget = DtTtMessageWidgetCreate(
367 dtb_ttsnoop_ttsnoop_win.ttsnoopWin, msg,
368 DtTtMessageWidgetUpdate );
369 status = tt_ptr_error( newWidget );
370 if (tt_is_err( status )) {
373 XRaiseWindow( XtDisplay( newWidget ), XtWindow( newWidget ));
374 XtUnmanageChild( instance->chooser_shellform );
376 case _DtTtChooserMessageOpSet:
377 XtVaGetValues( instance->chooserCancelButton,
378 XmNuserData, &xtPtr, NULL );
379 _DtTtMessageUpdate( (Tt_message)xtPtr, choice, text );
380 XtUnmanageChild( instance->chooser_shellform );
382 case _DtTtChooserPatternOpAdd:
383 XtVaGetValues( instance->chooserCancelButton,
384 XmNuserData, &xtPtr, NULL );
385 _DtTtPatternUpdate( (Tt_pattern)xtPtr, choice, text );
386 XtUnmanageChild( instance->chooser_shellform );
388 case _DtTtChooserMessageHandlerSet:
389 XtVaGetValues( instance->chooserCancelButton,
390 XmNuserData, &xtPtr, NULL );
391 _DtTtMessageUpdate( (Tt_message)xtPtr, choice, text );
392 XtUnmanageChild( instance->chooser_shellform );
394 case _DtTtChooserPatternSenderAdd:
395 XtVaGetValues( instance->chooserCancelButton,
396 XmNuserData, &xtPtr, NULL );
397 _DtTtPatternUpdate( (Tt_pattern)xtPtr, choice, text );
398 XtUnmanageChild( instance->chooser_shellform );
400 case _DtTtChooserMessageOpen:
401 case _DtTtChooserMessageDestroy:
406 sscanf( text, "%i", &ival );
407 msg = (Tt_message) (intptr_t) ival;
408 if (DtTtIndex( DTTT_MESSAGE, msg ) < 0) {
411 if (choice == _DtTtChooserMessageOpen) {
412 Widget newWidget = DtTtMessageWidgetCreate(
413 dtb_ttsnoop_ttsnoop_win.ttsnoopWin,
414 msg, DtTtMessageWidgetUpdate );
415 Tt_status status = tt_ptr_error( newWidget );
416 if (tt_is_err( status )) {
419 XRaiseWindow( XtDisplay( newWidget ), XtWindow( newWidget ));
421 Widget msgWidget = DtTtMessageWidget( msg );
422 Tt_status status = tttk_message_destroy( msg );
423 if (status == TT_WRN_STOPPED) {
424 DtTtSetLabel( label, "tttk_message_destroy()",
428 DtTtDestroyed( DTTT_MESSAGE, msg );
429 if (msgWidget != 0) {
430 XtDestroyWidget( msgWidget );
432 _DtTtChooserSet( _DtTtChooserMessageDestroy );
435 case _DtTtChooserPatternOpen:
436 case _DtTtChooserPatternDestroy:
441 sscanf( text, "%i", &ival );
442 pat = (Tt_pattern) (intptr_t) ival;
443 if (DtTtIndex( DTTT_PATTERN, pat ) < 0) {
446 if (choice == _DtTtChooserPatternOpen) {
447 Widget newWidget = DtTtPatternWidgetCreate(
448 dtb_ttsnoop_ttsnoop_win.ttsnoopWin,
450 Tt_status status = tt_ptr_error( newWidget );
451 if (tt_is_err( status )) {
454 XRaiseWindow( XtDisplay( newWidget ), XtWindow( newWidget ));
456 Widget patWidget = DtTtPatternWidget( pat );
457 Tt_status status = tt_pattern_destroy( pat );
458 if (status == TT_WRN_STOPPED) {
459 DtTtSetLabel( label, "tt_pattern_destroy()",
463 DtTtDestroyed( DTTT_PATTERN, pat );
464 if (patWidget != 0) {
465 XtDestroyWidget( patWidget );
467 _DtTtChooserSet( _DtTtChooserPatternDestroy );
470 case _DtTtChooserDtSessionQuit:
475 sscanf( text, "%i", &ival );
476 pats = (Tt_pattern *) (intptr_t) ival;
477 if (DtTtIndex( DTTT_DTSESSION, pats ) < 0) {
480 text = (char *)tt_pattern_user( *pats, _DtTtPatsNameKey );
481 if (tt_is_err( tt_ptr_error( text )) || text == 0) {
484 status = ttdt_session_quit( text, pats, 1 );
485 DtTtSetLabel( label, "ttdt_session_quit()", status );
486 if (status == TT_OK) {
487 DtTtDestroyed( DTTT_DTSESSION, pats );
489 XtUnmanageChild( instance->chooser_shellform );
491 case _DtTtChooserDtFileDeleted:
492 case _DtTtChooserDtFileModified:
493 case _DtTtChooserDtFileReverted:
494 case _DtTtChooserDtFileMoved:
495 case _DtTtChooserDtFileSaved:
496 case _DtTtChooserDtFileQuit:
501 sscanf( text, "%i", &ival );
502 pats = (Tt_pattern *) (intptr_t) ival;
503 if (DtTtIndex( DTTT_DTFILE, pats ) < 0) {
506 switch ((_DtTtChooserAction)choice) {
507 case _DtTtChooserDtFileModified:
508 status = ttdt_file_event( 0, TTDT_MODIFIED, pats, 1 );
509 func = "ttdt_file_event(,TTDT_MODIFIED)";
511 case _DtTtChooserDtFileReverted:
512 status = ttdt_file_event( 0, TTDT_REVERTED, pats, 1 );
513 func = "ttdt_file_event(,TTDT_REVERTED)";
515 case _DtTtChooserDtFileSaved:
516 status = ttdt_file_event( 0, TTDT_SAVED, pats, 1 );
517 func = "ttdt_file_event(,TTDT_SAVED)";
519 case _DtTtChooserDtFileQuit:
520 status = ttdt_file_quit( pats, 1 );
521 func = "ttdt_file_quit()";
522 if (status == TT_OK) {
523 DtTtDestroyed( DTTT_DTFILE, pats );
527 DtTtSetLabel( label, func, status );
528 XtUnmanageChild( instance->chooser_shellform );
529 case _DtTtChooserProcidSetDefault:
530 status = tt_default_procid_set( text );
531 DtTtSetLabel( label, "tt_default_procid_set()", status );
532 XtUnmanageChild( instance->chooser_shellform );
534 case _DtTtChooserProcidSuspend:
535 ival = DtTtIndex( DTTT_PROCID, text );
539 id = (XtInputId)DtTtNthClientDatum( DTTT_PROCID, ival );
542 DtTtSetLabel( label, "XtRemoveInput()" );
544 XtUnmanageChild( instance->chooser_shellform );
546 case _DtTtChooserProcidResume:
547 ival = DtTtIndex( DTTT_PROCID, text );
551 fd = tt_procid_fd( text );
552 if (tt_is_err( tt_int_error( fd ))) {
555 id = XtAppAddInput( XtWidgetToApplicationContext( label ),
556 fd, (XtPointer)XtInputReadMask,
557 tttk_Xt_input_handler, text );
558 DtTtSetLabel( label, "XtAppAddInput()", (int)id );
560 DtTtNthClientDatumSet( DTTT_PROCID, ival, (void *)id );
562 XtUnmanageChild( instance->chooser_shellform );
564 case _DtTtChooserDtProcidClose:
565 status = ttdt_close( text, 0, 1 );
566 DtTtSetLabel( label, "ttdt_close()", status );
567 ival = DtTtIndex( DTTT_PROCID, text );
571 id = (XtInputId)DtTtNthClientDatum( DTTT_PROCID, ival );
575 DtTtDestroyed( DTTT_PROCID, text );
576 XtUnmanageChild( instance->chooser_shellform );
579 /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
586 XtPointer clientData,
590 /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
591 /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
593 /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
594 DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
596 XtVaGetValues( instance->chooserOkButton, XmNuserData, &ival, NULL );
597 _DtTtChooserAction choice = (_DtTtChooserAction)ival;
598 Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
601 case _DtTtChooserNone:
603 case _DtTtChooserMessageOpSet:
604 case _DtTtChooserMessageCreateStandard:
605 case _DtTtChooserPatternOpAdd:
606 op = XmTextFieldGetString( instance->chooserText );
610 if (choice == _DtTtChooserMessageOpSet) {
611 _DtMan( label, "tt_message_op_set" );
613 _DtMan( label, "tt_pattern_op_add" );
616 case _DtTtChooserMessageOpen:
617 _DtMan( label, "tt_message_print" );
619 case _DtTtChooserMessageHandlerSet:
620 _DtMan( label, "tt_message_handler_set" );
622 case _DtTtChooserMessageDestroy:
623 _DtMan( label, "tt_message_destroy" );
625 case _DtTtChooserPatternOpen:
626 _DtMan( label, "tt_pattern_print" );
628 case _DtTtChooserPatternSenderAdd:
629 _DtMan( label, "tt_pattern_sender_add" );
631 case _DtTtChooserPatternDestroy:
632 _DtMan( label, "tt_pattern_destroy" );
634 case _DtTtChooserDtSessionQuit:
635 _DtMan( label, "ttdt_session_quit" );
637 case _DtTtChooserDtFileDeleted:
638 case _DtTtChooserDtFileModified:
639 case _DtTtChooserDtFileReverted:
640 case _DtTtChooserDtFileMoved:
641 case _DtTtChooserDtFileSaved:
642 _DtMan( label, "ttdt_file_event" );
644 case _DtTtChooserDtFileQuit:
645 _DtMan( label, "ttdt_file_quit" );
647 case _DtTtChooserProcidSetDefault:
648 _DtMan( label, "tt_default_procid_set" );
650 case _DtTtChooserProcidSuspend:
651 _DtMan( label, "XtRemoveInput" );
653 case _DtTtChooserProcidResume:
654 _DtMan( label, "XtAppAddInput" );
656 case _DtTtChooserDtProcidClose:
657 _DtMan( label, "ttdt_close" );
660 /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
665 /**************************************************************************
666 *** DTB_USER_CODE_START
668 *** All automatically-generated data and functions have been defined.
670 *** Add new functions here, or at the top of the file.
673 /*** DTB_USER_CODE_END
675 *** End of user code section
677 **************************************************************************/