Add GNU LGPL headers to all .c .C and .h files
[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 librararies 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 #ifdef __osf__
283 /* OSF/1 define va_list in <va_list.h> as structure of char ** and int
284  * Sun define va_list as void * */
285     va_list             paramList = { NULL, 0 };
286 #else
287     va_list             paramList = NULL;
288 #endif /* __osf__ */
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         strcpy(winParentName, 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, "stdio.h");
954     abmfP_write_c_system_include(genCodeInfo, "Xm/Xm.h");
955     abmfP_write_c_local_include(genCodeInfo, 
956                         abmfP_get_utils_header_file_name(module));
957
958     /* 
959      * Include project file if i18n is enabled. This file
960      * is needed for the message catalog stuff
961      */
962     if (genCodeInfo->i18n_method == ABMF_I18N_XPG4_API)
963         abmfP_write_c_local_include(genCodeInfo,
964             abmfP_get_project_header_file_name(project));
965     abmfP_write_c_local_include(genCodeInfo, moduleHeaderFileName);
966                     
967
968     /*
969      * Write out includes for modules with connection targets
970      */
971     {
972         StringListRec       connIncludes;
973         int                 i = 0;
974         int                 num_strings = 0;
975         strlist_construct(&connIncludes);
976
977         strlist_add_str(&connIncludes, moduleHeaderFileName, NULL);
978         abmfP_get_connect_includes(&connIncludes, module);
979         num_strings = strlist_get_num_strs(&connIncludes);
980         if (num_strings > 1)            /* start at 1 - skip this_ui.h */
981         {
982             abio_puts(codeFile, nlstr);
983             abmfP_write_c_comment(genCodeInfo, FALSE,
984                 "Header files for cross-module connections");
985         }
986         for (i = 1; i < num_strings; ++i)
987         {
988             abio_printf(codeFile, "#include %s\n",
989                                   strlist_get_str(&connIncludes, i, NULL));
990         }
991
992         strlist_destruct(&connIncludes);
993     }
994     abio_puts(codeFile, nlstr);
995
996     abmfP_write_user_file_top_seg(genCodeInfo);
997     abio_puts(codeFile, nlstr);
998
999     if (write_action_functions(genCodeInfo, module) != OK)
1000         return ERROR;
1001
1002     abmfP_write_user_file_bottom_seg(genCodeInfo);
1003     return OK;
1004 }
1005
1006
1007 int
1008 abmfP_write_action_function(
1009                         GenCodeInfo     genCodeInfo, 
1010                         ABObj           action
1011 )
1012 {
1013     int                 rc = 0;                 /* return code */
1014     BOOL                isTTCB = FALSE;
1015     BOOL                ss_cb = FALSE;
1016     File                codeFile = genCodeInfo->code_file;
1017     BOOL                topUserSegWritten = FALSE;
1018     BOOL                bottomUserSegWritten = FALSE;
1019     BOOL                funcBodyWritten = FALSE;
1020     BOOL                funcEndWritten = FALSE;
1021     BOOL                actionPrintfWritten = FALSE;
1022     int                 return_value = 0;
1023     ABObj               fromObj = obj_get_from(action);
1024     ABObj               actualFromObj = NULL;
1025     ABObj               toObj = obj_get_to(action);
1026     ABObj               module = NULL;
1027     char                actionName[1024];
1028     char                actionPrintf[1024];
1029
1030     abmfP_gencode_enter_func(genCodeInfo);
1031     abmfP_ip_obj(genCodeInfo) = obj_get_to(action);
1032     util_strncpy(actionName, abmfP_get_action_name(action), 1024);
1033     sprintf(actionPrintf, "printf(\"action: %s()\\n\");\n", actionName);
1034
1035     /***
1036      *** START OF FUNCTION
1037      ***/
1038
1039     switch (obj_get_when(action))
1040     {
1041     case AB_WHEN_AFTER_CREATED:
1042         /* 
1043          * post-create procs have the signature of an Xt Callback,
1044          * although they are called as conventional functions.
1045          */
1046         fromObj = obj_get_from(action);
1047         actualFromObj = get_actual_from_obj(action);
1048         abmfP_write_xm_callback_begin(genCodeInfo, FALSE, actionName);
1049         write_instance_ptr_var(genCodeInfo, actualFromObj,
1050             get_from_var_name(), "callData", TRUE, NULL);
1051         abio_puts(genCodeInfo->code_file, nlstr);
1052
1053     break;
1054
1055     case AB_WHEN_DRAGGED_FROM:
1056     {
1057         abio_printf(genCodeInfo->code_file, 
1058             abmfP_lib_default_dragCB->def,      /* this is a format string */
1059                 actionName,actionName,actionName,
1060                 actionName,actionName, actionName);
1061         abio_puts(genCodeInfo->code_file, "\n\n");
1062
1063         /* these are all in the "library" definition */
1064         topUserSegWritten = TRUE;
1065         bottomUserSegWritten = TRUE;
1066         funcBodyWritten = TRUE;
1067         funcEndWritten = TRUE;
1068         actionPrintfWritten = TRUE;
1069     }
1070     break;
1071
1072     case AB_WHEN_DROPPED_ON:
1073     {
1074         abio_printf(genCodeInfo->code_file, 
1075             abmfP_lib_default_dropCB->def,      /* this is a format string */
1076                 actionName,actionName,actionName,actionName);
1077         abio_puts(genCodeInfo->code_file, "\n\n");
1078
1079         /* these are all in the "library" definition */
1080         topUserSegWritten = TRUE;
1081         bottomUserSegWritten = TRUE;
1082         funcBodyWritten = TRUE;
1083         funcEndWritten = TRUE;
1084         actionPrintfWritten = TRUE;
1085     }
1086     break;
1087
1088     case AB_WHEN_TOOLTALK_QUIT:
1089     case AB_WHEN_TOOLTALK_DO_COMMAND:
1090     case AB_WHEN_TOOLTALK_GET_STATUS:
1091     case AB_WHEN_TOOLTALK_PAUSE_RESUME:
1092         isTTCB = TRUE;
1093             abio_printf(codeFile, begin_tt_callback_body, actionName);
1094             abmfP_write_c_block_begin(genCodeInfo);
1095             write_tooltalk_cb_vars(genCodeInfo, action);
1096     break;
1097
1098     case AB_WHEN_SESSION_RESTORE:
1099         ss_cb = TRUE;
1100             abio_printf(codeFile, begin_ss_restore_callback_body,
1101                 abmfP_get_action_name(action));
1102             abmfP_write_c_block_begin(genCodeInfo);
1103             write_ss_cb_vars(genCodeInfo, action);
1104     break;
1105
1106     case AB_WHEN_SESSION_SAVE:
1107         ss_cb = TRUE;
1108             abio_printf(codeFile, begin_ss_save_callback_body,
1109                 abmfP_get_action_name(action));
1110             abmfP_write_c_block_begin(genCodeInfo);
1111             write_ss_cb_vars(genCodeInfo, action);
1112     break;
1113
1114     default:
1115         abmfP_write_xm_callback_begin(genCodeInfo, FALSE, actionName);
1116     break;
1117
1118     } /* switch obj_get_when() */
1119
1120
1121     /***** 
1122      ***** TOP USER SEGMENT
1123      *****/
1124
1125     if (!topUserSegWritten)
1126     {
1127         STRING  contents = 
1128                     (actionPrintfWritten? NULL:(isTTCB? actionPrintf:NULL));
1129         abmfP_write_user_var_and_code_seg(genCodeInfo, contents);
1130         abio_puts(codeFile, nlstr);
1131         topUserSegWritten = TRUE;
1132         if (contents != NULL)
1133         {
1134             actionPrintfWritten = TRUE;
1135         }
1136     }
1137
1138     /***
1139      *** FUNCTION BODY
1140      ***/
1141
1142     if (isTTCB)
1143     {
1144         write_tooltalk_cb_body1(genCodeInfo, action);
1145         abmfP_write_user_code_seg(genCodeInfo, NULL);
1146         write_tooltalk_cb_body2(genCodeInfo, action);
1147         funcBodyWritten = TRUE;
1148         bottomUserSegWritten = TRUE; 
1149     }
1150     else if (ss_cb)
1151     {
1152         write_ss_cb_body1(genCodeInfo, action);
1153         abmfP_write_user_code_seg(genCodeInfo, NULL);
1154         write_ss_cb_body2(genCodeInfo, action);
1155         funcBodyWritten = TRUE;
1156         bottomUserSegWritten = TRUE;
1157     }
1158     else if (!funcBodyWritten) switch (obj_get_func_type(action))
1159     {
1160     case AB_FUNC_BUILTIN:
1161         rc = abmfP_write_builtin_action(genCodeInfo, action, TRUE);
1162         return_if_err(rc,rc);
1163         funcBodyWritten = TRUE;
1164         break;
1165
1166     case AB_FUNC_USER_DEF:
1167         abmfP_write_user_start_comment(genCodeInfo, "vvv Add C code below vvv");
1168         abmfP_write_user_end_comment(genCodeInfo, "^^^ Add C code above ^^^");
1169         bottomUserSegWritten = TRUE;
1170         funcBodyWritten = TRUE;
1171         break;
1172
1173     case AB_FUNC_CODE_FRAG:
1174         abio_puts(codeFile, obj_get_func_code(action));
1175         funcBodyWritten = TRUE;
1176         break;
1177
1178     case AB_FUNC_ON_ITEM_HELP:
1179         abio_printf(codeFile, "dtb_do_onitem_help();\n");
1180         funcBodyWritten = TRUE;
1181         break;
1182
1183     case AB_FUNC_HELP_VOLUME:
1184         abio_printf(codeFile, 
1185                 "dtb_show_help_volume_info(\"%s\", \"%s\");\n",
1186                 istr_string(action->info.action.volume_id), 
1187                 istr_string(action->info.action.location));
1188         funcBodyWritten = TRUE;
1189         break;
1190
1191     default:
1192         {
1193             char *obj_name_string = obj_get_name(fromObj);
1194             util_printf_err(catgets(Dtb_project_catd, 1, 78,
1195                     "unknown function type for action from object, %s"),
1196                     obj_name_string);
1197             return_code(ERR);
1198         }
1199         break;
1200     }
1201
1202     /***** 
1203      ***** BOTTOM USER SEGMENT
1204      *****/
1205
1206     if (!bottomUserSegWritten)
1207     {
1208         STRING  contents = (actionPrintfWritten? NULL:actionPrintf);
1209         abmfP_write_user_code_seg(genCodeInfo, contents);
1210         bottomUserSegWritten = TRUE;
1211         if (contents != NULL)
1212         {
1213             actionPrintfWritten = TRUE;
1214         }
1215     }
1216
1217     /***** 
1218      ***** FUNCTION END 
1219      *****/
1220
1221     if (!funcEndWritten)
1222     {
1223         abmfP_write_c_func_end(genCodeInfo, NULL);
1224         funcEndWritten = TRUE;
1225     }
1226
1227 epilogue:
1228     abmfP_gencode_exit_func(genCodeInfo);
1229     return return_value;
1230 }
1231
1232
1233 int
1234 abmfP_write_builtin_action(
1235                         GenCodeInfo     genCodeInfo, 
1236                         ABObj           action,
1237                         BOOL            setUpVars
1238 )
1239 {
1240     int                 return_value     = 0;
1241     File                codeFile         = genCodeInfo->code_file;
1242     ABObj               toObj            = NULL;
1243     STRING              actionTKResource = NULL;        /* in toolkit */
1244     STRING              actionResource   = NULL;        /* in source code */
1245     ISTRING             istr_resource    = NULL;
1246     AB_BUILTIN_ACTION   builtin_action   = AB_STDACT_UNDEF;
1247
1248     toObj          = obj_get_to(action);
1249     builtin_action = obj_get_func_builtin(action);
1250     if (toObj != NULL)
1251     {
1252         toObj = objxm_comp_get_target_for_builtin_action(toObj, builtin_action);
1253     }
1254     if (toObj == NULL)
1255     {
1256         abmfP_write_c_comment(genCodeInfo, FALSE, "Invalid action ignored.");
1257         abio_puts(codeFile, nlstr);
1258         return 0;
1259     }
1260
1261     /*
1262      * We need to convert the resource into a string that can be put
1263      * in the .c file.
1264      */
1265     actionTKResource = objxm_get_resource_for_builtin_action(
1266                                 toObj, builtin_action);
1267     istr_resource    = objxm_get_res_strname(actionTKResource);
1268     actionResource   = istr_string(istr_resource);
1269
1270     if (abmfP_get_c_name(genCodeInfo, toObj) == NULL)
1271     {
1272         return_value = write_builtin_action_for_ref(genCodeInfo,
1273             action, toObj, setUpVars, builtin_action, actionTKResource,
1274             actionResource);
1275     }
1276     else
1277     {
1278         if (setUpVars)
1279         {
1280             set_up_user_type_variables(genCodeInfo, toObj);
1281         }
1282         
1283         return_value = write_builtin_action(genCodeInfo, action, toObj,
1284             builtin_action, actionTKResource, actionResource);
1285     }
1286
1287     if (return_value == 0)
1288         abio_printf(codeFile, nlstr);
1289         
1290 epiloge:
1291     abio_printf(codeFile, nlstr);
1292     return return_value;
1293 }
1294
1295
1296 /*
1297 ** we are on a virtual object and need to write the actual builtin action
1298 ** for each ref to it.
1299 */
1300 static int
1301 write_builtin_action_for_ref(
1302     GenCodeInfo       genCodeInfo, 
1303     ABObj             action,
1304     ABObj             toObj,
1305     BOOL              setUpVars,
1306     AB_BUILTIN_ACTION builtin_action,
1307     STRING            actionTKResource,                /* in toolkit */
1308     STRING            actionResource                   /* in source code */
1309 )
1310 {
1311     int                        i = 0;
1312     int                  numRefs = 0;
1313     int             return_value = 0;
1314     ABObj                 refObj = NULL;
1315     ABObjList            refList = NULL;
1316         
1317     if (!genCodeInfo || !action || !toObj)
1318         return -1;
1319     
1320     refList = abmfP_find_refs_to(toObj);
1321     numRefs = objlist_get_num_objs(refList);
1322     
1323     if ((refList != NULL) && (numRefs > 0))
1324     {
1325         if (setUpVars)
1326         {
1327             refObj = objlist_get_obj(refList, 0, NULL);
1328             set_up_user_type_variables(genCodeInfo, refObj);
1329         }
1330             
1331         /* write the builtin actions */
1332         for (i = 0; i < numRefs; ++i)
1333         {
1334             refObj  = objlist_get_obj(refList, i, NULL);
1335
1336             if (abmfP_get_c_name(genCodeInfo, refObj) != NULL)
1337             {
1338                 return_value = write_builtin_action(genCodeInfo,
1339                     action, refObj, builtin_action, actionTKResource,
1340                     actionResource);
1341             }
1342         }
1343     }
1344     else
1345     {
1346         util_dprintf(0, "ERROR: write_builtin_action_for_ref(): ");
1347         util_dprintf(0, "Unable to obtain references to the object.\n");
1348     }
1349
1350 epiloge:
1351     objlist_destroy(refList);
1352     return return_value;
1353 }
1354
1355
1356 /*
1357 ** determine which builtin action and write the appropriate code.
1358 */
1359 static int
1360 write_builtin_action(
1361     GenCodeInfo       genCodeInfo, 
1362     ABObj             action,
1363     ABObj             toObj,
1364     AB_BUILTIN_ACTION builtin_action,
1365     STRING            actionTKResource,                /* in toolkit */
1366     STRING            actionResource                   /* in source code */
1367 )
1368 {
1369 #define  IS(type)       (obj_get_func_type(action) ==(type))
1370 #define  SVAL(action)   ((STRING)obj_get_arg_string(action))
1371 #define  IVAL(action)   ((int)obj_get_arg_int(action))
1372
1373     File                codeFile     = genCodeInfo->code_file;
1374     int                 return_value = 0;
1375
1376     if (!codeFile || !action || !toObj || !builtin_action)
1377         return return_value;
1378
1379     switch (builtin_action)
1380     {
1381         case AB_STDACT_ENABLE:
1382             abio_print_line(codeFile, NULL);
1383             abio_print_line(codeFile, "XtSetSensitive(%s, True);",
1384                 abmfP_get_c_name(genCodeInfo, toObj));
1385             break;
1386
1387         case AB_STDACT_DISABLE:
1388             abio_print_line(codeFile, NULL);
1389             abio_print_line(codeFile, "XtSetSensitive(%s, False);",
1390                 abmfP_get_c_name(genCodeInfo, toObj));
1391             break;
1392
1393         case AB_STDACT_SHOW:
1394             switch((obj_get_root(toObj))->type)
1395             {
1396                 case AB_TYPE_BASE_WINDOW:
1397                     abio_print_line(codeFile, "XtPopup(%s, XtGrabNone);",
1398                         abmfP_get_c_name(genCodeInfo, toObj));
1399                     break;
1400                         
1401                 case AB_TYPE_DIALOG: 
1402                 case AB_TYPE_FILE_CHOOSER: 
1403                 default:
1404                     abio_print_line(codeFile, "XtManageChild(%s);",
1405                         abmfP_get_c_name(genCodeInfo, toObj));
1406                     break;
1407             }
1408             break;
1409
1410         case AB_STDACT_HIDE:
1411             switch((obj_get_root(toObj))->type) 
1412             { 
1413                 case AB_TYPE_BASE_WINDOW: 
1414                     abio_print_line(codeFile, "XtPopdown(%s);",
1415                         abmfP_get_c_name(genCodeInfo, toObj));
1416                     break;
1417
1418                 case AB_TYPE_DIALOG:  
1419                 case AB_TYPE_FILE_CHOOSER:  
1420                 default:
1421                     abio_print_line(codeFile, "XtUnmanageChild(%s);",
1422                         abmfP_get_c_name(genCodeInfo, toObj));
1423                     break;
1424             }
1425             break;
1426
1427         case AB_STDACT_SET_LABEL:
1428             /* check toObj for root */
1429             if ( obj_get_label_type(obj_get_root(toObj)) == AB_LABEL_GLYPH)
1430             {
1431                 abio_printf(codeFile, "%s(%s, ",
1432                     abmfP_lib_set_label_from_image_file->name,
1433                     abmfP_get_c_name(genCodeInfo, toObj));
1434                 abio_put_string(codeFile, SVAL(action));
1435                 abio_puts(codeFile, ");\n");
1436             }
1437             else
1438             {
1439                 assert(actionTKResource != NULL);
1440                 printf_setval(genCodeInfo, toObj,
1441                     actionTKResource, SVAL(action),
1442                     NULL);
1443             }
1444             break;
1445
1446         case AB_STDACT_SET_VALUE:
1447             printf_setval(genCodeInfo, toObj, 
1448                 actionTKResource, IVAL(action), NULL);
1449             break;
1450
1451         case AB_STDACT_SET_TEXT:
1452             printf_setval(genCodeInfo, toObj, 
1453                 actionTKResource, SVAL(action),
1454                 NULL);
1455             break;
1456
1457 /*      case AB_STDACT_SHOW_HELP: */
1458 /*          abio_print_line(codeFile, NULL); */
1459 /*          abio_print_line(codeFile,  */
1460 /*              "XtCallCallbacks(%s,XmNhelpCallback,(XtPointer)NULL);", */
1461 /*              abmfP_get_c_name(genCodeInfo, toObj)); */
1462 /*          break; */
1463
1464         default:
1465             {
1466                 static char         msg[255];
1467
1468                 if (obj_get_name(action) != NULL)
1469                 {
1470                     char *action_name = obj_get_name(action);
1471                     sprintf(msg, catgets(Dtb_project_catd, 1, 76,
1472                         "Unknown action name, %s"), action_name);
1473                 }
1474                 else
1475                 {
1476                     int action_type = obj_get_func_builtin(action);
1477                     sprintf(msg, catgets(Dtb_project_catd, 1, 77,
1478                         "Unknown action type, %d"), action_type);
1479                 }
1480                 util_error(msg);
1481                 return_value = ERR_INTERNAL;
1482
1483                 /*
1484                  * return msg; Just print message and go on - JT
1485                  */
1486             }
1487             break;
1488     }                   /* switch func.value.builtin */
1489
1490     return return_value;
1491 #undef IS
1492 #undef SVAL
1493 #undef IVAL
1494 }
1495
1496