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
25 * $XConsortium: connect.c /main/3 1995/11/06 18:03:27 rswiston $
27 * @(#)connect.c 3.25 13 Feb 1994 cde_app_builder/src/abmf
29 * RESTRICTED CONFIDENTIAL INFORMATION:
31 * The information in this document is subject to special restrictions in a
32 * confidential disclosure agreement between HP, IBM, Sun, USL, SCO and
33 * Univel. Do not distribute this document outside HP, IBM, Sun, USL, SCO,
34 * or Univel without Sun's specific written approval. This document and all
35 * copies and derivative works thereof must be returned or destroyed at Sun's
38 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
43 * connect.c - Handles connections stuff
48 #include <ab_private/trav.h>
49 #include "ui_header_fileP.h" /* abmfP_comp_get_widget_specific_includes */
50 #include "obj_namesP.h"
53 #define APP_PREFIX_LEN 4
54 #define APP_PREFIX "_app"
56 static int abmfP_set_action_names_for_obj(ABObj rootObj);
60 abmfP_get_action_name(ABObj action)
62 static char name[256];
63 STRING parent_name = (STRING) NULL;
64 ABObj from = NULL, parent = NULL;
65 STRING tmpName = NULL;
68 from = obj_get_from(action);
69 if (action->info.action.auto_named && (from != NULL))
71 /* If the source object is the project,
72 * then this is an "Application" connection.
73 * This probably won't happen because right
74 * now "Application" connections can only be
75 * of type AB_FUNC_USER_DEF (which means auto-
78 if (obj_is_project(from))
80 parent = obj_get_project(action);
81 parent_name = (STRING) util_malloc(
82 strlen(obj_get_name(parent))
83 + APP_PREFIX_LEN + 1);
84 strcpy(parent_name, obj_get_name(parent));
85 strcat(parent_name, APP_PREFIX);
89 parent = obj_get_module(from);
90 parent_name = obj_get_name(parent);
93 if (!util_strempty(parent_name) &&
94 !util_strempty(obj_get_name(from)))
96 sprintf(name, "%s_%s%s",
99 obj_get_func_name_suffix(action));
102 if (obj_is_project(from))
104 util_free(parent_name);
109 if ((tmpName = obj_get_func_name(action)) != NULL)
111 sprintf(name, "%s", tmpName);
115 return (name[0] == 0 ? NULL : name);
123 abmfP_tree_set_action_names(ABObj rootObj)
125 int return_value = 0;
126 AB_TRAVERSAL moduleTrav;
129 if (!obj_is_project(rootObj))
131 return_value = abmfP_set_action_names_for_obj(rootObj);
135 /* for efficiency, we'll only visit those modules that are
136 * going to be written
138 abmfP_set_action_names_for_obj(rootObj); /* project 1st */
140 for (trav_open(&moduleTrav, rootObj, AB_TRAV_MODULES);
141 (module = trav_next(&moduleTrav)) != NULL; )
143 if (obj_get_write_me(module))
145 abmfP_set_action_names_for_obj(module); /* each module */
148 trav_close(&moduleTrav);
156 abmfP_set_action_names_for_obj(ABObj rootObj)
158 int return_value = 0;
160 AB_TRAVERSAL actionTrav;
162 ABObj fromObj = NULL;
165 if (mfobj_data(rootObj) == NULL)
170 for (trav_open(&actionTrav, rootObj, AB_TRAV_ACTIONS_FOR_OBJ);
171 (action = trav_next(&actionTrav)) != NULL;)
173 if ( (obj_get_func_type(action) != AB_FUNC_USER_DEF)
174 && ((fromObj = obj_get_from(action)) != NULL) )
176 action->info.action.auto_named = TRUE;
177 actionNum = mfobj_data(fromObj)->num_auto_callbacks + 1;
178 mfobj_data(fromObj)->num_auto_callbacks = actionNum;
179 sprintf(buf, "_CB%d", actionNum);
180 obj_set_func_name_suffix(action, buf);
183 trav_close(&actionTrav);
190 abmfP_get_connect_includes(StringList includeFiles, ABObj projOrModule)
193 BOOL actionIsCrossModule = FALSE;
194 ABObj project = obj_get_project(projOrModule);
197 ABObj compRoot = NULL;
198 ABObj toModule = NULL;
199 ABObj win_parent = NULL;
200 ABObj popup_win = NULL;
201 char headerFilename[MAXPATHLEN+1];
204 strlist_set_is_unique(includeFiles, TRUE);
205 assert(project != NULL);
211 for (trav_open(&trav, projOrModule, AB_TRAV_ACTIONS_FOR_OBJ);
212 (action = trav_next(&trav)) != NULL; )
214 actionIsCrossModule = obj_is_cross_module(action);
215 toObj = obj_get_to(action);
221 toModule = obj_get_module(toObj);
223 if (actionIsCrossModule)
225 sprintf(headerFilename, "\"%s\"",
226 abmfP_get_ui_header_file_name(toModule));
227 strlist_add_str(includeFiles, headerFilename, NULL);
231 * Check to see if the popup's window parent is in another module
233 compRoot = obj_get_root(toObj);
235 if (obj_is_popup_win(compRoot))
237 popup_win = compRoot;
239 if (popup_win == NULL)
241 popup_win = obj_get_parent_of_type(compRoot, AB_TYPE_DIALOG);
243 if (popup_win == NULL)
245 popup_win = obj_get_parent_of_type(compRoot, AB_TYPE_BASE_WINDOW);
248 if (popup_win != NULL)
250 win_parent= obj_get_win_parent(popup_win);
251 if (win_parent != NULL)
253 toModule = obj_get_module(win_parent);
254 if (toModule != NULL)
256 sprintf(headerFilename, "\"%s\"",
257 abmfP_get_ui_header_file_name(toModule));
258 strlist_add_str(includeFiles, headerFilename, NULL);
264 * For some actions, we need widget-specific convenience
265 * functions and resource strings that exist in the header files.
267 if (obj_get_func_type(action) == AB_FUNC_BUILTIN)
269 switch (obj_get_func_builtin(action))
271 case AB_STDACT_SET_LABEL:
272 case AB_STDACT_SET_TEXT:
273 case AB_STDACT_SET_VALUE:
274 abmfP_comp_get_widget_specific_includes(
275 includeFiles, obj_get_root(toObj));