Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtappbuilder / src / ab / conn_stubs.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 /*** DTB_USER_CODE_START vvv Add file header below vvv ***/
24 /*
25  *      $XConsortium: conn_stubs.c /main/4 1996/04/18 13:17:18 drk $
26  *
27  * @(#)conn_stubs.c     1.61 08 Jun 1995 cde_app_builder/src/ab
28  *
29  *      RESTRICTED CONFIDENTIAL INFORMATION:
30  *
31  *      The information in this document is subject to special
32  *      restrictions in a confidential disclosure agreement between
33  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
34  *      document outside HP, IBM, Sun, USL, SCO, or Univel without
35  *      Sun's specific written approval.  This document and all copies
36  *      and derivative works thereof must be returned or destroyed at
37  *      Sun's request.
38  *
39  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
40  *
41  */
42
43 /*** DTB_USER_CODE_END   ^^^ Add file header above ^^^ ***/
44
45 /*
46  * File: conn_stubs.c
47  * Contains: Module callbacks and connection functions
48  *
49  * This file was generated by dtcodegen, from module conn
50  *
51  * Any text may be added between the DTB_USER_CODE_START and
52  * DTB_USER_CODE_END comments (even non-C code). Descriptive comments
53  * are provided only as an aid.
54  *
55  *  ** EDIT ONLY WITHIN SECTIONS MARKED WITH DTB_USER_CODE COMMENTS.  **
56  *  ** ALL OTHER MODIFICATIONS WILL BE OVERWRITTEN. DO NOT MODIFY OR  **
57  *  ** DELETE THE GENERATED COMMENTS!                                 **
58  */
59
60 #include <stdio.h>
61 #include <Xm/Xm.h>
62 #include "dtb_utils.h"
63 #include "dtbuilder.h"
64 #include "conn_ui.h"
65
66
67 /**************************************************************************
68  *** DTB_USER_CODE_START
69  ***
70  *** All necessary header files have been included.
71  ***
72  *** Add include files, types, macros, externs, and user functions here.
73  ***/
74
75
76 #include <sys/param.h>
77 #include "dtbuilder.h"
78 #include "conn_ui.h"
79
80 #include "palette_ui.h"
81 #include "prop.h"
82
83 #include <ab_private/connP.h>
84
85 #include <X11/Xlib.h>
86 #include <X11/Intrinsic.h>
87 #include <X11/cursorfont.h>
88 #include <Xm/List.h>
89 #include <Xm/PushB.h>
90 #include <Xm/RowColumn.h>
91 #include <Xm/ToggleB.h>
92 #include <Xm/TextF.h>
93 #include <Xm/Text.h>
94
95 #include <ab_private/obj.h>
96 #include <ab_private/trav.h>
97 #include <ab_private/objxm.h>
98
99 #include <ab_private/abobj.h>
100 #include <ab_private/abobj_set.h>
101 #include <ab_private/abobj_list.h>
102 #include <ab_private/brws.h>
103 #include <ab_private/proj.h>
104 #include <ab_private/istr.h>
105 #include <ab_private/ab.h>
106 #include <ab_private/ui_util.h>
107 #include "dtb_utils.h"
108
109 /*
110  * Declarations of global widgets used by callbacks.
111  */
112
113 static Widget   src_menu        = NULL;
114 static Widget   target_menu     = NULL;
115 static Widget   when_menu       = NULL;
116 static Widget   action_menu     = NULL;
117 static Widget   view_menu       = NULL;
118
119 static Widget   when_pulldown   = NULL;
120 static Widget   action_pulldown = NULL;
121
122 static Widget   src_list        = NULL;
123 static Widget   target_list     = NULL;
124 static Widget   connection_list = NULL;
125
126 static Widget   arg_rowcol      = NULL;
127 static Widget   arg_label       = NULL;
128 static Widget   arg_field       = NULL;
129
130 static Widget   connect_button  = NULL;
131 static Widget   change_button   = NULL;
132 static Widget   cancel_button   = NULL;
133 static Widget   delete_button   = NULL;
134
135 static Widget   std_action_item = NULL;
136 static Widget   call_function_item = NULL;
137 static Widget   execute_code_item = NULL;
138 static Widget   on_item_help_item = NULL;
139 static Widget   help_volume_item = NULL;
140
141 static Widget   location_rowcol = NULL;
142 static Widget   location_field  = NULL;
143 static Widget   volume_rowcol   = NULL;
144 static Widget   volume_field    = NULL;
145 static Widget   action_type_opmenu = NULL;
146
147 static Widget   exec_code_dialog = NULL;
148 static Widget   exec_code_textpane = NULL;
149
150 static Widget   ConnP_view_source_obj = NULL; /* View:'s "Source Object" PushButton */
151 static int      ConnP_view_filter = -1;
152
153 static STRING   CodeFragBuf = NULL;
154 static STRING   action_type_labels[ACTION_TYPE_NUM_VALUES];             
155
156 static AB_WHEN          DefaultWhen = AB_WHEN_UNDEF;
157 static AB_FUNC_TYPE     DefaultFuncType = AB_FUNC_UNDEF;
158
159 /*
160  * End declarations of global widgets
161  */
162
163 static void             init_exec_code_dialog(
164                             DtbConnExecCodeDialogInfo   instance
165                         );
166
167 static void             populate_src_menu(
168                             Widget      widget,
169                             XtPointer   client_data,
170                             XtPointer   call_data
171                         );
172 static void             populate_target_menu(
173                             Widget      widget,
174                             XtPointer   client_data,
175                             XtPointer   call_data
176                         );
177 static void             populate_when_menu(
178                             Widget      widget,
179                             XtPointer   client_data,
180                             XtPointer   call_data
181                         );
182 static void             populate_action_menu(
183                             Widget      widget,
184                             XtPointer   client_data,
185                             XtPointer   call_data
186                         );
187 static void             populate_view_menu(
188                             Widget      widget,
189                             XtPointer   client_data,
190                             XtPointer   call_data
191                         );
192 static void             populate_list(
193                             Widget              list,
194                             ABObj               cur_selection,
195                             BOOL                invoke_cb
196                         );
197 static void             populate_connection_list(
198                             ABObj       cur_action_obj
199                         );
200 static void             change_src_type(
201                             Widget      w,
202                             XtPointer   client_data,
203                             XtPointer   call_data
204                         );
205 static void             change_target_type(
206                             Widget      w,
207                             XtPointer   client_data,
208                             XtPointer   call_data
209                         );
210 static void             change_arg_sensitivity(
211                             Widget      w,
212                             XtPointer   client_data,
213                             XtPointer   call_data
214                         );
215 static void             set_view_filter(
216                             Widget      w,
217                             XtPointer   client_data,
218                             XtPointer   call_data
219                         );
220 static BOOL             is_action_type(
221                             ABObj       obj,
222                             int         filter
223                         );
224 static void             update_cur_src(
225                             Widget      w,
226                             XtPointer   client_data,
227                             XtPointer   call_data
228                         );
229 static void             update_cur_target(
230                             Widget      w,
231                             XtPointer   client_data,
232                             XtPointer   call_data
233                         );
234 static void             select_connection(
235                             Widget      w,
236                             XtPointer   client_data,
237                             XtPointer   call_data
238                         );
239 \f
240 static void             setup_source(
241                             AB_OBJECT_TYPE      source_type,
242                             int                 source_subtype,
243                             ABObj               source
244                         );
245 static void             setup_target(
246                             AB_OBJECT_TYPE      target_type,
247                             int                 target_subtype,
248                             ABObj               target
249                         );
250 static int              get_cur_when(
251                             void
252                         );
253 static AB_BUILTIN_ACTION get_cur_act(
254                             void
255                         );
256 static void             set_cur_when(
257                             AB_WHEN     new_when
258                         );
259 static void             set_cur_act(
260                             AB_BUILTIN_ACTION   new_act
261                         );
262 static ABObj            get_cur_connection(
263                             void
264                         );
265 static void             set_standard_action_type(
266                             void
267                         );
268 static void             set_call_function_action_type(
269                             void
270                         );
271 static void             set_execute_code_action_type(
272                             void
273                         );
274 static void             set_on_item_help_action_type(
275                             void
276                         );
277 static void             set_access_help_vol_action_type(
278                             void
279                         );
280
281 static void             set_conn_controls(
282                             BOOL        state
283                         );
284 static void             hide_execute_code_win(
285                             void
286                         );
287 static BOOL             verify_builtin_arg_string(
288                             AB_BUILTIN_ACTION c_act,
289                             ABObj             c_target,
290                             Widget            field
291                         );
292 static void             update_on_src_type_change(
293                             AB_OBJECT_TYPE      obj_type,
294                             int                 obj_subtype
295                         );
296 static void             update_on_target_type_change(
297                             AB_OBJECT_TYPE      obj_type,
298                             int                 obj_subtype
299                         );
300 static void             update_conn_ed_controls(void);
301 static AB_FUNC_TYPE     get_cur_func_type(void);
302
303 static BOOL             src_list_test(
304                             ABObj test_obj
305                         );
306 static BOOL             target_list_test(
307                             ABObj test_obj
308                         );
309 static void             set_ctrls_for_src(
310                             BOOL        state
311                         );
312 static void             set_ctrls_for_target(
313                             BOOL        state
314                         );
315
316
317 extern void
318 conn_init(
319 )
320 {
321     conn_strings_init();
322
323     obj_add_destroy_callback(connP_update_on_obj_destroy, NULL);
324 }
325
326 extern void
327 conn_popup_dialog(
328     Widget      widget,
329     XtPointer   client_data,
330     XtPointer   call_data
331 )
332 {
333     extern Widget       AB_toplevel;
334
335     if (AB_conn_dialog == (Widget)NULL)
336     {
337         dtbConnConnDialogInfo_clear(&dtb_conn_conn_dialog);
338         (void)dtb_conn_conn_dialog_initialize(&dtb_conn_conn_dialog,
339                                               AB_toplevel);
340         AB_conn_dialog = dtb_conn_conn_dialog.conn_dialog_shellform;
341
342         /* 
343          * Setup dialog to participate in dtbuilder window protocol
344          */  
345         ab_register_window(AB_conn_dialog, AB_WIN_DIALOG,
346                 WindowHidden, AB_toplevel, AB_WPOS_TILE_HORIZONTAL,
347                 conn_cancelCB, (XtPointer)&dtb_conn_conn_dialog);  
348
349         /*
350          * These callbacks only operate on the Connections Editor dialog
351          * i.e. update lists
352          *
353          * If any code is added to them that is independent of 
354          * the Connections Editor, then the callback registration
355          * may have to be done in conn_init().
356          */
357         obj_add_rename_callback(connP_update_on_obj_rename, NULL);
358         obj_add_update_callback(connP_update_on_show_status, NULL);
359     }
360     XtManageChild(AB_conn_dialog);
361     ab_show_window(AB_conn_dialog);
362     update_conn_ed_controls();
363 }
364
365 static void
366 init_exec_code_dialog(
367     DtbConnExecCodeDialogInfo   instance
368 )
369 {
370     exec_code_dialog = instance->exec_code_dialog_shellform;
371     exec_code_textpane = instance->exec_code_textpane;
372
373     ab_register_window(exec_code_dialog, AB_WIN_DIALOG,
374                 WindowHidden, AB_conn_dialog, AB_WPOS_STACK_CENTER,
375                 NULL, NULL);
376 }
377
378 static void
379 populate_src_menu(
380     Widget      widget,
381     XtPointer   client_data,
382     XtPointer   call_data
383 )
384 {
385     int i;
386
387     for (i = 0; i < ConnP_num_conn_objs; i++)
388     {
389         Widget  w;
390
391         w = XtVaCreateManagedWidget("src_menu_push",
392                 xmPushButtonWidgetClass, widget,
393                 XtVaTypedArg, XmNlabelString, XtRString,
394                     ConnP_conn_objs[i].label, strlen(ConnP_conn_objs[i].label)+1,
395                 NULL);
396         XtAddCallback(w, XmNactivateCallback,
397                         (XtCallbackProc)change_src_type,
398                         (XtPointer)&(ConnP_conn_objs[i]));
399     }
400 }
401
402 static void
403 populate_target_menu(
404     Widget      widget,
405     XtPointer   client_data,
406     XtPointer   call_data
407 )
408 {
409     int i;
410
411     for (i = 0; i < ConnP_num_conn_objs; i++)
412     {
413         Widget  w = NULL;
414
415         /* Application and Message objects can never be a 
416          * target, so don't put them in the Target Object 
417          * Type option menu. 
418          */ 
419         if ( (ConnP_conn_objs[i].obj_type != AB_TYPE_MESSAGE) && 
420              (ConnP_conn_objs[i].obj_type != AB_TYPE_PROJECT) &&
421              (ConnP_conn_objs[i].obj_type != AB_TYPE_MENU) 
422            )
423         { 
424             w = XtVaCreateManagedWidget("target_menu_push",
425                         xmPushButtonWidgetClass, widget,
426                         XtVaTypedArg, XmNlabelString, XtRString,
427                                 ConnP_conn_objs[i].label,
428                                 strlen(ConnP_conn_objs[i].label)+1,
429                                 NULL);
430             XtAddCallback(w, XmNactivateCallback,
431                         (XtCallbackProc)change_target_type,
432                         (XtPointer)&(ConnP_conn_objs[i]));
433         }
434     }
435 }
436
437 static void
438 populate_when_menu(
439     Widget      widget,
440     XtPointer   client_data,
441     XtPointer   call_data
442 )
443 {
444     int         num_labels;
445     int         i;
446     char        **labels;
447     Widget      *w_list = NULL;
448
449     when_pulldown = widget;
450
451     labels = connP_get_when_labels(&num_labels);
452     if (num_labels > 0)
453     {
454         w_list = (Widget *)XtMalloc(sizeof(Widget) * (num_labels + 1));
455         for (i = 0; i < num_labels; i++)
456         {
457             Widget      w;
458
459             w = XtVaCreateWidget("when_menu_push",
460                     xmPushButtonWidgetClass, when_pulldown,
461                     XtVaTypedArg, XmNlabelString, XtRString,
462                         labels[i], strlen(labels[i])+1,
463                     NULL);
464             w_list[i] = w;
465         }
466         w_list[i] = NULL;
467     }
468     XtVaSetValues(when_pulldown, XmNuserData, (XtPointer)w_list, NULL);
469     connP_ui_source_type_update(connP_get_source_type(),
470                                 connP_get_source_subtype());
471 }
472
473 static void
474 populate_action_menu(
475     Widget      widget,
476     XtPointer   client_data,
477     XtPointer   call_data
478 )
479 {
480     int         num_labels;
481     int         i;
482     char        **labels;
483     Widget      *w_list = NULL;
484
485     action_pulldown = widget;
486
487     labels = connP_get_act_labels(&num_labels);
488     if (num_labels > 0)
489     {
490         w_list = (Widget *)XtMalloc(sizeof(Widget) * (num_labels + 1));
491         for (i = 0; i < num_labels; i++)
492         {
493             Widget      w;
494
495             w = XtVaCreateWidget("action_menu_push",
496                     xmPushButtonWidgetClass, action_pulldown,
497                     XtVaTypedArg, XmNlabelString, XtRString,
498                         labels[i], strlen(labels[i])+1,
499                     NULL);
500             XtAddCallback(w, XmNactivateCallback,
501                           change_arg_sensitivity, (XtPointer)NULL);
502             w_list[i] = w;
503         }
504         w_list[i] = NULL;
505     }
506     XtVaSetValues(action_pulldown, XmNuserData, (XtPointer)w_list, NULL);
507     connP_ui_target_type_update(connP_get_target_type(),
508                                 connP_get_target_subtype());
509 }
510
511 static void
512 populate_view_menu(
513     Widget      widget,
514     XtPointer   client_data,
515     XtPointer   call_data
516 )
517 {
518     int         i;
519     Widget      w;
520
521
522     w = XtVaCreateManagedWidget("view_menu_push",
523             xmPushButtonWidgetClass, widget,
524             XtVaTypedArg, XmNlabelString, XtRString,
525                 "Source Object", sizeof("Source Object"),
526             NULL);
527     XtAddCallback(w, XmNactivateCallback, set_view_filter, (XtPointer)-1);
528     ConnP_view_source_obj = w;
529
530     for (i = 0; i < ConnP_num_conn_objs; i++)
531     {
532         w = XtVaCreateManagedWidget("view_menu_push",
533                 xmPushButtonWidgetClass, widget,
534                 XtVaTypedArg, XmNlabelString, XtRString,
535                    ConnP_conn_objs[i].label, strlen(ConnP_conn_objs[i].label)+1,
536                 NULL);
537         XtAddCallback(w, XmNactivateCallback, set_view_filter, (XtPointer)i);
538     }
539 }
540
541 static void
542 setup_source(
543     AB_OBJECT_TYPE      source_type,
544     int                 source_subtype,
545     ABObj               source
546 )
547 {
548     int i = connP_get_obj_type_index(source_type, source_subtype);
549
550     if (i < 0) return;
551
552     XtVaSetValues(XmOptionButtonGadget(src_menu),
553         XtVaTypedArg, XmNlabelString, XtRString,
554             ConnP_conn_objs[i].label, strlen(ConnP_conn_objs[i].label)+1,
555         NULL);
556     populate_list(src_list, source, FALSE);
557 }
558
559 static void
560 setup_target(
561     AB_OBJECT_TYPE      target_type,
562     int                 target_subtype,
563     ABObj               target
564 )
565 {
566     int i = connP_get_obj_type_index(target_type, target_subtype);
567
568     if (i < 0) return;
569
570     XtVaSetValues(XmOptionButtonGadget(target_menu),
571         XtVaTypedArg, XmNlabelString, XtRString,
572             ConnP_conn_objs[i].label, strlen(ConnP_conn_objs[i].label)+1,
573         NULL);
574     populate_list(target_list, target, FALSE);
575 }
576
577 static void
578 populate_list(
579     Widget              list,
580     ABObj               cur_selection,
581     BOOL                invoke_cb
582 )
583 {
584     ABObj       project = proj_get_project();
585     STRING      select_item = NULL;
586     int         iRet = -1;
587     
588     if (list == NULL || project == NULL)
589         return;
590
591     if (list == src_list)
592         abobj_list_load(list, project, src_list_test);
593     else
594         abobj_list_load(list, project, target_list_test);
595
596     /* If the current object is in the list, then select
597      * (highlight) it and call the callback associated
598      * with selecting a list item. If all the items remain
599      * deselected, then we have to make sure to make the
600      * appropriate things inactive.
601      */
602     if (cur_selection)
603     {
604         select_item = abobj_get_moduled_name(cur_selection);
605         iRet = ui_list_select_item(list, select_item, invoke_cb);
606     }
607
608     /* If cur_selection is NOT in the list, grey out the
609      * the right controls.
610      */
611     if ((iRet < 0) || (cur_selection == NULL))
612     {
613         if (list == target_list)
614         {
615             if (get_cur_func_type() == AB_FUNC_BUILTIN)
616                 set_ctrls_for_target(FALSE);
617             else 
618                 set_ctrls_for_target(TRUE);
619         }
620         else if (list == src_list)
621             set_ctrls_for_src(FALSE);
622     }
623 }
624
625
626 static BOOL
627 src_list_test(
628     ABObj       test_obj
629 )
630 {
631     AB_OBJECT_TYPE      obj_type = obj_get_type(test_obj);
632     int                 obj_subtype = obj_get_subtype(test_obj);
633     AB_OBJECT_TYPE      cur_obj_type = connP_get_source_type();
634     int                 cur_obj_subtype = connP_get_source_subtype();
635     ABObj               mod = obj_get_module(test_obj);
636     BOOL                ret = FALSE;
637     
638     if ((cur_obj_type == AB_TYPE_PROJECT) &&
639         (obj_type == cur_obj_type))
640     {
641         ret = TRUE;
642     }
643     else if ((mod != NULL) && obj_has_flag(mod, MappedFlag) 
644              && obj_is_defined(mod)) 
645     {
646         if (connP_objtype_needs_subtype(cur_obj_type, cur_obj_subtype))
647         {
648             if (!obj_is_sub(test_obj) &&
649                 obj_is_defined(test_obj) && 
650                 (obj_type == cur_obj_type) &&
651                 (obj_subtype == cur_obj_subtype))
652             {
653                 ret = TRUE;
654             }
655         }
656         else
657         {
658             /* If the object is not a container (i.e. group,
659              * menubar, panedwindow, etc.), and the object
660              * doesn't need a subtype, either because it 
661              * doesn't have one (i.e. AB_TYPE_PROJECT) or
662              * because all object subtypes should appear
663              * under one catetory (i.e. AB_TYPE_CHOICE shows
664              * optionmenus, radioboxes, and checkboxes), then
665              * search for all those objects based solely on
666              * the object type - don't care about subtype.
667              * If the object is a container and it doesn't
668              * need a subtype, then its one of AB_CONT_FOOTER,
669              * AB_CONT_BUTTON_PANEL, AB_CONT_RELATIVE,
670              * AB_CONT_TOOL_BAR, so only count those objects.
671              */
672             if (!obj_is_container(test_obj) && 
673                 !obj_is_sub(test_obj) && 
674                 obj_is_defined(test_obj) && 
675                 obj_type == cur_obj_type)
676             {
677                 ret = TRUE;
678             }
679             else if (obj_is_container(test_obj) &&
680                      (cur_obj_type == AB_TYPE_CONTAINER) 
681                      && !obj_is_sub(test_obj) &&
682                      obj_is_defined(test_obj) &&
683                      (  (obj_subtype == AB_CONT_FOOTER) ||
684                         (obj_subtype == AB_CONT_BUTTON_PANEL)||
685                         (obj_subtype == AB_CONT_RELATIVE) ||
686                         (obj_subtype == AB_CONT_TOOL_BAR))) 
687             {
688                 ret = TRUE;
689             }
690         }
691     }
692     return ret;
693 }
694
695 static BOOL
696 target_list_test(
697     ABObj       test_obj
698 )
699 {
700     AB_OBJECT_TYPE      obj_type = obj_get_type(test_obj);
701     int                 obj_subtype = obj_get_subtype(test_obj);
702     AB_OBJECT_TYPE      cur_obj_type = connP_get_target_type();
703     int                 cur_obj_subtype = connP_get_target_subtype();
704     ABObj               mod = obj_get_module(test_obj);
705     BOOL                ret = FALSE;
706     
707     if ((mod != NULL) && obj_has_flag(mod, MappedFlag) 
708         && obj_is_defined(mod)) 
709     {
710         if (connP_objtype_needs_subtype(cur_obj_type, cur_obj_subtype))
711         {
712             if (!obj_is_sub(test_obj) &&
713                 obj_is_defined(test_obj) && 
714                 (obj_type == cur_obj_type) &&
715                 (obj_subtype == cur_obj_subtype))
716             {
717                 ret = TRUE;
718             }
719         }
720         else
721         {
722             /* If the object is not a container (i.e. group,
723              * menubar, panedwindow, etc.), and the object
724              * doesn't need a subtype, either because it 
725              * doesn't have one (i.e. AB_TYPE_PROJECT) or
726              * because all object subtypes should appear
727              * under one catetory (i.e. AB_TYPE_CHOICE shows
728              * optionmenus, radioboxes, and checkboxes), then
729              * search for all those objects based solely on
730              * the object type - don't care about subtype.
731              * If the object is a container and it doesn't
732              * need a subtype, then it's one of AB_CONT_FOOTER,
733              * AB_CONT_BUTTON_PANEL, AB_CONT_RELATIVE,
734              * AB_CONT_TOOL_BAR, so only count those objects.
735              */
736             if (!obj_is_container(test_obj) && 
737                 !obj_is_sub(test_obj) && 
738                 obj_is_defined(test_obj) && 
739                 obj_type == cur_obj_type)
740             {
741                 ret = TRUE;
742             }
743             else if (obj_is_container(test_obj) &&
744                      (cur_obj_type == AB_TYPE_CONTAINER) 
745                      && !obj_is_sub(test_obj) &&
746                      obj_is_defined(test_obj) &&
747                      (  (obj_subtype == AB_CONT_FOOTER) ||
748                         (obj_subtype == AB_CONT_BUTTON_PANEL)||
749                         (obj_subtype == AB_CONT_RELATIVE) ||
750                         (obj_subtype == AB_CONT_TOOL_BAR))) 
751             {
752                 ret = TRUE;
753             }
754         }
755     }
756     return ret;
757 }
758
759 static void
760 populate_connection_list(
761     ABObj       cur_action_obj
762 )
763 {
764     ABObj               project = proj_get_project();
765     ABObj               obj = NULL, selected_conn = NULL;
766     AB_TRAVERSAL        trav;
767     ABObj               *obj_list = (ABObj *)NULL;
768     int                 count;
769     
770     XtSetSensitive(change_button, FALSE);
771     XtSetSensitive(delete_button, FALSE);
772
773     if (connection_list == NULL || project == NULL)
774         return;
775
776     /* Save the currently selected connection in the View list */
777     selected_conn = get_cur_connection();
778
779     XtVaGetValues(connection_list, XmNuserData, (XtPointer)&obj_list, NULL);
780     if (obj_list != NULL)
781         XtFree((char *)obj_list);
782     obj_list = (ABObj *)NULL;
783     XtVaSetValues(connection_list, XmNuserData, (XtPointer)obj_list, NULL);
784
785     XmListDeselectAllItems(connection_list);
786     XmListDeleteAllItems(connection_list);
787  
788     /*
789     if (connP_get_source() != NULL &&
790         obj_get_type(connP_get_source()) != connP_get_source_type())
791         return;
792     */
793
794     count = 0;
795     for (trav_open(&trav, project, AB_TRAV_ACTIONS);
796         (obj = trav_next(&trav)) != NULL; )
797     {
798         if (!is_action_type(obj, ConnP_view_filter))
799             continue;
800         count++;
801     }
802     trav_close(&trav);
803
804     if (count == 0)
805     {
806         XtSetSensitive(connection_list, FALSE);
807         return;
808     }
809     else
810     {
811         XtSetSensitive(connection_list, TRUE);
812     }
813
814     obj_list = (ABObj *)XtMalloc(sizeof(ABObj) * (count+1));
815     if (obj_list == (ABObj *)NULL)
816         return;
817
818     count = 0;
819     for (trav_open(&trav, project, AB_TRAV_ACTIONS);
820         (obj = trav_next(&trav)) != NULL; )
821     {
822         register XmString       xm_item_str;
823         
824         if (is_action_type(obj, ConnP_view_filter))
825         {
826             STRING      item_str = connP_make_conn_string(obj);
827
828             xm_item_str = XmStringCreateLocalized(item_str);
829             XmListAddItem(connection_list, xm_item_str, 0);
830             XmStringFree(xm_item_str);
831             if ((cur_action_obj == obj) || 
832                 (selected_conn && (selected_conn == obj))) 
833             {
834                 ui_list_select_item(connection_list, item_str, FALSE);
835                 XtSetSensitive(change_button, TRUE);
836                 XtSetSensitive(delete_button, TRUE);
837             }
838
839             obj_list[count++] = obj;
840         }
841     }
842     trav_close(&trav);
843     obj_list[count] = (ABObj)NULL;
844     XtVaSetValues(connection_list, XmNuserData, (XtPointer)obj_list, NULL);
845
846 }
847
848 static BOOL
849 is_action_type(
850     ABObj       obj,
851     int         filter
852 )
853 {
854     BOOL        ret_val = (BOOL)FALSE;
855     ABObj       mod;
856
857     if (!obj_is_project(obj->info.action.from))
858     {
859         mod = obj_get_module(obj->info.action.from);
860
861         if (mod == NULL || !obj_has_flag(mod, MappedFlag))
862             goto cret;
863     }
864
865     if (filter == -1)
866     {
867         ret_val = obj->info.action.from == connP_get_source();
868     }
869     else
870     {
871         AB_OBJECT_TYPE  obj_type = ConnP_conn_objs[filter].obj_type;
872         int     obj_subtype = ConnP_conn_objs[filter].obj_subtype;
873
874         ret_val = obj_get_type(obj->info.action.from) == obj_type;
875         if (obj_subtype != -1)
876             ret_val &= (obj_get_subtype(obj->info.action.from) == obj_subtype);
877     }
878 cret:
879     return(ret_val);
880 }
881
882 static void
883 change_src_type(
884     Widget      w,
885     XtPointer   client_data,
886     XtPointer   call_data
887 )
888 {
889     ConnObj     *objtype_desc = (ConnObj *)client_data;
890
891     if (objtype_desc == (ConnObj *)NULL)
892         return;
893
894     update_on_src_type_change(objtype_desc->obj_type,
895                           objtype_desc->obj_subtype);
896
897     /* Reset the current source to be NULL */
898     conn_set_source((ABObj) NULL);
899
900     /* Reset the connections list */
901     connP_set_connection(NULL);
902     populate_connection_list(connP_get_connection());
903
904     /* Make When option menu inactive */
905     set_ctrls_for_src(FALSE);
906     
907     set_conn_controls(FALSE);
908 }
909
910 static void
911 change_target_type(
912     Widget      w,
913     XtPointer   client_data,
914     XtPointer   call_data
915 )
916 {
917     ConnObj     *objtype_desc = (ConnObj *)client_data;
918
919     if (objtype_desc == (ConnObj *)NULL)
920         return;
921
922     update_on_target_type_change(objtype_desc->obj_type,
923                           objtype_desc->obj_subtype);
924
925     /* Reset the current target to be NULL */
926     conn_set_target((ABObj) NULL);
927
928     /* Make action option menu and argument field inactive */
929     set_ctrls_for_target(FALSE);
930
931     if (!connP_conn_is_possible())
932         set_conn_controls(FALSE);
933 }
934
935 static void
936 change_arg_sensitivity(
937     Widget      w,
938     XtPointer   client_data,
939     XtPointer   call_data
940 )
941 {
942     int                 act_cand = get_cur_act();
943     AB_BUILTIN_ACTION   act_type = AB_STDACT_UNDEF;
944
945     if (act_cand < 0 || act_cand >= AB_BUILTIN_ACTION_NUM_VALUES)
946         return;
947
948     XmTextFieldSetString(arg_field, "");
949
950     act_type = (AB_BUILTIN_ACTION)act_cand;
951     if (connP_action_needs_arg(act_type))
952     {
953         XtSetSensitive(arg_label, TRUE);
954         XtSetSensitive(arg_field, TRUE);
955         XmProcessTraversal(arg_field, XmTRAVERSE_CURRENT);
956     }
957     else
958     {
959         XtSetSensitive(arg_label, FALSE);
960         XtSetSensitive(arg_field, FALSE);
961     }
962 }
963
964 static void
965 set_view_filter(
966     Widget      w,
967     XtPointer   client_data,
968     XtPointer   call_data
969 )
970 {
971     if (ConnP_view_filter != (int)client_data)
972     {
973         ConnP_view_filter = (int)client_data;
974         populate_connection_list(NULL);
975     }
976 }
977
978 /* This is the browseSelect callback for the Source
979  * object list.
980  */
981 static void
982 update_cur_src(
983     Widget      w,
984     XtPointer   client_data,
985     XtPointer   call_data
986 )
987 {
988     XmListCallbackStruct        *list_cl = (XmListCallbackStruct *)call_data;
989     ABObj                       module = (ABObj) NULL;
990     ABObj                       selected_obj = (ABObj) NULL;
991     STRING                      name = NULL;
992
993     if (list_cl->reason != XmCR_BROWSE_SELECT)
994     {
995         return;
996     }
997
998     if (name = objxm_xmstr_to_str(list_cl->item))
999     {
1000         abobj_moduled_name_extract(name, &module, &selected_obj);
1001         if (selected_obj == NULL)
1002             abobj_project_name_extract(name, &selected_obj);
1003         util_free(name);
1004
1005         if (selected_obj)
1006         {
1007             conn_set_source(selected_obj);
1008
1009             /* If the object is a message, then we have to do
1010              * some special processing for the "When" optionmenu.
1011              * The reason is that the "When" optionmenu can
1012              * change when different message objects are selected
1013              * from the Source Object List.  If a particular
1014              * message does not have a certain button, then that
1015              * "when" (i.e. Click Action1) is made inactive, so
1016              * another "when" should be shown instead.
1017              */
1018             if (obj_is_message(selected_obj))
1019             {
1020                 if (obj_has_action1_button(selected_obj))
1021                 {
1022                     XtVaSetValues(XmOptionButtonGadget(when_menu),
1023                     XtVaTypedArg, XmNlabelString, XtRString,
1024                         ConnP_conn_whens[0].label,
1025                         strlen(ConnP_conn_whens[0].label)+1, NULL);
1026                 }
1027                 else if (obj_has_action2_button(selected_obj))
1028                 {
1029                     XtVaSetValues(XmOptionButtonGadget(when_menu),
1030                     XtVaTypedArg, XmNlabelString, XtRString,
1031                         ConnP_conn_whens[1].label,
1032                         strlen(ConnP_conn_whens[1].label)+1, NULL);
1033                 }
1034                 else if (obj_has_action3_button(selected_obj))
1035                 {
1036                     XtVaSetValues(XmOptionButtonGadget(when_menu),
1037                     XtVaTypedArg, XmNlabelString, XtRString,
1038                         ConnP_conn_whens[2].label,
1039                         strlen(ConnP_conn_whens[2].label)+1, NULL);
1040                 }
1041                 else if (obj_has_cancel_button(selected_obj))
1042                 {
1043                     XtVaSetValues(XmOptionButtonGadget(when_menu),
1044                     XtVaTypedArg, XmNlabelString, XtRString,
1045                         ConnP_conn_whens[3].label,
1046                         strlen(ConnP_conn_whens[3].label)+1, NULL);
1047                 }
1048             }
1049
1050             /* If the currently selected object is a choice item,
1051              * then we have to check if it is a radio/checkbox
1052              * item or an optionmenu item.  If it's a radio/checkbox
1053              * item, then set the "When" to be "Toggled" ["Activated"
1054              * is made inactive in connP_update_when_menu()]. If the
1055              * the item is an optionmenu item, then make the "When"
1056              * ["Toggled" is made inactive in connP_update_when_menu()].
1057              */
1058             if (obj_is_choice_item(selected_obj))
1059             {
1060                 if (obj_is_option_menu(obj_get_root(obj_get_parent(selected_obj))))
1061                     XtVaSetValues(XmOptionButtonGadget(when_menu),
1062                     XtVaTypedArg, XmNlabelString, XtRString,
1063                         ConnP_conn_whens[2].label,
1064                         strlen(ConnP_conn_whens[2].label)+1, NULL);
1065                 else
1066                     XtVaSetValues(XmOptionButtonGadget(when_menu),
1067                     XtVaTypedArg, XmNlabelString, XtRString,
1068                         ConnP_conn_whens[3].label,
1069                         strlen(ConnP_conn_whens[3].label)+1, NULL);
1070             }
1071             connP_set_connection(NULL);
1072             populate_connection_list(connP_get_connection());
1073
1074             set_ctrls_for_src(TRUE);
1075
1076             if (connP_conn_is_possible())
1077                 set_conn_controls(TRUE);
1078             else
1079                 set_conn_controls(FALSE);
1080         }
1081     }
1082 }
1083
1084 static void
1085 update_cur_target(
1086     Widget      w,
1087     XtPointer   client_data,
1088     XtPointer   call_data
1089 )
1090 {
1091     XmListCallbackStruct        *list_cl = (XmListCallbackStruct *)call_data;
1092     ABObj                       module = (ABObj) NULL;
1093     ABObj                       selected_obj = (ABObj) NULL;
1094     STRING                      name = NULL;
1095     AB_WHEN                     g_when = AB_WHEN_UNDEF;
1096     AB_FUNC_TYPE                g_func = AB_FUNC_UNDEF;
1097     AB_BUILTIN_ACTION           g_act = AB_STDACT_UNDEF;
1098
1099     if (list_cl->reason != XmCR_BROWSE_SELECT)
1100         return;
1101
1102     if (name = objxm_xmstr_to_str(list_cl->item))
1103     {
1104         abobj_moduled_name_extract(name, &module, &selected_obj);
1105         util_free(name);
1106
1107         if (selected_obj)
1108         {
1109             conn_set_target(selected_obj);
1110
1111             /* Get the default action. It can change depending
1112              * upon the source and target objects.
1113              */
1114             connP_guess_when_action(connP_get_source_type(),
1115                 connP_get_source_subtype(),
1116                 connP_get_target_type(),
1117                 connP_get_target_subtype(),
1118                 &g_when, &g_func, &g_act);
1119
1120             if (g_act != get_cur_act())
1121                 set_cur_act(g_act);
1122
1123             set_ctrls_for_target(TRUE);
1124
1125             if (connP_conn_is_possible())
1126                 set_conn_controls(TRUE);
1127             else
1128                 set_conn_controls(FALSE);
1129         }
1130     }
1131 }
1132
1133 static void
1134 select_connection(
1135     Widget      w,
1136     XtPointer   client_data,
1137     XtPointer   call_data
1138 )
1139 {
1140     XmListCallbackStruct        *list_cl = (XmListCallbackStruct *)call_data;
1141     ABObj                       *obj_list = (ABObj *)NULL;
1142     ABObj                       cur_action;
1143     AB_ACTION_INFO              *cur_info;
1144
1145     if (list_cl->reason != XmCR_BROWSE_SELECT)
1146         return;
1147
1148     XtVaGetValues(w, XmNuserData, &obj_list, NULL);
1149     if (obj_list == NULL)
1150         return;
1151     if (list_cl->item_position > 0)
1152         cur_action = obj_list[list_cl->item_position-1];
1153
1154     if (cur_action == NULL || !obj_is_action(cur_action))
1155         return;
1156
1157     cur_info = &(cur_action->info.action);
1158
1159     if (cur_info->from == NULL)
1160         return;
1161
1162     XtSetSensitive(change_button, TRUE);
1163     XtSetSensitive(delete_button, TRUE);
1164
1165     if (connP_get_source_type() != obj_get_type(cur_info->from))
1166     {
1167         if (connP_objtype_needs_subtype(obj_get_type(cur_info->from),
1168                 obj_get_subtype(cur_info->from)))
1169         {
1170             if (connP_get_source_subtype() != obj_get_subtype(cur_info->from))
1171             {
1172                 conn_set_source(cur_info->from);
1173                 setup_source(connP_get_source_type(),
1174                              connP_get_source_subtype(),
1175                              connP_get_source());
1176             }
1177         }
1178         else
1179         {
1180             conn_set_source(cur_info->from);
1181             setup_source(connP_get_source_type(),
1182                          connP_get_source_subtype(),
1183                          connP_get_source());
1184         }
1185     }
1186     else
1187     {
1188         conn_set_source(cur_info->from);
1189         ui_list_select_item(src_list, 
1190                 abobj_get_moduled_name(cur_info->from), FALSE);
1191     }
1192
1193     set_cur_when(cur_info->when);
1194     set_ctrls_for_src(TRUE);
1195
1196     switch (cur_info->func_type)
1197     {
1198       case AB_FUNC_BUILTIN:
1199         if (cur_info->to == NULL)
1200             return;
1201         if (connP_get_target_type() != obj_get_type(cur_info->to))
1202         {
1203             if (connP_objtype_needs_subtype(obj_get_type(cur_info->to),
1204                         obj_get_subtype(cur_info->to)))
1205             {
1206                 if (connP_get_target_subtype() != obj_get_subtype(cur_info->to))
1207                 {
1208                     conn_set_target(cur_info->to);
1209                     setup_target(connP_get_target_type(),
1210                                 connP_get_target_subtype(), 
1211                                 connP_get_target());
1212                 }
1213             }
1214             else
1215             {
1216                 conn_set_target(cur_info->to);
1217                 setup_target(connP_get_target_type(),
1218                              connP_get_target_subtype(), 
1219                              connP_get_target());
1220             }
1221         }
1222         else
1223         {
1224             conn_set_target(cur_info->to);
1225             ui_list_select_item(target_list, 
1226                 abobj_get_moduled_name(cur_info->to), FALSE);
1227         }
1228         
1229         set_cur_act(cur_info->func_value.builtin);
1230         set_ctrls_for_target(TRUE);
1231
1232         if (connP_get_action_type() != AB_FUNC_BUILTIN)
1233         {
1234             ui_optionmenu_change_label(action_type_opmenu,
1235                         action_type_labels[ACTION_TYPE_PREDEFINED]);
1236             set_standard_action_type();
1237         }
1238
1239         switch (connP_action_needs_arg(cur_info->func_value.builtin))
1240         {
1241             case AB_ARG_STRING:
1242             {
1243                 ISTRING istr_val;
1244
1245                 istr_val = cur_info->arg_value.sval;
1246                 /*
1247                  * Populate arg entries
1248                  */
1249                 if (istr_val != NULL)
1250                     XtVaSetValues(arg_field, XmNvalue,
1251                                 istr_string(istr_val), NULL);
1252                 else
1253                     XtVaSetValues(arg_field, XmNvalue, "", NULL);
1254             }
1255             break;
1256
1257             case AB_ARG_INT:
1258             {
1259                 char    str_val[MAXPATHLEN];
1260         
1261                 *str_val = 0;
1262                 sprintf(str_val, "%d", cur_info->arg_value.ival);
1263                 XtVaSetValues(arg_field, XmNvalue, str_val, NULL);
1264             }
1265             break;
1266         }
1267         break;
1268
1269       case AB_FUNC_USER_DEF:
1270       {
1271         STRING          cur_func_name = NULL;
1272         STRING          func_name = obj_get_func_name(cur_action);
1273
1274         XtVaGetValues(arg_field, XmNvalue, &cur_func_name, NULL);
1275
1276         set_ctrls_for_target(TRUE);
1277
1278         if (connP_get_action_type() != AB_FUNC_USER_DEF)
1279         {
1280             ui_optionmenu_change_label(action_type_opmenu,
1281                         action_type_labels[ACTION_TYPE_CALLFUNC]);
1282             set_call_function_action_type();
1283         }
1284         if (strcmp(cur_func_name, func_name) != 0)
1285         {
1286             if (func_name != (STRING) NULL)
1287                 XtVaSetValues(arg_field, XmNvalue, func_name, NULL);
1288         }
1289         break;
1290       }
1291
1292       case AB_FUNC_CODE_FRAG:
1293       {
1294         STRING  code_frag = obj_get_func_code(cur_action);
1295
1296         set_ctrls_for_target(TRUE);
1297
1298         if (connP_get_action_type() != AB_FUNC_CODE_FRAG)
1299         {
1300             ui_optionmenu_change_label(action_type_opmenu, 
1301                         action_type_labels[ACTION_TYPE_EXECUTE_CODE]); 
1302             set_execute_code_action_type(); 
1303         }
1304         if (!util_strempty(code_frag))
1305         {
1306             char        *newline = NULL;
1307             STRING      first_line = NULL;
1308
1309             XmTextSetString(exec_code_textpane, code_frag);
1310             newline = strchr(code_frag, '\n');
1311             if (newline)
1312             {
1313                 *newline = '\0';
1314             }
1315             first_line = (STRING)util_malloc(strlen(code_frag) + 4);
1316             if (first_line)
1317             {
1318                 strcpy(first_line, code_frag);
1319                 strcat(first_line, "...");
1320                 XmTextFieldSetString(arg_field, first_line);
1321                 util_free(first_line);
1322             }
1323
1324             /* Put back the newline character */
1325             if (newline) *newline = '\n';
1326         }
1327         else
1328             XmTextFieldSetString(arg_field, "");
1329
1330         ab_show_window(exec_code_dialog);
1331         
1332         break;
1333       }
1334
1335       case AB_FUNC_ON_ITEM_HELP:
1336         if (connP_get_action_type() != AB_FUNC_ON_ITEM_HELP)
1337         {
1338             ui_optionmenu_change_label(action_type_opmenu,
1339                     action_type_labels[ACTION_TYPE_ON_ITEM_HELP]);
1340             set_on_item_help_action_type();
1341         }
1342         break;
1343
1344       case AB_FUNC_HELP_VOLUME:
1345       {
1346             STRING  help_loc = obj_get_func_help_location(cur_action);
1347             STRING  help_vol = obj_get_func_help_volume(cur_action);
1348
1349             if (connP_get_action_type() != AB_FUNC_HELP_VOLUME)
1350             {
1351                 ui_optionmenu_change_label(action_type_opmenu,
1352                         action_type_labels[ACTION_TYPE_HELP_VOLUME]);
1353             }
1354             set_access_help_vol_action_type();
1355
1356             if (help_loc != (STRING) NULL)
1357                 XmTextFieldSetString(location_field, help_loc);
1358             if (help_vol != (STRING) NULL)
1359                 XmTextFieldSetString(volume_field, help_vol);
1360         break;
1361       }
1362     }
1363 }
1364
1365 \f
1366
1367 static int
1368 get_cur_when(
1369     void
1370 )
1371 {
1372     Widget      label_wid = XmOptionButtonGadget(when_menu);
1373     XmString    xm_when_label   = (XmString)NULL;
1374     char        *when_label;
1375     register int        i;
1376
1377     XtVaGetValues(label_wid, XmNlabelString, &xm_when_label, NULL);
1378     if (xm_when_label != NULL)
1379         when_label = objxm_xmstr_to_str(xm_when_label);
1380
1381     for (i = 0; i < ConnP_num_conn_whens; i++)
1382         if (!strcmp(when_label, ConnP_conn_whens[i].label))
1383         {
1384             XtFree(when_label);
1385             return((int)ConnP_conn_whens[i].when_type);
1386         }
1387
1388     /*
1389      * Should never happen
1390      */
1391     XtFree(when_label);
1392     return(-1);
1393 }
1394
1395 static AB_BUILTIN_ACTION
1396 get_cur_act(
1397     void
1398 )
1399 {
1400     Widget      label_wid = XmOptionButtonGadget(action_menu);
1401     XmString    xm_act_label    = (XmString)NULL;
1402     char        *act_label;
1403     register int        i;
1404
1405     XtVaGetValues(label_wid, XmNlabelString, &xm_act_label, NULL);
1406     if (xm_act_label != NULL)
1407         act_label = objxm_xmstr_to_str(xm_act_label);
1408
1409     for (i = 0; i < ConnP_num_conn_acts; i++)
1410         if (!strcmp(act_label, ConnP_conn_acts[i].label))
1411         {
1412             XtFree(act_label);
1413             return(ConnP_conn_acts[i].act_type);
1414         }
1415
1416     /*
1417      * Should never happen
1418      */
1419     XtFree(act_label);
1420     return((AB_BUILTIN_ACTION)-1);
1421 }
1422
1423 static void
1424 set_cur_when(
1425     AB_WHEN     new_when
1426 )
1427 {
1428     register int        i;
1429
1430     for (i = 0; i < ConnP_num_conn_whens; i++)
1431     {
1432         if (new_when == ConnP_conn_whens[i].when_type)
1433             break;
1434     }
1435
1436     if (i < ConnP_num_conn_whens)
1437     {
1438         XtVaSetValues(XmOptionButtonGadget(when_menu),
1439             XtVaTypedArg, XmNlabelString, XtRString,
1440                 ConnP_conn_whens[i].label, strlen(ConnP_conn_whens[i].label)+1,
1441             NULL);
1442     }
1443
1444 }
1445 static void
1446 set_cur_act(
1447     AB_BUILTIN_ACTION   new_act
1448 )
1449 {
1450     register int        i;
1451
1452     for (i = 0; i < ConnP_num_conn_acts; i++)
1453         if (new_act == ConnP_conn_acts[i].act_type)
1454             break;
1455
1456     if (i < ConnP_num_conn_acts)
1457     {
1458         XtVaSetValues(XmOptionButtonGadget(action_menu),
1459             XtVaTypedArg, XmNlabelString, XtRString,
1460                 ConnP_conn_acts[i].label, strlen(ConnP_conn_acts[i].label)+1,
1461             NULL);
1462         change_arg_sensitivity(arg_field, (XtPointer)NULL, (XtPointer)NULL);
1463     }
1464
1465 }
1466
1467 extern void
1468 connP_ui_source_type_update(
1469     AB_OBJECT_TYPE      new_type,
1470     int                 new_subtype
1471 )
1472 {
1473     Widget      *w_list = NULL;
1474     int         i;
1475     AB_WHEN             g_when = AB_WHEN_UNDEF;
1476     AB_FUNC_TYPE        g_func = AB_FUNC_UNDEF;
1477     AB_BUILTIN_ACTION   g_act = AB_STDACT_UNDEF;
1478
1479     if (when_pulldown == NULL)
1480     {
1481         return;
1482     }
1483
1484     XtVaGetValues(when_pulldown,
1485             XmNuserData,        &w_list,
1486             NULL);
1487
1488     if (w_list == NULL)
1489     {
1490         return;
1491     }
1492
1493     for (i = 0; w_list[i] != NULL; i++)
1494     {
1495         XtUnmanageChild(w_list[i]);
1496     }
1497
1498     for (i = 0; i < ConnP_num_conn_whens; i++)
1499     {
1500         XtManageChild(w_list[ConnP_conn_whens[i].when_type - 1]);
1501     }
1502 }
1503
1504 extern void
1505 connP_ui_target_type_update(
1506     AB_OBJECT_TYPE      new_type,
1507     int                 new_subtype
1508 )
1509 {
1510     Widget      *w_list = NULL;
1511     int         i;
1512
1513     if (action_pulldown == NULL)
1514         return;
1515
1516     XtVaGetValues(action_pulldown,
1517             XmNuserData,        &w_list,
1518             NULL);
1519
1520     if (w_list == NULL)
1521         return;
1522
1523     for (i = 0; w_list[i] != NULL; i++)
1524         XtUnmanageChild(w_list[i]);
1525
1526     for (i = 0; i < ConnP_num_conn_acts; i++)
1527         XtManageChild(w_list[ConnP_conn_acts[i].act_type - 1]);
1528 }
1529
1530 static ABObj
1531 get_cur_connection(
1532     void
1533 )
1534 {
1535     XmString            *sel_items = NULL;
1536     int                 sel_count = 0;
1537     ABObj               *obj_list = (ABObj *) NULL;
1538     int                 pos = 0;
1539     ABObj               ab_action = NULL;
1540
1541     if (connection_list == NULL)
1542         return(NULL);
1543
1544     /*
1545      * Look for selected connection
1546      */
1547     XtVaGetValues(connection_list,
1548             XmNselectedItemCount,       &sel_count,
1549             XmNselectedItems,           &sel_items,
1550             XmNuserData,                &obj_list,
1551         NULL);
1552     
1553     if (sel_count != 1 || obj_list == NULL)
1554     {
1555         return(NULL);
1556     }
1557
1558     pos = XmListItemPos(connection_list, sel_items[0]);
1559     if (pos <= 0)
1560     {
1561         return(NULL);
1562     }
1563     ab_action = obj_list[pos-1];
1564     return(ab_action); 
1565 }
1566
1567 static void
1568 set_standard_action_type(
1569     void
1570 )
1571 {
1572     XmString    xm_label_str;
1573     int         i = 0;
1574     BOOL        found = FALSE;
1575
1576     connP_set_action_type(AB_FUNC_BUILTIN);
1577
1578     XtSetSensitive(target_menu, TRUE);
1579     XtSetSensitive(target_list, TRUE);
1580     XtManageChild(action_menu);
1581
1582     /* It's possible that the target list has a selected
1583      * item even though it is insensitive. That means
1584      * that when the Action Type is set back to Predefined
1585      * and the target list becomes active again, then the
1586      * action optionmenu has to have the right default
1587      * action showing for the target object type selected.
1588      */
1589     if (ui_list_get_selected_pos(target_list) > 0)
1590     {
1591         /* If the current predefined action is not appropriate
1592          * for the current target object type, then change
1593          * it to the default action. This shouldn't happen
1594          * though, I think. 
1595          */
1596         for (i = 0; i < ConnP_num_conn_acts; i++)
1597             if (get_cur_act() == ConnP_conn_acts[i].act_type) 
1598                 found = TRUE;
1599         if (!found)
1600         {
1601             i = -1;
1602             i = connP_get_obj_type_index(connP_get_target_type(),
1603                         connP_get_target_subtype());
1604             if (i >= 0)
1605                 set_cur_act(ConnP_conn_objs[i].default_act);
1606         }
1607         set_ctrls_for_target(TRUE);
1608     }
1609     else        /* No target object selected */
1610     {
1611         set_ctrls_for_target(FALSE);
1612     }
1613
1614     XtManageChild(arg_rowcol);
1615     XmTextFieldSetString(arg_field, "");
1616     XmTextFieldSetEditable(arg_field, True);
1617     XtUnmanageChild(location_rowcol);
1618     XtUnmanageChild(volume_rowcol);
1619     hide_execute_code_win();
1620
1621     xm_label_str = XmStringCreateLocalized(catgets(Dtb_project_catd,
1622 100, 54, ARGUMENT_LABEL));
1623     XtVaSetValues(arg_label, XmNlabelString, xm_label_str, NULL);
1624     XmStringFree(xm_label_str);
1625
1626     if (connP_conn_is_possible())
1627         set_conn_controls(TRUE);
1628     else
1629         set_conn_controls(FALSE);
1630 }
1631
1632 static void
1633 set_call_function_action_type(
1634     void
1635 )
1636 {
1637     XmString    xm_label_str;
1638
1639     connP_set_action_type(AB_FUNC_USER_DEF);
1640
1641     XtSetSensitive(target_menu, FALSE);
1642     XtSetSensitive(target_list, FALSE);
1643     XtManageChild(arg_rowcol);
1644     XmTextFieldSetEditable(arg_field, True);
1645     XmTextFieldSetString(arg_field, "");
1646     XtUnmanageChild(action_menu);
1647     XtUnmanageChild(volume_rowcol);
1648     XtUnmanageChild(location_rowcol);
1649     hide_execute_code_win();
1650
1651     xm_label_str = XmStringCreateLocalized(catgets(Dtb_project_catd,
1652                         100, 55, FUNCTION_LABEL));
1653     XtVaSetValues(arg_label, XmNlabelString, xm_label_str, NULL);
1654     XmStringFree(xm_label_str);
1655
1656     XtSetSensitive(arg_label, TRUE);
1657     XtSetSensitive(arg_field, TRUE);
1658     XmProcessTraversal(arg_field, XmTRAVERSE_CURRENT);
1659
1660     if (connP_conn_is_possible())
1661         set_conn_controls(TRUE);
1662     else
1663         set_conn_controls(FALSE);
1664 }
1665
1666 static void
1667 set_execute_code_action_type(
1668     void
1669 )
1670 {
1671     XmString    xm_label_str;
1672
1673     connP_set_action_type(AB_FUNC_CODE_FRAG);
1674
1675     XtSetSensitive(target_menu, FALSE);
1676     XtSetSensitive(target_list, FALSE);
1677     XtManageChild(arg_rowcol);
1678     XmTextFieldSetEditable(arg_field, False);
1679     XmTextFieldSetString(arg_field, "");
1680     XtUnmanageChild(action_menu);
1681     XtUnmanageChild(volume_rowcol);
1682     XtUnmanageChild(location_rowcol);
1683
1684     xm_label_str = XmStringCreateLocalized(catgets(Dtb_project_catd,
1685                         100, 56, CODE_LABEL));
1686     XtVaSetValues(arg_label, XmNlabelString, xm_label_str, NULL);
1687     XmStringFree(xm_label_str);
1688
1689     XtSetSensitive(arg_label, TRUE);
1690     XtSetSensitive(arg_field, TRUE);
1691     XmProcessTraversal(arg_field, XmTRAVERSE_CURRENT);
1692
1693     if (connP_conn_is_possible())
1694         set_conn_controls(TRUE);
1695     else
1696         set_conn_controls(FALSE);
1697 }
1698
1699 static void
1700 set_on_item_help_action_type(
1701     void
1702 )
1703 {
1704     connP_set_action_type(AB_FUNC_ON_ITEM_HELP);
1705
1706     XtSetSensitive(target_menu, FALSE);
1707     XtSetSensitive(target_list, FALSE);
1708     XtUnmanageChild(action_menu);
1709     XtUnmanageChild(arg_rowcol);
1710     XtUnmanageChild(volume_rowcol);
1711     XtUnmanageChild(location_rowcol);
1712     hide_execute_code_win();
1713
1714     if (connP_conn_is_possible())
1715         set_conn_controls(TRUE);
1716     else
1717         set_conn_controls(FALSE);
1718 }
1719
1720 static void
1721 set_access_help_vol_action_type(
1722     void 
1723
1724
1725     connP_set_action_type(AB_FUNC_HELP_VOLUME); 
1726
1727     XtSetSensitive(target_menu, FALSE); 
1728     XtSetSensitive(target_list, FALSE); 
1729     XtUnmanageChild(action_menu); 
1730     XtUnmanageChild(arg_rowcol); 
1731     XtManageChild(volume_rowcol); 
1732     XmTextFieldSetString(volume_field, "");
1733     XtManageChild(location_rowcol); 
1734     XmTextFieldSetString(location_field, "");
1735     hide_execute_code_win();
1736
1737     if (connP_conn_is_possible())
1738         set_conn_controls(TRUE);
1739     else
1740         set_conn_controls(FALSE);
1741
1742
1743 extern int
1744 connP_update_on_obj_destroy(
1745     ObjEvDestroyInfo    info
1746 )
1747 {
1748     ABObj               obj = info->obj,
1749                         project;
1750     AB_OBJECT_TYPE      ab_type;
1751
1752     ab_type = obj_get_type(obj);
1753     if (ab_type == AB_TYPE_UNDEF || ab_type == AB_TYPE_UNKNOWN)
1754         return 0;
1755
1756     project = obj_get_project(obj);
1757
1758     if (!project)
1759         return (0);
1760
1761     /*
1762      * If entire project is being destroyed, skip the cleanup
1763      */
1764     if (!obj_has_flag(project, BeingDestroyedFlag))
1765         connP_destroy_connections_for(obj);
1766
1767     if (AB_conn_dialog != (Widget)NULL)
1768     {
1769         if (obj == connP_get_source())
1770         {
1771             conn_set_source(NULL);
1772             set_ctrls_for_src(FALSE);
1773         }
1774         if (obj == connP_get_target())
1775         {
1776             conn_set_target(NULL);
1777             set_ctrls_for_target(FALSE);
1778         }
1779         if (connP_obj_part_of_conn(obj, connP_get_connection()))
1780         {
1781             connP_set_connection(NULL);
1782         }
1783
1784         /*
1785          * If obj is salient and its type is the same as that of
1786          * the current source or target type in the conn-mgr,
1787          * update the manager window
1788          */
1789         abobj_list_obj_destroyed(src_list, info->obj, src_list_test);
1790         abobj_list_obj_destroyed(target_list, info->obj, target_list_test);
1791         populate_connection_list(connP_get_connection());
1792
1793         if (connP_conn_is_possible())
1794             set_conn_controls(TRUE);
1795         else
1796             set_conn_controls(FALSE);
1797     }
1798
1799     return 0;
1800 }
1801
1802 extern int
1803 connP_update_on_obj_rename(
1804     ObjEvAttChangeInfo    info
1805 )
1806 {
1807     ABObj               obj = info->obj;
1808     AB_OBJECT_TYPE      ab_type = AB_TYPE_UNDEF;
1809     ABObj               module = obj_get_module(obj);
1810     int                 iRet = 0;
1811
1812     if ((obj != NULL) && (AB_conn_dialog != (Widget)NULL))
1813     {
1814         ab_type = obj_get_type(obj);
1815         if ((ab_type != AB_TYPE_UNDEF) && (ab_type != AB_TYPE_UNKNOWN)
1816             && !obj_is_project(obj))
1817         {
1818             /* Replace the items in the Source and Target lists
1819              * whose module name has changed or the object name
1820              * has changed.
1821              */
1822             abobj_list_obj_renamed(src_list, obj, 
1823                 istr_string(info->old_name), src_list_test);
1824             abobj_list_obj_renamed(target_list, obj, 
1825                 istr_string(info->old_name), target_list_test);
1826
1827             /* Update the Connections list. An object's name 
1828              * or an object's module name may have changed
1829              * and if it is part of a connection that is showing
1830              * in the list, it has to be replaced.
1831              */
1832             populate_connection_list(connP_get_connection());
1833         }
1834     }
1835
1836     return iRet;
1837 }
1838
1839 /* Handles module show/hide and Undo of deleted object */
1840 extern int
1841 connP_update_on_show_status(
1842     ObjEvUpdateInfo     info
1843 )
1844 {
1845     ABObj       obj = info->obj;
1846     ABObj       conn = NULL, cur_conn_src_mod = NULL;
1847     ABObj       cur_conn_target_mod = NULL;
1848     ABObj       src_mod = NULL, target_mod = NULL;
1849     int         iRet = 0;
1850
1851     util_dprintf(3, "object updated: %s\n", obj_get_name(info->obj));
1852
1853     if ((obj != NULL) && (AB_conn_dialog != (Widget) NULL))
1854     {
1855         /* Update the Source, Target, and Connections lists */
1856
1857         abobj_list_obj_updated(src_list, info, src_list_test);
1858         abobj_list_obj_updated(target_list, info, target_list_test);
1859         populate_connection_list(connP_get_connection());
1860
1861         /* A module is being hidden */
1862         if (obj_is_module(obj) && !obj_has_flag(obj, MappedFlag))
1863         {
1864             src_mod = obj_get_module(connP_get_source());
1865             if (src_mod == obj)
1866             {
1867                 conn_set_source(NULL);
1868                 set_ctrls_for_src(FALSE);
1869             }
1870             target_mod = obj_get_module(connP_get_target());
1871             if (target_mod == obj)
1872             {
1873                 conn_set_target(NULL);
1874                 if (connP_get_action_type() == AB_FUNC_BUILTIN) 
1875                     set_ctrls_for_target(FALSE);
1876                 else
1877                     set_ctrls_for_target(TRUE);
1878             }
1879
1880             if (conn = connP_get_connection())
1881             {
1882                 cur_conn_src_mod = obj_get_module(obj_get_from(conn));
1883                 cur_conn_target_mod = obj_get_module(obj_get_to(conn));
1884                 if ((obj == cur_conn_src_mod) || 
1885                     (obj == cur_conn_target_mod))
1886                 {
1887                     connP_set_connection(NULL);
1888                 }
1889             }
1890             if (connP_conn_is_possible())
1891                 set_conn_controls(TRUE);
1892             else
1893                 set_conn_controls(FALSE);
1894         }
1895     }
1896
1897     return(iRet);
1898 }
1899
1900
1901 BOOL
1902 connP_conn_is_possible()
1903 {
1904     BOOL        ConnIsPossible = FALSE;
1905     ABObj       source = NULL,
1906                 target = NULL;
1907  
1908     source = connP_get_source();
1909     target = connP_get_target();
1910
1911     switch (connP_get_action_type())
1912     {
1913         case AB_FUNC_BUILTIN:
1914             if ( (source != NULL) && (target != NULL) )
1915             {
1916                 /* If the source object is a message
1917                  * but the message doesn't have an
1918                  * Action1, Action2, Action3, or a
1919                  * Cancel button, then a connection
1920                  * cannot be made on that message.
1921                  */
1922                 if (obj_is_message(source))
1923                 {
1924                    if ( obj_has_action1_button(source) ||
1925                         obj_has_action2_button(source) ||
1926                         obj_has_action3_button(source) ||
1927                         obj_has_cancel_button(source)
1928                       ) 
1929                     {
1930                         ConnIsPossible = TRUE; 
1931                     }
1932                 }
1933                 else
1934                 {
1935                     ConnIsPossible = TRUE; 
1936                 }
1937             }
1938             break;
1939
1940         case AB_FUNC_USER_DEF:
1941         case AB_FUNC_CODE_FRAG:
1942             if (source != NULL)
1943             {
1944                 if (obj_is_message(source))
1945                 {
1946                    if ( obj_has_action1_button(source) ||
1947                         obj_has_action2_button(source) ||
1948                         obj_has_action3_button(source) ||
1949                         obj_has_cancel_button(source)
1950                       )
1951                     {
1952                         ConnIsPossible = TRUE;
1953                     }  
1954                 }
1955                 else
1956                 {
1957                     ConnIsPossible = TRUE;
1958                 }
1959             }
1960             break;
1961
1962         case AB_FUNC_ON_ITEM_HELP:
1963         case AB_FUNC_HELP_VOLUME:
1964             if ((source != NULL) && obj_is_menu_item(source))
1965             {
1966                 ConnIsPossible = TRUE;
1967             }
1968         default:
1969             break;
1970     }
1971  
1972     return (ConnIsPossible);
1973 }
1974
1975 static void
1976 set_conn_controls(
1977     BOOL        state
1978 )
1979 {
1980     XtSetSensitive(connect_button, state);
1981 }
1982
1983 /*
1984 ** validate a builtin connection's AB_ARG_STRING
1985 **
1986 ** called from connP_make_connection()
1987 */
1988 static BOOL
1989 verify_builtin_arg_string(
1990     AB_BUILTIN_ACTION c_act,
1991     ABObj             c_target,
1992     Widget            field
1993 )
1994 {
1995     BOOL rval = False;
1996     
1997     if (!c_act || !c_target || !field ||
1998         (connP_get_action_type() != AB_FUNC_BUILTIN) ||
1999         (connP_action_needs_arg(c_act) != AB_ARG_STRING))
2000     {
2001         return False;
2002     }
2003     
2004     switch (c_act)
2005     {
2006     case AB_STDACT_DISABLE:
2007     case AB_STDACT_ENABLE:
2008     case AB_STDACT_HIDE:
2009         rval = True;
2010         break;
2011         
2012     case AB_STDACT_SET_LABEL:
2013         /*
2014         ** cmvc 7896: set-label conn doesn't work on graphic
2015         */
2016         switch (obj_get_label_type(c_target))
2017         {
2018         case AB_LABEL_GLYPH:
2019             /* validate graphic filename */
2020             if (prop_graphic_filename_ok(field, False))
2021                 rval = True;
2022             break;
2023
2024         case AB_LABEL_ARROW_DOWN:       /* are these really valid? */
2025         case AB_LABEL_ARROW_LEFT:
2026         case AB_LABEL_ARROW_RIGHT:
2027         case AB_LABEL_ARROW_UP:
2028         case AB_LABEL_DRAWN:
2029         case AB_LABEL_SEPARATOR:
2030             rval = True;
2031             break;
2032
2033         case AB_LABEL_STRING:
2034             rval = True;
2035             break;
2036
2037         case AB_LABEL_UNDEF:
2038         case AB_LABEL_TYPE_NUM_VALUES:
2039         default:
2040             break;
2041         }
2042         break;
2043         
2044     case AB_STDACT_SET_TEXT:
2045     case AB_STDACT_SET_VALUE:
2046     case AB_STDACT_SHOW:
2047         rval = True;
2048         break;
2049         
2050     case AB_STDACT_UNDEF:
2051     case AB_BUILTIN_ACTION_NUM_VALUES:
2052     default:
2053         rval = False;
2054         break;
2055     }
2056     
2057     return rval;
2058 }
2059
2060 /*** DTB_USER_CODE_END
2061  ***
2062  *** End of user code section
2063  ***
2064  **************************************************************************/
2065
2066
2067
2068 void 
2069 conn_cancelCB(
2070     Widget widget,
2071     XtPointer clientData,
2072     XtPointer callData
2073 )
2074 {
2075     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
2076     DtbConnConnDialogInfo dtbSource = (DtbConnConnDialogInfo)clientData;
2077     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
2078     
2079     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
2080
2081     /* If secondary Execute code dialog is open, close it also
2082      * to ensure correct window state tracking
2083      */
2084     if (exec_code_dialog && ab_window_is_open(exec_code_dialog))
2085         ui_win_show(exec_code_dialog, False, XtGrabNone);
2086
2087     ui_win_show(AB_conn_dialog, False, XtGrabNone);
2088
2089     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
2090 }
2091
2092
2093 void 
2094 connP_make_connection(
2095     Widget widget,
2096     XtPointer clientData,
2097     XtPointer callData
2098 )
2099 {
2100     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
2101
2102     char        *str_value = (char *)NULL;
2103     ABObj       ab_action  = (ABObj)NULL;
2104     ABObj       c_source;
2105     ABObj       c_target;
2106     AB_WHEN     c_when;
2107     BOOL        is_cross_module = (BOOL)FALSE;
2108     STRING      vol_value = NULL,
2109                 loc_value = NULL;
2110     BOOL        valid     = False;
2111
2112     if ((c_source = connP_get_source()) == NULL ||
2113         connP_get_source_type() != obj_get_type(c_source))
2114         return;
2115
2116     c_when = (AB_WHEN)get_cur_when();
2117
2118     switch (connP_get_action_type())
2119     {
2120       case AB_FUNC_BUILTIN:
2121         if ((c_target = connP_get_target()) != NULL &&
2122             connP_get_target_type() == obj_get_type(c_target))
2123         {
2124             AB_BUILTIN_ACTION   c_act = (AB_BUILTIN_ACTION)get_cur_act();
2125
2126             ab_action = obj_create(AB_TYPE_ACTION, NULL);
2127
2128             switch (connP_action_needs_arg(c_act))
2129             {
2130               case AB_ARG_UNDEF:
2131                 break;
2132
2133               case AB_ARG_STRING:
2134                 if (!verify_builtin_arg_string(c_act, c_target, arg_field))
2135                     return;
2136                   
2137                 XtVaGetValues(arg_field, XmNvalue, &str_value, NULL);
2138                 if (str_value != (char *)NULL)
2139                     connP_set_conn_arg(ab_action, AB_ARG_STRING, str_value);
2140                 break;
2141
2142               case AB_ARG_INT:
2143                 if (!prop_number_ok(arg_field, "Argument Field", 
2144                         obj_get_min_value(c_target), 
2145                         obj_get_max_value(c_target)))
2146                 {
2147                     return;     
2148                 }
2149                 XtVaGetValues(arg_field, XmNvalue, &str_value, NULL);
2150                 if (str_value != (char *)NULL)
2151                     connP_set_conn_arg(ab_action, AB_ARG_INT, str_value);
2152                 break;
2153
2154               default:
2155                 break;
2156             }
2157             connP_make_builtin_conn(ab_action, c_source, c_target, c_when,
2158                                         c_act);
2159
2160             /* Set SaveNeeded flag */ 
2161             if (obj_get_module(c_source) == obj_get_module(c_target))
2162             {
2163                 abobj_set_save_needed(obj_get_module(c_source), TRUE);
2164             }
2165             else
2166             {
2167                 abobj_set_save_needed(obj_get_project(c_source), TRUE);
2168                 is_cross_module = TRUE;
2169             }
2170         }
2171         break;
2172
2173       case AB_FUNC_USER_DEF:
2174         /*
2175          * Populate function name
2176          */
2177         XtVaGetValues(arg_field, XmNvalue, &str_value, NULL);
2178         if (!util_strempty(str_value))
2179         {
2180             ab_action = obj_create(AB_TYPE_ACTION, NULL);
2181             connP_make_user_def_conn(ab_action, c_source, c_when, str_value);
2182
2183             /* Set SaveNeeded flag */ 
2184             abobj_set_save_needed(obj_is_project(c_source)? c_source :
2185                 obj_get_module(c_source), TRUE);
2186         }
2187         else
2188         {
2189             dtb_conn_no_func_msg_initialize(&dtb_conn_no_func_msg);
2190             (void)dtb_show_modal_message(dtb_get_toplevel_widget(),
2191                         &dtb_conn_no_func_msg, NULL, NULL, NULL);
2192         }
2193         break;
2194
2195       case AB_FUNC_CODE_FRAG:
2196         /*
2197          * Populate code fragment
2198          */
2199         str_value = CodeFragBuf;
2200         if (!util_strempty(str_value))
2201         {
2202             ab_action = obj_create(AB_TYPE_ACTION, NULL);
2203             connP_make_code_frag_conn(ab_action, c_source, c_when, str_value);
2204
2205             /* Set SaveNeeded flag */ 
2206             abobj_set_save_needed(obj_is_project(c_source)? c_source :
2207                 obj_get_module(c_source), TRUE);
2208         }
2209         break;
2210
2211       case AB_FUNC_ON_ITEM_HELP:
2212         ab_action = obj_create(AB_TYPE_ACTION, NULL);
2213         connP_make_on_item_help_conn(ab_action, c_source, c_when);
2214
2215         /* Set SaveNeeded flag */
2216         abobj_set_save_needed(obj_get_module(c_source), TRUE);
2217         break;
2218
2219       case AB_FUNC_HELP_VOLUME:
2220         XtVaGetValues(volume_field, XmNvalue, &vol_value, NULL);
2221         XtVaGetValues(location_field, XmNvalue, &loc_value, NULL);
2222         ab_action = obj_create(AB_TYPE_ACTION, NULL);
2223         connP_make_help_vol_conn(ab_action, c_source, 
2224                                 c_when, vol_value, loc_value);
2225
2226         /* Set SaveNeeded flag */
2227         abobj_set_save_needed(obj_get_module(c_source), TRUE);
2228         break;
2229     }
2230
2231     if (ab_action != (ABObj)NULL)
2232     {
2233         if (is_cross_module)
2234         {
2235             obj_add_action(obj_get_project(c_source), ab_action);
2236         }
2237         else
2238         {
2239             obj_add_action(obj_is_project(c_source)? c_source : 
2240                 obj_get_module(c_source), ab_action);
2241         }
2242         connP_set_connection(ab_action);
2243         /* 
2244          * cmvc 4359 - make View: be Source Object, if it is not already or
2245          * if the View: is not the Source: connection being made.
2246          */
2247         if (!((ConnP_view_filter == -1) ||
2248               (ConnP_view_filter == connP_get_obj_type_index(connP_get_source_type(), connP_get_source_subtype())))
2249            )
2250         {  
2251             ConnP_view_filter = -1;
2252             XtVaSetValues(view_menu,
2253                 XmNmenuHistory, ConnP_view_source_obj,
2254                 NULL);
2255         }
2256         populate_connection_list(connP_get_connection());
2257     }
2258
2259     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
2260     
2261     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
2262     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
2263 }
2264
2265
2266 void 
2267 connP_change_connection(
2268     Widget widget,
2269     XtPointer clientData,
2270     XtPointer callData
2271 )
2272 {
2273     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
2274
2275     ABObj               ab_action;
2276     AB_WHEN             c_when;
2277     AB_BUILTIN_ACTION   c_act;
2278     ABObj               c_source;
2279     ABObj               c_target;
2280     BOOL                is_changed;
2281     AB_FUNC_TYPE        cur_func_type;
2282     char                *str_value = (char *)NULL;
2283     STRING              loc_value = (STRING) NULL,
2284                         vol_value = (STRING) NULL;
2285     ISTRING             istr_value = (ISTRING)NULL,
2286                         istr_loc_value = (ISTRING)NULL,
2287                         istr_vol_value = (ISTRING)NULL;
2288
2289     if ((ab_action = get_cur_connection()) == NULL)
2290         return;
2291     if ((c_source = connP_get_source()) == NULL)
2292         return;
2293     if (connP_get_source_type() != obj_get_type(c_source))
2294         return;
2295     
2296     c_when = (AB_WHEN)get_cur_when();
2297
2298     /*
2299      * Match contents of selected action with
2300      * current selections on the connections manager.
2301      */
2302  
2303     is_changed = FALSE;
2304     cur_func_type = connP_get_action_type();
2305     switch (cur_func_type)
2306     {
2307       /**************************************************
2308        * Switching the action (function) type to        *
2309        * Predefined Action.                             *
2310        **************************************************/
2311       case AB_FUNC_BUILTIN:
2312         c_act = get_cur_act();
2313         if ((c_target = connP_get_target()) == NULL ||
2314             connP_get_target_type() != obj_get_type(c_target))
2315             return;
2316
2317         switch (ab_action->info.action.func_type)
2318         {
2319           /* Switching func type from predefined action
2320            * to predefined action.
2321            */
2322           case AB_FUNC_BUILTIN:
2323            if (connP_action_needs_arg(c_act) == AB_ARG_INT)
2324            {
2325               if (!prop_number_ok(arg_field, "Argument Field",
2326                         obj_get_min_value(c_target),
2327                         obj_get_max_value(c_target)))
2328               {
2329                 return;
2330               }
2331             }
2332             str_value = XmTextFieldGetString(arg_field);
2333             is_changed = connP_change_in_builtin(ab_action,
2334                             c_source, c_target, c_when,
2335                             get_cur_act(), str_value);
2336             if (!util_strempty(str_value))
2337                 XtFree(str_value);
2338             break;
2339
2340           /* Switching func type from call-function to 
2341            * predefined action.
2342            */
2343           case AB_FUNC_USER_DEF:
2344             is_changed = TRUE;
2345             if (ab_action->info.action.func_value.func_name != (ISTRING)NULL)
2346                 istr_destroy(ab_action->info.action.func_value.func_name);
2347             connP_make_builtin_conn(ab_action, c_source, c_target, 
2348                         c_when, c_act);
2349             break;
2350
2351           /* Switching func type from execute-code to 
2352            * predefined action.
2353            */
2354           case AB_FUNC_CODE_FRAG:
2355             is_changed = TRUE;
2356             XmTextFieldSetString(arg_field, "");
2357             XmTextSetString(exec_code_textpane, "");
2358             if (ab_action->info.action.func_value.code_frag != (ISTRING)NULL)
2359                 istr_destroy(ab_action->info.action.func_value.code_frag);
2360             connP_make_builtin_conn(ab_action, c_source, c_target, 
2361                         c_when, c_act);
2362             break;
2363         
2364           /* Switching func type from activate-on-item-help to 
2365            * predefined action.
2366            */
2367           case AB_FUNC_ON_ITEM_HELP:
2368             is_changed = TRUE;
2369             connP_make_builtin_conn(ab_action, c_source, c_target,
2370                         c_when, c_act);
2371             break;
2372
2373           /* Switching func type from access-help-volume to 
2374            * predefined action.
2375            */
2376           case AB_FUNC_HELP_VOLUME:
2377             is_changed = TRUE;
2378             if (ab_action->info.action.location != (ISTRING)NULL)
2379                 istr_destroy(ab_action->info.action.location);
2380             if (ab_action->info.action.volume_id != (ISTRING)NULL)
2381                 istr_destroy(ab_action->info.action.volume_id);
2382             connP_make_builtin_conn(ab_action, c_source, c_target, 
2383                         c_when, c_act);   
2384             XmTextFieldSetString(location_field, "");
2385             XmTextFieldSetString(volume_field, "");
2386             break;
2387         }
2388         if (is_changed == TRUE)
2389         {
2390             if (obj_get_module(c_source) == obj_get_module(c_target))
2391             {
2392                 abobj_set_save_needed(obj_is_project(c_source)? 
2393                         c_source : obj_get_module(c_source), TRUE);
2394             }
2395             else        /* This is a cross-module connection */
2396             {
2397                 abobj_set_save_needed(obj_is_project(c_source)? 
2398                         c_source : obj_get_module(c_source), TRUE);
2399             }
2400         }
2401         break;
2402
2403       /************************************************** 
2404        * Switching the action (function) type to        *
2405        * Call-Function .                                *     
2406        **************************************************/
2407       case AB_FUNC_USER_DEF:
2408         str_value = XmTextFieldGetString(arg_field);
2409         if (str_value == (char *)NULL)
2410             return;
2411
2412         switch (ab_action->info.action.func_type)
2413         {
2414           /* Switching func type from call-function to
2415            * call-function.
2416            */
2417           case AB_FUNC_USER_DEF:
2418             istr_value = istr_create(str_value);
2419             if (ab_action->info.action.func_value.func_name != istr_value)
2420             {
2421                 is_changed = TRUE;
2422                 istr_destroy(ab_action->info.action.func_value.func_name);
2423             }
2424             if (c_when != obj_get_when(ab_action))
2425                 is_changed = TRUE;
2426
2427             if (is_changed)
2428             {
2429                 connP_make_user_def_conn(ab_action, c_source, c_when, str_value);
2430                 abobj_set_save_needed(obj_is_project(c_source)? 
2431                         c_source : obj_get_module(c_source), TRUE);
2432             }
2433             break;
2434
2435           /* Switching func type from Predefined-action to
2436            * Call-Function.
2437            */
2438           case AB_FUNC_BUILTIN:
2439             connP_builtin_remove_arg(ab_action);
2440             is_changed = TRUE;
2441             connP_make_user_def_conn(ab_action, c_source, c_when, str_value);
2442             abobj_set_save_needed(obj_is_project(c_source)? c_source :
2443                 obj_get_module(c_source), TRUE);
2444             break;
2445
2446           /* Switching func type from Execute-code to
2447            * Call-Function.
2448            */
2449           case AB_FUNC_CODE_FRAG:
2450             is_changed = TRUE;
2451             XmTextFieldSetString(arg_field, "");
2452             XmTextSetString(exec_code_textpane, "");
2453             if (ab_action->info.action.func_value.code_frag != (ISTRING)NULL)
2454                 istr_destroy(ab_action->info.action.func_value.code_frag);
2455             connP_make_user_def_conn(ab_action, c_source, c_when, str_value);
2456             abobj_set_save_needed(obj_is_project(c_source)? c_source :
2457                 obj_get_module(c_source), TRUE);
2458             break;
2459
2460           /* Switching func type from activate-on-item-help to
2461            * call-function.
2462            */
2463           case AB_FUNC_ON_ITEM_HELP:
2464             is_changed = TRUE;
2465             connP_make_user_def_conn(ab_action, c_source, c_when, str_value);
2466             abobj_set_save_needed(obj_is_project(c_source)? 
2467                 c_source : obj_get_module(c_source), TRUE);
2468             break;
2469
2470           /* Switching func type from access-help-volume to
2471            * call-function.
2472            */
2473           case AB_FUNC_HELP_VOLUME:
2474             is_changed = TRUE;
2475             if (ab_action->info.action.location != (ISTRING) NULL)
2476                 istr_destroy(ab_action->info.action.location);
2477             if (ab_action->info.action.volume_id != (ISTRING) NULL)
2478                 istr_destroy(ab_action->info.action.volume_id);
2479             connP_make_user_def_conn(ab_action, c_source, c_when, str_value);        
2480             abobj_set_save_needed(obj_is_project(c_source)? 
2481                 c_source : obj_get_module(c_source), TRUE);
2482             XmTextFieldSetString(location_field, "");
2483             XmTextFieldSetString(volume_field, "");
2484             break;
2485         }
2486
2487         XtFree(str_value);
2488         break;
2489
2490       /**************************************************  
2491        * Switching the action (function) type to        * 
2492        * Execute-Code.                                  *
2493        **************************************************/ 
2494       case AB_FUNC_CODE_FRAG:
2495         str_value = CodeFragBuf;
2496         if (str_value == (STRING) NULL)
2497             return;
2498
2499         switch (ab_action->info.action.func_type)
2500         {
2501           /* Switching func type from Predefined Action to
2502            * Execute Code.
2503            */
2504           case AB_FUNC_BUILTIN:
2505             connP_builtin_remove_arg(ab_action);
2506             is_changed = TRUE;
2507             connP_make_code_frag_conn(ab_action, c_source, c_when, str_value);
2508             abobj_set_save_needed(obj_is_project(c_source)? c_source :
2509                     obj_get_module(c_source), TRUE);
2510             break;
2511
2512           /* Switching func type from Call-Function to
2513            * Execute Code.
2514            */
2515           case AB_FUNC_USER_DEF:
2516             if (ab_action->info.action.func_value.func_name != (ISTRING)NULL)
2517                 istr_destroy(ab_action->info.action.func_value.func_name);
2518             is_changed = TRUE;
2519             connP_make_code_frag_conn(ab_action, c_source, c_when, str_value);
2520             abobj_set_save_needed(obj_is_project(c_source)? c_source :
2521                     obj_get_module(c_source), TRUE);
2522             break;
2523
2524           /* Switching func type from Execute Code to
2525            * Execute Code.
2526            */
2527           case AB_FUNC_CODE_FRAG:
2528             istr_value = istr_create(str_value);
2529             if (ab_action->info.action.func_value.code_frag != istr_value)
2530             {
2531                 is_changed = TRUE;
2532                 istr_destroy(ab_action->info.action.func_value.code_frag);
2533             }
2534             if (c_when != obj_get_when(ab_action))
2535                 is_changed = TRUE;
2536
2537             if (is_changed)
2538             {
2539                 connP_make_code_frag_conn(ab_action, c_source, c_when, str_value);
2540                 abobj_set_save_needed(obj_is_project(c_source)? 
2541                         c_source : obj_get_module(c_source), TRUE);
2542             }
2543             break;
2544
2545           /* Switching func type from activate-on-item-help to
2546            * Execute Code.
2547            */
2548           case AB_FUNC_ON_ITEM_HELP:
2549             is_changed = TRUE;
2550             connP_make_code_frag_conn(ab_action, c_source, c_when, str_value);
2551             abobj_set_save_needed(obj_is_project(c_source)? 
2552                         c_source : obj_get_module(c_source), TRUE);
2553             break;
2554  
2555           /* Switching func type from access-help-volume to
2556            * Execute Code.
2557            */
2558           case AB_FUNC_HELP_VOLUME:
2559             is_changed = TRUE;
2560             if (ab_action->info.action.location != (ISTRING)NULL)
2561                 istr_destroy(ab_action->info.action.location);
2562             if (ab_action->info.action.volume_id != (ISTRING)NULL)
2563                 istr_destroy(ab_action->info.action.volume_id);
2564             connP_make_code_frag_conn(ab_action, c_source, c_when, str_value);
2565             abobj_set_save_needed(obj_is_project(c_source)? 
2566                         c_source : obj_get_module(c_source), TRUE);
2567             XmTextFieldSetString(location_field, "");
2568             XmTextFieldSetString(volume_field, "");
2569             break;
2570         }
2571
2572         XtFree(str_value);
2573         break;
2574
2575       /**************************************************  
2576        * Switching the action (function) type to        *  
2577        * 'Activate On-Item Help'.                       * 
2578        **************************************************/  
2579       case AB_FUNC_ON_ITEM_HELP:
2580         switch (ab_action->info.action.func_type)
2581         {
2582           /* Switching func type from activate-on-item-help
2583            * to activate-on-item-help.
2584            */
2585           case AB_FUNC_ON_ITEM_HELP:
2586             if (c_when != obj_get_when(ab_action))
2587             {
2588                 is_changed = TRUE;
2589                 connP_make_on_item_help_conn(ab_action, c_source, c_when);
2590                 abobj_set_save_needed(obj_is_project(c_source)? 
2591                     c_source : obj_get_module(c_source), TRUE);
2592             }
2593             break;
2594
2595           /* Switching func type from call-function to
2596            * activate-on-item-help.
2597            */
2598           case AB_FUNC_USER_DEF:
2599             is_changed = TRUE;
2600             if (ab_action->info.action.func_value.func_name != (ISTRING) NULL)
2601                 istr_destroy(ab_action->info.action.func_value.func_name);
2602             connP_make_on_item_help_conn(ab_action, c_source, c_when);
2603             abobj_set_save_needed(obj_is_project(c_source)? c_source :
2604                         obj_get_module(c_source), TRUE);
2605             XmTextFieldSetString(arg_field, "");
2606             break;
2607              
2608           /* Switching func type from predefined-action to
2609            * activate-on-item-help.
2610            */
2611           case AB_FUNC_BUILTIN:
2612             is_changed = TRUE;
2613             connP_builtin_remove_arg(ab_action);
2614             connP_make_on_item_help_conn(ab_action, c_source, c_when);
2615             abobj_set_save_needed(obj_is_project(c_source)? 
2616                 c_source : obj_get_module(c_source), TRUE);
2617             XmTextFieldSetString(arg_field, "");
2618             break;
2619  
2620           /* Switching func type from execute-code to
2621            * activate-on-item-help.
2622            */
2623           case AB_FUNC_CODE_FRAG:
2624             is_changed = TRUE;
2625             if (ab_action->info.action.func_value.code_frag != (ISTRING)NULL)
2626                 istr_destroy(ab_action->info.action.func_value.code_frag);
2627             connP_make_on_item_help_conn(ab_action, c_source, c_when);
2628             abobj_set_save_needed(obj_is_project(c_source)? 
2629                 c_source : obj_get_module(c_source), TRUE);
2630             XmTextFieldSetString(arg_field, "");
2631             XmTextSetString(exec_code_textpane, "");
2632             break;
2633
2634           /* Switching func type from access-help-volume to
2635            * activate-on-item-help.
2636            */
2637           case AB_FUNC_HELP_VOLUME:
2638             is_changed = TRUE;
2639             if (ab_action->info.action.location != (ISTRING) NULL)
2640                 istr_destroy(ab_action->info.action.location);
2641             if (ab_action->info.action.volume_id != (ISTRING) NULL)
2642                 istr_destroy(ab_action->info.action.volume_id);
2643             connP_make_on_item_help_conn(ab_action, c_source, c_when);
2644             abobj_set_save_needed(obj_is_project(c_source)?
2645                 c_source : obj_get_module(c_source), TRUE);
2646             XmTextFieldSetString(location_field, "");
2647             XmTextFieldSetString(volume_field, "");
2648             break;
2649         }
2650         break;
2651
2652       /**************************************************
2653        * Switching the action (function) type to        *
2654        * 'Access Help Volume'.                          *
2655        **************************************************/
2656       case AB_FUNC_HELP_VOLUME:
2657         loc_value = XmTextFieldGetString(location_field);
2658         vol_value = XmTextFieldGetString(volume_field);
2659         if (loc_value == (STRING)NULL || (vol_value == (STRING)NULL))
2660             return;
2661
2662         switch (ab_action->info.action.func_type)
2663         {
2664           /* Switching func type from call-function to
2665            * access-help-volume.
2666            */
2667           case AB_FUNC_USER_DEF:
2668             is_changed = TRUE;
2669             if (ab_action->info.action.func_value.func_name != (ISTRING) NULL)
2670                 istr_destroy(ab_action->info.action.func_value.func_name);
2671             connP_make_help_vol_conn(ab_action, c_source, c_when,
2672                                 vol_value, loc_value);
2673             abobj_set_save_needed(obj_is_project(c_source)?
2674                 c_source : obj_get_module(c_source), TRUE);
2675             XmTextFieldSetString(arg_field, "");
2676             break;
2677
2678           /* Switching func type from predefined-action to
2679            * access-help-volume.
2680            */
2681           case AB_FUNC_BUILTIN:
2682             is_changed = TRUE;
2683             connP_builtin_remove_arg(ab_action);
2684             connP_make_help_vol_conn(ab_action, c_source, c_when,
2685                                 vol_value, loc_value);
2686             abobj_set_save_needed(obj_is_project(c_source)?
2687                 c_source : obj_get_module(c_source), TRUE);
2688             XmTextFieldSetString(arg_field, "");
2689             break;
2690
2691           /* Switching func type from execute-code to
2692            * access-help-volume.
2693            */
2694           case AB_FUNC_CODE_FRAG:
2695             is_changed = TRUE;
2696             if (ab_action->info.action.func_value.code_frag != (ISTRING)NULL)
2697                 istr_destroy(ab_action->info.action.func_value.code_frag);
2698             connP_make_help_vol_conn(ab_action, c_source, c_when,
2699                                 vol_value, loc_value);
2700             abobj_set_save_needed(obj_is_project(c_source)?
2701                 c_source : obj_get_module(c_source), TRUE);
2702             XmTextFieldSetString(arg_field, "");
2703             XmTextSetString(exec_code_textpane, "");
2704             break;
2705                
2706           /* Switching func type from access-help-volume to
2707            * access-help-volume.
2708            */
2709           case AB_FUNC_HELP_VOLUME:
2710             istr_loc_value = istr_create(loc_value);
2711             istr_vol_value = istr_create(vol_value);
2712             if (ab_action->info.action.location != istr_loc_value)
2713             {
2714                 is_changed = TRUE;
2715                 istr_destroy(ab_action->info.action.location);
2716             }
2717             if (ab_action->info.action.volume_id != istr_vol_value)
2718             { 
2719                 is_changed = TRUE;
2720                 istr_destroy(ab_action->info.action.volume_id);
2721             }   
2722             if (c_when != obj_get_when(ab_action))
2723                 is_changed = TRUE;
2724
2725             if (is_changed)
2726             {
2727                 connP_make_help_vol_conn(ab_action, c_source, c_when,
2728                                 vol_value, loc_value);
2729                 abobj_set_save_needed(obj_is_project(c_source)? 
2730                     c_source : obj_get_module(c_source), TRUE);
2731             }
2732             break;
2733         }
2734         XtFree(loc_value);
2735         XtFree(vol_value);
2736         break;
2737     }
2738     if (is_changed == TRUE)
2739     {
2740         connP_set_connection(ab_action);
2741         populate_connection_list(connP_get_connection());
2742     }
2743
2744     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
2745     
2746     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
2747     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
2748 }
2749
2750
2751 void 
2752 connP_delete_connection(
2753     Widget widget,
2754     XtPointer clientData,
2755     XtPointer callData
2756 )
2757 {
2758     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
2759
2760     ABObj               ab_action;
2761     ABObj               source, target;
2762
2763     if ((ab_action = get_cur_connection()) == NULL)
2764         return;
2765
2766     source = ab_action->info.action.from;
2767     target = ab_action->info.action.to;
2768
2769     /* Set the SaveNeededFlag on the module, if it is an
2770      * intra-module connection.  Otherwise set it on the 
2771      * project, since it is a cross-module connection which 
2772      * is stored in the .bip file. 
2773      */  
2774     if ( obj_get_module(source) == obj_get_module(target) ) 
2775     {
2776         abobj_set_save_needed(obj_is_project(source)? source :
2777                 obj_get_module(source), TRUE);
2778     }
2779     else        /* This is a cross-module connection */
2780     {
2781         abobj_set_save_needed(obj_is_project(source)? source : 
2782                 obj_get_module(source), TRUE); 
2783     }
2784
2785     obj_destroy(ab_action);
2786     connP_set_connection(NULL);
2787     populate_connection_list(connP_get_connection());
2788
2789     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
2790     
2791     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
2792     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
2793 }
2794
2795
2796 void 
2797 connP_register_connect_button(
2798     Widget widget,
2799     XtPointer clientData,
2800     XtPointer callData
2801 )
2802 {
2803     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
2804     
2805     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
2806
2807     /* Make Connect button initially inactive */
2808     XtSetSensitive(dtbSource->connect_button, FALSE);
2809     connect_button = dtbSource->connect_button;
2810
2811     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
2812     
2813     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
2814     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
2815 }
2816
2817
2818 void 
2819 connP_register_change_button(
2820     Widget widget,
2821     XtPointer clientData,
2822     XtPointer callData
2823 )
2824 {
2825     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
2826     
2827     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
2828     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
2829     
2830     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
2831
2832     /* Make Change button initially inactive */
2833     XtSetSensitive(dtbSource->change_button, FALSE);
2834     change_button = dtbSource->change_button;
2835
2836     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
2837 }
2838
2839
2840 void 
2841 connP_register_cancel_button(
2842     Widget widget,
2843     XtPointer clientData,
2844     XtPointer callData
2845 )
2846 {
2847     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
2848     
2849     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
2850     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
2851     
2852     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
2853
2854     cancel_button = dtbSource->cancel_button;
2855
2856     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
2857 }
2858
2859
2860 void 
2861 connP_register_delete_button(
2862     Widget widget,
2863     XtPointer clientData,
2864     XtPointer callData
2865 )
2866 {
2867     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
2868     
2869     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
2870
2871     /* Make Delete button initially inactive */
2872     XtSetSensitive(dtbSource->delete_button, FALSE);
2873     delete_button = dtbSource->delete_button;
2874
2875     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
2876     
2877     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
2878     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
2879 }
2880
2881
2882 void 
2883 connP_register_source_choices(
2884     Widget widget,
2885     XtPointer clientData,
2886     XtPointer callData
2887 )
2888 {
2889     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
2890     
2891     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
2892
2893     /*
2894      * jit - Workaround for dtcodegen bug:
2895      *          does not set XmNsubMenuId if Option Menu has 0 items
2896      */
2897     XtVaSetValues(widget, XmNsubMenuId, dtbSource->source_choices_menu, NULL);
2898
2899     src_menu = dtbSource->source_choices;
2900     populate_src_menu(dtbSource->source_choices_menu, NULL, NULL);
2901
2902     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
2903     
2904     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
2905     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
2906 }
2907
2908
2909 void 
2910 connP_register_target_choices(
2911     Widget widget,
2912     XtPointer clientData,
2913     XtPointer callData
2914 )
2915 {
2916     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
2917     
2918     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
2919
2920     /*
2921      * jit - Workaround for dtcodegen bug:
2922      *          does not set XmNsubMenuId if Option Menu has 0 items
2923      */
2924     XtVaSetValues(widget, XmNsubMenuId, dtbSource->target_choices_menu, NULL);
2925
2926     target_menu = dtbSource->target_choices;
2927     populate_target_menu(dtbSource->target_choices_menu, NULL, NULL);
2928
2929     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
2930     
2931     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
2932     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
2933 }
2934
2935
2936 void 
2937 connP_register_when_choices(
2938     Widget widget,
2939     XtPointer clientData,
2940     XtPointer callData
2941 )
2942 {
2943     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
2944     
2945     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
2946
2947     /*
2948      * jit - Workaround for dtcodegen bug:
2949      *          does not set XmNsubMenuId if Option Menu has 0 items
2950      */
2951     XtVaSetValues(widget, XmNsubMenuId, dtbSource->when_choices_menu, NULL);
2952
2953     when_menu = dtbSource->when_choices;
2954     populate_when_menu(dtbSource->when_choices_menu, NULL, NULL);
2955     XtAddCallback(XtParent(dtbSource->when_choices_menu),
2956                 XmNpopupCallback, connP_update_when_menu,
2957                 (XtPointer) NULL);
2958
2959     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
2960     
2961     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
2962     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
2963 }
2964
2965
2966 void 
2967 connP_register_predef_act_choices(
2968     Widget widget,
2969     XtPointer clientData,
2970     XtPointer callData
2971 )
2972 {
2973     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
2974     
2975     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
2976
2977     /*
2978      * jit - Workaround for dtcodegen bug:
2979      *          does not set XmNsubMenuId if Option Menu has 0 items
2980      */
2981     XtVaSetValues(widget, XmNsubMenuId, dtbSource->predef_act_choices_menu, NULL)
2982 ;
2983
2984     action_menu = dtbSource->predef_act_choices;
2985     populate_action_menu(dtbSource->predef_act_choices_menu, NULL, NULL);
2986     XtAddCallback(XtParent(dtbSource->predef_act_choices_menu),
2987                 XmNpopupCallback, connP_update_action_menu,
2988                 (XtPointer) NULL);
2989
2990     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
2991     
2992     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
2993     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
2994 }
2995
2996
2997 void 
2998 connP_register_view_choices(
2999     Widget widget,
3000     XtPointer clientData,
3001     XtPointer callData
3002 )
3003 {
3004     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
3005     
3006     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3007
3008     /*
3009      * jit - Workaround for dtcodegen bug:
3010      *          does not set XmNsubMenuId if Option Menu has 0 items
3011      */
3012     XtVaSetValues(widget, XmNsubMenuId, dtbSource->view_choices_menu, NULL);
3013
3014     view_menu = dtbSource->view_choices;
3015     populate_view_menu(dtbSource->view_choices_menu, NULL, NULL);
3016
3017     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3018     
3019     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3020     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3021 }
3022
3023
3024 void 
3025 connP_register_source_list(
3026     Widget widget,
3027     XtPointer clientData,
3028     XtPointer callData
3029 )
3030 {
3031     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
3032     
3033     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3034
3035     src_list = dtbSource->source_list;
3036     XtAddCallback(dtbSource->source_list, XmNbrowseSelectionCallback,
3037                   update_cur_src, NULL);
3038
3039     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3040     
3041     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3042     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3043 }
3044
3045
3046 void 
3047 connP_register_target_list(
3048     Widget widget,
3049     XtPointer clientData,
3050     XtPointer callData
3051 )
3052 {
3053     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
3054     
3055     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3056
3057     target_list = dtbSource->target_list;
3058     XtAddCallback(dtbSource->target_list, XmNbrowseSelectionCallback,
3059                   update_cur_target, NULL);
3060
3061     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3062     
3063     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3064     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3065 }
3066
3067
3068 void 
3069 connP_register_conn_list(
3070     Widget widget,
3071     XtPointer clientData,
3072     XtPointer callData
3073 )
3074 {
3075     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
3076     
3077     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3078
3079     connection_list = dtbSource->conn_list;
3080     XtAddCallback(dtbSource->conn_list, XmNbrowseSelectionCallback,
3081                   select_connection, NULL);
3082
3083     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3084     
3085     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3086     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3087 }
3088
3089
3090 void 
3091 connP_register_arg_field(
3092     Widget widget,
3093     XtPointer clientData,
3094     XtPointer callData
3095 )
3096 {
3097     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
3098     
3099     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3100
3101     arg_rowcol = dtbSource->arg_field_rowcolumn;
3102     arg_label = dtbSource->arg_field_label;
3103     arg_field = dtbSource->arg_field;
3104
3105     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3106     
3107     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3108     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3109 }
3110
3111
3112 void 
3113 connP_register_action_Predefined_item(
3114     Widget widget,
3115     XtPointer clientData,
3116     XtPointer callData
3117 )
3118 {
3119     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
3120     
3121     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3122
3123     std_action_item = dtbSource->action_type_choices_items.Predefined_item;
3124
3125     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3126     
3127     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3128     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3129 }
3130
3131
3132 void 
3133 connP_register_action_Call_Function_item(
3134     Widget widget,
3135     XtPointer clientData,
3136     XtPointer callData
3137 )
3138 {
3139     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
3140     
3141     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3142
3143     call_function_item =
3144         dtbSource->action_type_choices_items.Call_Function_item;
3145
3146     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3147     
3148     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3149     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3150 }
3151
3152
3153 void 
3154 connP_register_action_Execute_Code_item(
3155     Widget widget,
3156     XtPointer clientData,
3157     XtPointer callData
3158 )
3159 {
3160     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
3161     
3162     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3163
3164     execute_code_item =
3165         dtbSource->action_type_choices_items.Execute_Code_item;
3166
3167     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3168     
3169     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3170     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3171 }
3172
3173
3174 void 
3175 connP_show_execute_code(
3176     Widget widget,
3177     XtPointer clientData,
3178     XtPointer callData
3179 )
3180 {
3181     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3182
3183     DtbConnExecCodeDialogInfo   dtbSource = &dtb_conn_exec_code_dialog;
3184
3185     if (!(dtbSource->initialized))
3186     {
3187         dtb_conn_exec_code_dialog_initialize(dtbSource, dtb_palette_ab_palette_main.ab_palette_main);
3188         init_exec_code_dialog(dtbSource);
3189     }
3190
3191     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3192     
3193     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3194
3195     set_execute_code_action_type();
3196     ab_show_window(exec_code_dialog);
3197
3198     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3199 }
3200
3201
3202 void 
3203 connP_register_action_on_item_help_item(
3204     Widget widget,
3205     XtPointer clientData,
3206     XtPointer callData
3207 )
3208 {
3209     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
3210     
3211     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3212     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3213     
3214     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3215
3216     on_item_help_item = widget;
3217
3218     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3219 }
3220
3221
3222 void 
3223 connP_register_action_help_vol_item(
3224     Widget widget,
3225     XtPointer clientData,
3226     XtPointer callData
3227 )
3228 {
3229     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
3230     
3231     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3232     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3233     
3234     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3235     
3236     help_volume_item = widget;
3237
3238     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3239 }
3240
3241
3242 void 
3243 connP_register_loc_textf(
3244     Widget widget,
3245     XtPointer clientData,
3246     XtPointer callData
3247 )
3248 {
3249     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
3250     
3251     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3252     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3253     
3254     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3255
3256     location_rowcol = dtbSource->loc_textf_rowcolumn;
3257     location_field = dtbSource->loc_textf;
3258
3259     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3260 }
3261
3262
3263 void 
3264 connP_register_vol_textf(
3265     Widget widget,
3266     XtPointer clientData,
3267     XtPointer callData
3268 )
3269 {
3270     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
3271     
3272     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3273     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3274     
3275     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3276
3277     volume_rowcol = dtbSource->vol_textf_rowcolumn;
3278     volume_field = dtbSource->vol_textf;
3279
3280     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3281 }
3282
3283
3284 void 
3285 connP_register_action_type_opmenu(
3286     Widget widget,
3287     XtPointer clientData,
3288     XtPointer callData
3289 )
3290 {
3291     DtbConnConnDialogInfo       dtbSource = (DtbConnConnDialogInfo)callData;
3292     
3293     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3294     
3295     XmString    xmstr = NULL;
3296     STRING      label = NULL;
3297
3298     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3299     
3300     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3301
3302     action_type_opmenu = widget;
3303     
3304     XtVaGetValues(std_action_item, XmNlabelString, &xmstr, NULL);
3305     action_type_labels[ACTION_TYPE_PREDEFINED] = objxm_xmstr_to_str(xmstr);
3306     xmstr = NULL;
3307     
3308     XtVaGetValues(call_function_item, XmNlabelString, &xmstr, NULL);
3309     action_type_labels[ACTION_TYPE_CALLFUNC] = objxm_xmstr_to_str(xmstr);
3310     xmstr = NULL;
3311     
3312     XtVaGetValues(execute_code_item, XmNlabelString, &xmstr, NULL);
3313     action_type_labels[ACTION_TYPE_EXECUTE_CODE] = objxm_xmstr_to_str(xmstr);
3314     xmstr = NULL;
3315
3316     XtVaGetValues(on_item_help_item, XmNlabelString, &xmstr, NULL);
3317     action_type_labels[ACTION_TYPE_ON_ITEM_HELP] = objxm_xmstr_to_str(xmstr);
3318     xmstr = NULL;
3319
3320     XtVaGetValues(help_volume_item, XmNlabelString, &xmstr, NULL);
3321     action_type_labels[ACTION_TYPE_HELP_VOLUME] = objxm_xmstr_to_str(xmstr);
3322     xmstr = NULL;
3323
3324     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3325 }
3326
3327
3328 void 
3329 connP_enable_std_actions(
3330     Widget widget,
3331     XtPointer clientData,
3332     XtPointer callData
3333 )
3334 {
3335     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3336     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3337     
3338     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3339
3340     set_standard_action_type();
3341
3342     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3343 }
3344
3345
3346 void 
3347 connP_enable_call_function(
3348     Widget widget,
3349     XtPointer clientData,
3350     XtPointer callData
3351 )
3352 {
3353     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3354     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3355     
3356     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3357
3358     set_call_function_action_type();
3359
3360     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3361 }
3362
3363
3364 void 
3365 connP_enable_on_item_help(
3366     Widget widget,
3367     XtPointer clientData,
3368     XtPointer callData
3369 )
3370 {
3371     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3372     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3373     
3374     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3375
3376     set_on_item_help_action_type();
3377     if (connP_conn_is_possible())
3378         set_conn_controls(TRUE);
3379     else
3380         set_conn_controls(FALSE);
3381
3382     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3383 }
3384
3385
3386 void 
3387 connP_enable_access_help_vol(
3388     Widget widget,
3389     XtPointer clientData,
3390     XtPointer callData
3391 )
3392 {
3393     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3394     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3395     
3396     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3397
3398     set_access_help_vol_action_type();
3399     if (connP_conn_is_possible())
3400         set_conn_controls(TRUE);
3401     else
3402         set_conn_controls(FALSE);
3403
3404     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3405 }
3406
3407
3408 void 
3409 connP_exec_code_okCB(
3410     Widget widget,
3411     XtPointer clientData,
3412     XtPointer callData
3413 )
3414 {
3415     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3416
3417     STRING      code_frag = NULL;
3418     STRING      first_line = NULL;
3419     char        *newline = NULL;
3420     DtbConnExecCodeDialogInfo   dtbSource =
3421                         (DtbConnExecCodeDialogInfo) clientData;
3422
3423     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3424     
3425     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3426
3427     code_frag = XmTextGetString(exec_code_textpane);
3428     if (!util_strempty(code_frag))
3429     {
3430         if (CodeFragBuf)
3431             util_free(CodeFragBuf);
3432         CodeFragBuf = strdup(code_frag);
3433
3434         newline = strchr(code_frag, '\n');
3435         if (newline)
3436         {
3437             *newline = '\0';
3438         }
3439         first_line = (STRING)util_malloc(strlen(code_frag) + 4);
3440         if (first_line)
3441         {
3442             strcpy(first_line, code_frag);
3443             strcat(first_line, "...");
3444             XmTextFieldSetString(arg_field, first_line);
3445             util_free(first_line);
3446         }
3447     }
3448     else
3449     {
3450         if (CodeFragBuf)
3451             util_free(CodeFragBuf);
3452         if (code_frag)
3453             CodeFragBuf = strdup(code_frag);
3454         else
3455             CodeFragBuf = NULL;
3456         XmTextFieldSetString(arg_field, "");
3457     }
3458
3459     XtFree(code_frag);
3460     ui_win_show(exec_code_dialog, False, XtGrabNone);
3461             
3462     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3463 }
3464
3465
3466 void 
3467 connP_exec_code_applyCB(
3468     Widget widget,
3469     XtPointer clientData,
3470     XtPointer callData
3471 )
3472 {
3473     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3474
3475     STRING      code_frag = NULL;
3476     STRING      first_line = NULL;
3477     char        *newline = NULL;
3478
3479     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3480     
3481     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3482
3483     code_frag = XmTextGetString(exec_code_textpane);
3484     if (!util_strempty(code_frag))
3485     {
3486         if (CodeFragBuf)
3487             util_free(CodeFragBuf);
3488         CodeFragBuf = strdup(code_frag);
3489
3490         newline = strchr(code_frag, '\n'); 
3491         if (newline)
3492         {
3493             *newline = '\0';
3494         }
3495         first_line = (STRING)util_malloc(strlen(code_frag) + 4);
3496         if (first_line)
3497         {
3498             strcpy(first_line, code_frag);
3499             strcat(first_line, "...");
3500             XmTextFieldSetString(arg_field, first_line);
3501             util_free(first_line);
3502         }
3503     }  
3504     else
3505     {
3506         if (CodeFragBuf)
3507             util_free(CodeFragBuf);
3508         if (code_frag)
3509             CodeFragBuf = strdup(code_frag);
3510         else 
3511             CodeFragBuf = NULL; 
3512         XmTextFieldSetString(arg_field, "");
3513     }
3514
3515     XtFree(code_frag);
3516
3517     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3518 }
3519
3520
3521 void 
3522 exec_code_cancelCB(
3523     Widget widget,
3524     XtPointer clientData,
3525     XtPointer callData
3526 )
3527 {
3528     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3529     DtbConnExecCodeDialogInfo   dtbSource = (DtbConnExecCodeDialogInfo)clientData;
3530     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3531     
3532     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3533     ui_win_show(exec_code_dialog, False, XtGrabNone);
3534     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3535 }
3536
3537
3538 void 
3539 connP_clear_exec_dlg(
3540     Widget widget,
3541     XtPointer clientData,
3542     XtPointer callData
3543 )
3544 {
3545     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
3546     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
3547     
3548     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
3549
3550     XmTextSetString(exec_code_textpane, "");
3551
3552     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
3553 }
3554
3555
3556
3557 /**************************************************************************
3558  *** DTB_USER_CODE_START
3559  ***
3560  *** All automatically-generated data and functions have been defined.
3561  ***
3562  *** Add new functions here, or at the top of the file.
3563  ***/
3564
3565 /*
3566 ** This function checks to see if a show-help connection can be allowed
3567 ** between any source/target object pair.  The rule it implements is that
3568 ** the source object must be a push or drawn button that is a child of the
3569 ** target dialog;
3570 */
3571 BOOL
3572 allow_show_help_connection(
3573         ABObj src_obj,
3574         ABObj target_obj
3575 )
3576 {
3577     AB_OBJECT_TYPE      src_type;
3578     AB_OBJECT_TYPE      target_type;
3579     int                 src_subtype;
3580
3581     if( (src_obj == (ABObj)NULL) || (target_obj == (ABObj)NULL)) return(FALSE);
3582
3583     src_type    = obj_get_type(src_obj);
3584     target_type = obj_get_type(target_obj);
3585     src_subtype = obj_get_subtype(src_obj);
3586
3587     if( (target_type == AB_TYPE_DIALOG) &&
3588         (src_type == AB_TYPE_BUTTON)  &&
3589         ((src_subtype == AB_BUT_PUSH) || (src_subtype == AB_BUT_DRAWN) ) &&
3590         (obj_get_parent_of_type(src_obj,AB_TYPE_DIALOG) == target_obj) ) {
3591             return(TRUE);
3592     }
3593     else return(FALSE);
3594 }
3595
3596 static void 
3597 hide_execute_code_win(void)
3598 {
3599     DtbConnExecCodeDialogInfo   instance = &dtb_conn_exec_code_dialog;
3600  
3601     if (!(instance->initialized))
3602     {
3603         dtb_conn_exec_code_dialog_initialize(instance, dtb_palette_ab_palette_main.ab_palette_main);
3604         init_exec_code_dialog(instance);
3605     }
3606     ui_win_show(exec_code_dialog, False, XtGrabNone);
3607 }
3608
3609 /* This function is the popupCallback for the "When" optionmenu.
3610  * It makes certain "whens" active or inactive depending upon
3611  * the object type and the specific object selected in the list.
3612  */
3613 void
3614 connP_update_when_menu(
3615     Widget widget,
3616     XtPointer clientData,
3617     XtPointer callData
3618 )
3619 {
3620     ABObj       cur_obj = connP_get_source();
3621     Widget      *w_list = NULL;
3622
3623     XtVaGetValues(when_pulldown, XmNuserData, &w_list, NULL);
3624
3625     if (w_list == NULL)
3626     {
3627         return;
3628     }
3629
3630     switch (connP_get_source_type())
3631     {
3632         /* If the current source object type is Choice Item,
3633          * then we have to check if the currently selected
3634          * object is a radiobox/checkbox item or if it is an
3635          * optionmenu item. If it is a radiobox/checkbox item
3636          * then "Toggled" should become active and "Activated"
3637          * should become inactive - vice versa if currently
3638          * selected object is an optionmenu item.
3639          */
3640         case AB_TYPE_ITEM:
3641             if (obj_is_choice_item(cur_obj)) 
3642             {
3643                 if (obj_is_option_menu(obj_get_root(obj_get_parent(cur_obj))))
3644                 {
3645                     XtSetSensitive(w_list[ConnP_conn_whens[2].when_type-1], True);
3646                     XtSetSensitive(w_list[ConnP_conn_whens[3].when_type-1], False);
3647                 }
3648                 else
3649                 {
3650                     XtSetSensitive(w_list[ConnP_conn_whens[2].when_type-1], False);
3651                     XtSetSensitive(w_list[ConnP_conn_whens[3].when_type-1], True);
3652                 }
3653             }
3654             break;
3655
3656         case AB_TYPE_MESSAGE:
3657             if (cur_obj != NULL)
3658             {
3659                 if (!obj_has_action1_button(cur_obj))
3660                    XtSetSensitive(w_list[ConnP_conn_whens[0].when_type-1],
3661                                  False);
3662                 else
3663                    XtSetSensitive(w_list[ConnP_conn_whens[0].when_type-1],
3664                                  True);
3665                 if (!obj_has_action2_button(cur_obj))
3666                    XtSetSensitive(w_list[ConnP_conn_whens[1].when_type-1],
3667                                  False);
3668                 else
3669                    XtSetSensitive(w_list[ConnP_conn_whens[1].when_type-1],
3670                                  True);
3671                 if (!obj_has_action3_button(cur_obj))
3672                    XtSetSensitive(w_list[ConnP_conn_whens[2].when_type-1],
3673                                  False);
3674                 else
3675                    XtSetSensitive(w_list[ConnP_conn_whens[2].when_type-1],
3676                                  True);
3677                 if (!obj_has_cancel_button(cur_obj))
3678                    XtSetSensitive(w_list[ConnP_conn_whens[3].when_type-1],
3679                                  False);
3680                 else
3681                    XtSetSensitive(w_list[ConnP_conn_whens[3].when_type-1],
3682                                  True);
3683             }
3684  
3685             break;
3686  
3687         default:
3688             break;
3689     }
3690        
3691 }
3692
3693 /* This function is the popupCallback for the "Action Type"
3694  * optionmenu.
3695  */
3696 void
3697 connP_update_action_menu(
3698     Widget widget,
3699     XtPointer clientData,
3700     XtPointer callData
3701 )
3702 {
3703     ABObj               src_obj = connP_get_source();
3704     ABObj               target_obj = connP_get_target();
3705     AB_OBJECT_TYPE      target_type = connP_get_target_type();
3706     Widget              *w_list = NULL;
3707
3708     XtVaGetValues(action_pulldown, XmNuserData, &w_list, NULL);
3709
3710     if (w_list == NULL)
3711         return;
3712
3713     switch (target_type)
3714     {
3715         /* If any target object of these types don't have
3716          * a label, then set "Set Label" action inactive.
3717          */
3718         case AB_TYPE_CHOICE:
3719         case AB_TYPE_COMBO_BOX:
3720         case AB_TYPE_LIST:
3721         case AB_TYPE_SPIN_BOX:
3722         case AB_TYPE_SCALE:
3723         case AB_TYPE_TEXT_FIELD:
3724             if (!obj_has_label(target_obj))
3725                 XtSetSensitive(w_list[AB_STDACT_SET_LABEL-1], False);
3726             else
3727                 XtSetSensitive(w_list[AB_STDACT_SET_LABEL-1], True);
3728         default:
3729             break;
3730     }
3731 }
3732
3733 void
3734 conn_override_default_when(
3735     AB_WHEN     when
3736 )
3737 {
3738     DefaultWhen = when;
3739 }
3740
3741 void
3742 conn_reset_default_when(void)
3743 {
3744     DefaultWhen = AB_WHEN_UNDEF;
3745 }
3746
3747 void
3748 conn_override_default_action_type(
3749     AB_FUNC_TYPE     func_type
3750 )
3751 {
3752     DefaultFuncType = func_type;
3753 }
3754  
3755 void
3756 conn_reset_default_action_type(void)
3757 {
3758     DefaultFuncType = AB_FUNC_UNDEF;
3759 }
3760
3761 static void
3762 update_on_src_type_change(
3763     AB_OBJECT_TYPE      obj_type,
3764     int                 obj_subtype
3765 )
3766 {
3767     AB_WHEN             g_when = AB_WHEN_UNDEF;
3768     AB_FUNC_TYPE        g_func = AB_FUNC_UNDEF;
3769     AB_BUILTIN_ACTION   g_act = AB_STDACT_UNDEF;
3770     
3771     if (obj_type == (AB_OBJECT_TYPE) NULL)
3772         return;
3773  
3774     /* Update the When option menu */
3775     connP_set_source_type(obj_type, obj_subtype);
3776
3777     /* Get the default when and action type */
3778     (void)connP_guess_when_action(obj_type, obj_subtype,
3779                 connP_get_target_type(),
3780                 connP_get_target_subtype(),
3781                 &g_when, &g_func, &g_act);
3782
3783     /* Set the default when */
3784     if (DefaultWhen != AB_WHEN_UNDEF)
3785         g_when = DefaultWhen;
3786
3787     if (g_when != get_cur_when())
3788         set_cur_when(g_when);
3789
3790     /* Set the default Action Type */
3791     if (DefaultFuncType != AB_FUNC_UNDEF)
3792         g_func = DefaultFuncType;
3793
3794     if (g_func == AB_FUNC_USER_DEF)
3795     {   
3796         ui_optionmenu_change_label(action_type_opmenu,
3797                 action_type_labels[ACTION_TYPE_CALLFUNC]);
3798         set_call_function_action_type();
3799     }   
3800     else
3801     {  
3802         ui_optionmenu_change_label(action_type_opmenu,
3803                 action_type_labels[ACTION_TYPE_PREDEFINED]);
3804         set_standard_action_type();
3805     }
3806  
3807     /* Update the Source object list and select the current
3808      * source object (if there is one) in the list.
3809      */
3810     populate_list(src_list, connP_get_source(), TRUE);
3811 }
3812
3813 static void
3814 update_on_target_type_change(
3815     AB_OBJECT_TYPE      obj_type,
3816     int                 obj_subtype
3817 )
3818 {
3819     AB_WHEN             g_when = AB_WHEN_UNDEF;
3820     AB_FUNC_TYPE        g_func = AB_FUNC_UNDEF;
3821     AB_BUILTIN_ACTION   g_act = AB_STDACT_UNDEF;
3822     
3823     if (obj_type == (AB_OBJECT_TYPE) NULL)
3824         return;
3825  
3826     /* Update the Action option menu */
3827     connP_set_target_type(obj_type, obj_subtype);
3828
3829     /* Get the default pre-defined action */
3830     (void)connP_guess_when_action(connP_get_source_type(),
3831                                 connP_get_source_subtype(),
3832                                 obj_type, obj_subtype,
3833                                 &g_when, &g_func, &g_act);
3834
3835     if (g_act != get_cur_act())
3836         set_cur_act(g_act);
3837
3838     /* Update the Target object list and select the current
3839      * source object (if there is one) in the list.
3840      */
3841     populate_list(target_list, connP_get_target(), TRUE);
3842 }
3843
3844 static void
3845 update_conn_ed_controls(void)
3846 {
3847     AB_WHEN             g_when = AB_WHEN_UNDEF;
3848     AB_FUNC_TYPE        g_func = AB_FUNC_UNDEF;
3849     AB_BUILTIN_ACTION   g_act = AB_STDACT_UNDEF;
3850     AB_OBJECT_TYPE      source_type = AB_TYPE_UNDEF; 
3851     int                 source_subtype = -1;
3852     AB_OBJECT_TYPE      target_type = AB_TYPE_UNDEF; 
3853     int                 target_subtype = -1;
3854     int                 i = -1, j = -1;
3855
3856     source_type = connP_get_source_type();
3857     source_subtype = connP_get_source_subtype();
3858     i = connP_get_obj_type_index(source_type, source_subtype);
3859
3860     target_type = connP_get_target_type();
3861     target_subtype = connP_get_target_subtype();
3862     j = connP_get_obj_type_index(target_type, target_subtype);
3863
3864     if ((i < 0) || (j < 0)) return;
3865
3866     /* Update the Source option menu */
3867     XtVaSetValues(XmOptionButtonGadget(src_menu),
3868         XtVaTypedArg, XmNlabelString, XtRString,
3869             ConnP_conn_objs[i].label, strlen(ConnP_conn_objs[i].label)+1,
3870         NULL);
3871     update_on_src_type_change(source_type, source_subtype);
3872
3873     /* Update the Target option menu */
3874     XtVaSetValues(XmOptionButtonGadget(target_menu),
3875         XtVaTypedArg, XmNlabelString, XtRString,
3876             ConnP_conn_objs[j].label, strlen(ConnP_conn_objs[j].label)+1,
3877         NULL);
3878     update_on_target_type_change(target_type, target_subtype);
3879
3880     if (connP_conn_is_possible())
3881         set_conn_controls(TRUE);
3882     else
3883         set_conn_controls(FALSE);
3884 }
3885
3886 static AB_FUNC_TYPE
3887 get_cur_func_type(void)
3888 {
3889     Widget      label_wid = XmOptionButtonGadget(action_type_opmenu);
3890     XmString    xm_act_label    = (XmString)NULL;
3891     char        *act_label;
3892     register int        i;
3893     AB_FUNC_TYPE        func_type = AB_FUNC_UNDEF;
3894  
3895     XtVaGetValues(label_wid, XmNlabelString, &xm_act_label, NULL);
3896     if (xm_act_label != NULL)
3897         act_label = objxm_xmstr_to_str(xm_act_label);
3898  
3899     for (i = 0; i < ACTION_TYPE_NUM_VALUES; i++)
3900         if (!strcmp(act_label, action_type_labels[i]))
3901             break;
3902
3903     switch (i)
3904     {
3905         case ACTION_TYPE_PREDEFINED:
3906             func_type = AB_FUNC_BUILTIN;    
3907             break;
3908         case ACTION_TYPE_CALLFUNC:
3909             func_type = AB_FUNC_USER_DEF;
3910             break;
3911         case ACTION_TYPE_EXECUTE_CODE:
3912             func_type = AB_FUNC_CODE_FRAG;    
3913             break;
3914         case ACTION_TYPE_ON_ITEM_HELP:
3915             func_type = AB_FUNC_ON_ITEM_HELP;    
3916             break;
3917         case ACTION_TYPE_HELP_VOLUME:
3918             func_type = AB_FUNC_HELP_VOLUME;    
3919             break;
3920         default:
3921             break;
3922     }
3923     
3924     XtFree(act_label);
3925     return(func_type);
3926 }
3927
3928 BOOL
3929 connP_obj_part_of_conn(
3930     ABObj       obj,
3931     ABObj       conn_obj
3932 )
3933 {
3934     BOOL        ret = FALSE;
3935
3936     if (obj && conn_obj)
3937     {
3938         if (obj_get_from(conn_obj) == obj)
3939             ret = TRUE;
3940         else if (obj_get_to(conn_obj) == obj)
3941             ret = TRUE;
3942     }
3943     return ret;
3944 }
3945
3946 static void
3947 set_ctrls_for_src(
3948     BOOL        state
3949 )
3950 {
3951     Widget      when_opmenu = XmOptionButtonGadget(when_menu);
3952
3953     XtSetSensitive(when_opmenu, state);
3954 }
3955
3956 static void
3957 set_ctrls_for_target(
3958     BOOL        state
3959
3960 {
3961     Widget              act_opmenu = XmOptionButtonGadget(action_menu);
3962     AB_FUNC_TYPE        cat = connP_get_action_type();
3963
3964     switch (cat)
3965     {
3966         case AB_FUNC_BUILTIN:
3967             XtSetSensitive(act_opmenu, state); 
3968             /* If setting the action option menu active,
3969              * then we have to look at the action to
3970              * determine if the argument field should
3971              * also become active.
3972              */
3973             if (state)
3974             {
3975                 change_arg_sensitivity(arg_field, 
3976                         (XtPointer) NULL, (XtPointer) NULL);
3977             }
3978             else
3979             {
3980                 XtSetSensitive(arg_label, state);
3981                 XtSetSensitive(arg_field, state);
3982             }
3983         break;
3984
3985         case AB_FUNC_USER_DEF:
3986         case AB_FUNC_CODE_FRAG:
3987             XtSetSensitive(arg_label, state);
3988             XtSetSensitive(arg_field, state);
3989         break;
3990         
3991         default: break;
3992     }
3993 }
3994
3995 /*** DTB_USER_CODE_END
3996  ***
3997  *** End of user code section
3998  ***
3999  **************************************************************************/
4000
4001