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: fileChooser_stubs.C.src /main/4 1996/10/14 09:35:42 barstow $
7 /*** DTB_USER_CODE_END ^^^ Add file header above ^^^ ***/
10 * File: fileChooser_stubs.c
11 * Contains: Module callbacks and connection functions
13 * This file was generated by dtcodegen, from module fileChooser
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 "fileChooser_ui.h"
30 /**************************************************************************
31 *** DTB_USER_CODE_START
33 *** All necessary header files have been included.
35 *** Add include files, types, macros, externs, and user functions here.
42 #include <strstream.h>
44 #include "ttsnoop_ui.h"
47 * There is no public header file for this function (only an
48 * internal header XmStringI.h).
51 extern XtPointer _XmStringUngenerate (XmString string,
54 XmTextType output_type);
57 extern ofstream snoopStream;
58 extern int globalTimeout;
60 typedef struct _FileChooserInfo {
61 _DtFileChooserAction choice;
67 _DtFileChooserAction choice,
75 case _DtFileChoosePatternAdd:
77 title = "tt_pattern_file_add";
79 case _DtFileChooseMessageSet:
81 title = "tt_message_file_set";
83 case _DtFileChooseJoin:
85 title = "tt_file_join";
87 case _DtFileChooseDtJoin:
89 title = "ttdt_file_join";
91 case _DtFileChooseQuit:
93 title = "tt_file_quit";
95 case _DtFileChooseDefault:
97 title = "tt_default_file_set";
99 case _DtFileChooseGetModified:
101 title = "ttdt_Get_Modified";
103 case _DtFileChooseSave:
107 case _DtFileChooseRevert:
109 title = "ttdt_Revert";
111 case _DtFileChooseNetfile:
112 okString = "Netfile";
113 title = "tt_file_netfile";
115 case _DtFileChooseChdir:
119 case _DtFileChooseTypesLoad:
121 title = "tt_session_types_load";
126 DtbFileChooserFchooserInfo instance =
127 &dtb_file_chooser_fchooser;
128 if (! instance->initialized) {
129 dtb_file_chooser_fchooser_initialize(
130 instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin );
132 XmString okXmString = XmStringCreateLocalized( okString );
133 XtVaSetValues( instance->fchooser, XmNokLabelString, okXmString, 0 );
134 XmStringFree( okXmString );
135 XtVaSetValues( instance->fchooser_shell, XmNtitle, title, 0 );
137 // Remember dialog mode, entity
138 FileChooserInfo *info = new FileChooserInfo;
139 info->choice = choice;
140 info->entity = entity;
141 XtVaSetValues( instance->fchooser, XmNuserData, info, 0 );
143 XtManageChild( instance->fchooser );
157 DtTtCreated( DTTT_MESSAGE, msg );
158 snoopIt( "Ttdt_file_cb", snoopFileMsg, msg );
159 if ( (tt_message_class( msg ) == TT_REQUEST)
160 && (tt_message_state( msg ) == TT_SENT))
162 // Let user fill in the answer
163 Widget newWidget = DtTtMessageWidgetCreate(
164 dtb_ttsnoop_ttsnoop_win.ttsnoopWin,
165 msg, DtTtMessageWidgetUpdate );
166 if (! tt_is_err( tt_ptr_error( newWidget ) )) {
167 XRaiseWindow( XtDisplay( newWidget ),
168 XtWindow( newWidget ));
174 /*** DTB_USER_CODE_END
176 *** End of user code section
178 **************************************************************************/
185 XtPointer clientData,
189 /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
190 /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
192 /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
193 DtbFileChooserFchooserInfo instance =
194 (DtbFileChooserFchooserInfo)clientData;
195 XmFileSelectionBoxCallbackStruct *cbRec =
196 (XmFileSelectionBoxCallbackStruct *)callData;
199 path = (char *) _XmStringUngenerate((XmString) cbRec->value, NULL,
200 XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
206 if ((path != 0) && (path[0] == '\0')) {
210 XtVaGetValues( instance->fchooser, XmNuserData, &xtPtr, 0 );
211 FileChooserInfo *info = (FileChooserInfo *)xtPtr;
212 Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
214 switch (info->choice) {
220 case _DtFileChoosePatternAdd:
221 _DtTtPatternUpdate( (Tt_pattern)info->entity, info->choice, path );
223 case _DtFileChooseMessageSet:
224 _DtTtMessageUpdate( (Tt_message)info->entity, info->choice, path );
226 case _DtFileChooseJoin:
227 status = tt_file_join( path );
228 DtTtSetLabel( label, "tt_file_join()", status );
230 case _DtFileChooseDtJoin:
231 pats = ttdt_file_join( path, TT_SCOPE_NONE, 1, snoopFileMsg, 0 );
232 status = DtTtSetLabel( label, "ttdt_file_join()", pats );
233 if ((status == TT_OK) && (pats != 0)) {
234 DtTtCreated( DTTT_DTFILE, pats, path );
237 case _DtFileChooseQuit:
238 status = tt_file_quit( path );
239 DtTtSetLabel( label, "tt_file_quit()", status );
241 case _DtFileChooseDefault:
242 status = tt_default_file_set( path );
243 DtTtSetLabel( label, "tt_default_file_set()", status );
245 case _DtFileChooseGetModified:
246 DtTtSetLabel( label, "ttdt_Get_Modified() = ..." );
247 XtSetSensitive( dtb_ttsnoop_ttsnoop_win.ttsnoopWin, False );
248 ival = ttdt_Get_Modified( 0, path, TT_BOTH,
249 XtWidgetToApplicationContext( label ),
251 XtSetSensitive( dtb_ttsnoop_ttsnoop_win.ttsnoopWin, True );
252 DtTtSetLabel( label, "ttdt_Get_Modified()", ival );
254 case _DtFileChooseSave:
255 DtTtSetLabel( label, "ttdt_Save() = ..." );
256 XtSetSensitive( dtb_ttsnoop_ttsnoop_win.ttsnoopWin, False );
257 status = ttdt_Save( 0, path, TT_BOTH,
258 XtWidgetToApplicationContext( label ),
260 // XXX Put up watch cursor; disable dialogs?
261 XtSetSensitive( dtb_ttsnoop_ttsnoop_win.ttsnoopWin, True );
262 DtTtSetLabel( label, "ttdt_Save()", status );
264 case _DtFileChooseRevert:
265 DtTtSetLabel( label, "ttdt_Revert() = ..." );
266 XtSetSensitive( dtb_ttsnoop_ttsnoop_win.ttsnoopWin, False );
267 ival = ttdt_Revert( 0, path, TT_BOTH,
268 XtWidgetToApplicationContext( label ),
270 XtSetSensitive( dtb_ttsnoop_ttsnoop_win.ttsnoopWin, True );
271 DtTtSetLabel( label, "ttdt_Revert()", ival );
273 case _DtFileChooseNetfile:
274 val = tt_file_netfile( path );
275 DtTtSetLabel( label, "tt_file_netfile()", val );
276 if (! tt_is_err( tt_ptr_error( val ))) {
277 snoopStream << "tt_file_netfile( \"" << val
278 << "\" ) = \"" << val << "\"" << endl;
281 case _DtFileChooseChdir:
282 ival = chdir( path );
283 DtTtSetLabel( label, "chdir()", ival );
285 case _DtFileChooseTypesLoad:
287 // Validate types file, with tt_type_comp -p
288 // (A corrupt file could crash ttsession.)
290 script << "numChars=`tt_type_comp -p \"" << path;
291 script << "\" | wc -c`; if [ $numChars = 0 ]; "
292 "then exit 1; else exit 0; fi" << endl;
293 ival = system( script.str() );
295 if (! WIFEXITED( ival )) {
297 "system( \"tt_type_comp -p\" )", ival );
300 if (WEXITSTATUS( ival ) != 0) {
301 ostrstream diagnosis;
302 diagnosis << "tt_type_comp -p: syntax error in "
304 DtTtSetLabel( label, diagnosis.str() );
305 delete diagnosis.str();
308 sess = tt_default_session();
309 status = tt_session_types_load( sess, path );
311 DtTtSetLabel( label, "tt_session_types_load()", status );
316 XtUnmanageChild( instance->fchooser_shell );
317 /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
322 /**************************************************************************
323 *** DTB_USER_CODE_START
325 *** All automatically-generated data and functions have been defined.
327 *** Add new functions here, or at the top of the file.
330 /*** DTB_USER_CODE_END
332 *** End of user code section
334 **************************************************************************/