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! **
26 #include "dtb_utils.h"
27 #include "ttChooser_ui.h"
30 * Header files for cross-module connections
32 #include "ttsnoop_ui.h"
35 /**************************************************************************
36 *** DTB_USER_CODE_START
38 *** All necessary header files have been included.
40 *** Add include files, types, macros, externs, and user functions here.
44 #include <strstream.h>
51 _DtTtChooserAction choice,
55 DtbTtChooserChooserInfo instance = &dtb_tt_chooser_chooser;
56 if (! instance->initialized) {
57 dtb_tt_chooser_chooser_initialize(
58 instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin );
65 case _DtTtChooserNone:
67 case _DtTtChooserMessageOpen:
69 title = "Open Tt_message";
71 case _DtTtChooserMessageCreateStandard:
73 title = "Create Standard Tt_message";
75 case _DtTtChooserMessageOpSet:
77 title = "tt_message_op_set";
79 case _DtTtChooserMessageHandlerSet:
81 title = "tt_message_handler_set";
83 case _DtTtChooserMessageDestroy:
85 title = "tt_message_destroy";
87 case _DtTtChooserPatternOpen:
89 title = "Open Tt_pattern";
91 case _DtTtChooserPatternOpAdd:
93 title = "tt_pattern_op_add";
95 case _DtTtChooserPatternSenderAdd:
97 title = "tt_pattern_sender_add";
99 case _DtTtChooserPatternDestroy:
100 okString = "Destroy";
101 title = "tt_pattern_destroy";
103 case _DtTtChooserDtSessionQuit:
105 title = "ttdt_session_quit";
107 case _DtTtChooserDtFileDeleted:
109 title = "ttdt_file_event(,TTDT_DELETED)";
111 case _DtTtChooserDtFileModified:
113 title = "ttdt_file_event(,TTDT_MODIFIED)";
115 case _DtTtChooserDtFileReverted:
117 title = "ttdt_file_event(,TTDT_REVERTED)";
119 case _DtTtChooserDtFileMoved:
121 title = "ttdt_file_event(,TTDT_MOVED)";
123 case _DtTtChooserDtFileSaved:
125 title = "ttdt_file_event(,TTDT_SAVED)";
127 case _DtTtChooserDtFileQuit:
129 title = "ttdt_file_quit";
131 case _DtTtChooserProcidSetDefault:
133 title = "tt_default_procid_set";
135 case _DtTtChooserProcidSuspend:
137 title = "XtRemoveInput";
139 case _DtTtChooserProcidResume:
141 title = "XtAppAddInput";
143 case _DtTtChooserDtProcidClose:
145 title = "ttdt_close";
150 case _DtTtChooserNone:
152 case _DtTtChooserMessageOpSet:
153 case _DtTtChooserPatternOpAdd:
154 case _DtTtChooserMessageCreateStandard:
156 valuesLabel = "Standard Op";
159 case _DtTtChooserMessageOpen:
160 case _DtTtChooserMessageDestroy:
161 valueLabel = "Tt_message:";
162 valuesLabel = "Tt_message";
165 case _DtTtChooserPatternOpen:
166 case _DtTtChooserPatternDestroy:
167 valueLabel = "Tt_pattern:";
168 valuesLabel = "Tt_pattern";
171 case _DtTtChooserDtSessionQuit:
172 valueLabel = "Tt_pattern *:";
173 valuesLabel = "Desktop-joined session";
174 type = DTTT_DTSESSION;
176 case _DtTtChooserDtFileDeleted:
177 case _DtTtChooserDtFileModified:
178 case _DtTtChooserDtFileReverted:
179 case _DtTtChooserDtFileMoved:
180 case _DtTtChooserDtFileSaved:
181 case _DtTtChooserDtFileQuit:
182 valueLabel = "Tt_pattern *:";
183 valuesLabel = "Desktop-joined file";
186 case _DtTtChooserMessageHandlerSet:
187 case _DtTtChooserPatternSenderAdd:
188 case _DtTtChooserProcidSetDefault:
189 case _DtTtChooserProcidSuspend:
190 case _DtTtChooserProcidResume:
191 case _DtTtChooserDtProcidClose:
192 valueLabel = "Procid:";
193 valuesLabel = "Procid";
197 DtTtSetLabel( instance->chooserOkButton, okString );
198 DtTtSetLabel( instance->chooserText_label, valueLabel );
201 XmString *items = _DtTtChoices( type, &itemCount );
202 XtVaSetValues( instance->chooserList,
203 XmNitemCount, itemCount,
206 XmListDeselectAllItems( instance->chooserList );
207 XmTextFieldSetString( instance->chooserText, 0 );
208 XtVaSetValues( instance->chooser, XmNtitle, title, 0 );
210 ostrstream valuesStream;
211 valuesStream << itemCount << " " << valuesLabel;
212 if (itemCount != 1) valuesStream << "s";
213 valuesStream << ends;
214 DtTtSetLabel( instance->chooserList_label, valuesStream.str() );
215 delete valuesStream.str();
217 // Remember dialog mode, entity
218 XtVaSetValues( instance->chooserOkButton, XmNuserData, choice, 0 );
219 XtVaSetValues( instance->chooserCancelButton, XmNuserData, entity, 0 );
221 XtManageChild( instance->chooser_shellform );
224 /*** DTB_USER_CODE_END
226 *** End of user code section
228 **************************************************************************/
233 ttChooser_chooserCancelButton_CB1(
235 XtPointer clientData,
239 /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
240 /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
242 DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
244 if (!(instance->initialized))
246 dtb_tt_chooser_chooser_initialize(instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin);
248 XtUnmanageChild(instance->chooser_shellform);
250 /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
251 /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
258 XtPointer clientData,
262 /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
263 /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
265 /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
266 DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
267 XmListCallbackStruct *info = (XmListCallbackStruct *)callData;
269 XtVaGetValues( instance->chooserOkButton, XmNuserData, &choice, 0 );
271 Boolean isString = False;
272 switch ((_DtTtChooserAction)choice) {
273 case _DtTtChooserNone:
275 case _DtTtChooserMessageOpSet:
276 case _DtTtChooserPatternOpAdd:
277 case _DtTtChooserMessageCreateStandard:
281 case _DtTtChooserMessageOpen:
282 case _DtTtChooserMessageDestroy:
285 case _DtTtChooserPatternOpen:
286 case _DtTtChooserPatternDestroy:
289 case _DtTtChooserDtSessionQuit:
290 type = DTTT_DTSESSION;
292 case _DtTtChooserDtFileDeleted:
293 case _DtTtChooserDtFileModified:
294 case _DtTtChooserDtFileReverted:
295 case _DtTtChooserDtFileMoved:
296 case _DtTtChooserDtFileSaved:
297 case _DtTtChooserDtFileQuit:
300 case _DtTtChooserMessageHandlerSet:
301 case _DtTtChooserPatternSenderAdd:
302 case _DtTtChooserProcidSetDefault:
303 case _DtTtChooserProcidSuspend:
304 case _DtTtChooserProcidResume:
305 case _DtTtChooserDtProcidClose:
310 void *entity = DtTtNth( type, info->item_position - 1 );
311 ostrstream entityName;
313 entityName << (char *)entity << ends;
315 entityName << entity << ends;
317 XmTextFieldSetString( instance->chooserText, entityName.str() );
318 delete entityName.str();
319 /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
326 XtPointer clientData,
330 /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
331 /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
333 /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
334 DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
335 char *text = XmTextFieldGetString( instance->chooserText );
337 XtVaGetValues( instance->chooserOkButton, XmNuserData, &ival, 0 );
338 _DtTtChooserAction choice = (_DtTtChooserAction)ival;
339 Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
350 case _DtTtChooserNone:
352 case _DtTtChooserMessageCreateStandard:
353 msg = tttk_message_create( text );
354 status = DtTtSetLabel( label, "tt_message_create()", msg );
355 if (tt_is_err( status )) {
358 DtTtCreated( DTTT_MESSAGE, msg );
359 newWidget = DtTtMessageWidgetCreate(
360 dtb_ttsnoop_ttsnoop_win.ttsnoopWin, msg,
361 DtTtMessageWidgetUpdate );
362 status = tt_ptr_error( newWidget );
363 if (tt_is_err( status )) {
366 XRaiseWindow( XtDisplay( newWidget ), XtWindow( newWidget ));
367 XtUnmanageChild( instance->chooser_shellform );
369 case _DtTtChooserMessageOpSet:
370 XtVaGetValues( instance->chooserCancelButton,
371 XmNuserData, &xtPtr, 0 );
372 _DtTtMessageUpdate( (Tt_message)xtPtr, choice, text );
373 XtUnmanageChild( instance->chooser_shellform );
375 case _DtTtChooserPatternOpAdd:
376 XtVaGetValues( instance->chooserCancelButton,
377 XmNuserData, &xtPtr, 0 );
378 _DtTtPatternUpdate( (Tt_pattern)xtPtr, choice, text );
379 XtUnmanageChild( instance->chooser_shellform );
381 case _DtTtChooserMessageHandlerSet:
382 XtVaGetValues( instance->chooserCancelButton,
383 XmNuserData, &xtPtr, 0 );
384 _DtTtMessageUpdate( (Tt_message)xtPtr, choice, text );
385 XtUnmanageChild( instance->chooser_shellform );
387 case _DtTtChooserPatternSenderAdd:
388 XtVaGetValues( instance->chooserCancelButton,
389 XmNuserData, &xtPtr, 0 );
390 _DtTtPatternUpdate( (Tt_pattern)xtPtr, choice, text );
391 XtUnmanageChild( instance->chooser_shellform );
393 case _DtTtChooserMessageOpen:
394 case _DtTtChooserMessageDestroy:
399 sscanf( text, "%i", &ival );
400 msg = (Tt_message)ival;
401 if (DtTtIndex( DTTT_MESSAGE, msg ) < 0) {
404 if (choice == _DtTtChooserMessageOpen) {
405 Widget newWidget = DtTtMessageWidgetCreate(
406 dtb_ttsnoop_ttsnoop_win.ttsnoopWin,
407 msg, DtTtMessageWidgetUpdate );
408 Tt_status status = tt_ptr_error( newWidget );
409 if (tt_is_err( status )) {
412 XRaiseWindow( XtDisplay( newWidget ), XtWindow( newWidget ));
414 Widget msgWidget = DtTtMessageWidget( msg );
415 Tt_status status = tttk_message_destroy( msg );
416 if (status == TT_WRN_STOPPED) {
417 DtTtSetLabel( label, "tttk_message_destroy()",
421 DtTtDestroyed( DTTT_MESSAGE, msg );
422 if (msgWidget != 0) {
423 XtDestroyWidget( msgWidget );
425 _DtTtChooserSet( _DtTtChooserMessageDestroy );
428 case _DtTtChooserPatternOpen:
429 case _DtTtChooserPatternDestroy:
434 sscanf( text, "%i", &ival );
435 pat = (Tt_pattern)ival;
436 if (DtTtIndex( DTTT_PATTERN, pat ) < 0) {
439 if (choice == _DtTtChooserPatternOpen) {
440 Widget newWidget = DtTtPatternWidgetCreate(
441 dtb_ttsnoop_ttsnoop_win.ttsnoopWin,
443 Tt_status status = tt_ptr_error( newWidget );
444 if (tt_is_err( status )) {
447 XRaiseWindow( XtDisplay( newWidget ), XtWindow( newWidget ));
449 Widget patWidget = DtTtPatternWidget( pat );
450 Tt_status status = tt_pattern_destroy( pat );
451 if (status == TT_WRN_STOPPED) {
452 DtTtSetLabel( label, "tt_pattern_destroy()",
456 DtTtDestroyed( DTTT_PATTERN, pat );
457 if (patWidget != 0) {
458 XtDestroyWidget( patWidget );
460 _DtTtChooserSet( _DtTtChooserPatternDestroy );
463 case _DtTtChooserDtSessionQuit:
468 sscanf( text, "%i", &ival );
469 pats = (Tt_pattern *)ival;
470 if (DtTtIndex( DTTT_DTSESSION, pats ) < 0) {
473 text = (char *)tt_pattern_user( *pats, _DtTtPatsNameKey );
474 if (tt_is_err( tt_ptr_error( text )) || text == 0) {
477 status = ttdt_session_quit( text, pats, 1 );
478 DtTtSetLabel( label, "ttdt_session_quit()", status );
479 if (status == TT_OK) {
480 DtTtDestroyed( DTTT_DTSESSION, pats );
482 XtUnmanageChild( instance->chooser_shellform );
484 case _DtTtChooserDtFileDeleted:
485 case _DtTtChooserDtFileModified:
486 case _DtTtChooserDtFileReverted:
487 case _DtTtChooserDtFileMoved:
488 case _DtTtChooserDtFileSaved:
489 case _DtTtChooserDtFileQuit:
494 sscanf( text, "%i", &ival );
495 pats = (Tt_pattern *)ival;
496 if (DtTtIndex( DTTT_DTFILE, pats ) < 0) {
499 switch ((_DtTtChooserAction)choice) {
500 case _DtTtChooserDtFileModified:
501 status = ttdt_file_event( 0, TTDT_MODIFIED, pats, 1 );
502 func = "ttdt_file_event(,TTDT_MODIFIED)";
504 case _DtTtChooserDtFileReverted:
505 status = ttdt_file_event( 0, TTDT_REVERTED, pats, 1 );
506 func = "ttdt_file_event(,TTDT_REVERTED)";
508 case _DtTtChooserDtFileSaved:
509 status = ttdt_file_event( 0, TTDT_SAVED, pats, 1 );
510 func = "ttdt_file_event(,TTDT_SAVED)";
512 case _DtTtChooserDtFileQuit:
513 status = ttdt_file_quit( pats, 1 );
514 func = "ttdt_file_quit()";
515 if (status == TT_OK) {
516 DtTtDestroyed( DTTT_DTFILE, pats );
520 DtTtSetLabel( label, func, status );
521 XtUnmanageChild( instance->chooser_shellform );
522 case _DtTtChooserProcidSetDefault:
523 status = tt_default_procid_set( text );
524 DtTtSetLabel( label, "tt_default_procid_set()", status );
525 XtUnmanageChild( instance->chooser_shellform );
527 case _DtTtChooserProcidSuspend:
528 ival = DtTtIndex( DTTT_PROCID, text );
532 id = (XtInputId)DtTtNthClientDatum( DTTT_PROCID, ival );
535 DtTtSetLabel( label, "XtRemoveInput()" );
537 XtUnmanageChild( instance->chooser_shellform );
539 case _DtTtChooserProcidResume:
540 ival = DtTtIndex( DTTT_PROCID, text );
544 fd = tt_procid_fd( text );
545 if (tt_is_err( tt_int_error( fd ))) {
548 id = XtAppAddInput( XtWidgetToApplicationContext( label ),
549 fd, (XtPointer)XtInputReadMask,
550 tttk_Xt_input_handler, text );
551 DtTtSetLabel( label, "XtAppAddInput()", (int)id );
553 DtTtNthClientDatumSet( DTTT_PROCID, ival, (void *)id );
555 XtUnmanageChild( instance->chooser_shellform );
557 case _DtTtChooserDtProcidClose:
558 status = ttdt_close( text, 0, 1 );
559 DtTtSetLabel( label, "ttdt_close()", status );
560 ival = DtTtIndex( DTTT_PROCID, text );
564 id = (XtInputId)DtTtNthClientDatum( DTTT_PROCID, ival );
568 DtTtDestroyed( DTTT_PROCID, text );
569 XtUnmanageChild( instance->chooser_shellform );
572 /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
579 XtPointer clientData,
583 /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
584 /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
586 /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
587 DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
589 XtVaGetValues( instance->chooserOkButton, XmNuserData, &ival, 0 );
590 _DtTtChooserAction choice = (_DtTtChooserAction)ival;
591 Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
594 case _DtTtChooserNone:
596 case _DtTtChooserMessageOpSet:
597 case _DtTtChooserMessageCreateStandard:
598 case _DtTtChooserPatternOpAdd:
599 op = XmTextFieldGetString( instance->chooserText );
603 if (choice == _DtTtChooserMessageOpSet) {
604 _DtMan( label, "tt_message_op_set" );
606 _DtMan( label, "tt_pattern_op_add" );
609 case _DtTtChooserMessageOpen:
610 _DtMan( label, "tt_message_print" );
612 case _DtTtChooserMessageHandlerSet:
613 _DtMan( label, "tt_message_handler_set" );
615 case _DtTtChooserMessageDestroy:
616 _DtMan( label, "tt_message_destroy" );
618 case _DtTtChooserPatternOpen:
619 _DtMan( label, "tt_pattern_print" );
621 case _DtTtChooserPatternSenderAdd:
622 _DtMan( label, "tt_pattern_sender_add" );
624 case _DtTtChooserPatternDestroy:
625 _DtMan( label, "tt_pattern_destroy" );
627 case _DtTtChooserDtSessionQuit:
628 _DtMan( label, "ttdt_session_quit" );
630 case _DtTtChooserDtFileDeleted:
631 case _DtTtChooserDtFileModified:
632 case _DtTtChooserDtFileReverted:
633 case _DtTtChooserDtFileMoved:
634 case _DtTtChooserDtFileSaved:
635 _DtMan( label, "ttdt_file_event" );
637 case _DtTtChooserDtFileQuit:
638 _DtMan( label, "ttdt_file_quit" );
640 case _DtTtChooserProcidSetDefault:
641 _DtMan( label, "tt_default_procid_set" );
643 case _DtTtChooserProcidSuspend:
644 _DtMan( label, "XtRemoveInput" );
646 case _DtTtChooserProcidResume:
647 _DtMan( label, "XtAppAddInput" );
649 case _DtTtChooserDtProcidClose:
650 _DtMan( label, "ttdt_close" );
653 /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
658 /**************************************************************************
659 *** DTB_USER_CODE_START
661 *** All automatically-generated data and functions have been defined.
663 *** Add new functions here, or at the top of the file.
666 /*** DTB_USER_CODE_END
668 *** End of user code section
670 **************************************************************************/