2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
24 * $XConsortium: conn_obj.c /main/4 1996/07/03 16:57:53 mustafa $
26 * @(#)conn_obj.c 1.17 17 Feb 1994 cde_app_builder/src/ab
28 * RESTRICTED CONFIDENTIAL INFORMATION:
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
38 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
44 #include <ab_private/obj.h>
45 #include <ab_private/trav.h>
47 #include <ab_private/connP.h>
48 #include <ab_private/brws.h>
49 #include <ab_private/abobj.h>
50 #include "dtbuilder.h"
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;
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,
71 AB_WHEN_AFTER_CREATED,
79 static AB_BUILTIN_ACTION
91 AB_WHEN_AFTER_CREATED,
96 static AB_BUILTIN_ACTION
109 AB_WHEN_AFTER_CREATED,
113 static AB_BUILTIN_ACTION
126 AB_WHEN_AFTER_CREATED,
128 AB_WHEN_ITEM_SELECTED,
131 static AB_BUILTIN_ACTION
144 AB_WHEN_AFTER_CREATED,
146 AB_WHEN_DRAGGED_FROM,
150 static AB_BUILTIN_ACTION
162 AB_WHEN_AFTER_CREATED,
166 static AB_BUILTIN_ACTION
178 AB_WHEN_AFTER_CREATED,
182 static AB_BUILTIN_ACTION
194 AB_WHEN_AFTER_CREATED,
198 static AB_BUILTIN_ACTION
210 AB_WHEN_AFTER_CREATED,
214 AB_WHEN_DRAGGED_FROM,
218 static AB_BUILTIN_ACTION
230 AB_WHEN_AFTER_CREATED,
232 AB_WHEN_DRAGGED_FROM,
234 AB_WHEN_REPAINT_NEEDED,
235 AB_WHEN_AFTER_RESIZED,
238 static AB_BUILTIN_ACTION
250 AB_WHEN_AFTER_CREATED,
252 AB_WHEN_DRAGGED_FROM,
256 static AB_BUILTIN_ACTION
269 AB_WHEN_AFTER_CREATED,
271 AB_WHEN_DOUBLE_CLICKED_ON,
272 AB_WHEN_DRAGGED_FROM,
274 AB_WHEN_ITEM_SELECTED,
277 static AB_BUILTIN_ACTION
290 AB_WHEN_AFTER_CREATED,
299 AB_WHEN_AFTER_CREATED,
303 static AB_BUILTIN_ACTION
315 AB_WHEN_AFTER_CREATED,
318 AB_WHEN_VALUE_CHANGED,
321 static AB_BUILTIN_ACTION
335 AB_WHEN_AFTER_CREATED,
337 AB_WHEN_VALUE_CHANGED,
340 static AB_BUILTIN_ACTION
354 AB_WHEN_AFTER_CREATED,
358 static AB_BUILTIN_ACTION
370 AB_WHEN_AFTER_CREATED,
372 AB_WHEN_BEFORE_TEXT_CHANGED,
373 AB_WHEN_TEXT_CHANGED,
376 static AB_BUILTIN_ACTION
390 AB_WHEN_AFTER_CREATED,
392 AB_WHEN_BEFORE_TEXT_CHANGED,
393 AB_WHEN_TEXT_CHANGED,
396 static AB_BUILTIN_ACTION
409 AB_WHEN_AFTER_CREATED,
414 static AB_BUILTIN_ACTION
425 menubaritem_whens[] =
427 AB_WHEN_AFTER_CREATED,
431 static AB_BUILTIN_ACTION
444 AB_WHEN_AFTER_CREATED,
450 static AB_BUILTIN_ACTION
472 AB_WHEN_AFTER_CREATED,
480 static AB_BUILTIN_ACTION
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),
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),
505 { AB_TYPE_ITEM, (int)AB_ITEM_FOR_CHOICE, "Choice Item",
506 choiceitem_whens, XtNumber(choiceitem_whens),
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),
515 { AB_TYPE_CONTAINER, -1, "Control Pane",
516 container_whens, XtNumber(container_whens),
517 AB_WHEN_AFTER_CREATED,
518 container_acts, XtNumber(container_acts),
520 { AB_TYPE_DIALOG, -1, "Custom Dialog",
521 dialog_whens, XtNumber(dialog_whens),
523 dialog_acts, XtNumber(dialog_acts),
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),
530 { AB_TYPE_FILE_CHOOSER, -1, "File Selection Dialog",
531 fchooser_whens, XtNumber(fchooser_whens),
533 fchooser_acts, XtNumber(fchooser_acts),
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),
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),
550 { AB_TYPE_BASE_WINDOW, -1, "Main Window",
551 basewin_whens, XtNumber(basewin_whens),
553 basewin_acts, XtNumber(basewin_acts),
555 { AB_TYPE_MENU, -1, "Menu",
556 menu_whens, XtNumber(menu_whens),
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),
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),
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),
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),
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),
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),
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),
617 int ConnP_num_conn_objs = XtNumber(ConnP_conn_objs);
620 ConnWhen *ConnP_conn_whens = (ConnWhen *)NULL;
621 int ConnP_num_conn_whens = 0;
624 ConnAct *ConnP_conn_acts = (ConnAct *)NULL;
625 int ConnP_num_conn_acts = 0;
628 static AB_OBJECT_TYPE cur_source_type = AB_TYPE_UNKNOWN;
629 static int cur_source_subtype = -1;
631 static AB_OBJECT_TYPE cur_target_type = AB_TYPE_UNKNOWN;
632 static int cur_target_subtype = -1;
634 static AB_FUNC_TYPE cur_action_type = AB_FUNC_UNDEF;
636 static ABObj cur_source = (ABObj)NULL;
637 static ABObj cur_target = (ABObj)NULL;
638 static ABObj cur_action_obj = (ABObj)NULL;
641 static BOOL is_descendant(
645 static void assign_when_list(
646 AB_OBJECT_TYPE source_type,
649 static void assign_action_list(
650 AB_OBJECT_TYPE target_type,
653 static STRING get_when_label(
656 static STRING get_stdact_label(
657 AB_BUILTIN_ACTION stdact_type
665 STRING ret_val = NULL;
668 * Fetch right string to return from when_labels array
669 * Make sure the index used is valid, otherwise, use
670 * the "unknown" string.
672 if ((AB_WHEN_UNDEF <= when_type) && (when_type <= AB_WHEN_NUM_VALUES))
673 ret_val = when_labels[when_type];
675 ret_val = when_labels[AB_WHEN_UNDEF];
678 * This returns the "invalid" string
681 ret_val = when_labels[AB_WHEN_UNDEF];
688 AB_BUILTIN_ACTION stdact_type
691 STRING ret_val = NULL;
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.
698 if ((AB_STDACT_UNDEF <= stdact_type) &&
699 (stdact_type <= AB_BUILTIN_ACTION_NUM_VALUES))
700 ret_val = stdact_labels[stdact_type];
702 ret_val = stdact_labels[stdact_type];
705 * This returns the "invalid" string
708 ret_val = when_labels[AB_WHEN_UNDEF];
715 connP_get_when_labels(
719 static STRING *when_label_list = (STRING *)NULL;
721 if (when_label_list == NULL)
725 when_label_list = (STRING *)XtMalloc(
726 sizeof(STRING) * ((int)AB_WHEN_NUM_VALUES - 1));
728 for (i = 1; i < (int)AB_WHEN_NUM_VALUES; i++)
729 when_label_list[i-1] = get_when_label((AB_WHEN)i);
731 *num_labels = (int)AB_WHEN_NUM_VALUES - 1;
732 return(when_label_list);
736 connP_get_act_labels(
740 static STRING *stdact_label_list = (STRING *)NULL;
742 if (stdact_label_list == NULL)
746 stdact_label_list = (STRING *)XtMalloc(
747 sizeof(STRING) * ((int)AB_BUILTIN_ACTION_NUM_VALUES - 1));
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);
752 *num_labels = (int)AB_BUILTIN_ACTION_NUM_VALUES - 1;
753 return(stdact_label_list);
756 extern AB_OBJECT_TYPE
757 connP_get_source_type(
761 if (cur_source_type == AB_TYPE_UNKNOWN)
762 connP_set_source_type(AB_TYPE_BUTTON, -1);
763 return cur_source_type;
767 connP_get_source_subtype(
771 return cur_source_subtype;
774 extern AB_OBJECT_TYPE
775 connP_get_target_type(
779 if (cur_target_type == AB_TYPE_UNKNOWN)
780 connP_set_target_type(AB_TYPE_BUTTON, -1);
781 return cur_target_type;
785 connP_get_target_subtype(
789 return cur_target_subtype;
793 connP_set_source_type(
794 AB_OBJECT_TYPE obj_type,
798 BOOL ChangedType = (obj_type != cur_source_type);
800 if (ChangedType || (obj_subtype != cur_source_subtype))
802 cur_source_type = obj_type;
803 if (connP_objtype_needs_subtype(obj_type, obj_subtype))
804 cur_source_subtype = obj_subtype;
806 cur_source_subtype = -1;
807 cur_action_obj = NULL;
809 assign_when_list(cur_source_type, cur_source_subtype);
810 connP_ui_source_type_update(cur_source_type, cur_source_subtype);
815 connP_set_target_type(
816 AB_OBJECT_TYPE obj_type,
820 BOOL ChangedType = (obj_type != cur_target_type);
822 if (ChangedType || (obj_subtype != cur_target_subtype))
824 cur_target_type = obj_type;
825 if (connP_objtype_needs_subtype(obj_type, obj_subtype))
826 cur_target_subtype = obj_subtype;
828 cur_target_subtype = -1;
829 cur_action_obj = NULL;
833 assign_action_list(cur_target_type, cur_target_subtype);
834 connP_ui_target_type_update(cur_target_type, cur_target_subtype);
844 if (cur_source == obj)
847 if ((cur_source = obj) != NULL)
849 connP_set_source_type(obj_get_type(obj), obj_get_subtype(obj));
853 if (connP_get_source_type() == AB_TYPE_UNDEF)
854 connP_set_source_type(AB_TYPE_BUTTON, -1);
870 if (cur_target == obj)
873 if ((cur_target = obj) != NULL)
875 connP_set_target_type(obj_get_type(obj), obj_get_subtype(obj));
879 if (connP_get_target_type() == AB_TYPE_UNDEF)
880 connP_set_target_type(AB_TYPE_BUTTON, -1);
892 connP_get_connection(
896 return cur_action_obj;
900 connP_set_connection(
904 cur_action_obj = action;
908 connP_set_action_type(
909 AB_FUNC_TYPE action_type
912 cur_action_type = action_type;
916 connP_get_action_type(
920 return cur_action_type;
924 connP_make_conn_string(
930 static char conn_string[BUFSIZ];
932 AB_ACTION_INFO *action_info;
936 conn_string[0] = '\0';
938 if (!obj_is_action(action_obj))
941 action_info = &(action_obj->info.action);
943 src_obj = action_info->from;
948 si = connP_get_obj_type_index(obj_get_type(src_obj),
949 obj_get_subtype(src_obj));
954 for (i = 0; i < ConnP_conn_objs[si].num_whens; i++)
955 if (ConnP_conn_objs[si].when_list[i] == action_info->when)
957 strcat(conn_string, get_when_label(action_info->when));
960 if (i == ConnP_conn_objs[si].num_whens)
962 strcat(conn_string, unknown_str);
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);
969 strcat(conn_string, " -> ");
971 switch (action_info->func_type)
973 case AB_FUNC_BUILTIN:
978 target_obj = action_info->to;
979 if (target_obj == NULL)
982 ti = connP_get_obj_type_index(obj_get_type(target_obj),
983 obj_get_subtype(target_obj));
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)
992 get_stdact_label(action_info->func_value.builtin));
995 if (i == ConnP_conn_objs[ti].num_actions)
997 strcat(conn_string, unknown_str);
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);
1007 case AB_FUNC_USER_DEF:
1008 strcat(conn_string, catgets(Dtb_project_catd, 100, 197, "Call function"));
1009 strcat(conn_string, " \"");
1011 ISTRING istr_val = action_info->func_value.func_name;
1013 if (istr_val != NULL)
1014 strcat(conn_string, istr_string(istr_val));
1016 strcat(conn_string, "\"");
1019 case AB_FUNC_CODE_FRAG:
1020 strcat(conn_string, catgets(Dtb_project_catd, 100, 198, "Execute Code"));
1023 case AB_FUNC_ON_ITEM_HELP:
1024 strcat(conn_string, catgets(Dtb_project_catd, 100, 199, "Activate On-Item Help"));
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, "\"");
1041 return(conn_string);
1045 connP_get_obj_type_index(
1046 AB_OBJECT_TYPE ab_type,
1052 if (connP_objtype_needs_subtype(ab_type, ab_subtype))
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))
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))
1070 connP_action_needs_arg(
1071 AB_BUILTIN_ACTION act_type
1076 case AB_STDACT_SET_LABEL:
1077 case AB_STDACT_SET_TEXT:
1078 return(AB_ARG_STRING);
1079 case AB_STDACT_SET_VALUE:
1082 return(AB_ARG_UNDEF);
1086 connP_guess_when_action(
1087 AB_OBJECT_TYPE source_type,
1089 AB_OBJECT_TYPE target_type,
1092 AB_FUNC_TYPE *func_type,
1093 AB_BUILTIN_ACTION *act_ret
1096 int i = connP_get_obj_type_index(source_type, source_subtype);
1097 int j = connP_get_obj_type_index(target_type, target_subtype);
1099 if (ConnP_conn_objs[i].when_list != NULL)
1100 *when_ret = ConnP_conn_objs[i].default_when;
1102 if (ConnP_conn_objs[j].action_list != NULL)
1103 *act_ret = ConnP_conn_objs[j].default_act;
1105 *func_type = AB_FUNC_BUILTIN;
1107 switch (source_type)
1109 case AB_TYPE_PROJECT:
1110 case AB_TYPE_CONTAINER:
1111 case AB_TYPE_DRAWING_AREA:
1113 case AB_TYPE_CHOICE:
1115 case AB_TYPE_SEPARATOR:
1116 case AB_TYPE_TERM_PANE:
1117 *func_type = AB_FUNC_USER_DEF;
1121 if (source_subtype == AB_ITEM_FOR_MENUBAR)
1122 *func_type = AB_FUNC_USER_DEF;
1124 switch (target_type)
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;
1133 case AB_TYPE_BUTTON:
1134 switch (target_type)
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;
1143 case AB_TYPE_MESSAGE:
1144 if (connP_get_source() != NULL)
1146 ABObj src_obj = connP_get_source();
1148 *func_type = AB_FUNC_USER_DEF;
1149 *act_ret = (AB_BUILTIN_ACTION) NULL;
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];
1174 BOOL ret_val = FALSE;
1176 if (parent == NULL || child == NULL)
1179 if (parent == child)
1182 for (trav_open(&trav, parent, AB_TRAV_CHILDREN);
1183 (obj = trav_next(&trav)) != NULL; )
1184 if (is_descendant(obj, child))
1196 AB_OBJECT_TYPE source_type,
1202 ConnObj *src_conn_obj;
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;
1209 i = connP_get_obj_type_index(source_type, source_subtype);
1213 src_conn_obj = &(ConnP_conn_objs[i]);
1214 n = src_conn_obj->num_whens;
1219 ConnP_conn_whens = (ConnWhen *)XtMalloc(sizeof(ConnWhen) * n);
1221 for (i = 0; i < n; i++)
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]);
1226 ConnP_num_conn_whens = n;
1231 AB_OBJECT_TYPE target_type,
1237 ConnObj *trg_conn_obj;
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;
1244 i = connP_get_obj_type_index(target_type, target_subtype);
1248 trg_conn_obj = &(ConnP_conn_objs[i]);
1249 n = trg_conn_obj->num_actions;
1254 ConnP_conn_acts = (ConnAct *)XtMalloc(sizeof(ConnAct) * n);
1256 for (i = 0; i < n; i++)
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]);
1261 ConnP_num_conn_acts = n;
1264 /* This routine tries to match on type and subtype to
1265 * get the "When" and "Action", Object Type string info.
1268 connP_objtype_needs_subtype(
1269 AB_OBJECT_TYPE obj_type,
1275 for (i = 0; i < ConnP_num_conn_objs; i++)
1277 if ((ConnP_conn_objs[i].obj_type == obj_type) &&
1278 (ConnP_conn_objs[i].obj_subtype == obj_subtype))
1280 if (ConnP_conn_objs[i].obj_subtype == -1)
1291 AB_OBJECT_TYPE obj_type,
1295 return(connP_get_obj_type_index(obj_type, obj_subtype) >= 0);
1301 AB_ARG_TYPE arg_type,
1306 * Populate arg entries
1308 ab_action->info.action.arg_type = arg_type;
1312 obj_set_arg_string(ab_action, str_value);
1315 obj_set_arg_int(ab_action, atoi(str_value));
1323 connP_make_builtin_conn(
1328 AB_BUILTIN_ACTION c_act
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;
1340 connP_make_user_def_conn(
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);
1355 connP_make_code_frag_conn(
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);
1369 #define ACT(field) ab_action->info.action.field
1372 connP_builtin_remove_arg(
1376 AB_ARG_TYPE arg_type = ACT(arg_type);
1381 if (ACT(arg_value.sval) != (ISTRING)NULL)
1383 istr_destroy(ACT(arg_value.sval));
1384 ACT(arg_value.sval) = (ISTRING)NULL;
1390 connP_change_in_builtin(
1395 AB_BUILTIN_ACTION c_act,
1399 AB_ARG_TYPE old_arg_type;
1400 AB_ARG_TYPE cur_arg_type;
1401 BOOL is_changed = FALSE;
1403 #define CSETQ(lval, rval) \
1404 if ((lval) != (rval)) \
1407 is_changed = TRUE; \
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);
1415 old_arg_type = connP_action_needs_arg(ACT(func_value.builtin));
1416 cur_arg_type = connP_action_needs_arg(c_act);
1418 if (old_arg_type != cur_arg_type)
1421 connP_builtin_remove_arg(ab_action);
1422 connP_set_conn_arg(ab_action, cur_arg_type, arg_str);
1428 switch (cur_arg_type)
1431 if (arg_str != (char *)NULL)
1432 istr_value = istr_create(arg_str);
1434 istr_value = (ISTRING)NULL;
1435 if (ACT(arg_value.sval) != istr_value)
1437 if (istr_value != (ISTRING)NULL)
1438 istr_destroy(istr_value);
1440 connP_builtin_remove_arg(ab_action);
1441 connP_set_conn_arg(ab_action, cur_arg_type, arg_str);
1446 if (!util_strempty(arg_str))
1448 CSETQ(ACT(arg_value.ival), atoi(arg_str));
1449 connP_set_conn_arg(ab_action, cur_arg_type, arg_str);
1464 connP_destroy_connections_for(
1473 (project = obj_get_project(obj)) == NULL)
1477 for (trav_open(&trav, project, AB_TRAV_ACTIONS);
1478 (cobj = trav_next(&trav)) != NULL; )
1480 if (cobj->info.action.from == obj ||
1481 (cobj->info.action.func_type == AB_FUNC_BUILTIN &&
1482 cobj->info.action.to == obj))
1489 connP_make_on_item_help_conn(
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;
1503 connP_make_help_vol_conn(
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;
1521 * Initializes strings used in connections editor
1528 XtNewString(catgets(Dtb_project_catd, 100, 158, "??unknown??"));
1530 XtNewString(catgets(Dtb_project_catd, 100, 159, "??invalid??"));
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;
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;