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: abobj_list.c /main/3 1995/11/06 17:16:26 rswiston $
27 * @(#)abobj_list.c 1.7 25 Jul 1994 cde_app_builder/src/ab
29 * RESTRICTED CONFIDENTIAL INFORMATION:
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
39 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
44 * File: abobj_list.c - handles a scrolling list of ABObjs
49 #include <ab_private/abobj_list.h>
50 #include <ab_private/ui_util.h>
51 #include <ab_private/trav.h>
54 /*************************************************************************
56 ** Private Function Declarations **
58 **************************************************************************/
60 /*************************************************************************
64 **************************************************************************/
66 /*************************************************************************
68 ** Function Definitions **
70 **************************************************************************/
73 ** Traverse the project and load all objects into the scrolling list. This
74 ** is a generalized function that traverses all salient objects as candidates
75 ** to be displayed. It takes an additional test function as an argument, and
76 ** applies that function to each object in turn. The object will appear in
77 ** the list only if the test function returns non-zero.
79 ** ("He's making a list, and checking it twice..." (well, o.k., once))
85 ABObjTestFunc list_obj_func
90 if ((root == NULL) || (list == NULL)) return(0);
92 /* Clear out the list so we can start afresh */
93 XmListDeleteAllItems(list);
95 return_value = abobj_list_update(list, root, list_obj_func);
104 ABObjTestFunc list_obj_func
113 if ((root == NULL) || (list == NULL)) return(0);
115 for( (trav_open(&trav,root,AB_TRAV_SALIENT));
116 (obj = trav_next(&trav)) != NULL; )
118 if (obj_get_name(obj) != NULL)
120 modname = abobj_get_moduled_name(obj);
121 if((*list_obj_func)(obj))
123 if (ui_list_find_item(list,modname,&item_pos)
126 ui_list_add_item(list,modname,0);
132 ui_list_delete_item(list,modname);
143 * An object was created - add it to the list (maybe)
145 * Returns a negative ERR_ code if an error occurs
146 * Returns 0 if the object was not added
147 * Returns 1 if the object was added to the list
150 abobj_list_obj_created(
153 ABObjTestFunc list_obj_test
156 int return_value = 0;
157 int rc = 0; /* return code */
159 if ((obj == NULL) || (list == NULL)) return(0);
161 if (!list_obj_test(obj))
166 if (obj_get_name(obj) != NULL)
168 STRING modname = abobj_get_moduled_name(obj);
169 rc = ui_list_add_item(list, modname, 0);
179 XtFree(modname); modname = NULL;
188 ** Some object has been deleted and we should act accordingly.
189 ** Note -- this is a synthetic callback generated from within AppBuilder,
190 ** not a traditional Xt-style callback (hence the different argument style)
193 abobj_list_obj_destroyed(
196 ABObjTestFunc list_obj_test
199 STRING modname = NULL;
201 if ((obj == NULL) || (list == NULL)) return(0);
204 ** Check to make sure this is an object we'd have in the list to
207 if (list_obj_test(obj)) {
208 modname = abobj_get_moduled_name(obj);
209 ui_list_delete_item(list, modname);
216 ** Some object has been renamed and we should act accordingly.
217 ** Note -- this is a synthetic callback generated from within AppBuilder,
218 ** not a traditional Xt-style callback (hence the different argument style)
221 abobj_list_obj_renamed(
225 ABObjTestFunc list_obj_test
228 int rc = 0; /* return code */
229 STRING new_modname = NULL;
230 STRING old_modname = NULL;
231 ABObj module = obj_get_module(obj);
233 if ((obj == NULL) || (list == NULL)) return(0);
235 if (obj_is_module(obj))
237 ui_list_replace_item_prefix(
238 list, old_name, obj_get_name(obj));
240 else if ((module != NULL) && list_obj_test(obj)) {
242 new_modname = abobj_get_moduled_name(obj);
243 old_modname = abobj_alloc_moduled_name(
244 obj_get_name(module), old_name);
245 rc = ui_list_replace_item(list, old_modname, new_modname);
246 if (rc == ERR_NOT_FOUND)
248 ui_list_add_item(list, new_modname, 0);
258 * Completely rebuild all that is known about this object or tree
261 abobj_list_obj_updated(
263 ObjEvUpdateInfo info,
264 ABObjTestFunc list_obj_test
267 return abobj_list_update(list, info->obj, list_obj_test);
271 abobj_list_obj_reparented(
273 ObjEvReparentInfo info,
274 ABObjTestFunc list_obj_test
277 static char full_name[BUFSIZ];
278 STRING moduled_name = NULL,
285 if ((obj == NULL) || (list == NULL)) return(0);
287 if (obj_get_parent(obj) == NULL)
289 module = obj_get_name(obj_get_module(info->old_parent));
290 strcpy(full_name, module);
291 strcat(full_name, " :: ");
292 strcat(full_name, obj_get_name(obj));
296 name = abobj_get_moduled_name(obj);
298 if (list_obj_test(obj))
299 ret = ui_list_add_item(list, name, 0);
301 ret = ui_list_delete_item(list, name);