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.
54 _DtTtChooserAction choice,
58 DtbTtChooserChooserInfo instance = &dtb_tt_chooser_chooser;
59 if (! instance->initialized) {
60 dtb_tt_chooser_chooser_initialize(
61 instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin );
68 case _DtTtChooserNone:
70 case _DtTtChooserMessageOpen:
72 title = "Open Tt_message";
74 case _DtTtChooserMessageCreateStandard:
76 title = "Create Standard Tt_message";
78 case _DtTtChooserMessageOpSet:
80 title = "tt_message_op_set";
82 case _DtTtChooserMessageHandlerSet:
84 title = "tt_message_handler_set";
86 case _DtTtChooserMessageDestroy:
88 title = "tt_message_destroy";
90 case _DtTtChooserPatternOpen:
92 title = "Open Tt_pattern";
94 case _DtTtChooserPatternOpAdd:
96 title = "tt_pattern_op_add";
98 case _DtTtChooserPatternSenderAdd:
100 title = "tt_pattern_sender_add";
102 case _DtTtChooserPatternDestroy:
103 okString = "Destroy";
104 title = "tt_pattern_destroy";
106 case _DtTtChooserDtSessionQuit:
108 title = "ttdt_session_quit";
110 case _DtTtChooserDtFileDeleted:
112 title = "ttdt_file_event(,TTDT_DELETED)";
114 case _DtTtChooserDtFileModified:
116 title = "ttdt_file_event(,TTDT_MODIFIED)";
118 case _DtTtChooserDtFileReverted:
120 title = "ttdt_file_event(,TTDT_REVERTED)";
122 case _DtTtChooserDtFileMoved:
124 title = "ttdt_file_event(,TTDT_MOVED)";
126 case _DtTtChooserDtFileSaved:
128 title = "ttdt_file_event(,TTDT_SAVED)";
130 case _DtTtChooserDtFileQuit:
132 title = "ttdt_file_quit";
134 case _DtTtChooserProcidSetDefault:
136 title = "tt_default_procid_set";
138 case _DtTtChooserProcidSuspend:
140 title = "XtRemoveInput";
142 case _DtTtChooserProcidResume:
144 title = "XtAppAddInput";
146 case _DtTtChooserDtProcidClose:
148 title = "ttdt_close";
153 case _DtTtChooserNone:
155 case _DtTtChooserMessageOpSet:
156 case _DtTtChooserPatternOpAdd:
157 case _DtTtChooserMessageCreateStandard:
159 valuesLabel = "Standard Op";
162 case _DtTtChooserMessageOpen:
163 case _DtTtChooserMessageDestroy:
164 valueLabel = "Tt_message:";
165 valuesLabel = "Tt_message";
168 case _DtTtChooserPatternOpen:
169 case _DtTtChooserPatternDestroy:
170 valueLabel = "Tt_pattern:";
171 valuesLabel = "Tt_pattern";
174 case _DtTtChooserDtSessionQuit:
175 valueLabel = "Tt_pattern *:";
176 valuesLabel = "Desktop-joined session";
177 type = DTTT_DTSESSION;
179 case _DtTtChooserDtFileDeleted:
180 case _DtTtChooserDtFileModified:
181 case _DtTtChooserDtFileReverted:
182 case _DtTtChooserDtFileMoved:
183 case _DtTtChooserDtFileSaved:
184 case _DtTtChooserDtFileQuit:
185 valueLabel = "Tt_pattern *:";
186 valuesLabel = "Desktop-joined file";
189 case _DtTtChooserMessageHandlerSet:
190 case _DtTtChooserPatternSenderAdd:
191 case _DtTtChooserProcidSetDefault:
192 case _DtTtChooserProcidSuspend:
193 case _DtTtChooserProcidResume:
194 case _DtTtChooserDtProcidClose:
195 valueLabel = "Procid:";
196 valuesLabel = "Procid";
200 DtTtSetLabel( instance->chooserOkButton, okString );
201 DtTtSetLabel( instance->chooserText_label, valueLabel );
204 XmString *items = _DtTtChoices( type, &itemCount );
205 XtVaSetValues( instance->chooserList,
206 XmNitemCount, itemCount,
209 XmListDeselectAllItems( instance->chooserList );
210 XmTextFieldSetString( instance->chooserText, 0 );
211 XtVaSetValues( instance->chooser, XmNtitle, title, NULL );
213 std::ostringstream valuesStream;
214 valuesStream << itemCount << " " << valuesLabel;
215 if (itemCount != 1) valuesStream << "s";
216 valuesStream << ends;
217 DtTtSetLabel( instance->chooserList_label, valuesStream.str().c_str() );
219 // Remember dialog mode, entity
220 XtVaSetValues( instance->chooserOkButton, XmNuserData, choice, NULL );
221 XtVaSetValues( instance->chooserCancelButton, XmNuserData, entity, NULL );
223 XtManageChild( instance->chooser_shellform );
226 /*** DTB_USER_CODE_END
228 *** End of user code section
230 **************************************************************************/
235 ttChooser_chooserCancelButton_CB1(
237 XtPointer clientData,
241 /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
242 /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
244 DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
246 if (!(instance->initialized))
248 dtb_tt_chooser_chooser_initialize(instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin);
250 XtUnmanageChild(instance->chooser_shellform);
252 /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
253 /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
260 XtPointer clientData,
264 /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
265 /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
267 /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
268 DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
269 XmListCallbackStruct *info = (XmListCallbackStruct *)callData;
271 XtVaGetValues( instance->chooserOkButton, XmNuserData, &choice, NULL );
273 Boolean isString = False;
274 switch ((_DtTtChooserAction)choice) {
275 case _DtTtChooserNone:
277 case _DtTtChooserMessageOpSet:
278 case _DtTtChooserPatternOpAdd:
279 case _DtTtChooserMessageCreateStandard:
283 case _DtTtChooserMessageOpen:
284 case _DtTtChooserMessageDestroy:
287 case _DtTtChooserPatternOpen:
288 case _DtTtChooserPatternDestroy:
291 case _DtTtChooserDtSessionQuit:
292 type = DTTT_DTSESSION;
294 case _DtTtChooserDtFileDeleted:
295 case _DtTtChooserDtFileModified:
296 case _DtTtChooserDtFileReverted:
297 case _DtTtChooserDtFileMoved:
298 case _DtTtChooserDtFileSaved:
299 case _DtTtChooserDtFileQuit:
302 case _DtTtChooserMessageHandlerSet:
303 case _DtTtChooserPatternSenderAdd:
304 case _DtTtChooserProcidSetDefault:
305 case _DtTtChooserProcidSuspend:
306 case _DtTtChooserProcidResume:
307 case _DtTtChooserDtProcidClose:
312 void *entity = DtTtNth( type, info->item_position - 1 );
313 std::ostringstream entityName;
315 entityName << (char *)entity << ends;
317 entityName << entity << ends;
319 XmTextFieldSetString( instance->chooserText, const_cast<char *>(entityName.str().c_str()) );
320 /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
327 XtPointer clientData,
331 /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
332 /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
334 /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
335 DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
336 char *text = XmTextFieldGetString( instance->chooserText );
338 XtVaGetValues( instance->chooserOkButton, XmNuserData, &ival, NULL );
339 _DtTtChooserAction choice = (_DtTtChooserAction)ival;
340 Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
351 case _DtTtChooserNone:
353 case _DtTtChooserMessageCreateStandard:
354 msg = tttk_message_create( text );
355 status = DtTtSetLabel( label, "tt_message_create()", msg );
356 if (tt_is_err( status )) {
359 DtTtCreated( DTTT_MESSAGE, msg );
360 newWidget = DtTtMessageWidgetCreate(
361 dtb_ttsnoop_ttsnoop_win.ttsnoopWin, msg,
362 DtTtMessageWidgetUpdate );
363 status = tt_ptr_error( newWidget );
364 if (tt_is_err( status )) {
367 XRaiseWindow( XtDisplay( newWidget ), XtWindow( newWidget ));
368 XtUnmanageChild( instance->chooser_shellform );
370 case _DtTtChooserMessageOpSet:
371 XtVaGetValues( instance->chooserCancelButton,
372 XmNuserData, &xtPtr, NULL );
373 _DtTtMessageUpdate( (Tt_message)xtPtr, choice, text );
374 XtUnmanageChild( instance->chooser_shellform );
376 case _DtTtChooserPatternOpAdd:
377 XtVaGetValues( instance->chooserCancelButton,
378 XmNuserData, &xtPtr, NULL );
379 _DtTtPatternUpdate( (Tt_pattern)xtPtr, choice, text );
380 XtUnmanageChild( instance->chooser_shellform );
382 case _DtTtChooserMessageHandlerSet:
383 XtVaGetValues( instance->chooserCancelButton,
384 XmNuserData, &xtPtr, NULL );
385 _DtTtMessageUpdate( (Tt_message)xtPtr, choice, text );
386 XtUnmanageChild( instance->chooser_shellform );
388 case _DtTtChooserPatternSenderAdd:
389 XtVaGetValues( instance->chooserCancelButton,
390 XmNuserData, &xtPtr, NULL );
391 _DtTtPatternUpdate( (Tt_pattern)xtPtr, choice, text );
392 XtUnmanageChild( instance->chooser_shellform );
394 case _DtTtChooserMessageOpen:
395 case _DtTtChooserMessageDestroy:
400 sscanf( text, "%i", &ival );
401 msg = (Tt_message) (intptr_t) ival;
402 if (DtTtIndex( DTTT_MESSAGE, msg ) < 0) {
405 if (choice == _DtTtChooserMessageOpen) {
406 Widget newWidget = DtTtMessageWidgetCreate(
407 dtb_ttsnoop_ttsnoop_win.ttsnoopWin,
408 msg, DtTtMessageWidgetUpdate );
409 Tt_status status = tt_ptr_error( newWidget );
410 if (tt_is_err( status )) {
413 XRaiseWindow( XtDisplay( newWidget ), XtWindow( newWidget ));
415 Widget msgWidget = DtTtMessageWidget( msg );
416 Tt_status status = tttk_message_destroy( msg );
417 if (status == TT_WRN_STOPPED) {
418 DtTtSetLabel( label, "tttk_message_destroy()",
422 DtTtDestroyed( DTTT_MESSAGE, msg );
423 if (msgWidget != 0) {
424 XtDestroyWidget( msgWidget );
426 _DtTtChooserSet( _DtTtChooserMessageDestroy );
429 case _DtTtChooserPatternOpen:
430 case _DtTtChooserPatternDestroy:
435 sscanf( text, "%i", &ival );
436 pat = (Tt_pattern) (intptr_t) ival;
437 if (DtTtIndex( DTTT_PATTERN, pat ) < 0) {
440 if (choice == _DtTtChooserPatternOpen) {
441 Widget newWidget = DtTtPatternWidgetCreate(
442 dtb_ttsnoop_ttsnoop_win.ttsnoopWin,
444 Tt_status status = tt_ptr_error( newWidget );
445 if (tt_is_err( status )) {
448 XRaiseWindow( XtDisplay( newWidget ), XtWindow( newWidget ));
450 Widget patWidget = DtTtPatternWidget( pat );
451 Tt_status status = tt_pattern_destroy( pat );
452 if (status == TT_WRN_STOPPED) {
453 DtTtSetLabel( label, "tt_pattern_destroy()",
457 DtTtDestroyed( DTTT_PATTERN, pat );
458 if (patWidget != 0) {
459 XtDestroyWidget( patWidget );
461 _DtTtChooserSet( _DtTtChooserPatternDestroy );
464 case _DtTtChooserDtSessionQuit:
469 sscanf( text, "%i", &ival );
470 pats = (Tt_pattern *) (intptr_t) ival;
471 if (DtTtIndex( DTTT_DTSESSION, pats ) < 0) {
474 text = (char *)tt_pattern_user( *pats, _DtTtPatsNameKey );
475 if (tt_is_err( tt_ptr_error( text )) || text == 0) {
478 status = ttdt_session_quit( text, pats, 1 );
479 DtTtSetLabel( label, "ttdt_session_quit()", status );
480 if (status == TT_OK) {
481 DtTtDestroyed( DTTT_DTSESSION, pats );
483 XtUnmanageChild( instance->chooser_shellform );
485 case _DtTtChooserDtFileDeleted:
486 case _DtTtChooserDtFileModified:
487 case _DtTtChooserDtFileReverted:
488 case _DtTtChooserDtFileMoved:
489 case _DtTtChooserDtFileSaved:
490 case _DtTtChooserDtFileQuit:
495 sscanf( text, "%i", &ival );
496 pats = (Tt_pattern *) (intptr_t) ival;
497 if (DtTtIndex( DTTT_DTFILE, pats ) < 0) {
500 switch ((_DtTtChooserAction)choice) {
501 case _DtTtChooserDtFileModified:
502 status = ttdt_file_event( 0, TTDT_MODIFIED, pats, 1 );
503 func = "ttdt_file_event(,TTDT_MODIFIED)";
505 case _DtTtChooserDtFileReverted:
506 status = ttdt_file_event( 0, TTDT_REVERTED, pats, 1 );
507 func = "ttdt_file_event(,TTDT_REVERTED)";
509 case _DtTtChooserDtFileSaved:
510 status = ttdt_file_event( 0, TTDT_SAVED, pats, 1 );
511 func = "ttdt_file_event(,TTDT_SAVED)";
513 case _DtTtChooserDtFileQuit:
514 status = ttdt_file_quit( pats, 1 );
515 func = "ttdt_file_quit()";
516 if (status == TT_OK) {
517 DtTtDestroyed( DTTT_DTFILE, pats );
521 DtTtSetLabel( label, func, status );
522 XtUnmanageChild( instance->chooser_shellform );
523 case _DtTtChooserProcidSetDefault:
524 status = tt_default_procid_set( text );
525 DtTtSetLabel( label, "tt_default_procid_set()", status );
526 XtUnmanageChild( instance->chooser_shellform );
528 case _DtTtChooserProcidSuspend:
529 ival = DtTtIndex( DTTT_PROCID, text );
533 id = (XtInputId)DtTtNthClientDatum( DTTT_PROCID, ival );
536 DtTtSetLabel( label, "XtRemoveInput()" );
538 XtUnmanageChild( instance->chooser_shellform );
540 case _DtTtChooserProcidResume:
541 ival = DtTtIndex( DTTT_PROCID, text );
545 fd = tt_procid_fd( text );
546 if (tt_is_err( tt_int_error( fd ))) {
549 id = XtAppAddInput( XtWidgetToApplicationContext( label ),
550 fd, (XtPointer)XtInputReadMask,
551 tttk_Xt_input_handler, text );
552 DtTtSetLabel( label, "XtAppAddInput()", (int)id );
554 DtTtNthClientDatumSet( DTTT_PROCID, ival, (void *)id );
556 XtUnmanageChild( instance->chooser_shellform );
558 case _DtTtChooserDtProcidClose:
559 status = ttdt_close( text, 0, 1 );
560 DtTtSetLabel( label, "ttdt_close()", status );
561 ival = DtTtIndex( DTTT_PROCID, text );
565 id = (XtInputId)DtTtNthClientDatum( DTTT_PROCID, ival );
569 DtTtDestroyed( DTTT_PROCID, text );
570 XtUnmanageChild( instance->chooser_shellform );
573 /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
580 XtPointer clientData,
584 /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
585 /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
587 /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
588 DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
590 XtVaGetValues( instance->chooserOkButton, XmNuserData, &ival, NULL );
591 _DtTtChooserAction choice = (_DtTtChooserAction)ival;
592 Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
595 case _DtTtChooserNone:
597 case _DtTtChooserMessageOpSet:
598 case _DtTtChooserMessageCreateStandard:
599 case _DtTtChooserPatternOpAdd:
600 op = XmTextFieldGetString( instance->chooserText );
604 if (choice == _DtTtChooserMessageOpSet) {
605 _DtMan( label, "tt_message_op_set" );
607 _DtMan( label, "tt_pattern_op_add" );
610 case _DtTtChooserMessageOpen:
611 _DtMan( label, "tt_message_print" );
613 case _DtTtChooserMessageHandlerSet:
614 _DtMan( label, "tt_message_handler_set" );
616 case _DtTtChooserMessageDestroy:
617 _DtMan( label, "tt_message_destroy" );
619 case _DtTtChooserPatternOpen:
620 _DtMan( label, "tt_pattern_print" );
622 case _DtTtChooserPatternSenderAdd:
623 _DtMan( label, "tt_pattern_sender_add" );
625 case _DtTtChooserPatternDestroy:
626 _DtMan( label, "tt_pattern_destroy" );
628 case _DtTtChooserDtSessionQuit:
629 _DtMan( label, "ttdt_session_quit" );
631 case _DtTtChooserDtFileDeleted:
632 case _DtTtChooserDtFileModified:
633 case _DtTtChooserDtFileReverted:
634 case _DtTtChooserDtFileMoved:
635 case _DtTtChooserDtFileSaved:
636 _DtMan( label, "ttdt_file_event" );
638 case _DtTtChooserDtFileQuit:
639 _DtMan( label, "ttdt_file_quit" );
641 case _DtTtChooserProcidSetDefault:
642 _DtMan( label, "tt_default_procid_set" );
644 case _DtTtChooserProcidSuspend:
645 _DtMan( label, "XtRemoveInput" );
647 case _DtTtChooserProcidResume:
648 _DtMan( label, "XtAppAddInput" );
650 case _DtTtChooserDtProcidClose:
651 _DtMan( label, "ttdt_close" );
654 /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
659 /**************************************************************************
660 *** DTB_USER_CODE_START
662 *** All automatically-generated data and functions have been defined.
664 *** Add new functions here, or at the top of the file.
667 /*** DTB_USER_CODE_END
669 *** End of user code section
671 **************************************************************************/