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.
46 #include "ttsnoop_ui.h"
49 * There is no public header file for this function (only an
50 * internal header XmStringI.h).
53 extern XtPointer _XmStringUngenerate (XmString string,
56 XmTextType output_type);
59 extern std::ofstream snoopStream;
60 extern int globalTimeout;
62 typedef struct _FileChooserInfo {
63 _DtFileChooserAction choice;
69 _DtFileChooserAction choice,
77 case _DtFileChoosePatternAdd:
79 title = "tt_pattern_file_add";
81 case _DtFileChooseMessageSet:
83 title = "tt_message_file_set";
85 case _DtFileChooseJoin:
87 title = "tt_file_join";
89 case _DtFileChooseDtJoin:
91 title = "ttdt_file_join";
93 case _DtFileChooseQuit:
95 title = "tt_file_quit";
97 case _DtFileChooseDefault:
99 title = "tt_default_file_set";
101 case _DtFileChooseGetModified:
103 title = "ttdt_Get_Modified";
105 case _DtFileChooseSave:
109 case _DtFileChooseRevert:
111 title = "ttdt_Revert";
113 case _DtFileChooseNetfile:
114 okString = "Netfile";
115 title = "tt_file_netfile";
117 case _DtFileChooseChdir:
121 case _DtFileChooseTypesLoad:
123 title = "tt_session_types_load";
128 DtbFileChooserFchooserInfo instance =
129 &dtb_file_chooser_fchooser;
130 if (! instance->initialized) {
131 dtb_file_chooser_fchooser_initialize(
132 instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin );
134 XmString okXmString = XmStringCreateLocalized( okString );
135 XtVaSetValues( instance->fchooser, XmNokLabelString, okXmString, NULL );
136 XmStringFree( okXmString );
137 XtVaSetValues( instance->fchooser_shell, XmNtitle, title, NULL );
139 // Remember dialog mode, entity
140 FileChooserInfo *info = new FileChooserInfo;
141 info->choice = choice;
142 info->entity = entity;
143 XtVaSetValues( instance->fchooser, XmNuserData, info, NULL );
145 XtManageChild( instance->fchooser );
159 DtTtCreated( DTTT_MESSAGE, msg );
160 snoopIt( "Ttdt_file_cb", (void *) snoopFileMsg, msg );
161 if ( (tt_message_class( msg ) == TT_REQUEST)
162 && (tt_message_state( msg ) == TT_SENT))
164 // Let user fill in the answer
165 Widget newWidget = DtTtMessageWidgetCreate(
166 dtb_ttsnoop_ttsnoop_win.ttsnoopWin,
167 msg, DtTtMessageWidgetUpdate );
168 if (! tt_is_err( tt_ptr_error( newWidget ) )) {
169 XRaiseWindow( XtDisplay( newWidget ),
170 XtWindow( newWidget ));
176 /*** DTB_USER_CODE_END
178 *** End of user code section
180 **************************************************************************/
187 XtPointer clientData,
191 /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
192 /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
194 /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
195 DtbFileChooserFchooserInfo instance =
196 (DtbFileChooserFchooserInfo)clientData;
197 XmFileSelectionBoxCallbackStruct *cbRec =
198 (XmFileSelectionBoxCallbackStruct *)callData;
201 path = (char *) _XmStringUngenerate((XmString) cbRec->value, NULL,
202 XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
208 if ((path != 0) && (path[0] == '\0')) {
212 XtVaGetValues( instance->fchooser, XmNuserData, &xtPtr, NULL );
213 FileChooserInfo *info = (FileChooserInfo *)xtPtr;
214 Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
215 std::ostringstream script;
216 switch (info->choice) {
222 case _DtFileChoosePatternAdd:
223 _DtTtPatternUpdate( (Tt_pattern)info->entity, info->choice, path );
225 case _DtFileChooseMessageSet:
226 _DtTtMessageUpdate( (Tt_message)info->entity, info->choice, path );
228 case _DtFileChooseJoin:
229 status = tt_file_join( path );
230 DtTtSetLabel( label, "tt_file_join()", status );
232 case _DtFileChooseDtJoin:
233 pats = ttdt_file_join( path, TT_SCOPE_NONE, 1, snoopFileMsg, 0 );
234 status = DtTtSetLabel( label, "ttdt_file_join()", pats );
235 if ((status == TT_OK) && (pats != 0)) {
236 DtTtCreated( DTTT_DTFILE, pats, path );
239 case _DtFileChooseQuit:
240 status = tt_file_quit( path );
241 DtTtSetLabel( label, "tt_file_quit()", status );
243 case _DtFileChooseDefault:
244 status = tt_default_file_set( path );
245 DtTtSetLabel( label, "tt_default_file_set()", status );
247 case _DtFileChooseGetModified:
248 DtTtSetLabel( label, "ttdt_Get_Modified() = ..." );
249 XtSetSensitive( dtb_ttsnoop_ttsnoop_win.ttsnoopWin, False );
250 ival = ttdt_Get_Modified( 0, path, TT_BOTH,
251 XtWidgetToApplicationContext( label ),
253 XtSetSensitive( dtb_ttsnoop_ttsnoop_win.ttsnoopWin, True );
254 DtTtSetLabel( label, "ttdt_Get_Modified()", ival );
256 case _DtFileChooseSave:
257 DtTtSetLabel( label, "ttdt_Save() = ..." );
258 XtSetSensitive( dtb_ttsnoop_ttsnoop_win.ttsnoopWin, False );
259 status = ttdt_Save( 0, path, TT_BOTH,
260 XtWidgetToApplicationContext( label ),
262 // XXX Put up watch cursor; disable dialogs?
263 XtSetSensitive( dtb_ttsnoop_ttsnoop_win.ttsnoopWin, True );
264 DtTtSetLabel( label, "ttdt_Save()", status );
266 case _DtFileChooseRevert:
267 DtTtSetLabel( label, "ttdt_Revert() = ..." );
268 XtSetSensitive( dtb_ttsnoop_ttsnoop_win.ttsnoopWin, False );
269 ival = ttdt_Revert( 0, path, TT_BOTH,
270 XtWidgetToApplicationContext( label ),
272 XtSetSensitive( dtb_ttsnoop_ttsnoop_win.ttsnoopWin, True );
273 DtTtSetLabel( label, "ttdt_Revert()", ival );
275 case _DtFileChooseNetfile:
276 val = tt_file_netfile( path );
277 DtTtSetLabel( label, "tt_file_netfile()", val );
278 if (! tt_is_err( tt_ptr_error( val ))) {
279 snoopStream << "tt_file_netfile( \"" << val
280 << "\" ) = \"" << val << "\"" << endl;
283 case _DtFileChooseChdir:
284 ival = chdir( path );
285 DtTtSetLabel( label, "chdir()", ival );
287 case _DtFileChooseTypesLoad:
289 // Validate types file, with tt_type_comp -p
290 // (A corrupt file could crash ttsession.)
292 script << "numChars=`tt_type_comp -p \"" << path;
293 script << "\" | wc -c`; if [ $numChars = 0 ]; "
294 "then exit 1; else exit 0; fi" << endl;
295 ival = system( script.str().c_str() );
296 if (! WIFEXITED( ival )) {
298 "system( \"tt_type_comp -p\" )", ival );
301 if (WEXITSTATUS( ival ) != 0) {
302 std::ostringstream diagnosis;
303 diagnosis << "tt_type_comp -p: syntax error in "
305 DtTtSetLabel( label, diagnosis.str().c_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 **************************************************************************/