Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtappbuilder / src / ab / conn_obj.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*
24  *      $XConsortium: conn_obj.c /main/4 1996/07/03 16:57:53 mustafa $
25  *
26  * @(#)conn_obj.c       1.17 17 Feb 1994        cde_app_builder/src/ab
27  *
28  *      RESTRICTED CONFIDENTIAL INFORMATION:
29  *
30  *      The information in this document is subject to special
31  *      restrictions in a confidential disclosure agreement between
32  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
33  *      document outside HP, IBM, Sun, USL, SCO, or Univel without
34  *      Sun's specific written approval.  This document and all copies
35  *      and derivative works thereof must be returned or destroyed at
36  *      Sun's request.
37  *
38  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
39  *
40  */
41
42
43 #include <stdio.h>
44 #include <ab_private/obj.h>
45 #include <ab_private/trav.h>
46
47 #include <ab_private/connP.h>
48 #include <ab_private/brws.h>
49 #include <ab_private/abobj.h>
50 #include "dtbuilder.h"
51
52 static char *when_labels[(int)AB_WHEN_NUM_VALUES+1];
53 static char *stdact_labels[(int)AB_BUILTIN_ACTION_NUM_VALUES+1];
54 static char     *unknown_str = NULL;
55 static char     *invalid_str = NULL;
56
57 static AB_WHEN
58 application_whens[] =
59 {
60     AB_WHEN_SESSION_SAVE,
61     AB_WHEN_SESSION_RESTORE,
62     AB_WHEN_TOOLTALK_DO_COMMAND,
63     AB_WHEN_TOOLTALK_GET_STATUS,
64     AB_WHEN_TOOLTALK_PAUSE_RESUME,
65     AB_WHEN_TOOLTALK_QUIT,
66 };
67
68 static AB_WHEN
69 basewin_whens[] =
70 {
71     AB_WHEN_AFTER_CREATED,
72     AB_WHEN_DESTROYED,
73     AB_WHEN_HIDDEN,
74     AB_WHEN_SHOWN,
75     AB_WHEN_DRAGGED_FROM,
76     AB_WHEN_DROPPED_ON
77 };
78
79 static AB_BUILTIN_ACTION
80 basewin_acts[] =
81 {
82     AB_STDACT_DISABLE,
83     AB_STDACT_ENABLE,
84     AB_STDACT_HIDE,
85     AB_STDACT_SHOW,
86 };
87
88 static AB_WHEN
89 button_whens[] =
90 {
91     AB_WHEN_AFTER_CREATED,
92     AB_WHEN_DESTROYED,
93     AB_WHEN_ACTIVATED,
94 };
95
96 static AB_BUILTIN_ACTION
97 button_acts[] =
98 {
99     AB_STDACT_DISABLE,
100     AB_STDACT_ENABLE,
101     AB_STDACT_HIDE,
102     AB_STDACT_SHOW,
103     AB_STDACT_SET_LABEL,
104 };
105
106 static AB_WHEN
107 choice_whens[] =
108 {
109     AB_WHEN_AFTER_CREATED,
110     AB_WHEN_DESTROYED,
111 };
112
113 static AB_BUILTIN_ACTION
114 choice_acts[] =
115 {
116     AB_STDACT_DISABLE,
117     AB_STDACT_ENABLE,
118     AB_STDACT_HIDE,
119     AB_STDACT_SHOW,
120     AB_STDACT_SET_LABEL,
121 };
122
123 static AB_WHEN
124 combobox_whens[] =
125 {
126     AB_WHEN_AFTER_CREATED,
127     AB_WHEN_DESTROYED,
128     AB_WHEN_ITEM_SELECTED,
129 };
130
131 static AB_BUILTIN_ACTION
132 combobox_acts[] =
133 {
134     AB_STDACT_DISABLE,
135     AB_STDACT_ENABLE,
136     AB_STDACT_HIDE,
137     AB_STDACT_SHOW,
138     AB_STDACT_SET_LABEL,
139 };
140
141 static AB_WHEN
142 container_whens[] =
143 {
144     AB_WHEN_AFTER_CREATED,
145     AB_WHEN_DESTROYED,
146     AB_WHEN_DRAGGED_FROM,
147     AB_WHEN_DROPPED_ON,
148 };
149
150 static AB_BUILTIN_ACTION
151 container_acts[] =
152 {
153     AB_STDACT_DISABLE,
154     AB_STDACT_ENABLE,
155     AB_STDACT_HIDE,
156     AB_STDACT_SHOW,
157 };
158
159 static AB_WHEN
160 group_whens[] =
161 {
162     AB_WHEN_AFTER_CREATED,
163     AB_WHEN_DESTROYED,
164 };
165
166 static AB_BUILTIN_ACTION
167 group_acts[] =
168 {
169     AB_STDACT_DISABLE,
170     AB_STDACT_ENABLE,
171     AB_STDACT_HIDE,
172     AB_STDACT_SHOW,
173 };
174
175 static AB_WHEN
176 menubar_whens[] = 
177
178     AB_WHEN_AFTER_CREATED, 
179     AB_WHEN_DESTROYED, 
180 };
181  
182 static AB_BUILTIN_ACTION 
183 menubar_acts[] = 
184
185     AB_STDACT_DISABLE, 
186     AB_STDACT_ENABLE, 
187     AB_STDACT_HIDE, 
188     AB_STDACT_SHOW, 
189 };
190
191 static AB_WHEN
192 panedwin_whens[] = 
193
194     AB_WHEN_AFTER_CREATED, 
195     AB_WHEN_DESTROYED, 
196 };
197  
198 static AB_BUILTIN_ACTION 
199 panedwin_acts[] = 
200
201     AB_STDACT_DISABLE, 
202     AB_STDACT_ENABLE, 
203     AB_STDACT_HIDE, 
204     AB_STDACT_SHOW, 
205 };
206
207 static AB_WHEN
208 dialog_whens[] =
209 {
210     AB_WHEN_AFTER_CREATED,
211     AB_WHEN_DESTROYED,
212     AB_WHEN_HIDDEN,
213     AB_WHEN_SHOWN,
214     AB_WHEN_DRAGGED_FROM,
215     AB_WHEN_DROPPED_ON
216 };
217
218 static AB_BUILTIN_ACTION
219 dialog_acts[] =
220 {
221     AB_STDACT_DISABLE,
222     AB_STDACT_ENABLE,
223     AB_STDACT_HIDE,
224     AB_STDACT_SHOW,
225 };
226
227 static AB_WHEN
228 drawarea_whens[] =
229 {
230     AB_WHEN_AFTER_CREATED,
231     AB_WHEN_DESTROYED,
232     AB_WHEN_DRAGGED_FROM,
233     AB_WHEN_DROPPED_ON,
234     AB_WHEN_REPAINT_NEEDED,
235     AB_WHEN_AFTER_RESIZED,
236 };
237
238 static AB_BUILTIN_ACTION
239 drawarea_acts[] =
240 {
241     AB_STDACT_DISABLE,
242     AB_STDACT_ENABLE,
243     AB_STDACT_HIDE,
244     AB_STDACT_SHOW,
245 };
246
247 static AB_WHEN
248 label_whens[] =
249 {
250     AB_WHEN_AFTER_CREATED,
251     AB_WHEN_DESTROYED,
252     AB_WHEN_DRAGGED_FROM,
253     AB_WHEN_DROPPED_ON,
254 };
255
256 static AB_BUILTIN_ACTION
257 label_acts[] =
258 {
259     AB_STDACT_DISABLE,
260     AB_STDACT_ENABLE,
261     AB_STDACT_HIDE,
262     AB_STDACT_SHOW,
263     AB_STDACT_SET_LABEL,
264 };
265
266 static AB_WHEN
267 list_whens[] =
268 {
269     AB_WHEN_AFTER_CREATED,
270     AB_WHEN_DESTROYED,
271     AB_WHEN_DOUBLE_CLICKED_ON,
272     AB_WHEN_DRAGGED_FROM,
273     AB_WHEN_DROPPED_ON,
274     AB_WHEN_ITEM_SELECTED,
275 };
276
277 static AB_BUILTIN_ACTION
278 list_acts[] =
279 {
280     AB_STDACT_DISABLE,
281     AB_STDACT_ENABLE,
282     AB_STDACT_HIDE,
283     AB_STDACT_SHOW,
284     AB_STDACT_SET_LABEL,
285 };
286
287 static AB_WHEN
288 menu_whens[] =
289 {
290     AB_WHEN_AFTER_CREATED,
291     AB_WHEN_DESTROYED,
292     AB_WHEN_POPPED_UP,
293     AB_WHEN_POPPED_DOWN,
294 };
295
296 static AB_WHEN
297 separator_whens[] =
298 {
299     AB_WHEN_AFTER_CREATED,
300     AB_WHEN_DESTROYED,
301 };
302
303 static AB_BUILTIN_ACTION
304 separator_acts[] =
305 {
306     AB_STDACT_DISABLE,
307     AB_STDACT_ENABLE,
308     AB_STDACT_HIDE,
309     AB_STDACT_SHOW,
310 };
311
312 static AB_WHEN
313 scale_whens[] =
314 {
315     AB_WHEN_AFTER_CREATED,
316     AB_WHEN_DESTROYED,
317     AB_WHEN_DRAGGED,
318     AB_WHEN_VALUE_CHANGED,
319 };
320
321 static AB_BUILTIN_ACTION
322 scale_acts[] =
323 {
324     AB_STDACT_DISABLE,
325     AB_STDACT_ENABLE,
326     AB_STDACT_HIDE,
327     AB_STDACT_SHOW,
328     AB_STDACT_SET_LABEL,
329     AB_STDACT_SET_VALUE,
330 };
331
332 static AB_WHEN
333 spinbox_whens[] =
334 {
335     AB_WHEN_AFTER_CREATED,
336     AB_WHEN_DESTROYED,
337     AB_WHEN_VALUE_CHANGED,
338 };
339
340 static AB_BUILTIN_ACTION
341 spinbox_acts[] =
342 {
343     AB_STDACT_DISABLE,
344     AB_STDACT_ENABLE,
345     AB_STDACT_HIDE,
346     AB_STDACT_SHOW,
347     AB_STDACT_SET_LABEL,
348     AB_STDACT_SET_VALUE,
349 };
350
351 static AB_WHEN
352 termpane_whens[] =
353 {
354     AB_WHEN_AFTER_CREATED,
355     AB_WHEN_DESTROYED,
356 };
357
358 static AB_BUILTIN_ACTION
359 termpane_acts[] =
360 {
361     AB_STDACT_DISABLE,
362     AB_STDACT_ENABLE,
363     AB_STDACT_HIDE,
364     AB_STDACT_SHOW,
365 };
366
367 static AB_WHEN
368 textfield_whens[] =
369 {
370     AB_WHEN_AFTER_CREATED,
371     AB_WHEN_DESTROYED,
372     AB_WHEN_BEFORE_TEXT_CHANGED,
373     AB_WHEN_TEXT_CHANGED,
374 };
375
376 static AB_BUILTIN_ACTION
377 textfield_acts[] =
378 {
379     AB_STDACT_DISABLE,
380     AB_STDACT_ENABLE,
381     AB_STDACT_HIDE,
382     AB_STDACT_SHOW,
383     AB_STDACT_SET_LABEL,
384     AB_STDACT_SET_TEXT,
385 };
386
387 static AB_WHEN
388 textpane_whens[] =
389 {
390     AB_WHEN_AFTER_CREATED,
391     AB_WHEN_DESTROYED,
392     AB_WHEN_BEFORE_TEXT_CHANGED,
393     AB_WHEN_TEXT_CHANGED,
394 };
395
396 static AB_BUILTIN_ACTION
397 textpane_acts[] =
398 {
399     AB_STDACT_DISABLE,
400     AB_STDACT_ENABLE,
401     AB_STDACT_HIDE,
402     AB_STDACT_SHOW,
403     AB_STDACT_SET_TEXT,
404 };
405
406 static AB_WHEN
407 menuitem_whens[] =
408 {
409     AB_WHEN_AFTER_CREATED,
410     AB_WHEN_DESTROYED,
411     AB_WHEN_ACTIVATED,
412 };
413
414 static AB_BUILTIN_ACTION
415 menuitem_acts[] =
416 {
417     AB_STDACT_DISABLE,
418     AB_STDACT_ENABLE,
419     AB_STDACT_HIDE,
420     AB_STDACT_SHOW,
421     AB_STDACT_SET_LABEL,
422 };
423
424 static AB_WHEN
425 menubaritem_whens[] =
426 {
427     AB_WHEN_AFTER_CREATED,
428     AB_WHEN_DESTROYED,
429 };
430
431 static AB_BUILTIN_ACTION
432 menubaritem_acts[] =
433 {
434     AB_STDACT_DISABLE,
435     AB_STDACT_ENABLE,
436     AB_STDACT_HIDE,
437     AB_STDACT_SHOW,
438     AB_STDACT_SET_LABEL,
439 };
440
441 static AB_WHEN
442 choiceitem_whens[] =
443 {
444     AB_WHEN_AFTER_CREATED,
445     AB_WHEN_DESTROYED,
446     AB_WHEN_ACTIVATED,
447     AB_WHEN_TOGGLED,
448 };
449
450 static AB_BUILTIN_ACTION
451 choiceitem_acts[] =
452 {
453     AB_STDACT_DISABLE,
454     AB_STDACT_ENABLE,
455     AB_STDACT_HIDE,
456     AB_STDACT_SHOW,
457     AB_STDACT_SET_LABEL,
458 };
459
460 static AB_WHEN
461 message_whens[] =
462 {
463     AB_WHEN_ACTION1,
464     AB_WHEN_ACTION2,
465     AB_WHEN_ACTION3,
466     AB_WHEN_CANCEL,
467 };
468
469 static AB_WHEN
470 fchooser_whens[] =
471 {
472     AB_WHEN_AFTER_CREATED,
473     AB_WHEN_DESTROYED,
474     AB_WHEN_HIDDEN,
475     AB_WHEN_SHOWN,
476     AB_WHEN_OK,
477     AB_WHEN_CANCEL,
478 };
479
480 static AB_BUILTIN_ACTION
481 fchooser_acts[] =
482 {
483     AB_STDACT_HIDE,
484     AB_STDACT_SHOW,
485 };   
486
487 ConnObj
488 ConnP_conn_objs[] =
489 {
490     { AB_TYPE_PROJECT,  -1,             "Application",
491         application_whens, XtNumber(application_whens),
492         AB_WHEN_SESSION_SAVE,
493         (AB_BUILTIN_ACTION *) NULL, (Cardinal) 0,
494         (AB_BUILTIN_ACTION) NULL                        },
495     { AB_TYPE_BUTTON,   -1,             "Button",
496         button_whens, XtNumber(button_whens),
497         AB_WHEN_ACTIVATED,
498         button_acts, XtNumber(button_acts),
499         AB_STDACT_SET_LABEL                             },
500     { AB_TYPE_CHOICE,   -1,             "Choice",
501         choice_whens, XtNumber(choice_whens),
502         AB_WHEN_AFTER_CREATED,
503         choice_acts, XtNumber(choice_acts),
504         AB_STDACT_DISABLE                               },
505     { AB_TYPE_ITEM,     (int)AB_ITEM_FOR_CHOICE, "Choice Item",
506         choiceitem_whens, XtNumber(choiceitem_whens),
507         AB_WHEN_ACTIVATED,
508         choiceitem_acts, XtNumber(choiceitem_acts),
509         AB_STDACT_SET_LABEL                             },
510     { AB_TYPE_COMBO_BOX, -1,            "Combo Box",
511         combobox_whens, XtNumber(combobox_whens),
512         AB_WHEN_ITEM_SELECTED,
513         combobox_acts, XtNumber(combobox_acts),
514         AB_STDACT_DISABLE                               },
515     { AB_TYPE_CONTAINER, -1,            "Control Pane",
516         container_whens, XtNumber(container_whens),
517         AB_WHEN_AFTER_CREATED,
518         container_acts, XtNumber(container_acts),
519         AB_STDACT_DISABLE                               },
520     { AB_TYPE_DIALOG,   -1,             "Custom Dialog",
521         dialog_whens, XtNumber(dialog_whens),
522         AB_WHEN_SHOWN,
523         dialog_acts, XtNumber(dialog_acts),
524         AB_STDACT_SHOW                                  },
525     { AB_TYPE_DRAWING_AREA,     -1,     "Draw Area Pane",
526         drawarea_whens, XtNumber(drawarea_whens),
527         AB_WHEN_AFTER_RESIZED,
528         drawarea_acts, XtNumber(drawarea_acts),
529         AB_STDACT_DISABLE                               },
530     { AB_TYPE_FILE_CHOOSER,     -1,     "File Selection Dialog",
531         fchooser_whens, XtNumber(fchooser_whens),
532         AB_WHEN_SHOWN,
533         fchooser_acts, XtNumber(fchooser_acts),
534         AB_STDACT_SHOW                                  },
535     { AB_TYPE_CONTAINER, AB_CONT_GROUP, "Group",
536         group_whens, XtNumber(group_whens),
537         AB_WHEN_AFTER_CREATED,
538         group_acts, XtNumber(group_acts),
539         AB_STDACT_DISABLE                               },
540     { AB_TYPE_LABEL,    -1,             "Label",
541         label_whens, XtNumber(label_whens),
542         AB_WHEN_AFTER_CREATED,
543         label_acts, XtNumber(label_acts),
544         AB_STDACT_SET_LABEL                             },
545     { AB_TYPE_LIST,     -1,             "List",
546         list_whens, XtNumber(list_whens),
547         AB_WHEN_ITEM_SELECTED,
548         list_acts, XtNumber(list_acts),
549         AB_STDACT_DISABLE                               },
550     { AB_TYPE_BASE_WINDOW,      -1,     "Main Window",
551         basewin_whens, XtNumber(basewin_whens),
552         AB_WHEN_SHOWN,
553         basewin_acts, XtNumber(basewin_acts),
554         AB_STDACT_SHOW                                  },
555     { AB_TYPE_MENU,     -1,             "Menu",
556         menu_whens, XtNumber(menu_whens),
557         AB_WHEN_POPPED_UP,
558         (AB_BUILTIN_ACTION *) NULL, (Cardinal) 0,
559         (AB_BUILTIN_ACTION) NULL                        },
560     { AB_TYPE_ITEM,     (int)AB_ITEM_FOR_MENU, "Menu Item",
561         menuitem_whens, XtNumber(menuitem_whens),
562         AB_WHEN_ACTIVATED,
563         menuitem_acts, XtNumber(menuitem_acts),
564         AB_STDACT_SET_LABEL                             },
565     { AB_TYPE_CONTAINER, AB_CONT_MENU_BAR,      "Menubar",
566         menubar_whens, XtNumber(menubar_whens),
567         AB_WHEN_AFTER_CREATED,
568         menubar_acts, XtNumber(menubar_acts),
569         AB_STDACT_DISABLE                               },
570     { AB_TYPE_ITEM,     (int)AB_ITEM_FOR_MENUBAR, "Menubar Item",
571         menubaritem_whens, XtNumber(menubaritem_whens),
572         AB_WHEN_AFTER_CREATED,
573         menubaritem_acts, XtNumber(menubaritem_acts),
574         AB_STDACT_SET_LABEL                             },
575     { AB_TYPE_MESSAGE,  -1,     "Message",
576         message_whens, XtNumber(message_whens), 
577         (AB_WHEN) NULL,
578         (AB_BUILTIN_ACTION *) NULL, (Cardinal) 0,
579         (AB_BUILTIN_ACTION) NULL                        },
580     { AB_TYPE_CONTAINER, AB_CONT_PANED, "Paned Window", 
581         panedwin_whens, XtNumber(panedwin_whens), 
582         AB_WHEN_AFTER_CREATED,
583         panedwin_acts, XtNumber(panedwin_acts),
584         AB_STDACT_DISABLE                               },
585     { AB_TYPE_SCALE,    -1,             "Scale",
586         scale_whens, XtNumber(scale_whens),
587         AB_WHEN_VALUE_CHANGED,
588         scale_acts, XtNumber(scale_acts),
589         AB_STDACT_SET_VALUE                             },
590     { AB_TYPE_SEPARATOR,-1,             "Separator",
591         separator_whens, XtNumber(separator_whens),
592         AB_WHEN_AFTER_CREATED,
593         separator_acts, XtNumber(separator_acts),
594         AB_STDACT_HIDE                                  },
595     { AB_TYPE_SPIN_BOX, -1,             "Spin Box",
596         spinbox_whens, XtNumber(spinbox_whens),
597         AB_WHEN_VALUE_CHANGED,
598         spinbox_acts, XtNumber(spinbox_acts),
599         AB_STDACT_SET_VALUE                             },
600     { AB_TYPE_TERM_PANE,        -1,     "Term Pane",
601         termpane_whens, XtNumber(termpane_whens),
602         AB_WHEN_AFTER_CREATED,
603         termpane_acts, XtNumber(termpane_acts),
604         AB_STDACT_DISABLE                               },
605     { AB_TYPE_TEXT_FIELD,       -1,     "Text Field",
606         textfield_whens, XtNumber(textfield_whens),
607         AB_WHEN_TEXT_CHANGED,
608         textfield_acts, XtNumber(textfield_acts),
609         AB_STDACT_SET_TEXT                              },
610     { AB_TYPE_TEXT_PANE,        -1,     "Text Pane",
611         textpane_whens, XtNumber(textpane_whens),
612         AB_WHEN_TEXT_CHANGED,
613         textpane_acts, XtNumber(textpane_acts),
614         AB_STDACT_SET_TEXT                              }
615 };
616
617 int             ConnP_num_conn_objs = XtNumber(ConnP_conn_objs);
618
619
620 ConnWhen        *ConnP_conn_whens = (ConnWhen *)NULL;
621 int             ConnP_num_conn_whens = 0;
622
623
624 ConnAct         *ConnP_conn_acts = (ConnAct *)NULL;
625 int             ConnP_num_conn_acts = 0;
626
627
628 static AB_OBJECT_TYPE   cur_source_type = AB_TYPE_UNKNOWN;
629 static int              cur_source_subtype      = -1;
630
631 static AB_OBJECT_TYPE   cur_target_type = AB_TYPE_UNKNOWN;
632 static int              cur_target_subtype      = -1;
633
634 static AB_FUNC_TYPE     cur_action_type = AB_FUNC_UNDEF;
635
636 static ABObj    cur_source      = (ABObj)NULL;
637 static ABObj    cur_target      = (ABObj)NULL;
638 static ABObj    cur_action_obj  = (ABObj)NULL;
639
640
641 static BOOL     is_descendant(
642                     ABObj       parent,
643                     ABObj       child
644                 );
645 static void     assign_when_list(
646                     AB_OBJECT_TYPE      source_type,
647                     int                 source_subtype
648                 );
649 static void     assign_action_list(
650                     AB_OBJECT_TYPE      target_type,
651                     int                 target_subtype
652                 );
653 static STRING   get_when_label(
654                     AB_WHEN     when_type
655                 );
656 static STRING   get_stdact_label(
657                     AB_BUILTIN_ACTION   stdact_type
658                 );
659
660 static STRING
661 get_when_label(
662     AB_WHEN     when_type
663 )
664 {
665     STRING      ret_val = NULL;
666
667     /*
668      * Fetch right string to return from when_labels array
669      * Make sure the index used is valid, otherwise, use
670      * the "unknown" string.
671      */
672     if ((AB_WHEN_UNDEF <= when_type) && (when_type <= AB_WHEN_NUM_VALUES))
673         ret_val = when_labels[when_type];
674     else
675         ret_val = when_labels[AB_WHEN_UNDEF];
676
677     /*
678      * This returns the "invalid" string
679      */
680     if (!ret_val)
681         ret_val = when_labels[AB_WHEN_UNDEF];
682
683     return(ret_val);
684 }
685
686 static STRING
687 get_stdact_label(
688     AB_BUILTIN_ACTION   stdact_type
689 )
690 {
691     STRING      ret_val = NULL;
692
693     /*
694      * Fetch right string to return from the stdact_labels array
695      * Make sure the index used is valid, otherwise, use
696      * the "unknown" string.
697      */
698     if ((AB_STDACT_UNDEF <= stdact_type) && 
699         (stdact_type <= AB_BUILTIN_ACTION_NUM_VALUES))
700         ret_val = stdact_labels[stdact_type];
701     else
702         ret_val = stdact_labels[stdact_type];
703
704     /*
705      * This returns the "invalid" string
706      */
707     if (!ret_val)
708         ret_val = when_labels[AB_WHEN_UNDEF];
709
710     return(ret_val);
711 }
712
713
714 extern char **
715 connP_get_when_labels(
716     int *num_labels
717 )
718 {
719     static STRING       *when_label_list = (STRING *)NULL;
720
721     if (when_label_list == NULL)
722     {
723         register int    i;
724
725         when_label_list = (STRING *)XtMalloc(
726                             sizeof(STRING) * ((int)AB_WHEN_NUM_VALUES - 1));
727
728         for (i = 1; i < (int)AB_WHEN_NUM_VALUES; i++)
729             when_label_list[i-1] = get_when_label((AB_WHEN)i);
730     }
731     *num_labels = (int)AB_WHEN_NUM_VALUES - 1;
732     return(when_label_list);
733 }
734
735 extern char **
736 connP_get_act_labels(
737     int *num_labels
738 )
739 {
740     static STRING       *stdact_label_list = (STRING *)NULL;
741
742     if (stdact_label_list == NULL)
743     {
744         register int    i;
745
746         stdact_label_list = (STRING *)XtMalloc(
747                         sizeof(STRING) * ((int)AB_BUILTIN_ACTION_NUM_VALUES - 1));
748
749         for (i = 1; i < (int)AB_BUILTIN_ACTION_NUM_VALUES; i++)
750             stdact_label_list[i-1] = get_stdact_label((AB_BUILTIN_ACTION)i);
751     }
752     *num_labels = (int)AB_BUILTIN_ACTION_NUM_VALUES - 1;
753     return(stdact_label_list);
754 }
755
756 extern AB_OBJECT_TYPE
757 connP_get_source_type(
758     void
759 )
760 {
761     if (cur_source_type == AB_TYPE_UNKNOWN)
762         connP_set_source_type(AB_TYPE_BUTTON, -1);
763     return cur_source_type;
764 }
765
766 extern int
767 connP_get_source_subtype(
768     void
769 )
770 {
771     return cur_source_subtype;
772 }
773
774 extern AB_OBJECT_TYPE
775 connP_get_target_type(
776     void
777 )
778 {
779     if (cur_target_type == AB_TYPE_UNKNOWN)
780         connP_set_target_type(AB_TYPE_BUTTON, -1);
781     return cur_target_type;
782 }
783
784 extern int
785 connP_get_target_subtype(
786     void
787 )
788 {
789     return cur_target_subtype;
790 }
791
792 extern void
793 connP_set_source_type(
794     AB_OBJECT_TYPE      obj_type,
795     int                 obj_subtype
796 )
797 {
798     BOOL        ChangedType = (obj_type != cur_source_type);
799
800     if (ChangedType || (obj_subtype != cur_source_subtype))
801     {
802         cur_source_type = obj_type;
803         if (connP_objtype_needs_subtype(obj_type, obj_subtype))
804             cur_source_subtype = obj_subtype;
805         else
806             cur_source_subtype = -1;
807         cur_action_obj = NULL;
808
809         assign_when_list(cur_source_type, cur_source_subtype);
810         connP_ui_source_type_update(cur_source_type, cur_source_subtype);
811     }
812 }
813
814 extern void
815 connP_set_target_type(
816     AB_OBJECT_TYPE      obj_type,
817     int                 obj_subtype
818 )
819 {
820     BOOL        ChangedType = (obj_type != cur_target_type);
821
822     if (ChangedType || (obj_subtype != cur_target_subtype))
823     {
824         cur_target_type = obj_type;
825         if (connP_objtype_needs_subtype(obj_type, obj_subtype))
826             cur_target_subtype = obj_subtype;
827         else
828             cur_target_subtype = -1;
829         cur_action_obj = NULL;
830
831         if (ChangedType)
832         {
833             assign_action_list(cur_target_type, cur_target_subtype);
834             connP_ui_target_type_update(cur_target_type, cur_target_subtype);
835         }
836     }
837 }
838
839 extern void
840 conn_set_source(
841     ABObj       obj
842 )
843 {
844     if (cur_source == obj)
845         return;
846
847     if ((cur_source = obj) != NULL)
848     {
849         connP_set_source_type(obj_get_type(obj), obj_get_subtype(obj));
850     }
851     else
852     {
853         if (connP_get_source_type() == AB_TYPE_UNDEF)
854             connP_set_source_type(AB_TYPE_BUTTON, -1);
855     }
856 }
857
858 extern ABObj
859 connP_get_source(
860 )
861 {
862     return cur_source;
863 }
864
865 extern void
866 conn_set_target(
867     ABObj       obj
868 )
869 {
870     if (cur_target == obj)
871         return;
872
873     if ((cur_target = obj) != NULL)
874     {
875         connP_set_target_type(obj_get_type(obj), obj_get_subtype(obj));
876     }
877     else
878     {
879         if (connP_get_target_type() == AB_TYPE_UNDEF)
880             connP_set_target_type(AB_TYPE_BUTTON, -1);
881     }
882 }
883
884 extern ABObj
885 connP_get_target(
886 )
887 {
888     return cur_target;
889 }
890
891 extern ABObj
892 connP_get_connection(
893     void
894 )
895 {
896     return cur_action_obj;
897 }
898
899 extern void
900 connP_set_connection(
901     ABObj       action
902 )
903 {
904     cur_action_obj = action;
905 }
906
907 extern void
908 connP_set_action_type(
909     AB_FUNC_TYPE        action_type
910 )
911 {
912     cur_action_type = action_type;
913 }
914
915 extern AB_FUNC_TYPE
916 connP_get_action_type(
917     void
918 )
919 {
920     return cur_action_type;
921 }
922
923 extern char *
924 connP_make_conn_string(
925     ABObj       action_obj
926 )
927 {
928     register int        i;
929     int                 si;
930     static char         conn_string[BUFSIZ];
931     char                buf[BUFSIZ];
932     AB_ACTION_INFO      *action_info;
933     ABObj               src_obj;
934     STRING              modname;
935
936     conn_string[0] = '\0';
937
938     if (!obj_is_action(action_obj))
939         return(conn_string);
940
941     action_info = &(action_obj->info.action);
942
943     src_obj = action_info->from;
944
945     if (src_obj == NULL)
946         return(conn_string);
947
948     si = connP_get_obj_type_index(obj_get_type(src_obj),
949                                   obj_get_subtype(src_obj));
950
951     if (si < 0)
952         return(conn_string);
953
954     for (i = 0; i < ConnP_conn_objs[si].num_whens; i++)
955         if (ConnP_conn_objs[si].when_list[i] == action_info->when)
956         {
957             strcat(conn_string, get_when_label(action_info->when));
958             break;
959         }
960     if (i == ConnP_conn_objs[si].num_whens)
961     {
962         strcat(conn_string, unknown_str);
963     }
964     
965     strcat(conn_string, catgets(Dtb_project_catd, 100, 196, " on "));
966     modname = abobj_get_moduled_name(src_obj);
967     strcat(conn_string, (char*)modname);
968     XtFree(modname);
969     strcat(conn_string, " -> ");
970     
971     switch (action_info->func_type)
972     {
973       case AB_FUNC_BUILTIN:
974           {
975             int                 ti;
976             ABObj               target_obj;
977
978             target_obj = action_info->to;
979             if (target_obj == NULL)
980                 return("");
981             
982             ti = connP_get_obj_type_index(obj_get_type(target_obj),
983                                           obj_get_subtype(target_obj));
984             if (ti < 0)
985                 return("");
986
987             for (i = 0; i < ConnP_conn_objs[ti].num_actions; i++)
988                 if (ConnP_conn_objs[ti].action_list[i] ==
989                             action_info->func_value.builtin)
990             {
991                 strcat(conn_string,
992                         get_stdact_label(action_info->func_value.builtin));
993                 break;
994             }
995             if (i == ConnP_conn_objs[ti].num_actions)
996             {
997                 strcat(conn_string, unknown_str);
998             }
999             
1000             strcat(conn_string, catgets(Dtb_project_catd, 100, 196, " on "));
1001             modname = abobj_get_moduled_name(target_obj);
1002             strcat(conn_string, (char*)modname);
1003             XtFree(modname);
1004         }
1005         break;
1006
1007       case AB_FUNC_USER_DEF:
1008         strcat(conn_string, catgets(Dtb_project_catd, 100, 197, "Call function"));
1009         strcat(conn_string, " \"");
1010         {
1011             ISTRING     istr_val = action_info->func_value.func_name;
1012
1013             if (istr_val != NULL)
1014                 strcat(conn_string, istr_string(istr_val));
1015         }
1016         strcat(conn_string, "\"");
1017         break;
1018
1019       case AB_FUNC_CODE_FRAG:
1020         strcat(conn_string, catgets(Dtb_project_catd, 100, 198, "Execute Code"));
1021         break;
1022
1023       case AB_FUNC_ON_ITEM_HELP:
1024         strcat(conn_string, catgets(Dtb_project_catd, 100, 199, "Activate On-Item Help"));
1025         break;
1026
1027       case AB_FUNC_HELP_VOLUME:
1028         strcat(conn_string, catgets(Dtb_project_catd, 100, 200, "Access Help Volume"));
1029         strcat(conn_string, " \"");
1030         strcat(conn_string, obj_get_func_help_volume(action_obj)?
1031                 obj_get_func_help_volume(action_obj):"");
1032         strcat(conn_string, "\" ");
1033         strcat(conn_string, catgets(Dtb_project_catd, 100, 201, "at location"));
1034         strcat(conn_string, " \"");
1035         strcat(conn_string, obj_get_func_help_location(action_obj)?
1036                 obj_get_func_help_location(action_obj):"");
1037         strcat(conn_string, "\"");
1038         break;
1039     }
1040
1041     return(conn_string);
1042 }
1043
1044 extern int
1045 connP_get_obj_type_index(
1046     AB_OBJECT_TYPE      ab_type,
1047     int                 ab_subtype
1048 )
1049 {
1050     register int        i;
1051
1052     if (connP_objtype_needs_subtype(ab_type, ab_subtype))
1053     {
1054         for (i = 0; i < ConnP_num_conn_objs; i++)
1055             if ((ConnP_conn_objs[i].obj_type == ab_type) &&
1056                 (ConnP_conn_objs[i].obj_subtype == ab_subtype))
1057                 return(i);
1058     }
1059     else
1060     {
1061         for (i = 0; i < ConnP_num_conn_objs; i++)
1062             if ((ConnP_conn_objs[i].obj_type == ab_type) &&
1063                 (ConnP_conn_objs[i].obj_subtype == -1))
1064                 return(i);
1065     }
1066     return(-1);
1067 }
1068
1069 extern AB_ARG_TYPE
1070 connP_action_needs_arg(
1071     AB_BUILTIN_ACTION   act_type
1072 )
1073 {
1074     switch (act_type)
1075     {
1076         case AB_STDACT_SET_LABEL:
1077         case AB_STDACT_SET_TEXT:
1078             return(AB_ARG_STRING);
1079         case AB_STDACT_SET_VALUE:
1080             return(AB_ARG_INT);
1081     }
1082     return(AB_ARG_UNDEF);
1083 }
1084
1085 extern void
1086 connP_guess_when_action(
1087     AB_OBJECT_TYPE      source_type,
1088     int                 source_subtype,
1089     AB_OBJECT_TYPE      target_type,
1090     int                 target_subtype,
1091     AB_WHEN             *when_ret,
1092     AB_FUNC_TYPE        *func_type,
1093     AB_BUILTIN_ACTION   *act_ret
1094 )
1095 {
1096     int     i = connP_get_obj_type_index(source_type, source_subtype);
1097     int     j = connP_get_obj_type_index(target_type, target_subtype);
1098
1099     if (ConnP_conn_objs[i].when_list != NULL)
1100         *when_ret = ConnP_conn_objs[i].default_when;
1101
1102     if (ConnP_conn_objs[j].action_list != NULL)
1103         *act_ret = ConnP_conn_objs[j].default_act;
1104
1105     *func_type = AB_FUNC_BUILTIN;
1106
1107     switch (source_type)
1108     {
1109       case AB_TYPE_PROJECT:
1110       case AB_TYPE_CONTAINER:
1111       case AB_TYPE_DRAWING_AREA:
1112       case AB_TYPE_MENU:
1113       case AB_TYPE_CHOICE:
1114       case AB_TYPE_LABEL:
1115       case AB_TYPE_SEPARATOR:
1116       case AB_TYPE_TERM_PANE:
1117         *func_type = AB_FUNC_USER_DEF;
1118         break;
1119
1120       case AB_TYPE_ITEM:
1121         if (source_subtype == AB_ITEM_FOR_MENUBAR)
1122             *func_type = AB_FUNC_USER_DEF;
1123         
1124         switch (target_type)
1125         {
1126           case AB_TYPE_BASE_WINDOW:
1127           case AB_TYPE_DIALOG:
1128             if (is_descendant(connP_get_target(), connP_get_source()))
1129                 *act_ret = AB_STDACT_HIDE;
1130         }
1131         break;
1132
1133       case AB_TYPE_BUTTON:
1134         switch (target_type)
1135         {
1136           case AB_TYPE_BASE_WINDOW:
1137           case AB_TYPE_DIALOG:
1138             if (is_descendant(connP_get_target(), connP_get_source()))
1139                 *act_ret = AB_STDACT_HIDE;
1140         }
1141         break;
1142
1143         case AB_TYPE_MESSAGE:
1144             if (connP_get_source() != NULL)
1145             {
1146                 ABObj   src_obj = connP_get_source();
1147
1148                 *func_type = AB_FUNC_USER_DEF;
1149                 *act_ret = (AB_BUILTIN_ACTION) NULL;
1150
1151                 if (obj_has_action1_button(src_obj))
1152                     *when_ret = ConnP_conn_objs[i].when_list[0];        
1153                 else if (obj_has_action2_button(src_obj))
1154                     *when_ret = ConnP_conn_objs[i].when_list[1];
1155                 else if (obj_has_action3_button(src_obj))
1156                     *when_ret = ConnP_conn_objs[i].when_list[2];
1157                 else if (obj_has_cancel_button(src_obj))
1158                     *when_ret = ConnP_conn_objs[i].when_list[3];
1159             }
1160             break;
1161     }
1162 }
1163
1164
1165 \f
1166 static BOOL
1167 is_descendant(
1168     ABObj       parent,
1169     ABObj       child
1170 )
1171 {
1172     AB_TRAVERSAL        trav;
1173     ABObj               obj;
1174     BOOL                ret_val = FALSE;
1175
1176     if (parent == NULL || child == NULL)
1177         return(FALSE);
1178
1179     if (parent == child)
1180         return(TRUE);
1181
1182     for (trav_open(&trav, parent, AB_TRAV_CHILDREN);
1183          (obj = trav_next(&trav)) != NULL; )
1184         if (is_descendant(obj, child))
1185         {
1186             ret_val = TRUE;
1187             break;
1188         }
1189     trav_close(&trav);
1190
1191     return(ret_val);
1192 }
1193
1194 static void
1195 assign_when_list(
1196     AB_OBJECT_TYPE      source_type,
1197     int                 source_subtype
1198 )
1199 {
1200     int         i;
1201     int         n;
1202     ConnObj     *src_conn_obj;
1203     
1204     if (ConnP_conn_whens != (ConnWhen *)NULL)
1205         XtFree((char *)ConnP_conn_whens);
1206     ConnP_conn_whens = (ConnWhen *)NULL;
1207     ConnP_num_conn_whens = 0;
1208     
1209     i = connP_get_obj_type_index(source_type, source_subtype);
1210     if (i < 0)
1211         return;
1212
1213     src_conn_obj = &(ConnP_conn_objs[i]);
1214     n = src_conn_obj->num_whens;
1215
1216     if (n <= 0)
1217         return;
1218     
1219     ConnP_conn_whens = (ConnWhen *)XtMalloc(sizeof(ConnWhen) * n);
1220
1221     for (i = 0; i < n; i++)
1222     {
1223         ConnP_conn_whens[i].when_type = src_conn_obj->when_list[i];
1224         ConnP_conn_whens[i].label = get_when_label(src_conn_obj->when_list[i]);
1225     }
1226     ConnP_num_conn_whens = n;
1227 }
1228
1229 static void
1230 assign_action_list(
1231     AB_OBJECT_TYPE      target_type,
1232     int                 target_subtype
1233 )
1234 {
1235     int         i;
1236     int         n;
1237     ConnObj     *trg_conn_obj;
1238     
1239     if (ConnP_conn_acts != (ConnAct *)NULL)
1240         XtFree((char *)ConnP_conn_acts);
1241     ConnP_conn_acts = (ConnAct *)NULL;
1242     ConnP_num_conn_acts = 0;
1243     
1244     i = connP_get_obj_type_index(target_type, target_subtype);
1245     if (i < 0)
1246         return;
1247
1248     trg_conn_obj = &(ConnP_conn_objs[i]);
1249     n = trg_conn_obj->num_actions;
1250
1251     if (n <= 0)
1252         return;
1253     
1254     ConnP_conn_acts = (ConnAct *)XtMalloc(sizeof(ConnAct) * n);
1255
1256     for (i = 0; i < n; i++)
1257     {
1258         ConnP_conn_acts[i].act_type = trg_conn_obj->action_list[i];
1259         ConnP_conn_acts[i].label = get_stdact_label(trg_conn_obj->action_list[i]);
1260     }
1261     ConnP_num_conn_acts = n;
1262 }
1263
1264 /* This routine tries to match on type and subtype to
1265  * get the "When" and "Action", Object Type string info.
1266  */
1267 extern int
1268 connP_objtype_needs_subtype(
1269     AB_OBJECT_TYPE      obj_type,
1270     int                 obj_subtype
1271 )
1272 {
1273     register    int     i;
1274
1275     for (i = 0; i < ConnP_num_conn_objs; i++)
1276     {
1277         if ((ConnP_conn_objs[i].obj_type == obj_type) &&
1278             (ConnP_conn_objs[i].obj_subtype == obj_subtype))
1279         {
1280             if (ConnP_conn_objs[i].obj_subtype == -1)
1281                 return (0);
1282             else
1283                 return(1);
1284         }
1285     }
1286     return(0);
1287 }
1288
1289 extern int
1290 connP_obj_enabled(
1291     AB_OBJECT_TYPE      obj_type,
1292     int                 obj_subtype
1293 )
1294 {
1295     return(connP_get_obj_type_index(obj_type, obj_subtype) >= 0);
1296 }
1297
1298 extern void     
1299 connP_set_conn_arg(
1300     ABObj               ab_action,
1301     AB_ARG_TYPE         arg_type,
1302     char                *str_value
1303 )
1304 {
1305     /*
1306      * Populate arg entries
1307      */
1308     ab_action->info.action.arg_type = arg_type;
1309     switch (arg_type)
1310     {
1311       case AB_ARG_STRING:
1312         obj_set_arg_string(ab_action, str_value);
1313         break;
1314       case AB_ARG_INT:
1315         obj_set_arg_int(ab_action, atoi(str_value));
1316         break;
1317       default:
1318         break;
1319     }
1320 }
1321
1322 extern void     
1323 connP_make_builtin_conn(
1324     ABObj               ab_action,
1325     ABObj               c_source,
1326     ABObj               c_target,
1327     AB_WHEN             c_when,
1328     AB_BUILTIN_ACTION   c_act
1329 )
1330 {
1331     ab_action->info.action.from = c_source;
1332     ab_action->info.action.to = c_target;
1333     ab_action->info.action.when = c_when;
1334     ab_action->info.action.func_type = AB_FUNC_BUILTIN;
1335     ab_action->info.action.func_value.builtin = c_act;
1336     ab_action->info.action.auto_named = TRUE;
1337 }
1338
1339 extern void     
1340 connP_make_user_def_conn(
1341     ABObj               ab_action,
1342     ABObj               c_source,
1343     AB_WHEN             c_when,
1344     char                *function_name
1345 )
1346 {
1347     ab_action->info.action.from = c_source;
1348     ab_action->info.action.to = NULL;
1349     ab_action->info.action.when = c_when;
1350     ab_action->info.action.func_type = AB_FUNC_USER_DEF;
1351     ab_action->info.action.func_value.func_name = istr_create(function_name);
1352 }
1353
1354 extern void     
1355 connP_make_code_frag_conn(
1356     ABObj               ab_action,
1357     ABObj               c_source,
1358     AB_WHEN             c_when,
1359     char                *code_frag
1360 )
1361 {
1362     ab_action->info.action.from = c_source;
1363     ab_action->info.action.to = NULL;
1364     ab_action->info.action.when = c_when;
1365     ab_action->info.action.func_type = AB_FUNC_CODE_FRAG;
1366     ab_action->info.action.func_value.code_frag = istr_create(code_frag);
1367 }
1368
1369 #define ACT(field) ab_action->info.action.field
1370
1371 extern void
1372 connP_builtin_remove_arg(
1373     ABObj               ab_action
1374 )
1375 {
1376     AB_ARG_TYPE arg_type = ACT(arg_type);
1377
1378     switch (arg_type)
1379     {
1380       case AB_ARG_STRING:
1381         if (ACT(arg_value.sval) != (ISTRING)NULL)
1382         {
1383             istr_destroy(ACT(arg_value.sval));
1384             ACT(arg_value.sval) = (ISTRING)NULL;
1385         }
1386     }
1387 }
1388
1389 extern BOOL
1390 connP_change_in_builtin(
1391     ABObj       ab_action,
1392     ABObj       c_source,
1393     ABObj       c_target,
1394     AB_WHEN     c_when,
1395     AB_BUILTIN_ACTION   c_act,
1396     char        *arg_str
1397 )
1398 {
1399     AB_ARG_TYPE         old_arg_type;
1400     AB_ARG_TYPE         cur_arg_type;
1401     BOOL                is_changed = FALSE;
1402
1403 #define CSETQ(lval, rval) \
1404     if ((lval) != (rval)) \
1405     { \
1406         (lval) = (rval); \
1407         is_changed = TRUE; \
1408     }
1409
1410     CSETQ(ACT(from), c_source);
1411     CSETQ(ACT(to), c_target);
1412     CSETQ(ACT(when), c_when);
1413     CSETQ(ab_action->info.action.func_value.builtin, c_act);
1414
1415     old_arg_type = connP_action_needs_arg(ACT(func_value.builtin));
1416     cur_arg_type = connP_action_needs_arg(c_act);
1417
1418     if (old_arg_type != cur_arg_type)
1419     {
1420         is_changed = TRUE;
1421         connP_builtin_remove_arg(ab_action);
1422         connP_set_conn_arg(ab_action, cur_arg_type, arg_str);
1423     }
1424     else
1425     {
1426         ISTRING istr_value;
1427
1428         switch (cur_arg_type)
1429         {
1430             case AB_ARG_STRING:
1431                 if (arg_str != (char *)NULL)
1432                     istr_value = istr_create(arg_str);
1433                 else
1434                     istr_value = (ISTRING)NULL;
1435                 if (ACT(arg_value.sval) != istr_value)
1436                 {
1437                     if (istr_value != (ISTRING)NULL)
1438                         istr_destroy(istr_value);
1439                     is_changed = TRUE;
1440                     connP_builtin_remove_arg(ab_action);
1441                     connP_set_conn_arg(ab_action, cur_arg_type, arg_str);
1442                 }
1443             break;
1444
1445             case AB_ARG_INT:
1446                 if (!util_strempty(arg_str))
1447                 {
1448                     CSETQ(ACT(arg_value.ival), atoi(arg_str));
1449                     connP_set_conn_arg(ab_action, cur_arg_type, arg_str);
1450                 }
1451             break;
1452         }
1453     }
1454
1455 #undef CSETQ
1456
1457     return(is_changed);
1458 }
1459
1460 #undef ACT
1461
1462
1463 extern void
1464 connP_destroy_connections_for(
1465     ABObj       obj
1466 )
1467 {
1468     ABObj               project;
1469     AB_TRAVERSAL        trav;
1470     ABObj               cobj;
1471
1472     if (obj == NULL ||
1473         (project = obj_get_project(obj)) == NULL)
1474         return;
1475
1476
1477     for (trav_open(&trav, project, AB_TRAV_ACTIONS);
1478         (cobj = trav_next(&trav)) != NULL; )
1479     {
1480         if (cobj->info.action.from == obj       ||
1481             (cobj->info.action.func_type == AB_FUNC_BUILTIN &&
1482              cobj->info.action.to == obj))
1483             obj_destroy(cobj);
1484     }
1485     trav_close(&trav);
1486 }
1487
1488 extern void
1489 connP_make_on_item_help_conn(
1490     ABObj               ab_action,
1491     ABObj               c_source,
1492     AB_WHEN             c_when
1493 )
1494 {
1495     ab_action->info.action.from = c_source;
1496     ab_action->info.action.to = NULL;
1497     ab_action->info.action.when = c_when;
1498     ab_action->info.action.func_type = AB_FUNC_ON_ITEM_HELP;
1499     ab_action->info.action.auto_named = TRUE;
1500 }
1501
1502 extern void
1503 connP_make_help_vol_conn(
1504     ABObj               ab_action,
1505     ABObj               c_source,
1506     AB_WHEN             c_when,
1507     STRING              volume,
1508     STRING              location
1509 )
1510 {
1511     ab_action->info.action.from = c_source;
1512     ab_action->info.action.to = NULL;
1513     ab_action->info.action.when = c_when;
1514     ab_action->info.action.func_type = AB_FUNC_HELP_VOLUME;
1515     ab_action->info.action.volume_id = istr_create(volume);
1516     ab_action->info.action.location= istr_create(location);
1517     ab_action->info.action.auto_named = TRUE;
1518 }
1519
1520 /*
1521  * Initializes strings used in connections editor
1522  */
1523 extern void
1524 conn_strings_init(
1525 )
1526 {
1527       unknown_str = 
1528         XtNewString(catgets(Dtb_project_catd, 100, 158, "??unknown??"));
1529       invalid_str = 
1530         XtNewString(catgets(Dtb_project_catd, 100, 159, "??invalid??"));
1531
1532       when_labels[AB_WHEN_UNDEF] = unknown_str;
1533       when_labels[AB_WHEN_ACTION1] =
1534         XtNewString(catgets(Dtb_project_catd, 100, 160, "Action1 Activated"));
1535       when_labels[AB_WHEN_ACTION2] =
1536         XtNewString(catgets(Dtb_project_catd, 100, 161, "Action2 Activated"));
1537       when_labels[AB_WHEN_ACTION3] =
1538         XtNewString(catgets(Dtb_project_catd, 100, 162, "Action3 Activated"));
1539       when_labels[AB_WHEN_ACTIVATED] =
1540         XtNewString(catgets(Dtb_project_catd, 100, 163, "Activated"));
1541       when_labels[AB_WHEN_AFTER_CREATED] =
1542         XtNewString(catgets(Dtb_project_catd, 100, 164, "Created"));
1543       when_labels[AB_WHEN_AFTER_RESIZED] =
1544         XtNewString(catgets(Dtb_project_catd, 100, 165, "Resized"));
1545       when_labels[AB_WHEN_BEFORE_TEXT_CHANGED] =  
1546         XtNewString(catgets(Dtb_project_catd, 100, 166, "Before Text Changed"));
1547       when_labels[AB_WHEN_CANCEL] = 
1548         XtNewString(catgets(Dtb_project_catd, 100, 167, "Cancel Activated"));
1549       when_labels[AB_WHEN_DESTROYED] =  
1550         XtNewString(catgets(Dtb_project_catd, 100, 168, "Destroyed"));
1551       when_labels[AB_WHEN_DOUBLE_CLICKED_ON] =  
1552         XtNewString(catgets(Dtb_project_catd, 100, 169, "Double Clicked On"));
1553       when_labels[AB_WHEN_DRAGGED] =  
1554         XtNewString(catgets(Dtb_project_catd, 100, 170, "Dragged"));
1555       when_labels[AB_WHEN_DRAGGED_FROM] =  
1556         XtNewString(catgets(Dtb_project_catd, 100, 171, "Dragged From"));
1557       when_labels[AB_WHEN_DROPPED_ON] =  
1558         XtNewString(catgets(Dtb_project_catd, 100, 172, "Dropped On"));
1559       when_labels[AB_WHEN_HIDDEN] =  
1560         XtNewString(catgets(Dtb_project_catd, 100, 173, "Hidden"));
1561       when_labels[AB_WHEN_ITEM_SELECTED] =  
1562         XtNewString(catgets(Dtb_project_catd, 100, 174, "Item Selected"));
1563       when_labels[AB_WHEN_OK] =  
1564         XtNewString(catgets(Dtb_project_catd, 100, 175, "Ok Activated"));
1565       when_labels[AB_WHEN_POPPED_DOWN] =  
1566         XtNewString(catgets(Dtb_project_catd, 100, 176, "Popped Down"));
1567       when_labels[AB_WHEN_POPPED_UP] =  
1568         XtNewString(catgets(Dtb_project_catd, 100, 177, "Popped Up"));
1569       when_labels[AB_WHEN_REPAINT_NEEDED] =  
1570         XtNewString(catgets(Dtb_project_catd, 100, 178, "Repaint Needed"));
1571       when_labels[AB_WHEN_SESSION_SAVE] =  
1572         XtNewString(catgets(Dtb_project_catd, 100, 179, "Session Save"));
1573       when_labels[AB_WHEN_SESSION_RESTORE] =  
1574         XtNewString(catgets(Dtb_project_catd, 100, 180, "Session Restore"));
1575       when_labels[AB_WHEN_SHOWN] =  
1576         XtNewString(catgets(Dtb_project_catd, 100, 181, "Shown"));
1577       when_labels[AB_WHEN_TEXT_CHANGED] =  
1578         XtNewString(catgets(Dtb_project_catd, 100, 182, "Text Changed"));
1579       when_labels[AB_WHEN_TOGGLED] =  
1580         XtNewString(catgets(Dtb_project_catd, 100, 183, "Toggled"));
1581       when_labels[AB_WHEN_TOOLTALK_DO_COMMAND] =  
1582         XtNewString(catgets(Dtb_project_catd, 100, 184, "ToolTalk Do Command"));
1583       when_labels[AB_WHEN_TOOLTALK_GET_STATUS] =  
1584         XtNewString(catgets(Dtb_project_catd, 100, 185, "ToolTalk Get Status"));
1585       when_labels[AB_WHEN_TOOLTALK_PAUSE_RESUME] =  
1586         XtNewString(catgets(Dtb_project_catd, 100, 186, "ToolTalk Pause/Resume"));
1587       when_labels[AB_WHEN_TOOLTALK_QUIT] = 
1588         XtNewString(catgets(Dtb_project_catd, 100, 187, "ToolTalk Quit"));
1589       when_labels[AB_WHEN_VALUE_CHANGED] =  
1590         XtNewString(catgets(Dtb_project_catd, 100, 188, "Value Changed"));
1591       when_labels[AB_WHEN_NUM_VALUES] = invalid_str;
1592
1593       stdact_labels[AB_STDACT_UNDEF] = unknown_str;
1594       stdact_labels[AB_STDACT_DISABLE] = 
1595         XtNewString(catgets(Dtb_project_catd, 100, 189, "Disable"));
1596       stdact_labels[AB_STDACT_ENABLE] = 
1597         XtNewString(catgets(Dtb_project_catd, 100, 190, "Enable"));
1598       stdact_labels[AB_STDACT_HIDE] = 
1599         XtNewString(catgets(Dtb_project_catd, 100, 191, "Hide"));
1600       stdact_labels[AB_STDACT_SET_LABEL] = 
1601         XtNewString(catgets(Dtb_project_catd, 100, 192, "Set Label"));
1602       stdact_labels[AB_STDACT_SET_TEXT] = 
1603         XtNewString(catgets(Dtb_project_catd, 100, 193, "Set Text"));
1604       stdact_labels[AB_STDACT_SET_VALUE] = 
1605         XtNewString(catgets(Dtb_project_catd, 100, 194, "Set Value"));
1606       stdact_labels[AB_STDACT_SHOW] = 
1607         XtNewString(catgets(Dtb_project_catd, 100, 195, "Show"));
1608       stdact_labels[AB_BUILTIN_ACTION_NUM_VALUES] = invalid_str;
1609 }