stringChooser_stubs.C.src 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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: stringChooser_stubs.C.src /main/3 1995/11/06 17:13:57 rswiston $
  7. /*** DTB_USER_CODE_END ^^^ Add file header above ^^^ ***/
  8. /*
  9. * File: stringChooser_stubs.c
  10. * Contains: Module callbacks and connection functions
  11. *
  12. * This file was generated by dtcodegen, from module stringChooser
  13. *
  14. * Any text may be added between the DTB_USER_CODE_START and
  15. * DTB_USER_CODE_END comments (even non-C code). Descriptive comments
  16. * are provided only as an aid.
  17. *
  18. * ** EDIT ONLY WITHIN SECTIONS MARKED WITH DTB_USER_CODE COMMENTS. **
  19. * ** ALL OTHER MODIFICATIONS WILL BE OVERWRITTEN. DO NOT MODIFY OR **
  20. * ** DELETE THE GENERATED COMMENTS! **
  21. */
  22. #include <stdio.h>
  23. #include <Xm/Xm.h>
  24. #include "dtb_utils.h"
  25. #include "stringChooser_ui.h"
  26. /*
  27. * Header files for cross-module connections
  28. */
  29. #include "ttsnoop_ui.h"
  30. /**************************************************************************
  31. *** DTB_USER_CODE_START
  32. ***
  33. *** All necessary header files have been included.
  34. ***
  35. *** Add include files, types, macros, externs, and user functions here.
  36. ***/
  37. #include <Xm/TextF.h>
  38. #include <fstream>
  39. #include "DtTt.h"
  40. extern ofstream snoopStream;
  41. void
  42. _DtStringChooserSet(
  43. _DtStringChooserAction choice,
  44. void * entity,
  45. const char * val
  46. )
  47. {
  48. DtbStringChooserStringChooserInfo instance =
  49. &dtb_string_chooser_string_chooser;
  50. if (! instance->initialized) {
  51. dtb_string_chooser_string_chooser_initialize(
  52. instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin );
  53. }
  54. if ((! tt_is_err( tt_ptr_error( val ))) && (val != 0)) {
  55. XmTextFieldSetString( instance->stringText, (char *)val );
  56. }
  57. _DtStringChooserSet( choice, entity );
  58. }
  59. void
  60. _DtStringChooserSet(
  61. _DtStringChooserAction choice,
  62. void * entity
  63. )
  64. {
  65. char *okString;
  66. char *title;
  67. char *valueLabel;
  68. switch (choice) {
  69. case _DtStringChoosePatternOp:
  70. okString = "Add";
  71. title = "tt_pattern_op_add";
  72. valueLabel = "Op:";
  73. break;
  74. case _DtStringChoosePatternOtype:
  75. okString = "Add";
  76. title = "tt_pattern_otype_add";
  77. valueLabel = "Otype:";
  78. break;
  79. case _DtStringChoosePatternObject:
  80. okString = "Add";
  81. title = "tt_pattern_object_add";
  82. valueLabel = "Object:";
  83. break;
  84. case _DtStringChoosePatternSenderPtype:
  85. okString = "Add";
  86. title = "tt_pattern_sender_ptype_add";
  87. valueLabel = "Ptype:";
  88. break;
  89. case _DtStringChooseMessageOtype:
  90. okString = "Set";
  91. title = "tt_message_otype_set";
  92. valueLabel = "Otype:";
  93. break;
  94. case _DtStringChooseMessageObject:
  95. okString = "Set";
  96. title = "tt_message_object_set";
  97. valueLabel = "Object:";
  98. break;
  99. case _DtStringChooseMessageSenderPtype:
  100. okString = "Set";
  101. title = "tt_message_sender_ptype_set";
  102. valueLabel = "Ptype:";
  103. break;
  104. case _DtStringChooseMessageHandlerPtype:
  105. okString = "Set";
  106. title = "tt_message_handler_ptype_set";
  107. valueLabel = "Ptype:";
  108. break;
  109. case _DtStringChooseMessageStatusString:
  110. okString = "Set";
  111. title = "tt_message_status_string_set";
  112. valueLabel = "String:";
  113. break;
  114. case _DtStringChooseMessageArgValSet:
  115. okString = "Set...";
  116. title = "tt_message_arg_val_set";
  117. valueLabel = "Arg:";
  118. break;
  119. case _DtStringChoosePtype2Declare:
  120. okString = "Declare";
  121. title = "tt_ptype_declare";
  122. valueLabel = "Ptype:";
  123. break;
  124. case _DtStringChooseMediaPtype2Declare:
  125. okString = "Undeclare";
  126. title = "ttmedia_ptype_undeclare";
  127. valueLabel = "Ptype:";
  128. break;
  129. case _DtStringChoosePtype2UnDeclare:
  130. okString = "Undeclare";
  131. title = "tt_ptype_undeclare";
  132. valueLabel = "Ptype:";
  133. break;
  134. case _DtStringChoosePtype2SetDefault:
  135. okString = "Set";
  136. title = "tt_default_ptype_set";
  137. valueLabel = "Ptype:";
  138. break;
  139. case _DtStringChoosePtype2Exists:
  140. okString = "Exists?";
  141. title = "tt_ptype_exists";
  142. valueLabel = "Ptype:";
  143. break;
  144. case _DtStringChooseSystem:
  145. okString = "system()";
  146. title = "system(3C)";
  147. valueLabel = "Command:";
  148. break;
  149. case _DtStringChoosePutenv:
  150. okString = "putenv()";
  151. title = "putenv(3C)";
  152. valueLabel = "variable=value:";
  153. break;
  154. case _DtStringChooseNetfile2File:
  155. okString = "File";
  156. title = "tt_netfile_file";
  157. valueLabel = "Netfile:";
  158. break;
  159. default:
  160. return;
  161. }
  162. DtbStringChooserStringChooserInfo instance =
  163. &dtb_string_chooser_string_chooser;
  164. if (! instance->initialized) {
  165. dtb_string_chooser_string_chooser_initialize(
  166. instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin );
  167. }
  168. DtTtSetLabel( instance->stringOkButton, okString );
  169. DtTtSetLabel( instance->stringText_label, valueLabel );
  170. XtVaSetValues( instance->stringChooser, XmNtitle, title, NULL );
  171. // Remember dialog mode, entity
  172. XtVaSetValues( instance->stringOkButton, XmNuserData, choice, NULL );
  173. XtVaSetValues( instance->stringCancelButton, XmNuserData, entity, NULL );
  174. XmTextPosition last = XmTextFieldGetLastPosition( instance->stringText );
  175. Time when = XtLastTimestampProcessed( XtDisplay( instance->stringText ));
  176. XmTextFieldSetSelection( instance->stringText, 0, last, when );
  177. XtManageChild( instance->stringChooser_shellform );
  178. }
  179. /*** DTB_USER_CODE_END
  180. ***
  181. *** End of user code section
  182. ***
  183. **************************************************************************/
  184. void
  185. stringChooser_stringCancelButton_CB1(
  186. Widget widget,
  187. XtPointer clientData,
  188. XtPointer callData
  189. )
  190. {
  191. /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
  192. /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
  193. DtbStringChooserStringChooserInfo instance = (DtbStringChooserStringChooserInfo)clientData;
  194. if (!(instance->initialized))
  195. {
  196. dtb_string_chooser_string_chooser_initialize(instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin);
  197. }
  198. XtUnmanageChild(instance->stringChooser_shellform);
  199. /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
  200. /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
  201. }
  202. void
  203. stringOkayed(
  204. Widget widget,
  205. XtPointer clientData,
  206. XtPointer callData
  207. )
  208. {
  209. /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
  210. /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
  211. /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
  212. DtbStringChooserStringChooserInfo instance =
  213. (DtbStringChooserStringChooserInfo)clientData;
  214. char *string = XmTextFieldGetString( instance->stringText );
  215. if ((string != 0) && (string[0] == '\0')) {
  216. XtFree( string );
  217. string = 0;
  218. }
  219. XtPointer val;
  220. XtVaGetValues( instance->stringOkButton, XmNuserData, &val, NULL );
  221. _DtStringChooserAction choice = (_DtStringChooserAction) (long) val;
  222. XtVaGetValues( instance->stringCancelButton, XmNuserData, &val, NULL );
  223. Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
  224. switch (choice) {
  225. Tt_status status;
  226. int ival;
  227. char *file;
  228. case _DtStringChoosePatternOp:
  229. case _DtStringChoosePatternOtype:
  230. case _DtStringChoosePatternObject:
  231. case _DtStringChoosePatternSenderPtype:
  232. _DtTtPatternUpdate( (Tt_pattern)val, choice, string );
  233. break;
  234. case _DtStringChooseMessageOtype:
  235. case _DtStringChooseMessageObject:
  236. case _DtStringChooseMessageSenderPtype:
  237. case _DtStringChooseMessageHandlerPtype:
  238. case _DtStringChooseMessageStatusString:
  239. case _DtStringChooseMessageArgValSet:
  240. _DtTtMessageUpdate( (Tt_message)val, choice, string );
  241. break;
  242. case _DtStringChoosePtype2Declare:
  243. status = tt_ptype_declare( string );
  244. DtTtSetLabel( label, "tt_ptype_declare()", status );
  245. break;
  246. case _DtStringChooseMediaPtype2Declare:
  247. // XXX prompt for base_opnum
  248. status = ttmedia_ptype_declare( string, 0, _DtTtMediaLoadPatCb,
  249. 0, 1 );
  250. DtTtSetLabel( label, "ttmedia_ptype_declare()", status );
  251. break;
  252. case _DtStringChoosePtype2UnDeclare:
  253. status = tt_ptype_undeclare( string );
  254. DtTtSetLabel( label, "tt_ptype_undeclare()", status );
  255. break;
  256. case _DtStringChoosePtype2SetDefault:
  257. status = tt_default_ptype_set( string );
  258. DtTtSetLabel( label, "tt_default_ptype_set()", status );
  259. break;
  260. case _DtStringChoosePtype2Exists:
  261. status = tt_ptype_exists( string );
  262. DtTtSetLabel( label, "tt_ptype_exists()", status );
  263. break;
  264. case _DtStringChooseSystem:
  265. ival = system( string );
  266. DtTtSetLabel( label, "system()", ival );
  267. break;
  268. case _DtStringChoosePutenv:
  269. ival = putenv( string );
  270. DtTtSetLabel( label, "putenv()", ival );
  271. break;
  272. case _DtStringChooseNetfile2File:
  273. file = tt_netfile_file( string );
  274. DtTtSetLabel( label, "tt_netfile_file()", file );
  275. if (! tt_is_err( tt_ptr_error( file ))) {
  276. snoopStream << "tt_netfile_file( \"" << string
  277. << "\" ) = \"" << file << "\"" << endl;
  278. }
  279. break;
  280. default:
  281. break;
  282. }
  283. if (string != 0) {
  284. XtFree( string );
  285. }
  286. XtUnmanageChild( instance->stringChooser_shellform );
  287. /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
  288. }
  289. void
  290. stringHelp(
  291. Widget widget,
  292. XtPointer clientData,
  293. XtPointer callData
  294. )
  295. {
  296. /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
  297. /*** DTB_USER_CODE_END ^^^ Add C variables and code above ^^^ ***/
  298. /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
  299. DtbStringChooserStringChooserInfo instance =
  300. (DtbStringChooserStringChooserInfo)clientData;
  301. XtPointer val;
  302. XtVaGetValues( instance->stringOkButton, XmNuserData, &val, NULL );
  303. _DtStringChooserAction choice = (_DtStringChooserAction) (long) val;
  304. Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
  305. switch (choice) {
  306. case _DtStringChoosePatternOp:
  307. _DtMan( label, "tt_pattern_op_add" );
  308. break;
  309. case _DtStringChoosePatternOtype:
  310. _DtMan( label, "tt_pattern_otype_add" );
  311. break;
  312. case _DtStringChoosePatternObject:
  313. _DtMan( label, "tt_pattern_object_add" );
  314. break;
  315. case _DtStringChoosePatternSenderPtype:
  316. _DtMan( label, "tt_pattern_sender_ptype_add" );
  317. break;
  318. case _DtStringChooseMessageOtype:
  319. _DtMan( label, "tt_message_otype_set" );
  320. break;
  321. case _DtStringChooseMessageObject:
  322. _DtMan( label, "tt_message_object_set" );
  323. break;
  324. case _DtStringChooseMessageSenderPtype:
  325. _DtMan( label, "tt_message_sender_ptype_set" );
  326. break;
  327. case _DtStringChooseMessageHandlerPtype:
  328. _DtMan( label, "tt_message_handler_ptype_set" );
  329. break;
  330. case _DtStringChooseMessageStatusString:
  331. _DtMan( label, "tt_message_status_string_set" );
  332. break;
  333. case _DtStringChooseMessageArgValSet:
  334. _DtMan( label, "tt_message_arg_val_set" );
  335. break;
  336. case _DtStringChoosePtype2Declare:
  337. _DtMan( label, "tt_ptype_declare" );
  338. break;
  339. case _DtStringChooseMediaPtype2Declare:
  340. _DtMan( label, "ttmedia_ptype_declare" );
  341. break;
  342. case _DtStringChoosePtype2UnDeclare:
  343. _DtMan( label, "tt_ptype_undeclare" );
  344. break;
  345. case _DtStringChoosePtype2SetDefault:
  346. _DtMan( label, "tt_default_ptype_set" );
  347. break;
  348. case _DtStringChoosePtype2Exists:
  349. _DtMan( label, "tt_ptype_exists" );
  350. break;
  351. case _DtStringChooseSystem:
  352. _DtMan( label, "system" );
  353. break;
  354. case _DtStringChoosePutenv:
  355. _DtMan( label, "putenv" );
  356. break;
  357. default:
  358. break;
  359. }
  360. /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/
  361. }
  362. /**************************************************************************
  363. *** DTB_USER_CODE_START
  364. ***
  365. *** All automatically-generated data and functions have been defined.
  366. ***
  367. *** Add new functions here, or at the top of the file.
  368. ***/
  369. /*** DTB_USER_CODE_END
  370. ***
  371. *** End of user code section
  372. ***
  373. **************************************************************************/