remove OSF1 support
[oweals/cde.git] / cde / programs / dtappbuilder / src / abmf / stubs_c_file.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23
24 /*
25  * $XConsortium: stubs_c_file.c /main/3 1995/11/06 18:13:48 rswiston $
26  * 
27  * @(#)stubs_c_file.c   3.48 11 Feb 1994        cde_app_builder/src/abmf
28  * 
29  * RESTRICTED CONFIDENTIAL INFORMATION:
30  * 
31  * The information in this document is subject to special restrictions in a
32  * confidential disclosure agreement between HP, IBM, Sun, USL, SCO and
33  * Univel.  Do not distribute this document outside HP, IBM, Sun, USL, SCO,
34  * or Univel without Sun's specific written approval.  This document and all
35  * copies and derivative works thereof must be returned or destroyed at Sun's
36  * request.
37  * 
38  * Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
39  * 
40  */
41
42
43 /*
44  * Create a file containing callback proc stubs. These are example notify
45  * procedures that will serve as a template for the actual notify procedures
46  * in the application.
47  */
48
49 #include <sys/param.h>
50 #include <sys/stat.h>
51 #include <stdio.h>
52 #include <stdarg.h>
53 #include <stdlib.h>
54 #include <string.h>
55 #include <ab/util_types.h>
56 #include <ab_private/abio.h>
57 #include <ab_private/trav.h>
58 #include <ab_private/objxm.h>
59 #include "abmfP.h"
60 #include "ui_header_fileP.h"
61 #include "cdefsP.h"
62 #include "motifdefsP.h"
63 #include "obj_namesP.h"
64 #include "utilsP.h"
65 #include "instancesP.h"
66 #include "argsP.h"
67 #include "connectP.h"
68 #include "write_cP.h"
69 #include "lib_func_stringsP.h"
70 #include "stubs_c_fileP.h"
71
72 typedef void *VoidPtr;
73
74 /*
75  * Action argument type.
76  */
77 typedef enum
78 {
79     IMMED_TYPE,
80     INT_TYPE,
81     STRING_TYPE
82 }                   ARG_TYPES;
83
84 /*
85  * REMIND: some time in the future, "instance" should be "dtbTarget"
86  */
87 static STRING   fromVarName = "dtbSource";
88 static STRING   toVarName = "dtbTarget";
89 static STRING   instanceVarName = "instance";
90
91 /*
92  * Data
93  */
94 static STRING   begin_tt_callback_body =
95 "\nBoolean\n\
96 %s(Tt_message msg, void *calldata)\n";
97
98 static STRING   begin_ss_save_callback_body =
99 "\nBoolean\n\
100 %s(Widget widget, String session_file, char ***argv, int *argc)\n";
101
102 static STRING   begin_ss_restore_callback_body =
103 "\nBoolean\n\
104 %s(Widget widget, char *session_file)\n";
105
106 /*
107  * Local functions.
108  */
109 static int      printf_setval(GenCodeInfo, ABObj, ...);
110 static int      printf_getval(GenCodeInfo, ABObj, int nres, ...);
111 static int write_tooltalk_cb_vars(GenCodeInfo genCodeInfo, ABObj action);
112 static int write_tooltalk_cb_body1(GenCodeInfo genCodeInfo, ABObj action);
113 static int write_tooltalk_cb_body2(GenCodeInfo genCodeInfo, ABObj action);
114 static int write_tooltalk_msg_reply(File codeFile);
115 static int write_ss_cb_vars(GenCodeInfo genCodeInfo, ABObj action);
116 static int write_ss_cb_body1(GenCodeInfo genCodeInfo, ABObj action);
117 static int write_ss_cb_body2(GenCodeInfo genCodeInfo, ABObj action);
118 static int      write_instance_ptr_var(
119                         GenCodeInfo     genCodeInfo,  
120                         ABObj           ipObj,
121                         STRING          instanceVarName,
122                         STRING          paramName,
123                         BOOL            castValue,
124                         STRING          comment
125                 );
126
127 static int write_builtin_action_for_ref(
128                         GenCodeInfo       genCodeInfo, 
129                         ABObj             action,
130                         ABObj             toObj,
131                         BOOL              setUpVars,
132                         AB_BUILTIN_ACTION builtin_action,
133                         STRING            actionTKResource,
134                         STRING            actionResource
135 );
136
137 static int write_builtin_action(
138                         GenCodeInfo       genCodeInfo, 
139                         ABObj             action,
140                         ABObj             toObj,
141                         AB_BUILTIN_ACTION builtin_action,
142                         STRING            actionTKResource,
143                         STRING            actionResource
144 );
145
146 /*
147  * Gets the object that the connection is "actually" from. If write_conn*
148  * is called on an object that has references to it, it's actually the
149  * references that have the connections, not the object, itself.
150  * (e.g., menus never have connections written, it's the menu references
151  * that do).
152  */
153 static ABObj
154 get_actual_from_obj(ABObj actionOrObj)
155 {
156     static ABObj        lastFromObj = NULL;
157     static ABObj        lastActualFromObj = NULL;
158     AB_TRAVERSAL        refTrav;
159     ABObj               refObj = NULL;
160     ABObj               module = NULL;
161     ABObj               fromObj = NULL;
162     ABObj               actualFromObj = NULL;
163
164     if (actionOrObj == NULL)
165     {
166         return NULL;
167     }
168
169     /*
170      * Get the "from" obj
171      */
172     if (obj_is_action(actionOrObj))
173     {
174         fromObj = obj_get_from(actionOrObj);
175     }
176     else if (obj_is_ui(actionOrObj))
177     {
178         fromObj = actionOrObj;
179     }
180
181     /*
182      * Shortcut, to avoid a lengthy traversal
183      */
184     if (fromObj == lastFromObj)
185     {
186         goto epilogue;
187     }
188
189     /*
190      * See if we can do anything
191      */
192     if (fromObj == NULL)
193     {
194         return NULL;
195     }
196     module = obj_get_module(fromObj);
197
198     /*
199      * Actually find it!
200      */
201     if (   (!obj_is_ref(fromObj))
202         && (   (obj_get_type(fromObj) == AB_TYPE_MENU)
203             || (obj_get_parent_of_type(fromObj, AB_TYPE_MENU) != NULL)) )
204     {
205         /* find an object that references this one, to
206          * get the appropriate type (only menu references are 
207          * supported, currently).
208          */
209         for (trav_open(&refTrav, module, AB_TRAV_UI);
210                 (refObj = trav_next(&refTrav)) != NULL; )
211         {
212             if (refObj->ref_to == fromObj)
213             {
214                 break;
215             }
216         }
217         trav_close(&refTrav);
218     }
219
220     if (actualFromObj == NULL)
221     {
222         if (refObj != NULL)
223         {
224             actualFromObj = refObj;
225         }
226         else
227         {
228             actualFromObj = fromObj;
229         }
230     }
231
232     lastFromObj = fromObj;
233     lastActualFromObj = actualFromObj;
234
235 epilogue:
236     return lastActualFromObj;
237 }
238
239
240 static BOOL
241 cwd_is_dtbuilder_src_dir(void)
242 {
243     static BOOL         initialized = FALSE;
244     static BOOL         isSrcDir = FALSE;
245
246     if (!initialized)
247     {
248         initialized = TRUE;
249         isSrcDir = (util_paths_are_same_file(".", "../../src/ab"));
250     }
251
252     return isSrcDir;
253 }
254
255
256 static STRING
257 get_to_var_name(void)
258 {
259     return (cwd_is_dtbuilder_src_dir()? instanceVarName:toVarName);
260 }
261
262
263 static STRING
264 get_from_var_name(void)
265 {
266     return fromVarName;
267 }
268
269
270 /*
271  * Generate XtVaSetvalues calls in callbacks.
272  * obj is the object that will have it's resources set.
273  *
274  * Resource list must be name,value pairs, NULL-terminated
275  * All resource values must be of type (void *)
276  */
277 static int
278 printf_setval(GenCodeInfo genCodeInfo, ABObj obj, ...)
279 {
280     int                 return_value = 0;
281     File                codeFile = genCodeInfo->code_file;
282 #if defined(linux) || defined(CSRG_BASED)
283 /* Define va_list in <va_list.h> as structure of char ** and int
284  * Sun define va_list as void * */
285     va_list             paramList = { 0, 0 };
286 #else
287     va_list             paramList = NULL;
288 #endif /* linux */
289     STRING              resName = NULL;
290     void                *resValue = NULL;
291     STRING              objCName = NULL;
292     ISTRING             istrValue = NULL;
293
294     va_start(paramList, obj);
295     
296     objCName = abmfP_get_c_name(genCodeInfo, obj);
297     abio_printf(codeFile, "\tXtVaSetValues(%s,", objCName);
298     abio_printf(codeFile, "\n\t\t");
299
300     while ((resName = va_arg(paramList, STRING)) != NULL)
301     {
302         resValue = va_arg(paramList, VoidPtr);
303         switch (abmfP_get_res_type(resName, obj))
304         {
305             case AB_ARG_LITERAL:
306             case AB_ARG_PIXEL:
307             case AB_ARG_PIXMAP:
308             case AB_ARG_XMSTRING:
309                 istrValue = istr_create((STRING)resValue);
310                 resValue = (VoidPtr)istrValue;
311             break;
312
313             case AB_ARG_WIDGET:
314                 util_dprintf(1, 
315                     "Ignoring unsupported connection resource type: WIDGET\n");
316             break;
317         }
318         abmfP_write_arg_val(genCodeInfo, FALSE, resName, resValue, obj);
319         abio_printf(codeFile, ",\n\t\t");
320
321         istr_destroy(istrValue);
322         resValue = NULL;
323     }
324     abio_printf(codeFile, "NULL);");
325
326     va_end(paramList);
327     return return_value;
328 }
329
330
331 /*
332  * printf_getval - can only get one resource.  This can be changed at a later
333  * date if need be. NOTE: We need to declare local variables in one pass,
334  * Then write out an XtVaGetValues on a second pass, if we ever want to get
335  * more that one value back.
336  */
337 static int
338 printf_getval(GenCodeInfo genCodeInfo, ABObj obj, int nres,...)
339 {
340     int                 return_value = 0;
341     File                codeFile = genCodeInfo->code_file;
342     va_list             ap;
343     STRING              resource;
344     ARG_TYPES           type;
345     STRING              objCName = NULL;
346     nres = nres;                /* avoid warning */
347
348     va_start(ap, nres);
349
350     objCName = abmfP_get_c_name(genCodeInfo, obj);
351     resource = va_arg(ap, STRING);
352     type = va_arg(ap, ARG_TYPES);
353
354     /* Print the declaration */
355     switch (type)
356     {
357     case IMMED_TYPE:
358     case INT_TYPE:
359         abio_printf(codeFile, "\tint i;\n\n");
360         break;
361     case STRING_TYPE:
362         abio_printf(codeFile, "\tchar *str;\n\n");
363         break;
364     }
365
366     abio_printf(codeFile, "\tXtVaGetValues(%s,\n\t\t%s, ", objCName, resource);
367
368     /* Print the local variable reference */
369     switch (type)
370     {
371     case IMMED_TYPE:
372     case INT_TYPE:
373         abio_printf(codeFile, "&i");
374         break;
375     case STRING_TYPE:
376         abio_printf(codeFile, "&str");
377         break;
378     }
379     abio_printf(codeFile, ",\n\t\tNULL);\n");
380
381     va_end(ap);
382     return return_value;
383 }
384
385 static void
386 set_up_user_type_variables(GenCodeInfo genCodeInfo, ABObj toObj)
387 {
388     File                codeFile = genCodeInfo->code_file;
389     ABObj               structObj = abmfP_obj_get_struct_obj(toObj);
390     ABObj               winParent = NULL;
391     char                winParentName[1024];
392     *winParentName = 0;
393
394     /*
395      * Determine window parent of this popup
396      */
397     winParent = obj_get_win_parent(structObj);
398     if (winParent == NULL)
399     {
400         sprintf(winParentName, "%s()", abmfP_lib_get_toplevel_widget->name);
401     }
402     else
403     {
404         snprintf(winParentName, sizeof(winParentName), "%s", abmfP_get_c_name(genCodeInfo, winParent));
405     }
406
407     /*
408      * REMIND: This is obsolete and should be removed!
409      */
410     if (cwd_is_dtbuilder_src_dir())
411     {
412         write_instance_ptr_var(genCodeInfo, toObj,
413             instanceVarName, abmfP_client_data_var_name, TRUE, NULL);
414         abio_puts(genCodeInfo->code_file, nlstr);
415     }
416     else
417     {
418         write_instance_ptr_var(genCodeInfo, toObj,
419             toVarName, abmfP_client_data_var_name, TRUE, NULL);
420         write_instance_ptr_var(genCodeInfo, toObj,
421             instanceVarName, toVarName, FALSE, "/* obsolete */");
422         abio_puts(genCodeInfo->code_file, nlstr);
423     }
424     abio_printf(codeFile, "if (!(%s->initialized))\n", get_to_var_name());
425     abmfP_write_c_block_begin(genCodeInfo);
426     abio_printf(codeFile, "%s(%s, %s);\n",
427                 abmfP_get_init_proc_name(structObj),
428                 get_to_var_name(),
429                 winParentName);
430     abmfP_write_c_block_end(genCodeInfo);
431 }
432
433
434 static int
435 write_instance_ptr_var(
436                         GenCodeInfo     genCodeInfo,  
437                         ABObj           ipObj,
438                         STRING          instanceVarName,
439                         STRING          paramName,
440                         BOOL            castValue,
441                         STRING          comment
442 )
443 {
444     FILE        *codeFile = genCodeInfo->code_file;
445
446     if (ipObj == NULL)
447     {
448         return 0;
449     }
450     abio_printf(genCodeInfo->code_file, "%s\t%s = ",
451                 abmfP_get_c_struct_ptr_type_name(ipObj),
452                 instanceVarName);
453     if (castValue)
454     {
455         abio_printf(codeFile, "(%s)", abmfP_get_c_struct_ptr_type_name(ipObj));
456     }
457
458     abio_printf(codeFile, "%s;", paramName);
459
460     if (comment != NULL)
461     {
462         abio_printf(genCodeInfo->code_file, "\t%s", comment);
463     }
464     abio_puts(genCodeInfo->code_file, nlstr);
465     return 0;
466 }
467
468
469 static int
470 write_tooltalk_cb_vars(
471     GenCodeInfo genCodeInfo,
472     ABObj action 
473 )
474 {
475     File                codeFile;
476
477     if (!genCodeInfo || !action)
478         return 0;
479
480     codeFile = genCodeInfo->code_file;
481
482     switch(obj_get_when(action))
483     {
484         case AB_WHEN_TOOLTALK_QUIT:
485             abio_puts(codeFile, "int\t\tsilent = 0;\n");
486             abio_puts(codeFile, "int\t\tforce = 0;\n");
487             abio_puts(codeFile, "Boolean\t\tcancel = False;\n");
488             break;
489         case AB_WHEN_TOOLTALK_GET_STATUS:
490             abio_puts(codeFile, "char\t\t*status_string = \"\";\n");
491             break;
492         case AB_WHEN_TOOLTALK_PAUSE_RESUME:
493             abio_puts(codeFile, "Boolean\t\tsensitive = (Bool)calldata;\n");
494             abio_puts(codeFile, "Boolean\t\talready_set = False;\n");
495             break;
496         case AB_WHEN_TOOLTALK_DO_COMMAND:
497             abio_puts(codeFile, "Tt_status\t\tstatus = TT_DESKTOP_ENOTSUP;\n");
498             abio_puts(codeFile, "char\t\t*command;\n");
499             abio_puts(codeFile, "char\t\t*result;\n");
500             break;
501         default:
502             break;
503     }
504     return 0;
505 }
506
507 static int
508 write_tooltalk_cb_body1(
509     GenCodeInfo genCodeInfo,
510     ABObj action
511 )
512 {
513     File                codeFile;
514
515     if (!genCodeInfo || !action)
516         return 0;
517  
518     codeFile = genCodeInfo->code_file; 
519
520     switch(obj_get_when(action))
521     {
522         case AB_WHEN_TOOLTALK_QUIT:
523             abio_puts(codeFile, "tt_message_arg_ival(msg, 0, &silent);\n");
524             abio_puts(codeFile, "tt_message_arg_ival(msg, 1, &force);\n");
525             abio_puts(codeFile,"\n");
526             abio_puts(codeFile, abmfP_comment_begin);
527             abio_puts(codeFile, abmfP_comment_continue);
528             abio_puts(codeFile,
529               "Process Quit request->\n");
530             abio_puts(codeFile, abmfP_comment_continue);
531             abio_puts(codeFile,
532                 "if \"silent\" == 1, then the Quit should occur without\n");
533             abio_puts(codeFile, abmfP_comment_continue);
534             abio_puts(codeFile,
535                 "notifying the user.  If \"force\" == 1, then the user may\n");
536             abio_puts(codeFile, abmfP_comment_continue);
537             abio_puts(codeFile,
538                 "be notified, but the Quit should not be cancellable.\n");
539             abio_puts(codeFile, abmfP_comment_continue);
540             abio_puts(codeFile,
541                 "If \"silent\" == 0 and \"force\" == 0, then this Quit\n");
542             abio_puts(codeFile, abmfP_comment_continue);
543             abio_puts(codeFile,
544                 "request may be cancelled, in which case \"cancel\" should\n");
545             abio_puts(codeFile, abmfP_comment_continue);
546             abio_puts(codeFile,
547                 "be set to True in order send the \"failed\" reply.\n");
548             abio_puts(codeFile, abmfP_comment_continue); 
549             abio_puts(codeFile, 
550                 "If the Quit request is honored (not cancelled), the\n");
551             abio_puts(codeFile, abmfP_comment_continue);  
552             abio_puts(codeFile,  
553                 "application exit should not occur until after the request\n");
554             abio_puts(codeFile, abmfP_comment_continue);   
555             abio_puts(codeFile,  
556                 "has been replied-to.\n");
557             abio_puts(codeFile, abmfP_comment_end);
558             break;
559
560         case AB_WHEN_TOOLTALK_GET_STATUS:
561             abio_puts(codeFile, abmfP_comment_begin);
562             abio_puts(codeFile, abmfP_comment_continue);
563             abio_puts(codeFile,
564               "Process Get Status request->\n");
565             abio_puts(codeFile, abmfP_comment_continue);
566             abio_puts(codeFile,
567                 "The application should assign \"status_string\" an appropriate\n");
568             abio_puts(codeFile, abmfP_comment_continue);
569             abio_puts(codeFile,
570                 "string value reflecting the application's status.\n");
571             abio_puts(codeFile, abmfP_comment_end);
572             break;
573         case AB_WHEN_TOOLTALK_PAUSE_RESUME:
574             abio_puts(codeFile, abmfP_comment_begin); 
575             abio_puts(codeFile, abmfP_comment_continue); 
576             abio_puts(codeFile, 
577               "Process Pause/Resume request->\n"); 
578             abio_puts(codeFile, abmfP_comment_continue);
579             abio_puts(codeFile,  
580                 "If \"sensitive\" == False (Pause), then the application should\n"); 
581             abio_puts(codeFile, abmfP_comment_continue); 
582             abio_puts(codeFile,   
583                 "set the sensitivity on all mapped shells to False.  If\n");  
584             abio_puts(codeFile, abmfP_comment_continue);  
585             abio_puts(codeFile,    
586                 "\"sensitive\" == True (Resume), then the application should\n"); 
587             abio_puts(codeFile, abmfP_comment_continue);   
588             abio_puts(codeFile,     
589                 "set the sensitivity on all mapped shells to True.n"); 
590             abio_puts(codeFile, abmfP_comment_continue);    
591             abio_puts(codeFile,      
592                 "If the application is already in the requested state of\n"); 
593             abio_puts(codeFile, abmfP_comment_continue);     
594             abio_puts(codeFile,       
595                 "sensitivity, then \"already_set\" should be set to True.\n");
596             abio_puts(codeFile, abmfP_comment_end);
597             break;
598         case AB_WHEN_TOOLTALK_DO_COMMAND:
599             abio_puts(codeFile, "command = tt_message_arg_val(msg, 0);\n");
600             abio_puts(codeFile, "\n"); 
601             abio_puts(codeFile, abmfP_comment_begin);
602             abio_puts(codeFile, abmfP_comment_continue);
603             abio_puts(codeFile,
604               "Process Do_Command request->\n");
605             abio_puts(codeFile, abmfP_comment_continue);
606             abio_puts(codeFile, 
607                 "The application should execute the code defined by \"command\".\n");
608             abio_puts(codeFile, abmfP_comment_continue);
609             abio_puts(codeFile,  
610                 "If execution is successful, then \"status\" should be set to TT_OK,\n"); 
611             abio_puts(codeFile, abmfP_comment_continue); 
612             abio_puts(codeFile,   
613                 "else set to the appropriate Tt_status value.\n");
614             abio_puts(codeFile, abmfP_comment_continue);  
615             abio_puts(codeFile,    
616                 "If the command returns a result, then \"result\" should be set\n");
617             abio_puts(codeFile, abmfP_comment_continue);   
618             abio_puts(codeFile,     
619                 "to the appropriate result string.\n"); 
620             abio_puts(codeFile, abmfP_comment_end);
621             break;
622         default:
623             break;
624     }
625     abio_puts(codeFile, "\n");
626     return 0;
627 }
628
629
630 static int
631 write_tooltalk_cb_body2(
632     GenCodeInfo genCodeInfo,
633     ABObj action
634 )
635 {
636     File                codeFile;
637
638     if (!genCodeInfo || !action)
639         return 0;
640
641     codeFile = genCodeInfo->code_file;
642
643     abio_puts(codeFile, "\n");
644
645     switch(obj_get_when(action))
646     {
647         case AB_WHEN_TOOLTALK_QUIT:
648             abio_puts(codeFile, "if (cancel == True)\n");
649             abio_indent(codeFile);
650             abio_puts(codeFile, "tttk_message_fail(msg, TT_DESKTOP_ECANCELED, 0, 1);\n");
651             abio_outdent(codeFile);
652             abio_puts(codeFile, "else\n");
653             abio_puts(codeFile, "{\n");
654             abio_indent(codeFile);
655             write_tooltalk_msg_reply(codeFile);
656             abio_puts(codeFile, "\n");
657
658             abmfP_write_c_comment(genCodeInfo, FALSE,
659                 "Now that the Message has been replied, process Quit operation");
660             abmfP_write_user_code_seg(genCodeInfo, NULL);
661             abio_puts(codeFile, nlstr);
662
663             abio_outdent(codeFile);
664             abio_puts(codeFile, "}\n");
665             break;
666         case AB_WHEN_TOOLTALK_GET_STATUS:
667             abio_puts(codeFile, "tt_message_arg_val_set(msg, 0, status_string);\n");
668             write_tooltalk_msg_reply(codeFile);
669             break;
670         case AB_WHEN_TOOLTALK_PAUSE_RESUME:
671             abio_puts(codeFile, "if (already_set == True)\n");
672             abio_indent(codeFile);
673             abio_puts(codeFile, "tt_message_status_set(msg, TT_DESKTOP_EALREADY);\n");
674             abio_outdent(codeFile);
675             write_tooltalk_msg_reply(codeFile);
676             break;
677         case AB_WHEN_TOOLTALK_DO_COMMAND:
678             abio_puts(codeFile, "tt_free(command);\n");
679             abio_puts(codeFile, "tt_message_status_set(msg, status);\n");
680             abio_puts(codeFile, "if (tt_is_err(status))\n");
681             abio_indent(codeFile);
682             abio_puts(codeFile, "tttk_message_fail(msg, status, 0, 1);\n");
683             abio_outdent(codeFile);
684             abio_puts(codeFile, "else\n");
685             abio_puts(codeFile, "{\n");
686             abio_indent(codeFile);
687             abio_puts(codeFile, "if (result != NULL)\n");
688             abio_indent(codeFile);
689             abio_puts(codeFile, "tt_message_arg_val_set(msg, 1, result);\n");
690             abio_outdent(codeFile);
691             write_tooltalk_msg_reply(codeFile);
692             abio_outdent(codeFile);
693             abio_puts(codeFile, "}\n");
694             break;
695         default:
696             break;
697     }
698
699     abio_puts(codeFile, nlstr);
700     abmfP_write_user_code_seg(genCodeInfo, NULL);
701     abio_puts(codeFile, nlstr);
702     abio_puts(codeFile, "return True;\n");
703     return 0;
704 }
705
706
707 static int
708 write_tooltalk_msg_reply(
709     File        codeFile
710 )
711 {
712      abio_puts(codeFile, "tt_message_reply(msg);\n"); 
713      abio_puts(codeFile, "tttk_message_destroy(msg);\n"); 
714
715      return 0;
716 }
717
718
719 static int
720 write_ss_cb_vars(
721     GenCodeInfo genCodeInfo,
722     ABObj action 
723 )
724 {
725     File                codeFile;
726
727     if (!genCodeInfo || !action)
728         return 0;
729
730     codeFile = genCodeInfo->code_file;
731
732     switch(obj_get_when(action))
733     {
734         case AB_WHEN_SESSION_SAVE:
735         case AB_WHEN_SESSION_RESTORE:
736             abio_puts(codeFile, "Boolean\t\tret_value = False;\n");
737             break;
738         default:
739             break;
740     }
741     return 0;
742 }
743
744 static int
745 write_ss_cb_body1(
746     GenCodeInfo genCodeInfo,
747     ABObj action
748 )
749 {
750     File                codeFile;
751
752     if (!genCodeInfo || !action)
753         return 0;
754  
755     codeFile = genCodeInfo->code_file; 
756
757     switch(obj_get_when(action))
758     {
759         case AB_WHEN_SESSION_RESTORE:
760             abio_puts(codeFile, abmfP_comment_begin);
761             abio_puts(codeFile, abmfP_comment_continue);
762             abio_puts(codeFile,
763               "Restore application state via session file.\n");
764             abio_puts(codeFile, abmfP_comment_continue);
765             abio_puts(codeFile,
766               "Use contents of \"session file\" to bring the application\n");
767             abio_puts(codeFile, abmfP_comment_continue);
768             abio_puts(codeFile,
769               "to the desired state.\n");
770             abio_puts(codeFile, abmfP_comment_continue);
771             abio_puts(codeFile,
772               "Set \"ret_value\" to True to indicate success.\n");
773             abio_puts(codeFile, abmfP_comment_end);
774             break;
775         case AB_WHEN_SESSION_SAVE:
776             abio_puts(codeFile, abmfP_comment_begin);
777             abio_puts(codeFile, abmfP_comment_continue);
778             abio_puts(codeFile,
779               "Save application state in either session file and/or\n");
780             abio_puts(codeFile, abmfP_comment_continue);
781             abio_puts(codeFile, 
782                 "command line vector.\n");
783             abio_puts(codeFile, abmfP_comment_continue);
784             abio_puts(codeFile, "\n");
785             abio_puts(codeFile, abmfP_comment_continue);
786             abio_puts(codeFile,  
787                 "Session File:\n"); 
788             abio_puts(codeFile, abmfP_comment_continue); 
789             abio_puts(codeFile,   
790                 "    Open the file \"session_file\"\n");
791             abio_puts(codeFile, abmfP_comment_continue); 
792             abio_puts(codeFile,   
793                 "    Write application state information into it\n");
794             abio_puts(codeFile, abmfP_comment_continue); 
795             abio_puts(codeFile,   
796                 "    Close the file\n");
797             abio_puts(codeFile, abmfP_comment_continue); 
798             abio_puts(codeFile,   
799                 "    Set \"ret_value\" to True\n");
800             abio_puts(codeFile, abmfP_comment_continue); 
801             abio_puts(codeFile,   
802                 "    (Setting \"ret_value\" to True is important if you are using\n");
803             abio_puts(codeFile, abmfP_comment_continue); 
804             abio_puts(codeFile,   
805                 "    session files! Do not set it to True if you are not using\n");
806             abio_puts(codeFile, abmfP_comment_continue); 
807             abio_puts(codeFile,   
808                 "    session files.)\n");
809             abio_puts(codeFile, abmfP_comment_continue);  
810             abio_puts(codeFile,   "\n");
811             abio_puts(codeFile, abmfP_comment_continue);  
812             abio_puts(codeFile,    
813                 "Command line vector:\n");
814             abio_puts(codeFile, abmfP_comment_continue);   
815             abio_puts(codeFile,     
816                 "    Allocate an argv vector\n"); 
817             abio_puts(codeFile, abmfP_comment_continue);   
818             abio_puts(codeFile,     
819                 "    Fill it up with the appropriate strings\n"); 
820             abio_puts(codeFile, abmfP_comment_continue);   
821             abio_puts(codeFile,     
822                 "    Return the argv vector in \"argv\" i.e.\n"); 
823             abio_puts(codeFile, abmfP_comment_continue);   
824             abio_puts(codeFile,     
825                 "    \t*argv = my_new_argv;\n"); 
826             abio_puts(codeFile, abmfP_comment_continue);   
827             abio_puts(codeFile,     
828                 "    Return the size of the vector in argc\n"); 
829             abio_puts(codeFile, abmfP_comment_end);
830             break;
831         default:
832             break;
833     }
834     abio_puts(codeFile, "\n");
835     return 0;
836 }
837
838
839 static int
840 write_ss_cb_body2(
841     GenCodeInfo genCodeInfo,
842     ABObj action
843 )
844 {
845     File                codeFile;
846
847     if (!genCodeInfo || !action)
848         return 0;
849
850     codeFile = genCodeInfo->code_file;
851
852     abio_puts(codeFile, "\n");
853     abio_puts(codeFile, "return ret_value;\n");
854     return 0;
855 }
856
857
858 static int
859 write_action_functions(GenCodeInfo genCodeInfo, ABObj obj)
860 {
861     File                codeFile = genCodeInfo->code_file;
862     static char         msg[256],
863                        *s;
864     AB_TRAVERSAL        trav;
865     ABObj               action = NULL;
866     ABObj               fromObj = NULL; /* for error reports */
867     int                 i = 0;
868
869     /*
870      * Auto-named functions
871      */
872     for (trav_open(&trav, obj, AB_TRAV_ACTIONS_FOR_OBJ | AB_TRAV_MOD_SAFE), i = 0;
873          (action = trav_next(&trav)) != NULL; ++i)
874     {
875         if (   mfobj_has_flags(action, CGenFlagIsDuplicateDef)
876             || mfobj_has_flags(action, CGenFlagWriteDefToProjFile))
877         {
878             continue;
879         }
880
881         if (action->info.action.auto_named)
882         {
883             abmfP_write_action_function(genCodeInfo, action);
884             abio_puts(genCodeInfo->code_file, "\n");
885         }
886     }
887     /* don't close traversal, yet */
888
889     /*
890      * User-named functions
891      */
892     for (trav_reset(&trav);
893          (action = trav_next(&trav)) != NULL; ++i)
894     {
895         if (   mfobj_has_flags(action, CGenFlagIsDuplicateDef)
896             || mfobj_has_flags(action, CGenFlagWriteDefToProjFile))
897         {
898             continue;
899         }
900
901         if (!(action->info.action.auto_named))
902         {
903             abmfP_write_action_function(genCodeInfo, action);
904             abio_puts(genCodeInfo->code_file, "\n");
905         }
906     }
907     trav_close(&trav);
908
909     return OK;
910 }
911
912
913 /*
914  * Write the callback proc stub file.
915  */
916 int
917 abmfP_write_stubs_c_file(
918                          GenCodeInfo genCodeInfo,
919                          STRING codeFileName,
920                          ABObj module
921 )
922 {
923     File                codeFile = genCodeInfo->code_file;
924     STRING              errmsg = NULL;
925     ABObj               win_obj = NULL;
926     ABObj               project = obj_get_project(module);
927     char                moduleHeaderFileName[MAX_PATH_SIZE];
928     char                moduleName[MAX_PATH_SIZE];
929
930     /*
931      * Write file header.
932      */
933
934     abmfP_write_user_header_seg(genCodeInfo);
935     abio_puts(codeFile, nlstr);
936
937     sprintf(moduleName, "module %s", obj_get_name(module));
938     abmfP_write_file_header(
939                 genCodeInfo, 
940                 codeFileName, 
941                 FALSE,
942                 moduleName,
943                 util_get_program_name(), 
944                 ABMF_MODIFY_USER_SEGS,
945            " * Contains: Module callbacks and connection functions"
946                 );
947
948
949     /*
950      * Write includes.
951      */
952     strcpy(moduleHeaderFileName, abmfP_get_ui_header_file_name(module));
953     abmfP_write_c_system_include(genCodeInfo, "stdint.h");
954     abmfP_write_c_system_include(genCodeInfo, "stdio.h");
955     abmfP_write_c_system_include(genCodeInfo, "Xm/Xm.h");
956     abmfP_write_c_local_include(genCodeInfo, 
957                         abmfP_get_utils_header_file_name(module));
958
959     /* 
960      * Include project file if i18n is enabled. This file
961      * is needed for the message catalog stuff
962      */
963     if (genCodeInfo->i18n_method == ABMF_I18N_XPG4_API)
964         abmfP_write_c_local_include(genCodeInfo,
965             abmfP_get_project_header_file_name(project));
966     abmfP_write_c_local_include(genCodeInfo, moduleHeaderFileName);
967                     
968
969     /*
970      * Write out includes for modules with connection targets
971      */
972     {
973         StringListRec       connIncludes;
974         int                 i = 0;
975         int                 num_strings = 0;
976         strlist_construct(&connIncludes);
977
978         strlist_add_str(&connIncludes, moduleHeaderFileName, NULL);
979         abmfP_get_connect_includes(&connIncludes, module);
980         num_strings = strlist_get_num_strs(&connIncludes);
981         if (num_strings > 1)            /* start at 1 - skip this_ui.h */
982         {
983             abio_puts(codeFile, nlstr);
984             abmfP_write_c_comment(genCodeInfo, FALSE,
985                 "Header files for cross-module connections");
986         }
987         for (i = 1; i < num_strings; ++i)
988         {
989             abio_printf(codeFile, "#include %s\n",
990                                   strlist_get_str(&connIncludes, i, NULL));
991         }
992
993         strlist_destruct(&connIncludes);
994     }
995     abio_puts(codeFile, nlstr);
996
997     abmfP_write_user_file_top_seg(genCodeInfo);
998     abio_puts(codeFile, nlstr);
999
1000     if (write_action_functions(genCodeInfo, module) != OK)
1001         return ERROR;
1002
1003     abmfP_write_user_file_bottom_seg(genCodeInfo);
1004     return OK;
1005 }
1006
1007
1008 int
1009 abmfP_write_action_function(
1010                         GenCodeInfo     genCodeInfo, 
1011                         ABObj           action
1012 )
1013 {
1014     int                 rc = 0;                 /* return code */
1015     BOOL                isTTCB = FALSE;
1016     BOOL                ss_cb = FALSE;
1017     File                codeFile = genCodeInfo->code_file;
1018     BOOL                topUserSegWritten = FALSE;
1019     BOOL                bottomUserSegWritten = FALSE;
1020     BOOL                funcBodyWritten = FALSE;
1021     BOOL                funcEndWritten = FALSE;
1022     BOOL                actionPrintfWritten = FALSE;
1023     int                 return_value = 0;
1024     ABObj               fromObj = obj_get_from(action);
1025     ABObj               actualFromObj = NULL;
1026     ABObj               toObj = obj_get_to(action);
1027     ABObj               module = NULL;
1028     char                actionName[1024];
1029     char                actionPrintf[1024];
1030
1031     abmfP_gencode_enter_func(genCodeInfo);
1032     abmfP_ip_obj(genCodeInfo) = obj_get_to(action);
1033     util_strncpy(actionName, abmfP_get_action_name(action), 1024);
1034     sprintf(actionPrintf, "printf(\"action: %s()\\n\");\n", actionName);
1035
1036     /***
1037      *** START OF FUNCTION
1038      ***/
1039
1040     switch (obj_get_when(action))
1041     {
1042     case AB_WHEN_AFTER_CREATED:
1043         /* 
1044          * post-create procs have the signature of an Xt Callback,
1045          * although they are called as conventional functions.
1046          */
1047         fromObj = obj_get_from(action);
1048         actualFromObj = get_actual_from_obj(action);
1049         abmfP_write_xm_callback_begin(genCodeInfo, FALSE, actionName);
1050         write_instance_ptr_var(genCodeInfo, actualFromObj,
1051             get_from_var_name(), "callData", TRUE, NULL);
1052         abio_puts(genCodeInfo->code_file, nlstr);
1053
1054     break;
1055
1056     case AB_WHEN_DRAGGED_FROM:
1057     {
1058         abio_printf(genCodeInfo->code_file, 
1059             abmfP_lib_default_dragCB->def,      /* this is a format string */
1060                 actionName,actionName,actionName,
1061                 actionName,actionName, actionName);
1062         abio_puts(genCodeInfo->code_file, "\n\n");
1063
1064         /* these are all in the "library" definition */
1065         topUserSegWritten = TRUE;
1066         bottomUserSegWritten = TRUE;
1067         funcBodyWritten = TRUE;
1068         funcEndWritten = TRUE;
1069         actionPrintfWritten = TRUE;
1070     }
1071     break;
1072
1073     case AB_WHEN_DROPPED_ON:
1074     {
1075         abio_printf(genCodeInfo->code_file, 
1076             abmfP_lib_default_dropCB->def,      /* this is a format string */
1077                 actionName,actionName,actionName,actionName);
1078         abio_puts(genCodeInfo->code_file, "\n\n");
1079
1080         /* these are all in the "library" definition */
1081         topUserSegWritten = TRUE;
1082         bottomUserSegWritten = TRUE;
1083         funcBodyWritten = TRUE;
1084         funcEndWritten = TRUE;
1085         actionPrintfWritten = TRUE;
1086     }
1087     break;
1088
1089     case AB_WHEN_TOOLTALK_QUIT:
1090     case AB_WHEN_TOOLTALK_DO_COMMAND:
1091     case AB_WHEN_TOOLTALK_GET_STATUS:
1092     case AB_WHEN_TOOLTALK_PAUSE_RESUME:
1093         isTTCB = TRUE;
1094             abio_printf(codeFile, begin_tt_callback_body, actionName);
1095             abmfP_write_c_block_begin(genCodeInfo);
1096             write_tooltalk_cb_vars(genCodeInfo, action);
1097     break;
1098
1099     case AB_WHEN_SESSION_RESTORE:
1100         ss_cb = TRUE;
1101             abio_printf(codeFile, begin_ss_restore_callback_body,
1102                 abmfP_get_action_name(action));
1103             abmfP_write_c_block_begin(genCodeInfo);
1104             write_ss_cb_vars(genCodeInfo, action);
1105     break;
1106
1107     case AB_WHEN_SESSION_SAVE:
1108         ss_cb = TRUE;
1109             abio_printf(codeFile, begin_ss_save_callback_body,
1110                 abmfP_get_action_name(action));
1111             abmfP_write_c_block_begin(genCodeInfo);
1112             write_ss_cb_vars(genCodeInfo, action);
1113     break;
1114
1115     default:
1116         abmfP_write_xm_callback_begin(genCodeInfo, FALSE, actionName);
1117     break;
1118
1119     } /* switch obj_get_when() */
1120
1121
1122     /***** 
1123      ***** TOP USER SEGMENT
1124      *****/
1125
1126     if (!topUserSegWritten)
1127     {
1128         STRING  contents = 
1129                     (actionPrintfWritten? NULL:(isTTCB? actionPrintf:NULL));
1130         abmfP_write_user_var_and_code_seg(genCodeInfo, contents);
1131         abio_puts(codeFile, nlstr);
1132         topUserSegWritten = TRUE;
1133         if (contents != NULL)
1134         {
1135             actionPrintfWritten = TRUE;
1136         }
1137     }
1138
1139     /***
1140      *** FUNCTION BODY
1141      ***/
1142
1143     if (isTTCB)
1144     {
1145         write_tooltalk_cb_body1(genCodeInfo, action);
1146         abmfP_write_user_code_seg(genCodeInfo, NULL);
1147         write_tooltalk_cb_body2(genCodeInfo, action);
1148         funcBodyWritten = TRUE;
1149         bottomUserSegWritten = TRUE; 
1150     }
1151     else if (ss_cb)
1152     {
1153         write_ss_cb_body1(genCodeInfo, action);
1154         abmfP_write_user_code_seg(genCodeInfo, NULL);
1155         write_ss_cb_body2(genCodeInfo, action);
1156         funcBodyWritten = TRUE;
1157         bottomUserSegWritten = TRUE;
1158     }
1159     else if (!funcBodyWritten) switch (obj_get_func_type(action))
1160     {
1161     case AB_FUNC_BUILTIN:
1162         rc = abmfP_write_builtin_action(genCodeInfo, action, TRUE);
1163         return_if_err(rc,rc);
1164         funcBodyWritten = TRUE;
1165         break;
1166
1167     case AB_FUNC_USER_DEF:
1168         abmfP_write_user_start_comment(genCodeInfo, "vvv Add C code below vvv");
1169         abmfP_write_user_end_comment(genCodeInfo, "^^^ Add C code above ^^^");
1170         bottomUserSegWritten = TRUE;
1171         funcBodyWritten = TRUE;
1172         break;
1173
1174     case AB_FUNC_CODE_FRAG:
1175         abio_puts(codeFile, obj_get_func_code(action));
1176         funcBodyWritten = TRUE;
1177         break;
1178
1179     case AB_FUNC_ON_ITEM_HELP:
1180         abio_printf(codeFile, "dtb_do_onitem_help();\n");
1181         funcBodyWritten = TRUE;
1182         break;
1183
1184     case AB_FUNC_HELP_VOLUME:
1185         abio_printf(codeFile, 
1186                 "dtb_show_help_volume_info(\"%s\", \"%s\");\n",
1187                 istr_string(action->info.action.volume_id), 
1188                 istr_string(action->info.action.location));
1189         funcBodyWritten = TRUE;
1190         break;
1191
1192     default:
1193         {
1194             char *obj_name_string = obj_get_name(fromObj);
1195             util_printf_err(catgets(Dtb_project_catd, 1, 78,
1196                     "unknown function type for action from object, %s"),
1197                     obj_name_string);
1198             return_code(ERR);
1199         }
1200         break;
1201     }
1202
1203     /***** 
1204      ***** BOTTOM USER SEGMENT
1205      *****/
1206
1207     if (!bottomUserSegWritten)
1208     {
1209         STRING  contents = (actionPrintfWritten? NULL:actionPrintf);
1210         abmfP_write_user_code_seg(genCodeInfo, contents);
1211         bottomUserSegWritten = TRUE;
1212         if (contents != NULL)
1213         {
1214             actionPrintfWritten = TRUE;
1215         }
1216     }
1217
1218     /***** 
1219      ***** FUNCTION END 
1220      *****/
1221
1222     if (!funcEndWritten)
1223     {
1224         abmfP_write_c_func_end(genCodeInfo, NULL);
1225         funcEndWritten = TRUE;
1226     }
1227
1228 epilogue:
1229     abmfP_gencode_exit_func(genCodeInfo);
1230     return return_value;
1231 }
1232
1233
1234 int
1235 abmfP_write_builtin_action(
1236                         GenCodeInfo     genCodeInfo, 
1237                         ABObj           action,
1238                         BOOL            setUpVars
1239 )
1240 {
1241     int                 return_value     = 0;
1242     File                codeFile         = genCodeInfo->code_file;
1243     ABObj               toObj            = NULL;
1244     STRING              actionTKResource = NULL;        /* in toolkit */
1245     STRING              actionResource   = NULL;        /* in source code */
1246     ISTRING             istr_resource    = NULL;
1247     AB_BUILTIN_ACTION   builtin_action   = AB_STDACT_UNDEF;
1248
1249     toObj          = obj_get_to(action);
1250     builtin_action = obj_get_func_builtin(action);
1251     if (toObj != NULL)
1252     {
1253         toObj = objxm_comp_get_target_for_builtin_action(toObj, builtin_action);
1254     }
1255     if (toObj == NULL)
1256     {
1257         abmfP_write_c_comment(genCodeInfo, FALSE, "Invalid action ignored.");
1258         abio_puts(codeFile, nlstr);
1259         return 0;
1260     }
1261
1262     /*
1263      * We need to convert the resource into a string that can be put
1264      * in the .c file.
1265      */
1266     actionTKResource = objxm_get_resource_for_builtin_action(
1267                                 toObj, builtin_action);
1268     istr_resource    = objxm_get_res_strname(actionTKResource);
1269     actionResource   = istr_string(istr_resource);
1270
1271     if (abmfP_get_c_name(genCodeInfo, toObj) == NULL)
1272     {
1273         return_value = write_builtin_action_for_ref(genCodeInfo,
1274             action, toObj, setUpVars, builtin_action, actionTKResource,
1275             actionResource);
1276     }
1277     else
1278     {
1279         if (setUpVars)
1280         {
1281             set_up_user_type_variables(genCodeInfo, toObj);
1282         }
1283         
1284         return_value = write_builtin_action(genCodeInfo, action, toObj,
1285             builtin_action, actionTKResource, actionResource);
1286     }
1287
1288     if (return_value == 0)
1289         abio_printf(codeFile, nlstr);
1290         
1291 epiloge:
1292     abio_printf(codeFile, nlstr);
1293     return return_value;
1294 }
1295
1296
1297 /*
1298 ** we are on a virtual object and need to write the actual builtin action
1299 ** for each ref to it.
1300 */
1301 static int
1302 write_builtin_action_for_ref(
1303     GenCodeInfo       genCodeInfo, 
1304     ABObj             action,
1305     ABObj             toObj,
1306     BOOL              setUpVars,
1307     AB_BUILTIN_ACTION builtin_action,
1308     STRING            actionTKResource,                /* in toolkit */
1309     STRING            actionResource                   /* in source code */
1310 )
1311 {
1312     int                        i = 0;
1313     int                  numRefs = 0;
1314     int             return_value = 0;
1315     ABObj                 refObj = NULL;
1316     ABObjList            refList = NULL;
1317         
1318     if (!genCodeInfo || !action || !toObj)
1319         return -1;
1320     
1321     refList = abmfP_find_refs_to(toObj);
1322     numRefs = objlist_get_num_objs(refList);
1323     
1324     if ((refList != NULL) && (numRefs > 0))
1325     {
1326         if (setUpVars)
1327         {
1328             refObj = objlist_get_obj(refList, 0, NULL);
1329             set_up_user_type_variables(genCodeInfo, refObj);
1330         }
1331             
1332         /* write the builtin actions */
1333         for (i = 0; i < numRefs; ++i)
1334         {
1335             refObj  = objlist_get_obj(refList, i, NULL);
1336
1337             if (abmfP_get_c_name(genCodeInfo, refObj) != NULL)
1338             {
1339                 return_value = write_builtin_action(genCodeInfo,
1340                     action, refObj, builtin_action, actionTKResource,
1341                     actionResource);
1342             }
1343         }
1344     }
1345     else
1346     {
1347         util_dprintf(0, "ERROR: write_builtin_action_for_ref(): ");
1348         util_dprintf(0, "Unable to obtain references to the object.\n");
1349     }
1350
1351 epiloge:
1352     objlist_destroy(refList);
1353     return return_value;
1354 }
1355
1356
1357 /*
1358 ** determine which builtin action and write the appropriate code.
1359 */
1360 static int
1361 write_builtin_action(
1362     GenCodeInfo       genCodeInfo, 
1363     ABObj             action,
1364     ABObj             toObj,
1365     AB_BUILTIN_ACTION builtin_action,
1366     STRING            actionTKResource,                /* in toolkit */
1367     STRING            actionResource                   /* in source code */
1368 )
1369 {
1370 #define  IS(type)       (obj_get_func_type(action) ==(type))
1371 #define  SVAL(action)   ((STRING)obj_get_arg_string(action))
1372 #define  IVAL(action)   ((int)obj_get_arg_int(action))
1373
1374     File                codeFile     = genCodeInfo->code_file;
1375     int                 return_value = 0;
1376
1377     if (!codeFile || !action || !toObj || !builtin_action)
1378         return return_value;
1379
1380     switch (builtin_action)
1381     {
1382         case AB_STDACT_ENABLE:
1383             abio_print_line(codeFile, NULL);
1384             abio_print_line(codeFile, "XtSetSensitive(%s, True);",
1385                 abmfP_get_c_name(genCodeInfo, toObj));
1386             break;
1387
1388         case AB_STDACT_DISABLE:
1389             abio_print_line(codeFile, NULL);
1390             abio_print_line(codeFile, "XtSetSensitive(%s, False);",
1391                 abmfP_get_c_name(genCodeInfo, toObj));
1392             break;
1393
1394         case AB_STDACT_SHOW:
1395             switch((obj_get_root(toObj))->type)
1396             {
1397                 case AB_TYPE_BASE_WINDOW:
1398                     abio_print_line(codeFile, "XtPopup(%s, XtGrabNone);",
1399                         abmfP_get_c_name(genCodeInfo, toObj));
1400                     break;
1401                         
1402                 case AB_TYPE_DIALOG: 
1403                 case AB_TYPE_FILE_CHOOSER: 
1404                 default:
1405                     abio_print_line(codeFile, "XtManageChild(%s);",
1406                         abmfP_get_c_name(genCodeInfo, toObj));
1407                     break;
1408             }
1409             break;
1410
1411         case AB_STDACT_HIDE:
1412             switch((obj_get_root(toObj))->type) 
1413             { 
1414                 case AB_TYPE_BASE_WINDOW: 
1415                     abio_print_line(codeFile, "XtPopdown(%s);",
1416                         abmfP_get_c_name(genCodeInfo, toObj));
1417                     break;
1418
1419                 case AB_TYPE_DIALOG:  
1420                 case AB_TYPE_FILE_CHOOSER:  
1421                 default:
1422                     abio_print_line(codeFile, "XtUnmanageChild(%s);",
1423                         abmfP_get_c_name(genCodeInfo, toObj));
1424                     break;
1425             }
1426             break;
1427
1428         case AB_STDACT_SET_LABEL:
1429             /* check toObj for root */
1430             if ( obj_get_label_type(obj_get_root(toObj)) == AB_LABEL_GLYPH)
1431             {
1432                 abio_printf(codeFile, "%s(%s, ",
1433                     abmfP_lib_set_label_from_image_file->name,
1434                     abmfP_get_c_name(genCodeInfo, toObj));
1435                 abio_put_string(codeFile, SVAL(action));
1436                 abio_puts(codeFile, ");\n");
1437             }
1438             else
1439             {
1440                 assert(actionTKResource != NULL);
1441                 printf_setval(genCodeInfo, toObj,
1442                     actionTKResource, SVAL(action),
1443                     NULL);
1444             }
1445             break;
1446
1447         case AB_STDACT_SET_VALUE:
1448             printf_setval(genCodeInfo, toObj, 
1449                 actionTKResource, IVAL(action), NULL);
1450             break;
1451
1452         case AB_STDACT_SET_TEXT:
1453             printf_setval(genCodeInfo, toObj, 
1454                 actionTKResource, SVAL(action),
1455                 NULL);
1456             break;
1457
1458 /*      case AB_STDACT_SHOW_HELP: */
1459 /*          abio_print_line(codeFile, NULL); */
1460 /*          abio_print_line(codeFile,  */
1461 /*              "XtCallCallbacks(%s,XmNhelpCallback,(XtPointer)NULL);", */
1462 /*              abmfP_get_c_name(genCodeInfo, toObj)); */
1463 /*          break; */
1464
1465         default:
1466             {
1467                 static char         msg[255];
1468
1469                 if (obj_get_name(action) != NULL)
1470                 {
1471                     char *action_name = obj_get_name(action);
1472                     sprintf(msg, catgets(Dtb_project_catd, 1, 76,
1473                         "Unknown action name, %s"), action_name);
1474                 }
1475                 else
1476                 {
1477                     int action_type = obj_get_func_builtin(action);
1478                     sprintf(msg, catgets(Dtb_project_catd, 1, 77,
1479                         "Unknown action type, %d"), action_type);
1480                 }
1481                 util_error(msg);
1482                 return_value = ERR_INTERNAL;
1483
1484                 /*
1485                  * return msg; Just print message and go on - JT
1486                  */
1487             }
1488             break;
1489     }                   /* switch func.value.builtin */
1490
1491     return return_value;
1492 #undef IS
1493 #undef SVAL
1494 #undef IVAL
1495 }
1496
1497