Example #1
0
static int
write_action_functions(GenCodeInfo genCodeInfo, ABObj obj)
{
    File                codeFile = genCodeInfo->code_file;
    static char         msg[256],
           *s;
    AB_TRAVERSAL        trav;
    ABObj               action = NULL;
    ABObj               fromObj = NULL;	/* for error reports */
    int                 i = 0;

    /*
     * Auto-named functions
     */
    for (trav_open(&trav, obj, AB_TRAV_ACTIONS_FOR_OBJ | AB_TRAV_MOD_SAFE), i = 0;
            (action = trav_next(&trav)) != NULL; ++i)
    {
        if (   mfobj_has_flags(action, CGenFlagIsDuplicateDef)
                || mfobj_has_flags(action, CGenFlagWriteDefToProjFile))
        {
            continue;
        }

        if (action->info.action.auto_named)
        {
            abmfP_write_action_function(genCodeInfo, action);
            abio_puts(genCodeInfo->code_file, "\n");
        }
    }
    /* don't close traversal, yet */

    /*
     * User-named functions
     */
    for (trav_reset(&trav);
            (action = trav_next(&trav)) != NULL; ++i)
    {
        if (   mfobj_has_flags(action, CGenFlagIsDuplicateDef)
                || mfobj_has_flags(action, CGenFlagWriteDefToProjFile))
        {
            continue;
        }

        if (!(action->info.action.auto_named))
        {
            abmfP_write_action_function(genCodeInfo, action);
            abio_puts(genCodeInfo->code_file, "\n");
        }
    }
    trav_close(&trav);

    return OK;
}
Example #2
0
static int
abmfP_set_action_names_for_obj(ABObj rootObj)
{
    int			return_value = 0;
    int          	actionNum = -1;
    AB_TRAVERSAL        actionTrav;
    ABObj               action = NULL;
    ABObj		fromObj = NULL;
    char                buf[256];

    if (mfobj_data(rootObj) == NULL)
    {
	return -1;
    }

    for (trav_open(&actionTrav, rootObj, AB_TRAV_ACTIONS_FOR_OBJ);
	 	(action = trav_next(&actionTrav)) != NULL;)
    {
	if (   (obj_get_func_type(action) != AB_FUNC_USER_DEF)
	    && ((fromObj = obj_get_from(action)) != NULL) )
	{
	        action->info.action.auto_named = TRUE;
		actionNum = mfobj_data(fromObj)->num_auto_callbacks + 1;
		mfobj_data(fromObj)->num_auto_callbacks = actionNum;
	        sprintf(buf, "_CB%d", actionNum);
	        obj_set_func_name_suffix(action, buf);
	}
    }
    trav_close(&actionTrav);

    return return_value;
}
Example #3
0
int
abmfP_tree_set_action_names(ABObj rootObj)
{
    int			return_value = 0;
    AB_TRAVERSAL	moduleTrav;
    ABObj		module = NULL;

    if (!obj_is_project(rootObj))
    {
	return_value = abmfP_set_action_names_for_obj(rootObj);
    }
    else
    {
	/* for efficiency, we'll only visit those modules that are 
	 * going to be written
	 */
	abmfP_set_action_names_for_obj(rootObj);	/* project 1st */

	for (trav_open(&moduleTrav, rootObj, AB_TRAV_MODULES);
		(module = trav_next(&moduleTrav)) != NULL; )
	{
	    if (obj_get_write_me(module))
	    {
	        abmfP_set_action_names_for_obj(module);	/* each module */
	    }
	}
	trav_close(&moduleTrav);
    }

    return return_value;
}
Example #4
0
static int
write_main_session_restore(
    GenCodeInfo	genCodeInfo, 
    ABObj	project
)
{
    File	codeFile;

    if (!genCodeInfo || !project)
	return (0);

    codeFile = genCodeInfo->code_file;

    if (abmfP_proj_needs_session_restore(project))
    {
        AB_TRAVERSAL	trav;
	ABObj		action;
	char		*ss_restore_CB_name = NULL;

        abio_puts(codeFile,"\n");
        abio_puts(codeFile,"if (dtb_app_resource_rec.session_file)\n");
        abio_puts(codeFile,"{\n");

	if (!obj_is_project(project))
	    project = obj_get_project(project);

	/*
	 * Search for session restore callback in project
	 * action list
	 */
    	for (trav_open(&trav, project, AB_TRAV_ACTIONS);
             (action = trav_next(&trav)) != NULL;)
    	{
	    switch(obj_get_when(action))
	    {
		case AB_WHEN_SESSION_RESTORE:
		    /*
		     * Remember session restore callback if found
		     */
		    ss_restore_CB_name = obj_get_func_name(action);
		    break;
		default:
		    break;
	    }
	}
	trav_close(&trav);

	abio_printf(codeFile, 
	"    dtb_set_client_session_restoreCB((DtbClientSessionRestoreCB)%s);\n",
		ss_restore_CB_name ? ss_restore_CB_name : "NULL");

        abio_puts(codeFile,
	"    (void)dtb_session_restore(toplevel, dtb_app_resource_rec.session_file);\n");
        abio_puts(codeFile,"}\n");

        abio_puts(codeFile,"\n");
    }

    return (0);
}
Example #5
0
int
gilP_load_att_menu_item_handlers(FILE * inFile, ABObj obj, ABObj module)
{
    int                 return_value = 0;
    int                 rc = 0; /* r turn code */
    ISTRING_ARRAY       handlers;
    AB_TRAVERSAL        trav;
    ABObj               item = NULL;
    int                 i = 0;

    istr_array_init(&handlers);
    if ((rc = gilP_load_handlers(inFile, &handlers)) < 0)
    {
        return rc;
    }
    obj_ensure_num_children(obj, handlers.count);
    for (trav_open(&trav, obj, AB_TRAV_ITEMS_FOR_OBJ), i = 0;
         (item = trav_next(&trav)) != NULL; ++i)
    {
        add_user_handler(item, module,
                         handlers.strings[i], AB_WHEN_ACTIVATED);
        handlers.strings[i] = NULL;
    }
    trav_close(&trav);
    istr_array_uninit(&handlers);
    return return_value;
}
Example #6
0
/*
 * Traverse object list and write out callback decls, for those
 * connections with the proper value of auto_named.
 */
static int
write_user_or_auto_decls(
			GenCodeInfo genCodeInfo, 
			ABObj project, 
			BOOL auto_named)
{
    AB_TRAVERSAL        trav;
    ABObj               action = NULL;
    AB_ACTION_INFO     *actinfo = NULL;
    STRING              func_name = NULL;

    for (trav_open(&trav, project, AB_TRAV_ACTIONS);
	 (action = trav_next(&trav)) != NULL;)
    {
	/* If action is not a cross-module connection AND it
	 * is not a shared connection, continue.
	 */
	if ( !obj_is_cross_module(action) &&
	     ( mfobj_has_flags(action, CGenFlagIsDuplicateDef) ||
	       (!mfobj_has_flags(action, CGenFlagWriteDefToProjFile))
	     )
	   )
	{
	    continue;
	}

	actinfo = &(action->info.action);
	func_name = abmfP_get_action_name(action);
	if (!util_xor(actinfo->auto_named, auto_named))
	{
	    abmfP_write_action_func_decl(genCodeInfo, action);
	    abio_puts(genCodeInfo->code_file, nlstr);
	}
    }
    trav_close(&trav);
    return 0;
}
Example #7
0
static int
choice_prop_apply(
    AB_PROP_TYPE   type
)
{
    PropChoiceSettingsRec *pcs = &(prop_choice_settings_rec[type]);
    STRING	    	value;
    BOOL	    	size_chg = False;
    BOOL	    	reset_bg = False;
    BOOL	    	reset_fg = False;

    if (!verify_props(type))
        return ERROR;

    if (prop_changed(pcs->name.changebar))
    {
        value = prop_field_get_value(&(pcs->name));
        abobj_set_name(pcs->current_obj, value);
        util_free(value);
    }
    if (prop_changed(pcs->label.changebar) ||
            prop_changed(pcs->label_type.changebar))
    {
        value = prop_field_get_value(&(pcs->label));

        abobj_set_label(pcs->current_obj,
                        (AB_LABEL_TYPE)prop_options_get_value(&(pcs->label_type)),
                        value);
        util_free(value);

        abobj_set_label_position(pcs->current_obj,
                                 (AB_COMPASS_POINT)prop_options_get_value(&(pcs->label_pos)));

        size_chg = True;
    }
    /*
        if (prop_changed(pcs->choice_type.changebar))
        {
            abobj_set_choice_type(pcs->current_obj,
                (AB_CHOICE_TYPE)prop_options_get_value(&(pcs->choice_type)));
            size_chg = True;
        }
    */
    if (prop_changed(pcs->row_col.changebar))
    {
        int cols;
        abobj_set_orientation(pcs->current_obj,
                              (AB_ORIENTATION)prop_radiobox_get_value(&(pcs->row_col)));
        cols = prop_field_get_numeric_value(&(pcs->row_col_count));
        abobj_set_num_columns(pcs->current_obj, cols);
        size_chg = True;
    }
    if (prop_changed(pcs->pos.changebar))
    {
        if (abobj_is_movable(pcs->current_obj))
            abobj_set_xy(pcs->current_obj,
                         prop_geomfield_get_value(&(pcs->pos), GEOM_X),
                         prop_geomfield_get_value(&(pcs->pos), GEOM_Y));
    }
    if (prop_changed(pcs->init_state.changebar))
    {
        abobj_set_visible(pcs->current_obj,
                          prop_checkbox_get_value(&(pcs->init_state), AB_STATE_VISIBLE));
        abobj_set_active(pcs->current_obj,
                         prop_checkbox_get_value(&(pcs->init_state), AB_STATE_ACTIVE));
    }
    if (prop_changed(pcs->fg_color.changebar))
    {
        value = prop_colorfield_get_value(&(pcs->fg_color));
        abobj_set_foreground_color(pcs->current_obj, value);
        if (util_strempty(value))
            reset_fg = True;
        util_free(value);
        prop_colorfield_set_value(&(pcs->fg_color),
                                  obj_get_fg_color(pcs->current_obj), False);
    }
    if (prop_changed(pcs->bg_color.changebar))
    {
        value = prop_colorfield_get_value(&(pcs->bg_color));
        abobj_set_background_color(pcs->current_obj, value);
        if (util_strempty(value))
            reset_bg = True;
        util_free(value);
        prop_colorfield_set_value(&(pcs->bg_color),
                                  obj_get_bg_color(pcs->current_obj), False);
    }
    if (prop_changed(pcs->items.changebar))
    {
        /* Ensure edits to current item are saved before apply */
        prop_item_change(&(pcs->items), False);
        prop_item_editor_apply(&(pcs->items));
        size_chg = True;
    }
    if (prop_changed(pcs->choice_type.changebar))
    {
        abobj_set_choice_type(pcs->current_obj,
                              (AB_CHOICE_TYPE)prop_options_get_value(&(pcs->choice_type)));
        size_chg = True;
    }

    abobj_tree_instantiate_changes(pcs->current_obj);

    if (reset_bg || reset_fg) /* Set back to No Color */
    {
        ABObj 	     item;
        AB_TRAVERSAL trav;

        abobj_reset_colors(pcs->current_obj, reset_bg, reset_fg);

        /* Need to also reset the Item's colors also */
        for (trav_open(&trav, pcs->current_obj, AB_TRAV_ITEMS);
                (item = trav_next(&trav)) != NULL; )
        {
            abobj_reset_colors(item, reset_bg, reset_fg);
        }
        trav_close(&trav);
    }
    if (size_chg)
        abobj_force_dang_form_resize(pcs->current_obj);

    turnoff_changebars(type);

    return OK;
}
Example #8
0
static int 	
write_main_register_save_yourself(
			GenCodeInfo	genCodeInfo, 
			ABObj		project, 
			char		*atom_name
)
{
    File	codeFile;

    if (!genCodeInfo || !project)
	return (0);

    if (!atom_name)
	atom_name = "save_yourself_atom";

    codeFile = genCodeInfo->code_file;

    abio_puts(codeFile,"\n");

    /*
     * Set client save session callback
     */
    if (abmfP_proj_needs_session_save(project))
    {
        AB_TRAVERSAL	trav;
	ABObj		action;
	char		*ss_save_CB_name = NULL;

	/*
	 * Search for session save callback in project
	 * action list
	 */
    	for (trav_open(&trav, project, AB_TRAV_ACTIONS);
             (action = trav_next(&trav)) != NULL;)
    	{
	    switch(obj_get_when(action))
	    {
		case AB_WHEN_SESSION_SAVE:
		    /*
		     * Remember session save callback if found
		     */
		    ss_save_CB_name = obj_get_func_name(action);
		    break;
		default:
		    break;
	    }
	}
	trav_close(&trav);

	abio_printf(codeFile, 
	    "dtb_set_client_session_saveCB((DtbClientSessionSaveCB)%s);\n",
		ss_save_CB_name ? ss_save_CB_name : "NULL");

	abio_puts(codeFile, "\n");
    }

    abio_printf(codeFile,"XmAddWMProtocolCallback(toplevel, %s,\n", atom_name);
    abio_puts(codeFile,"\tdtb_session_save, (XtPointer)NULL);\n");

    abio_puts(codeFile,"\n");

    return (0);
}
Example #9
0
static void display_variable(GtkTreeModel *Variables, GtkTreeIter *Iter, Std$Object$t *Value, Std$Object_t **Address) {
	//printf("Address = 0x%x, Value = 0x%x\n", Address, Value);
	const char *String;
	if (Value->Type == Agg$Table$T) {
		size_t OldGeneration, CurrentGeneration = Agg$Table$generation(Value);
		gtk_tree_model_get(Variables, Iter, 5, &OldGeneration, -1);
		//printf("OldGeneration = %d, CurrentGeneration = %d\n", OldGeneration, CurrentGeneration);
		if (OldGeneration != CurrentGeneration) {
			gtk_tree_store_set(Variables, Iter, 1, "{...}", 3, Value, 5, CurrentGeneration, -1);
			GtkTreeIter Child;
			while (gtk_tree_model_iter_children(Variables, &Child, Iter)) gtk_tree_store_remove(Variables, &Child);
			if (Agg$Table$size(Value) < 100) {
				Agg$Table$trav *Trav = Agg$Table$trav_new();
				for (Std$Object$t *Node = Agg$Table$trav_first(Trav, Value); Node; Node = Agg$Table$trav_next(Trav)) {
					gtk_tree_store_append(Variables, &Child, Iter);
					gtk_tree_store_set(Variables, &Child, 0, to_string(Agg$Table$node_key(Node)) ?: "<key>", 5, -1, -1);
					Std$Object$t **NodeAddress = Agg$Table$node_value_ref(Node);
					display_variable(Variables, &Child, *NodeAddress, NodeAddress);
				};
			};
Example #10
0
/*
 * Write main() for the given project.
 */
static int
write_main(GenCodeInfo genCodeInfo, ABObj project)
{
    int                 returnValue = 0;
    File                codeFile = genCodeInfo->code_file;
    ABObj               window = NULL;
    int                 initialized = FALSE;
    ABObj		main_window= NULL;
    AB_TRAVERSAL        trav;
    BOOL		mainWindowHasIcon = FALSE;

    abmfP_gencode_enter_func(genCodeInfo);

    main_window = abmfP_get_root_window(project);
    if (main_window != NULL)
    {
	mfobj_set_flags(main_window, CGenFlagTreatAsAppShell);
    }
    mainWindowHasIcon = 
	(   (main_window != NULL) 
	 && (   (obj_get_icon(main_window) != NULL)
	     || (obj_get_icon_mask(main_window) != NULL)) );

    abio_puts(codeFile, "\n\n");
    abio_puts(codeFile, abmfP_comment_begin);
    abio_puts(codeFile, abmfP_comment_continue);
    abio_printf(codeFile, "main for application %s\n",
		obj_get_name(project));
    abio_puts(codeFile, abmfP_comment_end);

    /*
     * Write func declaration.
     */
    abio_puts(codeFile, "int\n");
    if (genCodeInfo->prototype_funcs)
    {
	abio_puts(codeFile, "main(int argc, char **argv)\n");
    }
    else
    {
	abio_puts(codeFile, "main(argc, argv)\n");
	abio_indent(codeFile);
	abio_puts(codeFile, "int\t\targc;\n");
	abio_puts(codeFile, "char\t\t**argv;\n");
	abio_outdent(codeFile);
    }

    abio_puts(codeFile, "{\n");
    abio_set_indent(codeFile, 1);

    /*
     * Local variables
     */
    abio_puts(codeFile, "Widget\t\ttoplevel = (Widget)NULL;\n");
    abio_puts(codeFile, "Display\t\t*display = (Display*)NULL;\n");
    abio_puts(codeFile, "XtAppContext\tapp = (XtAppContext)NULL;\n");
    abio_puts(codeFile, "String\t\t*fallback_resources = (String*)NULL;\n");
    abio_puts(codeFile, "ArgList\t\tinit_args = (ArgList)NULL;\n");
    abio_puts(codeFile, "Cardinal\t\tnum_init_args = (Cardinal)0;\n");
    abio_puts(codeFile, "ArgList\t\tget_resources_args = (ArgList)NULL;\n");
    abio_puts(codeFile, "Cardinal\t\tnum_get_resources_args = (Cardinal)0;\n");
    abio_puts(codeFile, "Atom\t\tsave_yourself_atom = (Atom)NULL;\n");
    write_main_i18n_local_vars(genCodeInfo, project);
    write_main_tooltalk_local_vars(genCodeInfo, project);
    abio_puts(codeFile, nlstr);

    if (mainWindowHasIcon)
    {
	abmfP_icon_pixmap_var(genCodeInfo) = istr_const("icon_pixmap");
	abmfP_icon_mask_pixmap_var(genCodeInfo) = 
					istr_const("icon_mask_pixmap");
	abio_puts(codeFile, "Pixmap\ticon_pixmap = NULL;\n");
	abio_puts(codeFile, "Pixmap\ticon_mask_pixmap = NULL;\n");
    }

    abmfP_write_user_long_seg(genCodeInfo,
    " No initialization has been done.\n"
"     ***\n"
"     *** Add local variables and code."
    );

    if (genCodeInfo->i18n_method == ABMF_I18N_XPG4_API)
        write_main_xt_i18n(genCodeInfo, project);

    /*
     * Create a parent shell for every other shell and don't realize it. This
     * way, we can be consistent with our hierarchy.
     */
    abio_printf(codeFile,"toplevel = XtAppInitialize(&app, \"%s\",\n",
	abmfP_capitalize_first_char(obj_get_name(project)));
    abio_indent(codeFile);
    abio_puts(codeFile, "optionDescList, XtNumber(optionDescList),\n");
    abio_puts(codeFile, "&argc, argv, fallback_resources,\n");
    abio_puts(codeFile, "init_args, num_init_args);\n\n");
    abio_outdent(codeFile);

    abmfP_write_c_comment(genCodeInfo, FALSE,
	"Get display and verify initialization was successful.");
    abio_puts(codeFile, "if (toplevel != NULL)\n");
    abmfP_write_c_block_begin(genCodeInfo);
    abio_puts(codeFile, "display = XtDisplayOfObject(toplevel);\n");
    abmfP_write_c_block_end(genCodeInfo);

    if (genCodeInfo->i18n_method == ABMF_I18N_XPG4_API)
        write_main_msg_i18n(genCodeInfo, project);
    
    abio_puts(codeFile, "if (display == NULL)\n");
    abmfP_write_c_block_begin(genCodeInfo);
    abio_puts(codeFile, "fprintf(stderr, \"Could not open display.\");\n");
    abio_puts(codeFile, "exit(1);\n");
    abmfP_write_c_block_end(genCodeInfo);

    /* Save the toplevel widget so it can be fetched later as needed */
    abio_puts(codeFile,"\n");
    abmfP_write_c_comment(genCodeInfo, FALSE,
      "Save the toplevel widget so it can be fetched later as needed.");
    abio_puts(codeFile, "dtb_save_toplevel_widget(toplevel);\n");

    /* Save the command used to invoke the application */
    abio_puts(codeFile,"\n");
    abmfP_write_c_comment(genCodeInfo, FALSE,
      "Save the command used to invoke the application.");
    abio_puts(codeFile, "dtb_save_command(argv[0]);\n");

    /*
     * Get application resources
     */
    abio_puts(codeFile,"\n");
    abio_puts(codeFile, "XtGetApplicationResources(toplevel, (XtPointer)&dtb_app_resource_rec,\n");
    abio_indent(codeFile);
    abio_puts(codeFile, "resources, XtNumber(resources),\n");
    abio_puts(codeFile, "get_resources_args, num_get_resources_args);\n");
    abio_outdent(codeFile);
    abio_puts(codeFile, nlstr);

    /*
     * User segment after initialization
     */
    abmfP_write_user_long_seg(genCodeInfo,
"     A connection to the X server has been established, and all\n"
"     *** initialization has been done.\n"
"     ***\n"
"     ***  Add extra initialization code after this comment."
    );

    /*
     * Call session restore callback (if needed)
     */
    write_main_session_restore(genCodeInfo, project);

    /*
     * Initialize all global variables
     */
    abio_puts(codeFile, nlstr);
    abmfP_write_c_comment(genCodeInfo, FALSE, 
	"Initialize all global variables.");
    for (trav_open(&trav, project, AB_TRAV_SALIENT_UI);
	(window= trav_next(&trav)) != NULL; )
    {
	if (!obj_is_defined(window))
	{
	    continue;
	}

	if (obj_is_message(window))
 	{
	    abio_printf(codeFile, "%s(&%s);\n",
		abmfP_get_msg_clear_proc_name(window),
		abmfP_get_c_struct_global_name(window));
	}
	else if (obj_is_window(window))
	{
	    abio_printf(codeFile, "%s(&%s);\n",
		abmfP_get_clear_proc_name(window),
		abmfP_get_c_struct_global_name(window));
	}
    }
    trav_close(&trav);
    abio_puts(codeFile, "\n");

    if (main_window != NULL)
    {
	abmfP_write_c_comment(genCodeInfo, FALSE,
		"Set up the application's root window.");
        abio_printf(codeFile, "%s = toplevel;\n",
	    abmfP_get_c_name_global(main_window));

	if (obj_get_icon(main_window) != NULL)
	{
	    abio_printf(codeFile, "%s(%s,\n", 
		abmfP_lib_cvt_image_file_to_pixmap->name,
	        abmfP_get_c_name_global(main_window));
	    abio_indent(codeFile);
	    abio_put_string(codeFile, obj_get_icon(main_window));
	    abio_printf(codeFile, ", &%s);\n",
		istr_string(abmfP_icon_pixmap_var(genCodeInfo)));
	    abio_outdent(codeFile);
	    abmfP_icon_pixmap_var_has_value(genCodeInfo) = TRUE;
	}
	if (obj_get_icon_mask(main_window) != NULL)
	{
	    abio_printf(codeFile, "%s(%s,\n", 
		abmfP_lib_cvt_image_file_to_pixmap->name,
	        abmfP_get_c_name_global(main_window));
	    abio_indent(codeFile);
	    abio_put_string(codeFile, obj_get_icon_mask(main_window));
	    abio_printf(codeFile, ", &%s);\n",
		istr_string(abmfP_icon_mask_pixmap_var(genCodeInfo)));
	    abio_outdent(codeFile);
	    abmfP_icon_mask_pixmap_var_has_value(genCodeInfo) = TRUE;
	}

	if (abmfP_get_num_args_of_classes(main_window, ABMF_ARGCLASS_ALL) > 0)
	{
	    abmfP_xt_va_list_open_setvalues(genCodeInfo, main_window);
            abmfP_obj_spew_args(genCodeInfo, 
		main_window, ABMF_ARGCLASS_ALL, ABMF_ARGFMT_VA_LIST);
    	    if (!obj_get_resizable(main_window))
	    {
        	abio_printf(codeFile,
            	    "XmNmwmDecorations, MWM_DECOR_ALL | MWM_DECOR_RESIZEH,\n");
        	abio_printf(codeFile, 
            	    "XmNmwmFunctions, MWM_FUNC_ALL | MWM_FUNC_RESIZE,\n"); 
	    }
	    abmfP_xt_va_list_close(genCodeInfo);
	}
    }
    abio_puts(codeFile, nlstr);
    if ((main_window != NULL) && (obj_is_initially_visible(main_window)))
    {
	/* ApplicationShell doesn't require "show" action for mapping */
        write_map_window(genCodeInfo, main_window, False);
    }
    /*
     * Display any initially mapped windows
     */  
    abio_puts(codeFile, nlstr);
    abmfP_write_c_comment(genCodeInfo, FALSE,
        "Map any initially-visible windows");
    for (trav_open(&trav, project, AB_TRAV_WINDOWS);
	 (window = trav_next(&trav)) != NULL;)
    {
	if ( (window != main_window) && 	
	     (obj_is_initially_visible(window)) &&
	     obj_is_defined(window)
	   )
	{
	    write_map_window(genCodeInfo, window, True);
	}
    }
    trav_close(&trav);

    /*
     * Get WM_SAVE_YOURSELF atom
     */
    abio_puts(codeFile, "\n");
    abio_puts(codeFile, "save_yourself_atom = XmInternAtom(XtDisplay(toplevel),\n");
    abio_puts(codeFile, "\t\"WM_SAVE_YOURSELF\", False);\n");

    /*
     * Register callback for WM_SAVE_YOURSELF
     */
    write_main_register_save_yourself(genCodeInfo, project, "save_yourself_atom");

    /*
     * User seg before realize
     */
    abmfP_write_user_long_seg(genCodeInfo,
"     All initially-mapped widgets have been created, but not\n"
"     *** realized. Set resources on widgets, or perform other operations\n"
"     *** that must be completed before the toplevel widget is\n"
"     *** realized."
    );

    /*
     * Realize the widget hierarchy
     */
    abio_puts(codeFile, "XtRealizeWidget(toplevel);\n\n");

    /*
     * Write ToolTalk Initialization if needed
     */
    write_main_tooltalk_init(genCodeInfo, project);

    /*
     * User seg before event loop
     */
    abmfP_write_user_long_seg(genCodeInfo,
"     The initially-mapped widgets have all been realized, and\n"
"     *** the Xt main loop is about to be entered."
    );

    abio_puts(codeFile, nlstr);

    abmfP_write_c_comment(genCodeInfo, FALSE, "Enter event loop");
    abio_puts(codeFile, "XtAppMainLoop(app);\n");

    /*
     * Write func footer.
     */
    abio_printf(codeFile, "return 0;\n");
    abio_set_indent(codeFile, 0);
    abio_puts(codeFile, "}\n\n");

    abmfP_gencode_exit_func(genCodeInfo);
    return returnValue;
}
Example #11
0
File: proj.c Project: juddy/edcde
/*
 * Action: Show the module when double-clicked on.
 */
static void
show_module(
    Widget widget, 
    XEvent *event, 
    String *params, 
    int num_params
)
{
    Vwr         v = NULL;
    VNode       selected_node;
    VMethods    m;
    ABObj       obj;
    ABObj       winobj;
    AB_TRAVERSAL trav;
 
    XtVaGetValues(widget, XmNuserData, &v, NULL);

    if (!v)
        return;

    selected_node = vwr_locate_node(v,
                        event->xbutton.x, event->xbutton.y);

    if (selected_node)
    {
        VNode   *selected_nodes = NULL;
        int     num_selected = 0;
 
        if (!(m = v->methods))
            return;

        /* USE METHODS !! */
        obj = (ABObj) selected_node->obj_data;
 
        if (!obj)
            return;

        /*
         * Set busy cursor before this potentially
         * lengthy operation
         */
        ab_set_busy_cursor(TRUE);

        /* If the module is already showing, then
         * make all of its windows come to the fore-
         * ground.
         */
        if (obj_has_flag(obj, MappedFlag))
        {
            for (trav_open(&trav, obj, AB_TRAV_WINDOWS);
                (winobj = trav_next(&trav)) != NULL; )
            {
                if (obj_has_flag(winobj, MappedFlag))
                    ui_win_front(objxm_get_widget(winobj));
            }
            trav_close(&trav);
            proj_set_cur_module(obj);
        }    
        else if( abobj_show_tree(obj, TRUE) == -1 )
        {
           if (util_get_verbosity() > 0)
             fprintf(stderr,"show_module: error in abobj_show_tree\n");
	}
        else 
        {
            proj_set_cur_module(obj);
        }

        vwr_get_cond(v->current_tree, &selected_nodes,
                        &num_selected, select_fn);

        if (selected_nodes)                        
            free((char *)selected_nodes);
 
        update_menu_items(0, num_selected);

        /*
         * Unset busy cursor
         */
        ab_set_busy_cursor(FALSE);

    }
}
Example #12
0
/*
 * Write the project.c file.
 */
int
abmfP_write_project_c_file(
			   GenCodeInfo genCodeInfo,
			   STRING codeFileName,
			   BOOL prepareForMerge,
			   ABObj project
)
{
    File                codeFile = genCodeInfo->code_file;
    STRING              errmsg = NULL;
    STRING             *p = NULL;
    ABObj               win_obj = NULL;
    ABObj               obj = NULL;
    ABObj               action = NULL;
    AB_ACTION_INFO     *action_info = NULL;
    AB_TRAVERSAL        trav;
    ABObj		module = NULL;
    int			numFuncsWritten = 0;
    char		projectName[1024];
    *projectName = 0;

    /*
     * Write file header.
     */
    abmfP_write_user_header_seg(genCodeInfo);
    abio_puts(codeFile, nlstr);

    sprintf(projectName, "project %s", obj_get_name(project));
    abmfP_write_file_header(
		genCodeInfo, 
		codeFileName, 
		FALSE,
		projectName,
		util_get_program_name(), 
		ABMF_MODIFY_USER_SEGS,
	   " * Contains: main() and cross-module connections"
		);

    /*
     * Write includes.
     */
    write_includes(genCodeInfo, project);

    /*
     * Write user segment
     */
    abmfP_write_user_file_top_seg(genCodeInfo);
   
    /* i18n variable declarations */
    if (genCodeInfo->i18n_method == ABMF_I18N_XPG4_API)
        write_i18n_var_declrs(genCodeInfo, project);

    write_option_desc_list(genCodeInfo, project);
    write_app_resources(genCodeInfo, project);
    write_app_resource_var(genCodeInfo, project);

    /*
     * Write main().
     */
    write_main(genCodeInfo, project);

    /*
     * Write callback funcs.
     */
    numFuncsWritten = 0;
    for (trav_open(&trav, project, AB_TRAV_ACTIONS);
	 (action = trav_next(&trav)) != NULL;)
    {
	action_info = &(action->info.action);

	/* If the function name for the action is not NULL AND
	 * the action is a cross-module connection OR the action
	 * is a shared connection, then write it out.
	 */
	if ( 	(abmfP_get_action_name(action) != NULL) && 
		(   obj_is_cross_module(action) || 
		    ( (!mfobj_has_flags(action, CGenFlagIsDuplicateDef))
	              && (mfobj_has_flags(action, CGenFlagWriteDefToProjFile))
	              && (obj_get_func_type(action) == AB_FUNC_USER_DEF)
		    )
		)
	   )

	{
	    ++numFuncsWritten;
	    abmfP_write_action_function(genCodeInfo, action);
	}
    }
    trav_close(&trav);

    if (numFuncsWritten > 0)
    {
	abio_puts(codeFile, nlstr);
    }
    abmfP_write_user_file_bottom_seg(genCodeInfo);

    return OK;
}
Example #13
0
static int
write_includes(GenCodeInfo genCodeInfo, ABObj project)
{
    File	 codeFile = genCodeInfo->code_file;
    STRING	 *p       = NULL;
    AB_TRAVERSAL trav;
    ABObj	 module   = NULL;
    StringList   includes = strlist_create();
    char         buf[MAXPATHLEN+1];
    int          i;
    
    strlist_set_is_unique(includes, TRUE);
    *buf = 0;

    /* standard system includes */
    for (p = Includes; *p; p++)
    {
	strlist_add_str(includes, *p, NULL);
    }

    /*
     * Includes for sessioning.
     * These include files are needed only if sessioning
     * is used.
     */
    if (abmfP_proj_needs_session_save(project) || 
	abmfP_proj_needs_session_restore(project))
    {
        for (p = Session_Includes; *p; p++)
        {
	    strlist_add_str(includes, *p, NULL);
        }
    }

    /*
     * Includes for i18n.
     * These include files are needed only if i18n
     * is enabled.
     */
    if (genCodeInfo->i18n_method == ABMF_I18N_XPG4_API)
    {
        for (p = I18n_Includes; *p; p++)
        {
	    strlist_add_str(includes, *p, NULL);
        }
    }

    /* module includes */
    for (trav_open(&trav, project, AB_TRAV_MODULES);
	(module = trav_next(&trav)) != NULL; )
    {
	if (!obj_is_defined(module))
	{
	    continue;
	}
	sprintf(buf, "\"%s\"", abmfP_get_ui_header_file_name(module));
	strlist_add_str(includes, buf, NULL);
    }
    trav_close(&trav);

    /* project include */
    sprintf(buf, "\"%s\"", abmfP_get_project_header_file_name(project));
    strlist_add_str(includes, buf, NULL);

    sprintf(buf, "\"%s\"", abmfP_get_utils_header_file_name(project));
    strlist_add_str(includes, buf, NULL);

    abmfP_get_connect_includes(includes, project);

    /* Write the includes */
    for (i = 0; i < strlist_get_num_strs(includes); ++i)
    {
	abio_printf(codeFile, "#include %s\n",
	    strlist_get_str(includes, i, NULL));
    }
    
    abio_puts(codeFile, nlstr);

    strlist_destroy(includes);
    return 0;
}
Example #14
0
static int
write_main_tooltalk_init(
    GenCodeInfo genCodeInfo, 
    ABObj project 
) 
{ 
    AB_TOOLTALK_LEVEL	tt_level;
    AB_TRAVERSAL	trav;
    STRING		vendor, version;
    ABObj		action;
    File        	codeFile; 
    int         	ret_val = 0; 
 
    if (!genCodeInfo || !project ||
        (tt_level = obj_get_tooltalk_level(project)) == AB_TOOLTALK_NONE)
        return 0;
 
    codeFile = genCodeInfo->code_file; 

    abio_puts(codeFile, abmfP_comment_begin);
    abio_puts(codeFile, abmfP_comment_continue);
    abio_puts(codeFile, "Initialize ToolTalk to handle Desktop Message Protocol\n");
    abio_puts(codeFile, abmfP_comment_end);

    if (tt_level == AB_TOOLTALK_DESKTOP_ADVANCED)
    {
    	for (trav_open(&trav, project, AB_TRAV_ACTIONS);
             (action = trav_next(&trav)) != NULL;)
    	{
	    switch(obj_get_when(action))
	    {
		case AB_WHEN_TOOLTALK_QUIT:
		    abio_printf(codeFile, "dtb_set_tt_msg_quitCB((DtbTTMsgHandlerCB)%s);\n",
			obj_get_func_name(action));
		    break;
		case AB_WHEN_TOOLTALK_DO_COMMAND:
                    abio_printf(codeFile, "dtb_set_tt_msg_do_commandCB((DtbTTMsgHandlerCB)%s);\n", 
                        obj_get_func_name(action)); 
                    break; 
                case AB_WHEN_TOOLTALK_GET_STATUS: 
                    abio_printf(codeFile, "dtb_set_tt_msg_get_statusCB((DtbTTMsgHandlerCB)%s);\n",  
                        obj_get_func_name(action));  
                    break; 
                case AB_WHEN_TOOLTALK_PAUSE_RESUME:
                    abio_printf(codeFile, "dtb_set_tt_msg_pause_resumeCB((DtbTTMsgHandlerCB)%s);\n",  
                        obj_get_func_name(action));
                    break;
		default:
		    break;
	    }
	}
	trav_close(&trav);
	abio_puts(codeFile, "\n");
    }

    /* Write out tt init code to deal with possible remote display session */
    abio_puts(codeFile, "ttenv = getenv(\"TT_SESSION\");\n");
    abio_puts(codeFile, "if (!ttenv || strlen(ttenv) == 0)\n");
    abio_indent(codeFile);
    abio_puts(codeFile,"ttenv = getenv(\"_SUN_TT_SESSION\");\n");
    abio_outdent(codeFile);
    abio_puts(codeFile, "if (!ttenv || strlen(ttenv) == 0)\n");
    abmfP_write_c_block_begin(genCodeInfo);
    abio_puts(codeFile, "session = tt_X_session(XDisplayString(display));\n");
    abio_puts(codeFile, "tt_default_session_set(session);\n");
    abio_puts(codeFile, "tt_free(session);\n");
    abmfP_write_c_block_end(genCodeInfo);
    
    abio_printf(codeFile, "tt_proc_id = ttdt_open(&tt_fd, \"%s\", ",
	obj_get_name(project));
    vendor = obj_get_vendor(project);
    version = obj_get_version(project);
    abio_printf(codeFile, "\"%s\", \"%s\", 1);\n",
	vendor? vendor : "NULL", version? version : "NULL");
    abio_puts(codeFile, "tt_status = tt_ptr_error(tt_proc_id);\n");
    abio_puts(codeFile, "if (tt_status != TT_OK)\n");
/*
    abio_puts(codeFile, "{\n");
    abio_indent(codeFile);
*/
    abmfP_write_c_block_begin(genCodeInfo);
    abio_puts(codeFile, 
	"fprintf(stderr,\"ttdt_open(): %s\\n\", tt_status_message(tt_status));\n");
    abio_puts(codeFile, "tt_proc_id = NULL;\n");
/*
    abio_outdent(codeFile);
    abio_puts(codeFile, "}\n");
*/
    abmfP_write_c_block_end(genCodeInfo); 
    abio_puts(codeFile, "else\n");
/*
    abio_puts(codeFile, "{\n");
    abio_indent(codeFile);
*/
    abmfP_write_c_block_begin(genCodeInfo);
    abio_puts(codeFile, "XtAppAddInput(app, tt_fd, (XtPointer)XtInputReadMask,\n");
    abio_indent(codeFile);
    abio_puts(codeFile, "tttk_Xt_input_handler, tt_proc_id);\n\n");
    abio_outdent(codeFile); 
    abio_printf(codeFile, "tt_session_pattern = ttdt_session_join(NULL, %s,\n",
	tt_level == AB_TOOLTALK_DESKTOP_ADVANCED? "dtb_tt_contractCB" : "NULL");
    abio_indent(codeFile);
    abio_puts(codeFile, "toplevel, NULL, True);\n\n");
    abio_outdent(codeFile);
    abio_puts(codeFile, "atexit(dtb_tt_close);\n");
/*
    abio_outdent(codeFile); 
    abio_puts(codeFile, "}\n");
*/
    abmfP_write_c_block_end(genCodeInfo);  

    return 0;

}
Example #15
0
/*
 * Either works on a object or its children.
 * Clear the obj's attachments entirely if init_attachments
 * is TRUE but also configure the widget hierarchy to have two 
 * basic connections: North and West point attachments with the 
 * objs x and y offsets.
 */ 
void
abobj_clear_layout(
	ABObj	obj,
	BOOL	clear_children,
	BOOL	init_attachments
)
{
    ABObj  pos_obj = objxm_comp_get_subobj(obj, AB_CFG_POSITION_OBJ);	
    ABAttachment  attach;

    if (clear_children)
    {
        AB_TRAVERSAL  trav;
	ABObj         child;

	for (trav_open(&trav, pos_obj, AB_TRAV_SALIENT_CHILDREN |
			AB_TRAV_MOD_SAFE);
	    (child = trav_next(&trav)) != NULL; )
	{
	    /* Configure the tree to have just basic attachments */
	    attach.type = AB_ATTACH_POINT;
	    attach.value = (void *)NULL;
	    attach.offset = abobj_get_y(child);
	    abobj_set_attachment(child, AB_CP_NORTH, &attach);

	    attach.type = AB_ATTACH_POINT;
	    attach.value = (void *)NULL;
	    attach.offset = abobj_get_x(child);
	    abobj_set_attachment(child, AB_CP_WEST, &attach);

	    attach.type = AB_ATTACH_NONE;
	    attach.value = (void *)NULL;
	    attach.offset = 0;
	    abobj_set_attachment(child, AB_CP_SOUTH, &attach);

	    abobj_set_attachment(child, AB_CP_EAST, &attach);

	    abobj_instantiate_changes(child);

	    /*
	     * Clear out all attachments in obj structure
	     * if init_attachments is set
	     */
	    if (init_attachments)
		obj_init_attachments(child);
	}
	trav_close(&trav);
    }
    else
    {
	attach.type = AB_ATTACH_POINT;
	attach.value = (void *)NULL;
	attach.offset = abobj_get_y(pos_obj);
	abobj_set_attachment(pos_obj, AB_CP_NORTH, &attach);

	attach.type = AB_ATTACH_POINT;
	attach.value = (void *)NULL;
	attach.offset = abobj_get_x(pos_obj);
	abobj_set_attachment(pos_obj, AB_CP_WEST, &attach);

	attach.type = AB_ATTACH_NONE;
	attach.value = (void *)NULL;
	attach.offset = 0;
	abobj_set_attachment(pos_obj, AB_CP_SOUTH, &attach);

	abobj_set_attachment(pos_obj, AB_CP_EAST, &attach);

	abobj_instantiate_changes(pos_obj);

	/*
	 * Clear out all attachments in obj structure
	 * if init_attachments is set
	 */
	if (init_attachments)
	    obj_init_attachments(pos_obj);

    }
}
Example #16
0
/*
 * Gets the object that the connection is "actually" from. If write_conn*
 * is called on an object that has references to it, it's actually the
 * references that have the connections, not the object, itself.
 * (e.g., menus never have connections written, it's the menu references
 * that do).
 */
static ABObj
get_actual_from_obj(ABObj actionOrObj)
{
    static ABObj	lastFromObj = NULL;
    static ABObj	lastActualFromObj = NULL;
    AB_TRAVERSAL	refTrav;
    ABObj		refObj = NULL;
    ABObj		module = NULL;
    ABObj		fromObj = NULL;
    ABObj		actualFromObj = NULL;

    if (actionOrObj == NULL)
    {
        return NULL;
    }

    /*
     * Get the "from" obj
     */
    if (obj_is_action(actionOrObj))
    {
        fromObj = obj_get_from(actionOrObj);
    }
    else if (obj_is_ui(actionOrObj))
    {
        fromObj = actionOrObj;
    }

    /*
     * Shortcut, to avoid a lengthy traversal
     */
    if (fromObj == lastFromObj)
    {
        goto epilogue;
    }

    /*
     * See if we can do anything
     */
    if (fromObj == NULL)
    {
        return NULL;
    }
    module = obj_get_module(fromObj);

    /*
     * Actually find it!
     */
    if (   (!obj_is_ref(fromObj))
            && (   (obj_get_type(fromObj) == AB_TYPE_MENU)
                   || (obj_get_parent_of_type(fromObj, AB_TYPE_MENU) != NULL)) )
    {
        /* find an object that references this one, to
         * get the appropriate type (only menu references are
         * supported, currently).
         */
        for (trav_open(&refTrav, module, AB_TRAV_UI);
                (refObj = trav_next(&refTrav)) != NULL; )
        {
            if (refObj->ref_to == fromObj)
            {
                break;
            }
        }
        trav_close(&refTrav);
    }

    if (actualFromObj == NULL)
    {
        if (refObj != NULL)
        {
            actualFromObj = refObj;
        }
        else
        {
            actualFromObj = fromObj;
        }
    }

    lastFromObj = fromObj;
    lastActualFromObj = actualFromObj;

epilogue:
    return lastActualFromObj;
}
Example #17
0
/*
 * Finds the target matching the given description, creating it if necessary.
 * 
 * Assumes: strings are pointers to allocated space. Sets strings to NULL, if
 * the values are used.
 * 
 * Assumes that obj may not be in the object tree yet, and may return it as the
 * target.
 */
static ABObj
find_or_create_target(
			ABObj	obj, 
			ABObj	module,
		      	ISTRING	interface_name,
                      	ISTRING	parent_name,
                      	ISTRING	obj_name,
                      	ISTRING	item_label
)
{
    ABObj               target = NULL;	/* the real thing, baby! */
    ABObj		target_project = NULL;
    char		target_interface_file[MAXPATHLEN+1];
    char		target_interface_name[GIL_MAX_NAME_SIZE];
    ABObj		target_module = NULL;
    char		target_parent_name[GIL_MAX_NAME_SIZE];
    ABObj		target_parent = NULL;
    char		target_obj_name[GIL_MAX_NAME_SIZE];
    ABObj		target_obj = NULL;
    char		target_item_label[GIL_MAX_NAME_SIZE];
    ABObj		target_item = NULL;
    AB_TRAVERSAL	trav;
    *target_interface_file = 0;
    *target_interface_name = 0;
    *target_parent_name = 0;
    *target_obj_name = 0;
    *target_item_label = 0;
   
    /* must have object name */
    if (debugging()) 
    {
	assert(   (obj_name != NULL)
	       && (obj_is_project(module) || obj_is_module(module)));
    }

    if (obj_is_project(module))
    {
	/* The first string must be an interface file name */
	if (interface_name != NULL)
	{
	    util_strncpy(target_interface_file, istr_string(interface_name),
			GIL_MAX_NAME_SIZE);
	    if (parent_name != NULL)
	    {
		util_strncpy(target_parent_name, istr_string(parent_name),
			GIL_MAX_NAME_SIZE);
	    }
	}
	else if (parent_name != NULL)
	{
	    util_strncpy(target_interface_file, istr_string(parent_name),
			GIL_MAX_NAME_SIZE);
	}
	else
	{
	    abil_print_load_err(ERR_WANT_FULL_NAME);
	    goto epilogue;
	}

	/* derive the name from the file name */
	strcpy(target_interface_name, target_interface_file);
	{
	    int		len = strlen(target_interface_name);
	    if (    (len >= 2) 
		&& (   util_streq(&(target_interface_name[len-2]), ".G")
		    || util_streq(&(target_interface_name[len-2]), ".P")))
	    {
		target_interface_name[len-2] = 0;
	    }
	}

	util_strncpy(target_obj_name, istr_string(obj_name), 
			GIL_MAX_NAME_SIZE);
	if (item_label != NULL)
	{
	    util_strncpy(target_item_label, istr_string(item_label), 
			GIL_MAX_NAME_SIZE);
	}
    }
    else 	/* ! obj_is_project() */
    {
        if (parent_name != NULL)
        {
            /* we have parent name and object name */
            util_strncpy(target_parent_name, istr_string(parent_name), 
			GIL_MAX_NAME_SIZE);
        }

	util_strncpy(target_obj_name, istr_string(obj_name), 
			GIL_MAX_NAME_SIZE);
        if (item_label != NULL)
        {
            /* we have object name and item_label */
            util_strncpy(target_item_label, istr_string(item_label),
		GIL_MAX_NAME_SIZE);
        }
     }

     /*
      * We've got the name broken down into the appropriate pieces.
      * Now find the actual target.
      */
    /*util_dprintf(3, "finding: module:'%s' parent:'%s' obj:'%s' item:'%s'\n",
	target_interface_name, target_parent_name, 
	target_obj_name, target_item_label);*/
    

    /*
     * Find target project
     */
    target_project = obj_get_project(module);

    /*
     * Find target module
     */
    if (util_strempty(target_interface_name))
    {
	target_module = module;
    }
    else
    {
	/* find specified intefarce (module) */
	for (trav_open(&trav, target_project, AB_TRAV_MODULES);
		(target_module = trav_next(&trav)) != NULL; )
	{
	    if (   (target_module != target_project)
		&& (util_streq(
			obj_get_file(target_module), target_interface_file)))
	    {
		break;
	    }
	}
	trav_close(&trav);
	if (target_module == NULL)
	{
	    target_module = obj_create(AB_TYPE_MODULE, target_project);
	    obj_set_is_defined(target_module, FALSE);
	    obj_set_file(target_module, target_interface_file);
	    obj_set_name(target_module, target_interface_name);
	}
    }

    /*
     * Find target parent
     */
    if (util_strempty(target_parent_name))
    {
	target_parent = target_module;
    }
    else
    {
	for (trav_open(&trav, target_module, 
			AB_TRAV_ALL | AB_TRAV_MOD_PARENTS_FIRST);
	    	(target_parent = trav_next(&trav)) != NULL; )
	{
	    if (   (target_parent != target_module)
		&& (util_streq(
			obj_get_name(target_parent), target_parent_name)))
	    {
		break;
	    }
	}
	trav_close(&trav);
	if (target_parent == NULL)
	{
	    target_parent = obj_create(AB_TYPE_UNDEF, target_module);
	    obj_set_is_defined(target_parent, FALSE);
	    obj_set_file(target_parent, target_interface_file);
	    obj_set_name(target_parent, target_parent_name);
	}
    }

    /*
     * Find target obj
     */
    for (trav_open(&trav, target_parent,
			AB_TRAV_ALL | AB_TRAV_MOD_PARENTS_FIRST);
		(target_obj = trav_next(&trav)) != NULL; )
    {
	if (   (target_obj != target_parent)
	   && util_streq(target_obj_name, obj_get_name(target_obj)))
	{
	    break;
	}
    }
    trav_close(&trav);
    if (target_obj == NULL)
    {
        target_obj = obj_create(AB_TYPE_UNDEF, target_parent);
        obj_set_is_defined(target_obj, FALSE);
        obj_set_file(target_obj, target_interface_file);
        obj_set_name(target_obj, target_obj_name);
    }

    /*
     * Find item
     */
    if (util_strempty(target_item_label))
    {
	target_item = NULL;
    }
    else
    {
	for (trav_open(&trav, target_obj, AB_TRAV_ITEMS);
		(target_item = trav_next(&trav)) != NULL; )
	{
	    if (   (target_item != target_obj)
		&& util_streq(obj_get_label(target_item), target_item_label))
	    {
		break;
	    }
	}
	trav_close(&trav);
	if (target_item == NULL)
	{
	    target_item = obj_create(AB_TYPE_ITEM, target_obj);
	    obj_set_is_defined(target_item, FALSE);
	    obj_set_file(target_item, target_interface_file);
	    obj_set_label(target_item, target_item_label);
	    obj_set_name_from_label(target_item, 
				obj_get_name(obj_get_parent(target_item)));
	}
    }

    if (target_item != NULL)
    {
	target = target_item;
    }
    else
    {
	target = target_obj;
    }

epilogue:
    return target;
}
Example #18
0
int
abmfP_get_connect_includes(StringList includeFiles, ABObj projOrModule)
{
    AB_TRAVERSAL	trav;
    BOOL		actionIsCrossModule = FALSE;
    ABObj		project = obj_get_project(projOrModule);
    ABObj		action = NULL;
    ABObj		toObj = NULL;
    ABObj		compRoot = NULL;
    ABObj		toModule = NULL;
    ABObj		win_parent = NULL;
    ABObj		popup_win = NULL;
    char		headerFilename[MAXPATHLEN+1];
    *headerFilename = 0;

    strlist_set_is_unique(includeFiles, TRUE);
    assert(project != NULL);
    if (project == NULL)
    {
	return 0;
    }

    for (trav_open(&trav, projOrModule, AB_TRAV_ACTIONS_FOR_OBJ);
	(action = trav_next(&trav)) != NULL; )
    {
	actionIsCrossModule = obj_is_cross_module(action);
	toObj = obj_get_to(action);
	if (toObj == NULL)
	{
	    continue;
	}

	toModule = obj_get_module(toObj);

	if (actionIsCrossModule)
	{
	    sprintf(headerFilename, "\"%s\"", 
	        abmfP_get_ui_header_file_name(toModule));
            strlist_add_str(includeFiles,  headerFilename, NULL);
  	}

	/*
	 * Check to see if the popup's window parent is in another module
	 */
	compRoot = obj_get_root(toObj);
	popup_win = NULL;
	if (obj_is_popup_win(compRoot))
	{
	    popup_win = compRoot;
	}
	if (popup_win == NULL) 
	{
	    popup_win = obj_get_parent_of_type(compRoot, AB_TYPE_DIALOG);
	}
	if (popup_win == NULL)
	{
	    popup_win = obj_get_parent_of_type(compRoot, AB_TYPE_BASE_WINDOW);
	}

	if (popup_win != NULL)
	{
	    win_parent= obj_get_win_parent(popup_win);
	    if (win_parent != NULL)
	    {
	       toModule = obj_get_module(win_parent);
	       if (toModule != NULL)
	       {
		   sprintf(headerFilename, "\"%s\"", 
			abmfP_get_ui_header_file_name(toModule));
	           strlist_add_str(includeFiles, headerFilename, NULL);
	       }
 	    }
        }

	/*
	 * For some actions, we need widget-specific convenience
	 * functions and resource strings that exist in the header files.
	 */
	if (obj_get_func_type(action) == AB_FUNC_BUILTIN)
	{
	    switch (obj_get_func_builtin(action))
	    {
		case AB_STDACT_SET_LABEL:
		case AB_STDACT_SET_TEXT:
		case AB_STDACT_SET_VALUE:
	            abmfP_comp_get_widget_specific_includes(
			includeFiles, obj_get_root(toObj));
		break;
	    }
	}
    }
    trav_close(&trav);

    return 0;
}