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.
45 #if defined(linux) || defined(CSRG_BASED)
48 #include <strstream.h>
57 _DtTtChooserAction choice,
61 DtbTtChooserChooserInfo instance = &dtb_tt_chooser_chooser;
62 if (! instance->initialized) {
63 dtb_tt_chooser_chooser_initialize(
64 instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin );
71 case _DtTtChooserNone:
73 case _DtTtChooserMessageOpen:
75 title = "Open Tt_message";
77 case _DtTtChooserMessageCreateStandard:
79 title = "Create Standard Tt_message";
81 case _DtTtChooserMessageOpSet:
83 title = "tt_message_op_set";
85 case _DtTtChooserMessageHandlerSet:
87 title = "tt_message_handler_set";
89 case _DtTtChooserMessageDestroy:
91 title = "tt_message_destroy";
93 case _DtTtChooserPatternOpen:
95 title = "Open Tt_pattern";
97 case _DtTtChooserPatternOpAdd:
99 title = "tt_pattern_op_add";
101 case _DtTtChooserPatternSenderAdd:
103 title = "tt_pattern_sender_add";
105 case _DtTtChooserPatternDestroy:
106 okString = "Destroy";
107 title = "tt_pattern_destroy";
109 case _DtTtChooserDtSessionQuit:
111 title = "ttdt_session_quit";
113 case _DtTtChooserDtFileDeleted:
115 title = "ttdt_file_event(,TTDT_DELETED)";
117 case _DtTtChooserDtFileModified:
119 title = "ttdt_file_event(,TTDT_MODIFIED)";
121 case _DtTtChooserDtFileReverted:
123 title = "ttdt_file_event(,TTDT_REVERTED)";
125 case _DtTtChooserDtFileMoved:
127 title = "ttdt_file_event(,TTDT_MOVED)";
129 case _DtTtChooserDtFileSaved:
131 title = "ttdt_file_event(,TTDT_SAVED)";
133 case _DtTtChooserDtFileQuit:
135 title = "ttdt_file_quit";
137 case _DtTtChooserProcidSetDefault:
139 title = "tt_default_procid_set";
141 case _DtTtChooserProcidSuspend:
143 title = "XtRemoveInput";
145 case _DtTtChooserProcidResume:
147 title = "XtAppAddInput";
149 case _DtTtChooserDtProcidClose:
151 title = "ttdt_close";
156 case _DtTtChooserNone:
158 case _DtTtChooserMessageOpSet:
159 case _DtTtChooserPatternOpAdd:
160 case _DtTtChooserMessageCreateStandard:
162 valuesLabel = "Standard Op";
165 case _DtTtChooserMessageOpen:
166 case _DtTtChooserMessageDestroy:
167 valueLabel = "Tt_message:";
168 valuesLabel = "Tt_message";
171 case _DtTtChooserPatternOpen:
172 case _DtTtChooserPatternDestroy:
173 valueLabel = "Tt_pattern:";
174 valuesLabel = "Tt_pattern";
177 case _DtTtChooserDtSessionQuit:
178 valueLabel = "Tt_pattern *:";
179 valuesLabel = "Desktop-joined session";
180 type = DTTT_DTSESSION;
182 case _DtTtChooserDtFileDeleted:
183 case _DtTtChooserDtFileModified:
184 case _DtTtChooserDtFileReverted:
185 case _DtTtChooserDtFileMoved:
186 case _DtTtChooserDtFileSaved:
187 case _DtTtChooserDtFileQuit:
188 valueLabel = "Tt_pattern *:";
189 valuesLabel = "Desktop-joined file";
192 case _DtTtChooserMessageHandlerSet:
193 case _DtTtChooserPatternSenderAdd:
194 case _DtTtChooserProcidSetDefault:
195 case _DtTtChooserProcidSuspend:
196 case _DtTtChooserProcidResume:
197 case _DtTtChooserDtProcidClose:
198 valueLabel = "Procid:";
199 valuesLabel = "Procid";
203 DtTtSetLabel( instance->chooserOkButton, okString );
204 DtTtSetLabel( instance->chooserText_label, valueLabel );
207 XmString *items = _DtTtChoices( type, &itemCount );
208 XtVaSetValues( instance->chooserList,
209 XmNitemCount, itemCount,
212 XmListDeselectAllItems( instance->chooserList );
213 XmTextFieldSetString( instance->chooserText, 0 );
214 XtVaSetValues( instance->chooser, XmNtitle, title, 0 );
216 std::ostrstream valuesStream;
217 valuesStream << itemCount << " " << valuesLabel;
218 if (itemCount != 1) valuesStream << "s";
219 valuesStream << ends;
220 DtTtSetLabel( instance->chooserList_label, valuesStream.str() );
221 delete valuesStream.str();
223 // Remember dialog mode, entity
224 XtVaSetValues( instance->chooserOkButton, XmNuserData, choice, 0 );
225 XtVaSetValues( instance->chooserCancelButton, XmNuserData, entity, 0 );
227 XtManageChild( instance->chooser_shellform );
230 /*** DTB_USER_CODE_END
232 *** End of user code section
234 **************************************************************************/
239 ttChooser_chooserCancelButton_CB1(
241 XtPointer clientData,
245 /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
246 /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
248 DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
250 if (!(instance->initialized))
252 dtb_tt_chooser_chooser_initialize(instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin);
254 XtUnmanageChild(instance->chooser_shellform);
256 /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
257 /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
264 XtPointer clientData,
268 /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
269 /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
271 /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
272 DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
273 XmListCallbackStruct *info = (XmListCallbackStruct *)callData;
275 XtVaGetValues( instance->chooserOkButton, XmNuserData, &choice, 0 );
277 Boolean isString = False;
278 switch ((_DtTtChooserAction)choice) {
279 case _DtTtChooserNone:
281 case _DtTtChooserMessageOpSet:
282 case _DtTtChooserPatternOpAdd:
283 case _DtTtChooserMessageCreateStandard:
287 case _DtTtChooserMessageOpen:
288 case _DtTtChooserMessageDestroy:
291 case _DtTtChooserPatternOpen:
292 case _DtTtChooserPatternDestroy:
295 case _DtTtChooserDtSessionQuit:
296 type = DTTT_DTSESSION;
298 case _DtTtChooserDtFileDeleted:
299 case _DtTtChooserDtFileModified:
300 case _DtTtChooserDtFileReverted:
301 case _DtTtChooserDtFileMoved:
302 case _DtTtChooserDtFileSaved:
303 case _DtTtChooserDtFileQuit:
306 case _DtTtChooserMessageHandlerSet:
307 case _DtTtChooserPatternSenderAdd:
308 case _DtTtChooserProcidSetDefault:
309 case _DtTtChooserProcidSuspend:
310 case _DtTtChooserProcidResume:
311 case _DtTtChooserDtProcidClose:
316 void *entity = DtTtNth( type, info->item_position - 1 );
317 std::ostrstream entityName;
319 entityName << (char *)entity << ends;
321 entityName << entity << ends;
323 XmTextFieldSetString( instance->chooserText, entityName.str() );
324 delete entityName.str();
325 /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
332 XtPointer clientData,
336 /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
337 /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
339 /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
340 DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
341 char *text = XmTextFieldGetString( instance->chooserText );
343 XtVaGetValues( instance->chooserOkButton, XmNuserData, &ival, 0 );
344 _DtTtChooserAction choice = (_DtTtChooserAction)ival;
345 Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
356 case _DtTtChooserNone:
358 case _DtTtChooserMessageCreateStandard:
359 msg = tttk_message_create( text );
360 status = DtTtSetLabel( label, "tt_message_create()", msg );
361 if (tt_is_err( status )) {
364 DtTtCreated( DTTT_MESSAGE, msg );
365 newWidget = DtTtMessageWidgetCreate(
366 dtb_ttsnoop_ttsnoop_win.ttsnoopWin, msg,
367 DtTtMessageWidgetUpdate );
368 status = tt_ptr_error( newWidget );
369 if (tt_is_err( status )) {
372 XRaiseWindow( XtDisplay( newWidget ), XtWindow( newWidget ));
373 XtUnmanageChild( instance->chooser_shellform );
375 case _DtTtChooserMessageOpSet:
376 XtVaGetValues( instance->chooserCancelButton,
377 XmNuserData, &xtPtr, 0 );
378 _DtTtMessageUpdate( (Tt_message)xtPtr, choice, text );
379 XtUnmanageChild( instance->chooser_shellform );
381 case _DtTtChooserPatternOpAdd:
382 XtVaGetValues( instance->chooserCancelButton,
383 XmNuserData, &xtPtr, 0 );
384 _DtTtPatternUpdate( (Tt_pattern)xtPtr, choice, text );
385 XtUnmanageChild( instance->chooser_shellform );
387 case _DtTtChooserMessageHandlerSet:
388 XtVaGetValues( instance->chooserCancelButton,
389 XmNuserData, &xtPtr, 0 );
390 _DtTtMessageUpdate( (Tt_message)xtPtr, choice, text );
391 XtUnmanageChild( instance->chooser_shellform );
393 case _DtTtChooserPatternSenderAdd:
394 XtVaGetValues( instance->chooserCancelButton,
395 XmNuserData, &xtPtr, 0 );
396 _DtTtPatternUpdate( (Tt_pattern)xtPtr, choice, text );
397 XtUnmanageChild( instance->chooser_shellform );
399 case _DtTtChooserMessageOpen:
400 case _DtTtChooserMessageDestroy:
405 sscanf( text, "%i", &ival );
406 msg = (Tt_message)ival;
407 if (DtTtIndex( DTTT_MESSAGE, msg ) < 0) {
410 if (choice == _DtTtChooserMessageOpen) {
411 Widget newWidget = DtTtMessageWidgetCreate(
412 dtb_ttsnoop_ttsnoop_win.ttsnoopWin,
413 msg, DtTtMessageWidgetUpdate );
414 Tt_status status = tt_ptr_error( newWidget );
415 if (tt_is_err( status )) {
418 XRaiseWindow( XtDisplay( newWidget ), XtWindow( newWidget ));
420 Widget msgWidget = DtTtMessageWidget( msg );
421 Tt_status status = tttk_message_destroy( msg );
422 if (status == TT_WRN_STOPPED) {
423 DtTtSetLabel( label, "tttk_message_destroy()",
427 DtTtDestroyed( DTTT_MESSAGE, msg );
428 if (msgWidget != 0) {
429 XtDestroyWidget( msgWidget );
431 _DtTtChooserSet( _DtTtChooserMessageDestroy );
434 case _DtTtChooserPatternOpen:
435 case _DtTtChooserPatternDestroy:
440 sscanf( text, "%i", &ival );
441 pat = (Tt_pattern)ival;
442 if (DtTtIndex( DTTT_PATTERN, pat ) < 0) {
445 if (choice == _DtTtChooserPatternOpen) {
446 Widget newWidget = DtTtPatternWidgetCreate(
447 dtb_ttsnoop_ttsnoop_win.ttsnoopWin,
449 Tt_status status = tt_ptr_error( newWidget );
450 if (tt_is_err( status )) {
453 XRaiseWindow( XtDisplay( newWidget ), XtWindow( newWidget ));
455 Widget patWidget = DtTtPatternWidget( pat );
456 Tt_status status = tt_pattern_destroy( pat );
457 if (status == TT_WRN_STOPPED) {
458 DtTtSetLabel( label, "tt_pattern_destroy()",
462 DtTtDestroyed( DTTT_PATTERN, pat );
463 if (patWidget != 0) {
464 XtDestroyWidget( patWidget );
466 _DtTtChooserSet( _DtTtChooserPatternDestroy );
469 case _DtTtChooserDtSessionQuit:
474 sscanf( text, "%i", &ival );
475 pats = (Tt_pattern *)ival;
476 if (DtTtIndex( DTTT_DTSESSION, pats ) < 0) {
479 text = (char *)tt_pattern_user( *pats, _DtTtPatsNameKey );
480 if (tt_is_err( tt_ptr_error( text )) || text == 0) {
483 status = ttdt_session_quit( text, pats, 1 );
484 DtTtSetLabel( label, "ttdt_session_quit()", status );
485 if (status == TT_OK) {
486 DtTtDestroyed( DTTT_DTSESSION, pats );
488 XtUnmanageChild( instance->chooser_shellform );
490 case _DtTtChooserDtFileDeleted:
491 case _DtTtChooserDtFileModified:
492 case _DtTtChooserDtFileReverted:
493 case _DtTtChooserDtFileMoved:
494 case _DtTtChooserDtFileSaved:
495 case _DtTtChooserDtFileQuit:
500 sscanf( text, "%i", &ival );
501 pats = (Tt_pattern *)ival;
502 if (DtTtIndex( DTTT_DTFILE, pats ) < 0) {
505 switch ((_DtTtChooserAction)choice) {
506 case _DtTtChooserDtFileModified:
507 status = ttdt_file_event( 0, TTDT_MODIFIED, pats, 1 );
508 func = "ttdt_file_event(,TTDT_MODIFIED)";
510 case _DtTtChooserDtFileReverted:
511 status = ttdt_file_event( 0, TTDT_REVERTED, pats, 1 );
512 func = "ttdt_file_event(,TTDT_REVERTED)";
514 case _DtTtChooserDtFileSaved:
515 status = ttdt_file_event( 0, TTDT_SAVED, pats, 1 );
516 func = "ttdt_file_event(,TTDT_SAVED)";
518 case _DtTtChooserDtFileQuit:
519 status = ttdt_file_quit( pats, 1 );
520 func = "ttdt_file_quit()";
521 if (status == TT_OK) {
522 DtTtDestroyed( DTTT_DTFILE, pats );
526 DtTtSetLabel( label, func, status );
527 XtUnmanageChild( instance->chooser_shellform );
528 case _DtTtChooserProcidSetDefault:
529 status = tt_default_procid_set( text );
530 DtTtSetLabel( label, "tt_default_procid_set()", status );
531 XtUnmanageChild( instance->chooser_shellform );
533 case _DtTtChooserProcidSuspend:
534 ival = DtTtIndex( DTTT_PROCID, text );
538 id = (XtInputId)DtTtNthClientDatum( DTTT_PROCID, ival );
541 DtTtSetLabel( label, "XtRemoveInput()" );
543 XtUnmanageChild( instance->chooser_shellform );
545 case _DtTtChooserProcidResume:
546 ival = DtTtIndex( DTTT_PROCID, text );
550 fd = tt_procid_fd( text );
551 if (tt_is_err( tt_int_error( fd ))) {
554 id = XtAppAddInput( XtWidgetToApplicationContext( label ),
555 fd, (XtPointer)XtInputReadMask,
556 tttk_Xt_input_handler, text );
557 DtTtSetLabel( label, "XtAppAddInput()", (int)id );
559 DtTtNthClientDatumSet( DTTT_PROCID, ival, (void *)id );
561 XtUnmanageChild( instance->chooser_shellform );
563 case _DtTtChooserDtProcidClose:
564 status = ttdt_close( text, 0, 1 );
565 DtTtSetLabel( label, "ttdt_close()", status );
566 ival = DtTtIndex( DTTT_PROCID, text );
570 id = (XtInputId)DtTtNthClientDatum( DTTT_PROCID, ival );
574 DtTtDestroyed( DTTT_PROCID, text );
575 XtUnmanageChild( instance->chooser_shellform );
578 /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
585 XtPointer clientData,
589 /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
590 /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
592 /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
593 DtbTtChooserChooserInfo instance = (DtbTtChooserChooserInfo)clientData;
595 XtVaGetValues( instance->chooserOkButton, XmNuserData, &ival, 0 );
596 _DtTtChooserAction choice = (_DtTtChooserAction)ival;
597 Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
600 case _DtTtChooserNone:
602 case _DtTtChooserMessageOpSet:
603 case _DtTtChooserMessageCreateStandard:
604 case _DtTtChooserPatternOpAdd:
605 op = XmTextFieldGetString( instance->chooserText );
609 if (choice == _DtTtChooserMessageOpSet) {
610 _DtMan( label, "tt_message_op_set" );
612 _DtMan( label, "tt_pattern_op_add" );
615 case _DtTtChooserMessageOpen:
616 _DtMan( label, "tt_message_print" );
618 case _DtTtChooserMessageHandlerSet:
619 _DtMan( label, "tt_message_handler_set" );
621 case _DtTtChooserMessageDestroy:
622 _DtMan( label, "tt_message_destroy" );
624 case _DtTtChooserPatternOpen:
625 _DtMan( label, "tt_pattern_print" );
627 case _DtTtChooserPatternSenderAdd:
628 _DtMan( label, "tt_pattern_sender_add" );
630 case _DtTtChooserPatternDestroy:
631 _DtMan( label, "tt_pattern_destroy" );
633 case _DtTtChooserDtSessionQuit:
634 _DtMan( label, "ttdt_session_quit" );
636 case _DtTtChooserDtFileDeleted:
637 case _DtTtChooserDtFileModified:
638 case _DtTtChooserDtFileReverted:
639 case _DtTtChooserDtFileMoved:
640 case _DtTtChooserDtFileSaved:
641 _DtMan( label, "ttdt_file_event" );
643 case _DtTtChooserDtFileQuit:
644 _DtMan( label, "ttdt_file_quit" );
646 case _DtTtChooserProcidSetDefault:
647 _DtMan( label, "tt_default_procid_set" );
649 case _DtTtChooserProcidSuspend:
650 _DtMan( label, "XtRemoveInput" );
652 case _DtTtChooserProcidResume:
653 _DtMan( label, "XtAppAddInput" );
655 case _DtTtChooserDtProcidClose:
656 _DtMan( label, "ttdt_close" );
659 /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
664 /**************************************************************************
665 *** DTB_USER_CODE_START
667 *** All automatically-generated data and functions have been defined.
669 *** Add new functions here, or at the top of the file.
672 /*** DTB_USER_CODE_END
674 *** End of user code section
676 **************************************************************************/