Exemplo n.º 1
0
/********************************************************************
 * FUNCTION do_show_one_object (sub-mode of show objects local RPC)
 * 
 * show objects: 1 of N
 *
 * INPUTS:
 *    obj == object to show
 *    mode == requested help mode
 *    anyout == address of return anyout status
 *
 * OUTPUTS:
 *    *anyout set to TRUE only if any suitable objects found
 *
 * RETURNS:
 *   status
 *********************************************************************/
static status_t
    do_show_one_object (obj_template_t *obj,
                        help_mode_t mode,
                        boolean *anyout)
{
    boolean               imode;

    imode = interactive_mode();

    if (obj_is_data_db(obj) && 
        obj_has_name(obj) &&
        !obj_is_hidden(obj) && !obj_is_abstract(obj)) {

        if (mode == HELP_MODE_BRIEF) {
            if (imode) {
                log_stdout("\n%s:%s",
                           obj_get_mod_name(obj),
                           obj_get_name(obj));
            } else {
                log_write("\n%s:%s",
                          obj_get_mod_name(obj),
                          obj_get_name(obj));
            }
        } else {
            obj_dump_template(obj, mode-1, 0, 0); 
        }
        *anyout = TRUE;
    }

    return NO_ERR;

} /* do_show_one_object */
Exemplo n.º 2
0
STRING
abmfP_get_action_name(ABObj action)
{
    static char         name[256];
    STRING		parent_name = (STRING) NULL;
    ABObj               from = NULL, parent = NULL;
    STRING		tmpName = NULL;
    *name = 0;

    from = obj_get_from(action);
    if (action->info.action.auto_named && (from != NULL))
    {
        /* If the source object is the project,
         * then this is an "Application" connection.
	 * This probably won't happen because right
	 * now "Application" connections can only be
	 * of type AB_FUNC_USER_DEF (which means auto-
	 * named is FALSE).
         */
        if (obj_is_project(from))
	{
	    parent = obj_get_project(action);
	    parent_name = (STRING) util_malloc(
				strlen(obj_get_name(parent)) 
				+ APP_PREFIX_LEN + 1);
	    strcpy(parent_name, obj_get_name(parent));
	    strcat(parent_name, APP_PREFIX);
	}
	else
	{
            parent = obj_get_module(from);
            parent_name = obj_get_name(parent);
	}

        if (!util_strempty(parent_name) &&
            !util_strempty(obj_get_name(from)))
	{
	    sprintf(name, "%s_%s%s",
		    parent_name,
		    obj_get_name(from),
		    obj_get_func_name_suffix(action));
	}

        if (obj_is_project(from))
        {
	    util_free(parent_name);
	}
    }
    else
    {
	if ((tmpName = obj_get_func_name(action)) != NULL)
	{
	    sprintf(name, "%s", tmpName);
	}
    }

    return (name[0] == 0 ? NULL : name);
}
Exemplo n.º 3
0
Arquivo: proj.c Projeto: juddy/edcde
/*
 * Action: Update "Module Path:" in the project window
 *	   whenever the user moves the pointer over a
 *	   module icon.
 */
static void
pointer_motion_proc(
    Widget widget, 
    XEvent *event, 
    String *params, 
    int num_params
)
{
    Vwr			v = NULL;
    VNode		node_under_pointer = NULL;
    ABObj		obj = NULL;
    XMotionEvent	*mevent = (XMotionEvent*)event;
    char		mod_path[MAXPATHLEN] = "";

    util_dprintf(2, "pointer_motion_proc:\n");
    XtVaGetValues(widget, XmNuserData, &v, NULL); 

    if (!v)
	return;

    node_under_pointer = vwr_locate_node(v, 
		        mevent->x, mevent->y);
    if (node_under_pointer != NULL)
    {
	/* USE METHODS !! */
	obj = (AB_OBJ *)node_under_pointer->obj_data;
	
	if (!obj)
	    return;

	util_dprintf(2, "\tmodule name is %s\n", obj_get_name(obj));

	/* If the module has not been saved, file will be NULL */
	if (obj_get_file(obj) != NULL)
	{
	    util_get_dir_name_from_path(obj_get_file(obj), mod_path,
			MAXPATHLEN);
	}
	else
	{
	    strcpy(mod_path, ".");
	}

	util_dprintf(2, "\tmodule path is %s\n", mod_path);

	if (!util_strempty(mod_path))
	{
	    util_dprintf(2, "\tupdating the project window status region\n");
	    proj_update_stat_region(PROJ_STATUS_MOD_PATH, mod_path);
	}
    }
    else
    {
	/* If we're not over a node, clear out the module
	 * path status label in the project window.
	 */
	util_dprintf(2, "\tpointer is not positioned over a node\n");
	proj_update_stat_region(PROJ_STATUS_MOD_PATH, NULL);
    }
}
Exemplo n.º 4
0
static void
custdlg_create_buttons(
    ABObj	obj,
    ABObj	area
)
{
    ABObj	bobj;
    char    *button_names[] = {"button1","button2","button3"};
    char    *button_labels[3];
    int     startpos, endpos;
    int		i;

    button_labels[0] = catgets(Dtb_project_catd, 100, 265, "Button1");
    button_labels[1] = catgets(Dtb_project_catd, 100, 266, "Button2");
    button_labels[2] = catgets(Dtb_project_catd, 100, 267, "Button3");

    endpos = 0;
    for(i=0; i < XtNumber(button_names); i++)
    {
        bobj = obj_create(AB_TYPE_BUTTON, area);
        obj_set_subtype(bobj, AB_BUT_PUSH);
        obj_set_unique_name(bobj,
            ab_ident_from_name_and_label(obj_get_name(obj),button_names[i]));
        obj_set_label(bobj, button_labels[i]);
        obj_set_is_initially_visible(bobj, True);
        obj_set_is_initially_active(bobj, True);
        startpos = endpos + 10;
        obj_set_attachment(bobj, AB_CP_WEST, AB_ATTACH_GRIDLINE, (void*)startpos, 0);
        endpos = startpos + 20;
        obj_set_attachment(bobj, AB_CP_EAST, AB_ATTACH_GRIDLINE, (void*)endpos, 0);
	obj_set_attachment(bobj, AB_CP_NORTH, AB_ATTACH_POINT, (void*)0, 5);
    }

}
Exemplo n.º 5
0
static MsgSet
get_cached_msg_set(
    MsgFile	msg_file,
    ABObj	obj
)
{
    static ABObj	prev_obj = (ABObj)NULL;
    static MsgSet	prev_msg_set = (MsgSet)NULL;

    MsgSet		msg_set;

    if (obj == prev_obj)
        msg_set = prev_msg_set;
    else if (obj_is_project(obj))
    {
	char	*project_name = obj_get_name(obj);
	char	proj_suffixed_name[BUFSIZ];

	strcpy(proj_suffixed_name, project_name);
	strcat(proj_suffixed_name, "_project");

	msg_set = MsgFile_sure_find_msg_set(msg_file, proj_suffixed_name);
	prev_msg_set = msg_set;
    }
    else
    {
	static ABObj	prev_module = (ABObj)NULL;
	ABObj		module;
        char		*module_name;
        
        module = obj_get_module(obj);

        if (module == prev_module)
            msg_set = prev_msg_set;
        else
        {
            prev_module = module;

            module_name = obj_get_name(module);
            msg_set = MsgFile_sure_find_msg_set(msg_file, module_name);

            prev_msg_set = msg_set;
        }
    }
    return(msg_set);
}
Exemplo n.º 6
0
static void
custdlg_create_area(
    ABObj		obj,
    AB_CONTAINER_TYPE	area_type
)
{
    ABObj	pwobj;
    ABObj	label, area;
    ABObj       workobj;
    Dimension   height;

    pwobj = objxm_comp_get_subobj(obj, AB_CFG_WINDOW_PW_OBJ);
    workobj = objxm_comp_get_subobj(obj, AB_CFG_PARENT_OBJ);

    area = obj_create(AB_TYPE_CONTAINER, pwobj);
    obj_set_subtype(area, area_type);
    pal_initialize_obj(area);

    if (area_type == AB_CONT_FOOTER)
    {
	label = obj_create(AB_TYPE_LABEL, area);
        obj_set_x(label, 1);
        obj_set_y(label, 1);
	pal_initialize_obj(label);
	obj_set_label(label, catgets(Dtb_project_catd, 100, 264, "footer message"));
	obj_set_label_alignment(label, AB_ALIGN_LEFT);
	obj_set_unique_name(label,
		ab_ident_from_name_and_label(obj_get_name(obj), "label"));

	/*
	 * Workaround part1: MainWindow bug that causes MainWindow to shrink
	 * when a MessageWindow area is added
	 */
	XtVaGetValues(objxm_get_widget(workobj),
		XmNheight,	&height,
		NULL);
    }
    else if (area_type == AB_CONT_BUTTON_PANEL)
	custdlg_create_buttons(obj, area);

    abobj_show_tree(area, True);

    /* Workaround part2 */
    if (area_type == AB_CONT_FOOTER)
	XtVaSetValues(objxm_get_widget(workobj),
		XmNheight,	height,
		NULL);

    abobj_set_save_needed(obj_get_module(obj), True);

}
Exemplo n.º 7
0
extern BOOL
abmfP_initialize_msg_file(
    GenCodeInfo	genCodeInfo,
    ABObj	project
    )
{
    BOOL	ret_val = (BOOL)FALSE;

    char	msg_file_name[BUFSIZ];
    MsgFile	msg_file;

    if (project == NULL)
        goto cret;

    if (genCodeInfo->msg_file_obj != NULL)
    {
        ret_val = TRUE;
        goto cret;
    }
    
    /*
     * Make path name of message src file
     */
    sprintf(msg_file_name, "%s%s", obj_get_name(project), ".msg");

    if ((msg_file = MsgFile_create(obj_get_name(project), msg_file_name))
	!= NULL)
    {
	genCodeInfo->msg_src_file_name = strdup(msg_file_name);
	genCodeInfo->msg_file_obj = msg_file;
        ret_val = (BOOL)TRUE;
    }
    
cret:
    return(ret_val);
}
Exemplo n.º 8
0
/*
 * Write the project.h file.
 */
int
abmfP_write_project_header_file(
		GenCodeInfo	genCodeInfo,
		ABObj		project,
		STRING		codeFileName
)
{
    File		codeFile = genCodeInfo->code_file;
    char		projectName[1024];

    /*
     * 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, 
		TRUE,
		projectName,
		util_get_program_name(), 
		ABMF_MODIFY_USER_SEGS,
	   " * Contains: object data structures and callback declarations"
		);

    write_includes(genCodeInfo);

    /*
     * Write declarations for i18n.
     * These are needed only if i18n is enabled.
     */
    if (genCodeInfo->i18n_method == ABMF_I18N_XPG4_API)
        write_i18n_declarations(genCodeInfo, project);
    
    write_app_resource_struct(genCodeInfo, project);
    write_connection_decls(genCodeInfo, project);
    write_callback_decls(genCodeInfo, project);
    write_app_resource_var_extern(genCodeInfo, project);

    abmfP_write_user_long_seg(genCodeInfo,
	"Add types, macros, and externs here");

    abmfP_write_file_footer(genCodeInfo, codeFileName, TRUE);

    return OK;
}
Exemplo n.º 9
0
Arquivo: proj.c Projeto: juddy/edcde
int
proj_set_cur_module(
    ABObj	module
)
{
    if ( (module != NULL) && (obj_get_type(module) != AB_TYPE_MODULE) )
	return -1;

    AB_cur_module = module;
    if (module != NULL)
	ab_update_stat_region(AB_STATUS_CUR_MODULE, obj_get_name(module));
    else
	ab_update_stat_region(AB_STATUS_CUR_MODULE, NULL);
	
    return OK;
}
Exemplo n.º 10
0
int 
abmfP_write_utils_c_file(
			GenCodeInfo	genCodeInfo,
			STRING		fileName,
			ABObj		project
)
{
    char	projName[1024];
    sprintf(projName, "project %s", obj_get_name(project));
    abmfP_write_file_header(
		genCodeInfo, 
		fileName, 
		FALSE,
		projName,
		util_get_program_name(), 
		ABMF_MODIFY_NOT,
		" * CDE Application Builder General Utility Functions"
		);

    abmfP_write_c_system_include(genCodeInfo, "unistd.h");
    abmfP_write_c_system_include(genCodeInfo, "stdlib.h");
    abmfP_write_c_system_include(genCodeInfo, "stdio.h");
    abmfP_write_c_system_include(genCodeInfo, "sys/param.h");
    abmfP_write_c_system_include(genCodeInfo, "sys/stat.h");
    abmfP_write_c_system_include(genCodeInfo, "Xm/Xm.h");
    abmfP_write_c_system_include(genCodeInfo, "Xm/Form.h");
    abmfP_write_c_system_include(genCodeInfo, "Xm/Frame.h");
    abmfP_write_c_system_include(genCodeInfo, "Xm/Label.h");
    abmfP_write_c_system_include(genCodeInfo, "Xm/MessageB.h");
    abmfP_write_c_system_include(genCodeInfo, "Xm/PanedW.h");
    abmfP_write_c_system_include(genCodeInfo, "Xm/PushB.h");
    abmfP_write_c_system_include(genCodeInfo, "Xm/SashP.h");
    abmfP_write_c_system_include(genCodeInfo, "Xm/RowColumn.h");
    abmfP_write_c_system_include(genCodeInfo, "Dt/Help.h");
    abmfP_write_c_system_include(genCodeInfo, "Dt/HelpDialog.h");
    abmfP_write_c_system_include(genCodeInfo, "Dt/HelpQuickD.h");
    abmfP_write_c_system_include(genCodeInfo, "Dt/Session.h");
    abmfP_write_c_system_include(genCodeInfo, "Dt/Dnd.h");
    abmfP_write_c_local_include(genCodeInfo, "dtb_utils.h");

    write_all_macros(genCodeInfo, project);
    write_all_types(genCodeInfo, project);
    write_all_static_func_decls(genCodeInfo, project);
    write_all_vars(genCodeInfo, project);
    write_all_lib_funcs(genCodeInfo, project);
    return 0;
}
Exemplo n.º 11
0
static int
write_i18n_declarations(
    GenCodeInfo	genCodeInfo,
    ABObj	project
    )
{
    File	codeFile;
    STRING      *p = NULL;
    int		ret_val = 0;

    if (genCodeInfo == NULL)
        goto cret;

    codeFile = genCodeInfo->code_file;

    /*
     * Write out the include directives
     */
    for (p = I18n_Includes; *p; p++)
    {
	abio_printf(codeFile, "#include %s\n", *p);
    }

    /*
     * Write out the macro for the name of the catalog
     */
    abio_printf(codeFile, "#define DTB_PROJECT_CATALOG\t\"%s\"\n",
                obj_get_name(project));

    abio_puts(codeFile,
              "/* Handle for standard message catalog for the project */\n");
    
    abio_puts(codeFile, "extern nl_catd\tDtb_project_catd;\n");
    
cret:
    return(ret_val);
}
Exemplo n.º 12
0
/********************************************************************
* FUNCTION parse_val
* 
* Parse, and fill one val_value_t struct during
* processing of a text config file
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
* The value name is the current token.
* Based on the value typdef, the res of the tokens
* comprising the value statement will be processed
*
* INPUTS:
*   tkc == token chain
*   obj == the object template struct to use for filling in 'val'
*   val == initialized value struct, without any value,
*          which will be filled in by this function
*   nsid == namespace ID to use for this value
*   valname == name of the value struct
*
* RETURNS:
*   status of the operation
*********************************************************************/
static status_t 
    parse_val (tk_chain_t  *tkc,
               obj_template_t *obj,
               val_value_t *val)
{
    obj_template_t  *chobj;
    val_value_t     *chval;
    const xmlChar   *valname, *useval;
    typ_def_t       *typdef;
    status_t         res;
    ncx_btype_t      btyp;
    boolean          done;
    xmlns_id_t       nsid;

    btyp = obj_get_basetype(obj);
    nsid = obj_get_nsid(obj);
    valname = obj_get_name(obj);
    typdef = obj_get_typdef(obj);

    /* check if there is an index clause expected */
    if (typ_has_index(btyp)) {
        res = parse_index(tkc, obj, val, nsid);
        if (res != NO_ERR) {
            return res;
        }
    }

    /* get next token, NEWLINE is significant at this point */
    res = adv_tk(tkc);
    if (res != NO_ERR) {
        return res;
    }

    /* the current token should be the value for a leaf
     * or a left brace for the start of a complex type
     * A NEWLINE is treated as if the user entered a
     * zero-length string for the value.  (Unless the
     * base type is NCX_BT_EMPTY, in which case the NEWLINE
     * is the expected token
     */
    if (typ_is_simple(btyp)) {
        /* form for a leaf is: foo [value] NEWLINE  */
        if (TK_CUR_TYP(tkc)==TK_TT_NEWLINE) {
            useval = NULL;
        } else {
            useval = TK_CUR_VAL(tkc);
        }
        res = val_set_simval(val, 
                             typdef, 
                             nsid, 
                             valname,
                             useval);

        if (res != NO_ERR) {
            log_error("\nError: '%s' cannot be set to '%s'",
                      valname,
                      (TK_CUR_VAL(tkc)) ? TK_CUR_VAL(tkc) : EMPTY_STRING);
            if (btyp == NCX_BT_EMPTY) {
                ncx_conf_exp_err(tkc, res, "empty");
            } else {
                ncx_conf_exp_err(tkc, res, "simple value string");
            }
            return res;
        }

        /* get a NEWLINE unless current token is already a NEWLINE */
        if (TK_CUR_TYP(tkc) != TK_TT_NEWLINE) {
            res = adv_tk(tkc);
            if (res != NO_ERR) {
                return res;
            }
            if (TK_CUR_TYP(tkc) != TK_TT_NEWLINE) {
                res = ERR_NCX_WRONG_TKTYPE;
                ncx_conf_exp_err(tkc, res, "\\n");
            }
        }
    } else {
        /* complex type is foo {  ... } or
         * foo index1 index2 { ... }
         * If there is an index, it was already parsed
         */
        res = consume_tk(tkc, TK_TT_LBRACE);
        if (res != NO_ERR) {
            ncx_conf_exp_err(tkc, res, "left brace");
            return res;
        }

        /* get all the child nodes specified for this complex type */
        res = NO_ERR;
        done = FALSE;
        while (!done && res==NO_ERR) {
            /* start out looking for a child node name or a
             * right brace to end the sub-section
             */
            if (tk_next_typ(tkc)==TK_TT_NEWLINE) {
                /* skip the NEWLINE token */
                (void)adv_tk(tkc);
            } else if (tk_next_typ(tkc)==TK_TT_RBRACE) {
                /* found end of sub-section */
                done = TRUE;
            } else {
                /* get the next token */
                res = adv_tk(tkc);
                if (res != NO_ERR) {
                    continue;
                }

                /* make sure cur token is an identifier string
                 * if so, find the child node and call this function
                 * recursively to fill it in and add it to
                 * the parent 'val'
                 */
                if (TK_CUR_ID(tkc)) {
                    /* parent 'typdef' must have a child with a name
                     * that matches the current token vale
                     */
                    chobj = obj_find_child(obj, 
                                           TK_CUR_MOD(tkc),
                                           TK_CUR_VAL(tkc));
                    if (chobj) {
                        chval = val_new_value();
                        if (!chval) {
                            res = ERR_INTERNAL_MEM;
                            ncx_print_errormsg(tkc, NULL, res);
                        } else {
                            val_init_from_template(chval, chobj);
                            res = parse_val(tkc, chobj, chval);
                            if (res == NO_ERR) {
                                val_add_child(chval, val);
                            } else {
                                val_free_value(chval);
                            }
                        }
                    } else {
                        /* string is not a child name in this typdef */
                        res = ERR_NCX_DEF_NOT_FOUND;
                        ncx_conf_exp_err(tkc, res, "identifier string");
                    }
                } else {
                    /* token is not an identifier string */
                    res = ERR_NCX_WRONG_TKTYPE;
                    ncx_conf_exp_err(tkc, res, "identifier string");
                }
            }
        }  /* end loop through all the child nodes */

        /* expecting a right brace to finish the complex value */
        if (res == NO_ERR) {
            res = consume_tk(tkc, TK_TT_RBRACE);
            if (res != NO_ERR) {
                ncx_conf_exp_err(tkc, res, "right brace");
                return res;
            }
        }
    }

    return res;

}  /* parse_val */
Exemplo n.º 13
0
/********************************************************************
* FUNCTION parse_top
* 
* Parse, and fill one val_value_t struct
*
* Error messages are printed by this function!!
* Do not duplicate error messages upon error return
*
*
* INPUTS:
*   tkc == token chain
*   val == value iniitalized and could be already filled in
*   keepvals == TRUE to save existing values in 'val', as needed
*               FALSE to overwrite old values in 'val', as needed
*
* RETURNS:
*   status of the operation
*********************************************************************/
static status_t 
    parse_top (tk_chain_t  *tkc,
               val_value_t *val,
               boolean keepvals)
{
    status_t       res;
    boolean        done;

    res = NO_ERR;

    /* get the container name */
    done = FALSE;
    while (!done) {
        res = match_name(tkc, obj_get_name(val->obj));
        if (res == ERR_NCX_EOF) {
            if (LOGDEBUG) {
                log_debug("\nconf: object '%s' not found in file '%s'",
                          obj_get_name(val->obj), 
                          tkc->filename);
            }
            return NO_ERR;
        } else if (res != NO_ERR) {
            res = skip_object(tkc);
            if (res != NO_ERR) {
                return res;
            }
        } else {
            done = TRUE;
        }
    }

    /* get a left brace */
    res = consume_tk(tkc, TK_TT_LBRACE);
    if (res != NO_ERR) {
        ncx_conf_exp_err(tkc, res, "left brace to start object");
        return res;
    }

    done = FALSE;
    while (!done) {

        res = get_tk(tkc);
        if (res == ERR_NCX_EOF) {
            return NO_ERR;
        } else if (res != NO_ERR) {
            return res;
        }
        
        /* allow an empty parmset */
        if (TK_CUR_TYP(tkc)==TK_TT_RBRACE) {
            done = TRUE;
        } else {
            res = parse_parm(tkc, val, keepvals);
            if (res != NO_ERR) {
                done = TRUE;
            }
        }
    }

    return res;

}  /* parse_top */
Exemplo n.º 14
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;
}
Exemplo n.º 15
0
/*************************************************************************
**                                                                      **
**       Function Definitions                                           **
**                                                                      **
**************************************************************************/
int
abobjP_move_object_outline(
    ABObj         	obj, 
    XMotionEvent        *mevent
)
{
    static XRectangle parent_rect;
    static XRectangle last_rect;
    static int        x_offset, y_offset;
    static Dimension  border_w;
    static Display    *dpy;
    XRectangle	      widget_rect;
    int               trans_x, trans_y;

    /* First time: set up initial move variables */
    if (first_move)
    {
	if (obj_is_item(obj))
	    obj = obj_get_parent(obj);

	obj    = obj_get_root(obj);
	
        /* Multiple objects might be selected...*/ 
        if (obj_is_control(obj) || 
	    obj_is_group(obj) ||
	    obj_is_pane(obj)) 
        { 
            abobj_get_selected(obj_get_root(obj_get_parent(obj)), False, False, &sel);
        } 
        else
	{
            sel.count = 1; 
	    sel.list = (ABObj*)util_malloc(sizeof(ABObj));
	    sel.list[0] = obj;
	}

	xy_obj = objxm_comp_get_subobj(obj, AB_CFG_POSITION_OBJ);
        xy_widget = (Widget)xy_obj->ui_handle;

        if (xy_widget == NULL)
        {
            if (util_get_verbosity() > 2)
                fprintf(stderr,"abobjP_move_object_outline: %s :no POSITION widget\n",
			util_strsafe(obj_get_name(obj)));
            return ERROR;
        }

        dpy    = XtDisplay(xy_widget);
        parent = XtParent(xy_widget);

	x_get_widget_rect(xy_widget, &widget_rect);
        x_get_widget_rect(parent, &parent_rect);

	if (sel.count > 1)
	{
            abobj_get_rect_for_objects(sel.list, sel.count, &orig_rect);
	} 
	else
	{
	    orig_rect = widget_rect;
	    XtVaGetValues(xy_widget, XtNborderWidth, &border_w, NULL);
	    orig_rect.width  += (2*border_w);
	    orig_rect.height += (2*border_w);
	    orig_rect.width--;
	    orig_rect.height--;
	}
	move_rect = orig_rect;

        drag_init_rect.x     = mevent->x - AB_drag_threshold;
        drag_init_rect.y     = mevent->y - AB_drag_threshold;
        drag_init_rect.width = drag_init_rect.height = 2 * AB_drag_threshold;

	x_offset = widget_rect.x - orig_rect.x + mevent->x;
	y_offset = widget_rect.y - orig_rect.y + mevent->y;

        first_move  = False;

        rect_zero_out(&last_rect);
    }
    /* Don't begin rendering move outline until pointer is out of
     * the drag_init bounding box
     */
    else if (!rect_includespoint(&drag_init_rect, mevent->x, mevent->y))
    {    
        Window win;

        /* event coords are relative to widget-must translate to parent */
        XTranslateCoordinates(dpy, XtWindow(xy_widget), XtWindow(parent),
            mevent->x, mevent->y, &trans_x, &trans_y, &win);

        move_rect.x = trans_x - x_offset;
        move_rect.y = trans_y - y_offset;

        /* Ensure move outline is within the parent's rect */
        if (move_rect.x < 0)
            move_rect.x = 0;
        else if ((move_rect.x + (short)move_rect.width + 1) >= (short)parent_rect.width)
            move_rect.x = parent_rect.width - (move_rect.width + 1);

        if (move_rect.y < 0)
            move_rect.y = 0;
        else if ((move_rect.y + (short)move_rect.height + 1) >= (short)parent_rect.height)
            move_rect.y = parent_rect.height - (move_rect.height + 1);

        /* If cursor has moved since last event, erase previous outline
         * and render new one (using XOR function)
         */
        if (!rect_equal(&move_rect, &last_rect))
        {
            if (!rect_isnull(&last_rect))
                x_box_r(parent, &last_rect);
            x_box_r(parent, &move_rect);
            last_rect = move_rect;
        }
    }
    return OK;
}
Exemplo n.º 16
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;

}
Exemplo n.º 17
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;
}
Exemplo n.º 18
0
/*
** determine which builtin action and write the appropriate code.
*/
static int
write_builtin_action(
    GenCodeInfo	      genCodeInfo,
    ABObj 	      action,
    ABObj             toObj,
    AB_BUILTIN_ACTION builtin_action,
    STRING            actionTKResource,		       /* in toolkit */
    STRING	      actionResource		       /* in source code */
)
{
#define	 IS(type)	(obj_get_func_type(action) ==(type))
#define	 SVAL(action)	((STRING)obj_get_arg_string(action))
#define	 IVAL(action)	((int)obj_get_arg_int(action))

    File                codeFile     = genCodeInfo->code_file;
    int			return_value = 0;

    if (!codeFile || !action || !toObj || !builtin_action)
        return return_value;

    switch (builtin_action)
    {
    case AB_STDACT_ENABLE:
        abio_print_line(codeFile, NULL);
        abio_print_line(codeFile, "XtSetSensitive(%s, True);",
                        abmfP_get_c_name(genCodeInfo, toObj));
        break;

    case AB_STDACT_DISABLE:
        abio_print_line(codeFile, NULL);
        abio_print_line(codeFile, "XtSetSensitive(%s, False);",
                        abmfP_get_c_name(genCodeInfo, toObj));
        break;

    case AB_STDACT_SHOW:
        switch((obj_get_root(toObj))->type)
        {
        case AB_TYPE_BASE_WINDOW:
            abio_print_line(codeFile, "XtPopup(%s, XtGrabNone);",
                            abmfP_get_c_name(genCodeInfo, toObj));
            break;

        case AB_TYPE_DIALOG:
        case AB_TYPE_FILE_CHOOSER:
        default:
            abio_print_line(codeFile, "XtManageChild(%s);",
                            abmfP_get_c_name(genCodeInfo, toObj));
            break;
        }
        break;

    case AB_STDACT_HIDE:
        switch((obj_get_root(toObj))->type)
        {
        case AB_TYPE_BASE_WINDOW:
            abio_print_line(codeFile, "XtPopdown(%s);",
                            abmfP_get_c_name(genCodeInfo, toObj));
            break;

        case AB_TYPE_DIALOG:
        case AB_TYPE_FILE_CHOOSER:
        default:
            abio_print_line(codeFile, "XtUnmanageChild(%s);",
                            abmfP_get_c_name(genCodeInfo, toObj));
            break;
        }
        break;

    case AB_STDACT_SET_LABEL:
        /* check toObj for root */
        if ( obj_get_label_type(obj_get_root(toObj)) == AB_LABEL_GLYPH)
        {
            abio_printf(codeFile, "%s(%s, ",
                        abmfP_lib_set_label_from_image_file->name,
                        abmfP_get_c_name(genCodeInfo, toObj));
            abio_put_string(codeFile, SVAL(action));
            abio_puts(codeFile, ");\n");
        }
        else
        {
            assert(actionTKResource != NULL);
            printf_setval(genCodeInfo, toObj,
                          actionTKResource, SVAL(action),
                          NULL);
        }
        break;

    case AB_STDACT_SET_VALUE:
        printf_setval(genCodeInfo, toObj,
                      actionTKResource, IVAL(action), NULL);
        break;

    case AB_STDACT_SET_TEXT:
        printf_setval(genCodeInfo, toObj,
                      actionTKResource, SVAL(action),
                      NULL);
        break;

    /* 	case AB_STDACT_SHOW_HELP: */
    /* 	    abio_print_line(codeFile, NULL); */
    /* 	    abio_print_line(codeFile,  */
    /* 		"XtCallCallbacks(%s,XmNhelpCallback,(XtPointer)NULL);", */
    /* 		abmfP_get_c_name(genCodeInfo, toObj)); */
    /* 	    break; */

    default:
    {
        static char         msg[255];

        if (obj_get_name(action) != NULL)
        {
            char *action_name = obj_get_name(action);
            sprintf(msg, catgets(Dtb_project_catd, 1, 76,
                                 "Unknown action name, %s"), action_name);
        }
        else
        {
            int action_type = obj_get_func_builtin(action);
            sprintf(msg, catgets(Dtb_project_catd, 1, 77,
                                 "Unknown action type, %d"), action_type);
        }
        util_error(msg);
        return_value = ERR_INTERNAL;

        /*
         * return msg; Just print message and go on - JT
         */
    }
    break;
    }			/* switch func.value.builtin */

    return return_value;
#undef IS
#undef SVAL
#undef IVAL
}
Exemplo n.º 19
0
/*
 * Write the callback proc stub file.
 */
int
abmfP_write_stubs_c_file(
    GenCodeInfo genCodeInfo,
    STRING codeFileName,
    ABObj module
)
{
    File                codeFile = genCodeInfo->code_file;
    STRING              errmsg = NULL;
    ABObj               win_obj = NULL;
    ABObj               project = obj_get_project(module);
    char		moduleHeaderFileName[MAX_PATH_SIZE];
    char		moduleName[MAX_PATH_SIZE];

    /*
     * Write file header.
     */

    abmfP_write_user_header_seg(genCodeInfo);
    abio_puts(codeFile, nlstr);

    sprintf(moduleName, "module %s", obj_get_name(module));
    abmfP_write_file_header(
        genCodeInfo,
        codeFileName,
        FALSE,
        moduleName,
        util_get_program_name(),
        ABMF_MODIFY_USER_SEGS,
        " * Contains: Module callbacks and connection functions"
    );


    /*
     * Write includes.
     */
    strcpy(moduleHeaderFileName, abmfP_get_ui_header_file_name(module));
    abmfP_write_c_system_include(genCodeInfo, "stdio.h");
    abmfP_write_c_system_include(genCodeInfo, "Xm/Xm.h");
    abmfP_write_c_local_include(genCodeInfo,
                                abmfP_get_utils_header_file_name(module));

    /*
     * Include project file if i18n is enabled. This file
     * is needed for the message catalog stuff
     */
    if (genCodeInfo->i18n_method == ABMF_I18N_XPG4_API)
        abmfP_write_c_local_include(genCodeInfo,
                                    abmfP_get_project_header_file_name(project));
    abmfP_write_c_local_include(genCodeInfo, moduleHeaderFileName);


    /*
     * Write out includes for modules with connection targets
     */
    {
        StringListRec       connIncludes;
        int                 i = 0;
        int                 num_strings = 0;
        strlist_construct(&connIncludes);

        strlist_add_str(&connIncludes, moduleHeaderFileName, NULL);
        abmfP_get_connect_includes(&connIncludes, module);
        num_strings = strlist_get_num_strs(&connIncludes);
        if (num_strings > 1)		/* start at 1 - skip this_ui.h */
        {
            abio_puts(codeFile, nlstr);
            abmfP_write_c_comment(genCodeInfo, FALSE,
                                  "Header files for cross-module connections");
        }
        for (i = 1; i < num_strings; ++i)
        {
            abio_printf(codeFile, "#include %s\n",
                        strlist_get_str(&connIncludes, i, NULL));
        }

        strlist_destruct(&connIncludes);
    }
    abio_puts(codeFile, nlstr);

    abmfP_write_user_file_top_seg(genCodeInfo);
    abio_puts(codeFile, nlstr);

    if (write_action_functions(genCodeInfo, module) != OK)
        return ERROR;

    abmfP_write_user_file_bottom_seg(genCodeInfo);
    return OK;
}
Exemplo n.º 20
0
/*************************************************************************
**                                                                      **
**       Function Definitions                                           **
**                                                                      **
**************************************************************************/
static int
choice_initialize(
    ABObj    obj
)
{
    AB_CHOICE_TYPE choice_type;
    ABObj	module = obj_get_module(obj);
    ABObj	iobj;
    String  items[2];
    int		i;

    choice_type = obj->info.choice.type;

    switch(choice_type)
    {
    case AB_CHOICE_NONEXCLUSIVE:
        obj_set_unique_name(obj, "checkbox");
        obj_set_label(obj, catgets(Dtb_project_catd, 100, 253, "Choice:"));
        break;
    case AB_CHOICE_OPTION_MENU:
        obj_set_unique_name(obj, "optionmenu");
        obj_set_label(obj, catgets(Dtb_project_catd, 100, 254, "Options:"));
        break;
    case AB_CHOICE_EXCLUSIVE:
    default:
        obj_set_unique_name(obj, "radiobox");
        obj_set_label(obj, catgets(Dtb_project_catd, 100, 253, "Choice:"));
        break;
    }

    obj_set_is_initially_visible(obj, True);
    obj_set_is_initially_active(obj, True);

    if (choice_type == AB_CHOICE_EXCLUSIVE)
        obj_set_orientation(obj, AB_ORIENT_HORIZONTAL);
    else
        obj_set_orientation(obj, AB_ORIENT_VERTICAL);

    obj_set_num_columns(obj, 1);

    /* Add initial items to Choice */
    items[0] = catgets(Dtb_project_catd, 6, 70, "itemA");
    items[1] = catgets(Dtb_project_catd, 6, 71, "itemB");
    for (i=0; i < XtNumber(items); i++)
    {
        iobj = obj_create(AB_TYPE_ITEM, NULL);
        obj_append_child(obj, iobj);
        obj_set_subtype(iobj, AB_ITEM_FOR_CHOICE);
        iobj->label_type = AB_LABEL_STRING;

        if (i == 0)
            obj_set_is_initially_selected(iobj, True);
        else
            obj_set_is_initially_selected(iobj, False);

        obj_set_is_initially_active(iobj, True);
        abobj_set_item_name(iobj, obj_get_module(obj), obj_get_name(obj), items[i]);
        obj_set_label(iobj, items[i]);
    }

    obj_set_attachment(obj, AB_CP_NORTH, AB_ATTACH_POINT, NULL, obj->y);
    obj_set_attachment(obj, AB_CP_WEST,  AB_ATTACH_POINT, NULL, obj->x);

    return OK;

}
Exemplo n.º 21
0
/********************************************************************
* FUNCTION obj_dump_template
*
* Dump the contents of an obj_template_t struct for help text
*
* INPUTS:
*   obj == obj_template to dump help for
*   mode == requested help mode
*   nestlevel == number of levels from the top-level
*                that should be printed; 0 == all levels
*   indent == start indent count
*********************************************************************/
void
    obj_dump_template (obj_template_t *obj,
                       help_mode_t mode,
                       uint32 nestlevel,
                       uint32 indent)
{
    const xmlChar        *val, *keystr;
    obj_template_t       *testobj;
    uint32                count, objnestlevel;
    char                  numbuff[NCX_MAX_NUMLEN];
    boolean               normalpass, neednewline;

#ifdef DEBUG
    if (mode > HELP_MODE_FULL) {
        SET_ERROR(ERR_INTERNAL_VAL);
        return;
    }
#endif

    if (obj == NULL) {
        /* could be called because disabled first child found */
        return;
    }

    if (!obj_has_name(obj) || !obj_is_enabled(obj)) {
        return;
    }

    if (mode == HELP_MODE_NONE) {
        return;
    }

    objnestlevel = obj_get_level(obj);

    if (mode == HELP_MODE_BRIEF && 
        nestlevel > 0 &&
        objnestlevel > nestlevel) {
        return;
    }

    normalpass = (nestlevel && (objnestlevel > nestlevel))
        ? FALSE : TRUE;

    if (obj->objtype == OBJ_TYP_RPCIO || 
        obj->objtype == OBJ_TYP_RPC) {
        help_write_lines(obj_get_name(obj), indent, TRUE);
        count = 0;
    } else if (obj->objtype == OBJ_TYP_CASE) {
        count = obj_enabled_child_count(obj);
    } else {
        count = 2;
    }
    if (count > 1) {
        help_write_lines(obj_get_typestr(obj), indent, TRUE);
        help_write_lines((const xmlChar *)" ", 0, FALSE);
        help_write_lines(obj_get_name(obj), 0, FALSE);
    }

    neednewline = FALSE;

    switch (obj->objtype) {
    case OBJ_TYP_CONTAINER:
    case OBJ_TYP_LIST:
    case OBJ_TYP_CASE:
    case OBJ_TYP_RPC:
    case OBJ_TYP_RPCIO:
    case OBJ_TYP_NOTIF:
        break;
    default:
        /* print type and default for leafy and choice objects */
        if (obj->objtype != OBJ_TYP_CHOICE) {
            help_write_lines((const xmlChar *)" [", 0, FALSE); 
            help_write_lines((const xmlChar *)
                             obj_get_type_name(obj), 0, FALSE);
            help_write_lines((const xmlChar *)"]", 0, FALSE); 
        }

        if (mode != HELP_MODE_BRIEF) {
            val = obj_get_default(obj);
            if (val != NULL) {
                help_write_lines((const xmlChar *)" [d:", 0, FALSE); 
                help_write_lines(val, 0, FALSE);
                help_write_lines((const xmlChar *)"]", 0, FALSE); 
            }
            if (obj_is_key(obj)) {
                help_write_lines((const xmlChar *)" <Key>", 0, FALSE);
            } else if (obj_is_mandatory(obj)) {
                help_write_lines((const xmlChar *)" <Mandatory>", 0, FALSE);
            }
        }
    }

    if (normalpass) {
        val = obj_get_description(obj);
        if (val == NULL) {
            val = obj_get_alt_description(obj);
        }
        if (val != NULL) {
            switch (mode) {
            case HELP_MODE_BRIEF:
                if (obj->objtype == OBJ_TYP_RPC || 
                    obj->objtype == OBJ_TYP_NOTIF) {
                    help_write_lines_max(val, indent+NCX_DEF_INDENT,
                                         TRUE, HELP_MODE_BRIEF_MAX); 
                }
                break;
            case HELP_MODE_NORMAL:
                help_write_lines_max(val, indent+NCX_DEF_INDENT,
                                     TRUE, HELP_MODE_NORMAL_MAX); 
                break;
            case HELP_MODE_FULL:
                help_write_lines(val, indent+NCX_DEF_INDENT, TRUE); 
                break;
            default:
                SET_ERROR(ERR_INTERNAL_VAL);
                return;
            }
        }
    }

    switch (obj->objtype) {
    case OBJ_TYP_CONTAINER:
        switch (mode) {
        case HELP_MODE_BRIEF:
            neednewline = TRUE;
            break;
        case HELP_MODE_NORMAL:
            if (obj->def.container->presence) {
                help_write_lines((const xmlChar *)" (P)", 0, FALSE); 
            } else {
                help_write_lines((const xmlChar *)" (NP)", 0, FALSE); 
            }
            testobj = obj_get_default_parm(obj);
            if (testobj) {
                help_write_lines((const xmlChar *)"default parameter: ", 
                                 indent+NCX_DEF_INDENT, TRUE); 
                help_write_lines(obj_get_name(testobj), 0, FALSE);
            }
            break;
        case HELP_MODE_FULL:
            if (obj->def.container->presence) {
                help_write_lines((const xmlChar *)"presence: ", 
                                 indent+NCX_DEF_INDENT, TRUE); 
                help_write_lines(obj->def.container->presence, 0, FALSE);
            }
            testobj = obj_get_default_parm(obj);
            if (testobj) {
                help_write_lines((const xmlChar *)"default parameter: ", 
                                 indent+NCX_DEF_INDENT, TRUE); 
                help_write_lines(obj_get_name(testobj), 0, FALSE);
            }
            if (mode == HELP_MODE_FULL) {
                /*** add mustQ ***/;
            }
            break;
        default:
            SET_ERROR(ERR_INTERNAL_VAL);
            return;
        }
        obj_dump_datadefQ(obj->def.container->datadefQ, 
                          mode, nestlevel, indent+NCX_DEF_INDENT);
        break;
    case OBJ_TYP_ANYXML:
        /* nothing interesting in the typdef to report */
        neednewline = TRUE;
        break;
    case OBJ_TYP_LEAF:
        switch (mode) {
        case HELP_MODE_BRIEF:
            break;
        case HELP_MODE_NORMAL:
            if (normalpass) {
                dump_typdef_data(obj, mode, indent+NCX_DEF_INDENT);
            }
            break;
        case HELP_MODE_FULL:
            dump_typdef_data(obj, mode, indent+NCX_DEF_INDENT);
            val = obj_get_units(obj);
            if (val) {
                help_write_lines((const xmlChar *)"units: ", 
                                 indent+NCX_DEF_INDENT, TRUE); 
                help_write_lines(val, 0, FALSE);
            }
            break;
        default:
            ;
        }
        break;
    case OBJ_TYP_LEAF_LIST:
        switch (mode) {
        case HELP_MODE_NORMAL:
            if (normalpass) {
                dump_typdef_data(obj, mode, indent+NCX_DEF_INDENT);
            }
            break;
        case HELP_MODE_FULL:
            dump_typdef_data(obj, mode, indent+NCX_DEF_INDENT);
            val = obj_get_units(obj);
            if (val) {
                help_write_lines((const xmlChar *)"units: ", 
                                 indent+NCX_DEF_INDENT, TRUE); 
                help_write_lines(val, 0, FALSE);
            }
            if (!obj->def.leaflist->ordersys) {
                help_write_lines((const xmlChar *)"ordered-by: user", 
                                 indent+NCX_DEF_INDENT, TRUE); 
            } else {
                help_write_lines((const xmlChar *)"ordered-by: system", 
                                 indent+NCX_DEF_INDENT, TRUE); 
            }
            if (obj->def.leaflist->minset) {
                help_write_lines((const xmlChar *)"min-elements: ", 
                                 indent+NCX_DEF_INDENT, TRUE); 
                snprintf(numbuff, sizeof(numbuff), "%u",
                         obj->def.leaflist->minelems);
                help_write_lines((const xmlChar *)numbuff, 0, FALSE);
            }
            if (obj->def.leaflist->maxset) {
                help_write_lines((const xmlChar *)"max-elements: ", 
                                 indent+NCX_DEF_INDENT, TRUE); 
                snprintf(numbuff, sizeof(numbuff), "%u",
                         obj->def.leaflist->maxelems);
                help_write_lines((const xmlChar *)numbuff, 0, FALSE);
            }
            break;
        default:
            ;
        }
        break;
    case OBJ_TYP_CHOICE:
        if (mode == HELP_MODE_BRIEF) {
            neednewline = TRUE;
            break;
        }
        count = obj_enabled_child_count(obj);
        if (count) {
            obj_dump_datadefQ(obj_get_datadefQ(obj),
                              mode, nestlevel, indent+NCX_DEF_INDENT);
        }
        break;
    case OBJ_TYP_CASE:
        if (mode == HELP_MODE_BRIEF) {
            neednewline = TRUE;
            break;
        }
        count = obj_enabled_child_count(obj);
        if (count > 1) {
            obj_dump_datadefQ(obj_get_datadefQ(obj), 
                              mode, nestlevel, indent+NCX_DEF_INDENT);
        } else if (count == 1) {
            testobj = obj_first_child(obj);
            if (testobj) {
                obj_dump_template(testobj, mode, nestlevel, indent);
            }
        } /* else skip this case */
        break;
    case OBJ_TYP_LIST:
        switch (mode) {
        case HELP_MODE_BRIEF:
            break;
        case HELP_MODE_NORMAL:
        case HELP_MODE_FULL:
            keystr = obj_get_keystr(obj);
            if (keystr != NULL) {
                help_write_lines((const xmlChar *)"key: ", 
                                 indent+NCX_DEF_INDENT, TRUE); 
                help_write_lines(keystr, 0, FALSE);
            }
            if (!obj->def.list->ordersys) {
                help_write_lines((const xmlChar *)"ordered-by: user", 
                                 indent+NCX_DEF_INDENT, TRUE); 
            }

            if (mode == HELP_MODE_NORMAL) {
                break;
            }

            if (obj->def.list->minset) {
                help_write_lines((const xmlChar *)"min-elements: ", 
                                 indent+NCX_DEF_INDENT, TRUE); 
                snprintf(numbuff, sizeof(numbuff), "%u",
                         obj->def.list->minelems);
                help_write_lines((const xmlChar *)numbuff, 0, FALSE);
            }
            if (obj->def.list->maxset) {
                help_write_lines((const xmlChar *)"max-elements: ", 
                                 indent+NCX_DEF_INDENT, TRUE); 
                snprintf(numbuff, sizeof(numbuff), "%u",
                         obj->def.list->maxelems);
                help_write_lines((const xmlChar *)numbuff, 0, FALSE);
            }
            break;
        default:
            ;
        }
        if (mode != HELP_MODE_BRIEF) {
            obj_dump_datadefQ(obj_get_datadefQ(obj), 
                              mode, nestlevel, indent+NCX_DEF_INDENT);
        }
        break;
    case OBJ_TYP_RPC:
        testobj = obj_find_child(obj, NULL, YANG_K_INPUT);
        if (testobj && obj_enabled_child_count(testobj)) {
            obj_dump_template(testobj, mode, nestlevel,
                              indent+NCX_DEF_INDENT);
        }

        testobj = obj_find_child(obj, NULL, YANG_K_OUTPUT);
        if (testobj && obj_enabled_child_count(testobj)) {
            obj_dump_template(testobj, mode, nestlevel,
                              indent+NCX_DEF_INDENT);
        }
        help_write_lines((const xmlChar *)"\n", 0, FALSE);
        break;
    case OBJ_TYP_RPCIO:
        if (mode != HELP_MODE_BRIEF) {
            testobj = obj_get_default_parm(obj);
            if (testobj && obj_is_enabled(testobj)) {
                help_write_lines((const xmlChar *)"default parameter: ", 
                                 indent+NCX_DEF_INDENT, TRUE); 
                help_write_lines(obj_get_name(testobj), 0, FALSE);
            } else {
                neednewline = FALSE;
            }
        }
        obj_dump_datadefQ(obj_get_datadefQ(obj), 
                          mode, nestlevel, indent+NCX_DEF_INDENT);
        break;
    case OBJ_TYP_NOTIF:
        obj_dump_datadefQ(obj_get_datadefQ(obj),
                          mode, nestlevel, indent+NCX_DEF_INDENT);
        break;
    case OBJ_TYP_AUGMENT:
    case OBJ_TYP_USES:
    case OBJ_TYP_REFINE:
    default:
        SET_ERROR(ERR_INTERNAL_VAL);
    }

    if (neednewline) {
        help_write_lines(NULL, 0, TRUE);
    }

}   /* obj_dump_template */
Exemplo n.º 22
0
/********************************************************************
* FUNCTION send_lock_pdu_to_server
* 
* Send a <lock> or <unlock> operation to the server
*
* INPUTS:
*   server_cb == server control block to use
*   lockcb == lock control block to use within server_cb
*   islock == TRUE for lock; FALSE for unlock
*
* RETURNS:
*    status
*********************************************************************/
static status_t
    send_lock_pdu_to_server (server_cb_t *server_cb,
                            lock_cb_t *lockcb,
                            boolean islock)
{
    obj_template_t        *rpc, *input;
    mgr_rpc_req_t         *req;
    val_value_t           *reqdata, *targetval, *parmval;
    ses_cb_t              *scb;
    status_t               res;
    xmlns_id_t             obj_nsid;

    req = NULL;
    reqdata = NULL;
    res = NO_ERR;

    if (LOGDEBUG) {
        log_debug("\nSending <%s> request",
                  (islock) ? NCX_EL_LOCK : NCX_EL_UNLOCK);
    }

    if (islock) {
        rpc = ncx_find_object(get_netconf_mod(server_cb), 
                              NCX_EL_LOCK);
    } else {
        rpc = ncx_find_object(get_netconf_mod(server_cb), 
                              NCX_EL_UNLOCK);
    }
    if (!rpc) {
        return SET_ERROR(ERR_NCX_DEF_NOT_FOUND);
    }

    obj_nsid = obj_get_nsid(rpc);

    /* get the 'input' section container */
    input = obj_find_child(rpc, NULL, YANG_K_INPUT);
    if (!input) {
        return SET_ERROR(ERR_NCX_DEF_NOT_FOUND);
    }

    /* construct a method + parameter tree */
    reqdata = xml_val_new_struct(obj_get_name(rpc), obj_nsid);
    if (!reqdata) {
        log_error("\nError allocating a new RPC request");
        return ERR_INTERNAL_MEM;
    }

    /* set the [un]lock/input/target node XML namespace */
    targetval = xml_val_new_struct(NCX_EL_TARGET, obj_nsid);
    if (!targetval) {
        log_error("\nError allocating a new RPC request");
        val_free_value(reqdata);
        return ERR_INTERNAL_MEM;
    } else {
        val_add_child(targetval, reqdata);
    }

    parmval = xml_val_new_flag(lockcb->config_name,
                               obj_nsid);
    if (!parmval) {
        val_free_value(reqdata);
        return ERR_INTERNAL_MEM;
    } else {
        val_add_child(parmval, targetval);
    }

    scb = mgr_ses_get_scb(server_cb->mysid);
    if (!scb) {
        res = SET_ERROR(ERR_INTERNAL_PTR);
    } else {
        req = mgr_rpc_new_request(scb);
        if (!req) {
            res = ERR_INTERNAL_MEM;
            log_error("\nError allocating a new RPC request");
        } else {
            req->data = reqdata;
            req->rpc = rpc;
            req->timeout = server_cb->timeout;
        }
    }
        
    /* if all OK, send the RPC request */
    if (res == NO_ERR) {
        if (LOGDEBUG2) {
            log_debug2("\nabout to send RPC request with reqdata:");
            val_dump_value_max(reqdata, 
                               0,
                               server_cb->defindent,
                               DUMP_VAL_LOG,
                               server_cb->display_mode,
                               FALSE,
                               FALSE);
        }

        /* the request will be stored if this returns NO_ERR */
        res = mgr_rpc_send_request(scb, req, yangcli_reply_handler);
        if (res == NO_ERR) {
            if (islock) {
                lockcb->lock_state = LOCK_STATE_REQUEST_SENT;
            } else {
                lockcb->lock_state = LOCK_STATE_RELEASE_SENT;
            }
            (void)uptime(&lockcb->last_msg_time);
            server_cb->locks_cur_cfg = lockcb->config_id;
        }
    }

    /* cleanup and set next state */
    if (res != NO_ERR) {
        if (req) {
            mgr_rpc_free_request(req);
        } else if (reqdata) {
            val_free_value(reqdata);
        }
    } else {
        server_cb->state = MGR_IO_ST_CONN_RPYWAIT;
    }

    return res;

} /* send_lock_pdu_to_server */
Exemplo n.º 23
0
/*
 * Given a new x,y,width,height, calculate appropriate layout info
 */
int
abobj_calculate_new_layout(
    ABObj	obj,
    int		new_x,
    int		new_y,
    Dimension	new_width,
    Dimension	new_height
)
{
    ABObj	parent;
    ABAttachListPtr attachments;
    Position    x, y;
    Dimension   width, height;
    Dimension   p_width, p_height;
    long	gridpos;

    if ((attachments = obj->attachments) == NULL)
        return -1;

    if (obj->ui_handle == NULL)
    {
	if (util_get_verbosity() > 0)
	    fprintf(stderr,"abobj_calculate_new_layout: %s: NULL widget\n", obj_get_name(obj));
	return -1;
    }

    XtVaGetValues((Widget)obj->ui_handle,
			XmNx,		&x,
			XmNy,		&y,
                        XmNwidth,       &width,
                        XmNheight,      &height,
			NULL);

    parent = obj_get_parent(obj);
    XtVaGetValues((Widget)parent->ui_handle,
                        XmNwidth,       &p_width,
                        XmNheight,      &p_height,
                        NULL);

    switch(attachments->west.type)
    {
	case AB_ATTACH_POINT:
	   attachments->west.offset = new_x;
	   break;
	case AB_ATTACH_GRIDLINE:
	   gridpos = (100 * new_x)/(int)p_width;
	   attachments->west.value = (void*)gridpos;
	   break;
	case AB_ATTACH_CENTER_GRIDLINE:
           gridpos = (100 * (new_x + (int)new_width/2))/(int)p_width;
	   attachments->west.value = (void*)gridpos;
	   break;
	case AB_ATTACH_OBJ:
	case AB_ATTACH_ALIGN_OBJ_EDGE:
	   attachments->west.offset += (new_x - x);
	   if (new_x == 0 && attachments->west.offset < 0)
		attachments->west.offset = 0;
	   break;
    }

    switch(attachments->east.type) 
    { 
        case AB_ATTACH_POINT: 
           attachments->east.offset = p_width - (new_x + new_width);
           break;
        case AB_ATTACH_GRIDLINE:
           gridpos = (100 * (new_x + (int)new_width))/(int)p_width;
           attachments->east.value = (void*)gridpos;
           break;
	case AB_ATTACH_CENTER_GRIDLINE:
           gridpos = (100 * (new_x + (int)new_width/2))/(int)p_width;
           attachments->east.value = (void*)gridpos;
           break;
	case AB_ATTACH_OBJ:
	   attachments->east.offset = p_width - (new_x + new_width + 1);
	   break;
	case AB_ATTACH_ALIGN_OBJ_EDGE:
	   attachments->east.offset += (x + width - new_x - new_width);
	   break;
    }

    switch(attachments->north.type)
    {
        case AB_ATTACH_POINT:
           attachments->north.offset = new_y;
           break;
        case AB_ATTACH_GRIDLINE:
           gridpos = (100 * new_y)/(int)p_height;
           attachments->north.value = (void*)gridpos;
           break;
	case AB_ATTACH_CENTER_GRIDLINE:
           gridpos = (100 * (new_y + (int)new_height/2))/(int)p_height;
           attachments->north.value = (void*)gridpos;
           break;
        case AB_ATTACH_OBJ: 
        case AB_ATTACH_ALIGN_OBJ_EDGE: 
           attachments->north.offset += (new_y - y); 
           if (new_y == 0 && attachments->north.offset < 0) 
        	attachments->north.offset = 0; 
           break; 
    }

    switch(attachments->south.type)
    {
        case AB_ATTACH_POINT:
           attachments->south.offset = p_height - (new_y + new_height);
           break;
        case AB_ATTACH_GRIDLINE:
           gridpos = (100 * (new_y + (int)new_height))/(int)p_height;
           attachments->south.value = (void*)gridpos;
           break;
	case AB_ATTACH_CENTER_GRIDLINE:
           gridpos = (100 * (new_y + (int)new_height/2))/(int)p_height;
           attachments->south.value = (void*)gridpos;
           break;
        case AB_ATTACH_OBJ:
           attachments->south.offset = p_height - (new_y + new_height + 1);
	   break;
        case AB_ATTACH_ALIGN_OBJ_EDGE: 
           attachments->south.offset += (y + height - new_y - new_height); 
           break; 
    }

    objxm_obj_set_attachment_args(obj, OBJXM_CONFIG_BUILD);

    return 0;

}
Exemplo n.º 24
0
static int
custdlg_prop_load(
    ABObj    	 obj,
    AB_PROP_TYPE type,
    unsigned long loadkey
)
{
    ABObj			area;
    PropCustdlgSettingsRec 	*pcs = &(prop_custdlg_settings_rec[type]);
    BOOL                        load_all = (loadkey & LoadAll);

    if (obj == NULL)
    {
        if (pcs->current_obj != NULL)
            obj = pcs->current_obj;
        else
            return ERROR;
    }
    else if (!obj_is_popup_win(obj))
        return ERROR;
    else
        pcs->current_obj = obj;

    /* Load Name */
    if (load_all || loadkey & LoadName)
    	prop_field_set_value(&(pcs->name), obj_get_name(obj), False);

    if (load_all)
    {
	/* Load Window Parent */
	prop_obj_options_load(&(pcs->win_parent), proj_get_project());
	prop_obj_options_set_value(&(pcs->win_parent),
	obj_get_win_parent(obj), False);

	/* Load Title */
	prop_field_set_value(&(pcs->title), obj_get_label(obj), False);

	/* Load Resize Mode */
	prop_radiobox_set_value(&(pcs->resize_mode),
                                (XtPointer)obj_get_resizable(obj), False);

	/* Load Window Areas */
	area = objxm_comp_custdlg_get_area(obj, AB_CONT_BUTTON_PANEL);
	prop_checkbox_set_value(&(pcs->areas), AB_CONT_BUTTON_PANEL,
	area != NULL, False);

	area = objxm_comp_custdlg_get_area(obj, AB_CONT_FOOTER);
	prop_checkbox_set_value(&(pcs->areas), AB_CONT_FOOTER,
		area != NULL, False);

	/* Load Default Button */
	prop_obj_options_load(&(pcs->default_but),
	objxm_comp_custdlg_get_area(obj, AB_CONT_BUTTON_PANEL));
	prop_obj_options_set_value(&(pcs->default_but),
	obj_get_default_act_button(obj), False);

	/* Load Help Button */
	prop_obj_options_load(&(pcs->help_but),
	objxm_comp_custdlg_get_area(obj, AB_CONT_BUTTON_PANEL));
	prop_obj_options_set_value(&(pcs->help_but),
	obj_get_help_act_button(obj), False);

	/* Load Size Policy */
	prop_radiobox_set_value(&(pcs->size_policy),
				abobj_width_resizable(obj)?
                                (XtPointer)SIZE_FIXED_KEY :
                                (XtPointer)SIZE_OF_CONTENTS_KEY, False);

	/* Load Initial State */
	prop_checkbox_set_value(&(pcs->init_state), AB_STATE_VISIBLE,
		obj_is_initially_visible(obj), False);

	/* Load Color */
	prop_colorfield_set_value(&(pcs->bg_color), obj_get_bg_color(obj), False);
	prop_colorfield_set_value(&(pcs->fg_color), obj_get_fg_color(obj), False);

    	turnoff_changebars(type);
    }

    /* Load Size */
    if (load_all || loadkey & LoadSize)
        prop_load_obj_size(obj, &(pcs->geometry));

    return OK;
}
Exemplo n.º 25
0
/*
 *    Draw rubberbanding outline for resizing action    
 */
int
abobjP_resize_object_outline(
    ABObj        obj,
    XEvent       *event,
    RESIZE_DIR   dir
)
{
    ABObj	       s_obj;
    static Widget      parent;
    static Window      rootwin;
    static Display     *dpy;
    static XRectangle  orig_r, r;
    static int         last_x, last_y;
    int                x,y;
    char               buf[80];

    if (event->type == MotionNotify)
    {
    	x = ((XMotionEvent*)event)->x_root;
    	y = ((XMotionEvent*)event)->y_root;
    }
    else if (event->type == ButtonPress)
    {
        x = ((XButtonEvent*)event)->x_root;
        y = ((XButtonEvent*)event)->y_root;
    } 
    else
	return -1;

    if (first_move)
    {
        Window     win;
        int    orig_x, orig_y;
        int    trans_x, trans_y;

	if (obj_is_item(obj))
	    obj = obj_get_parent(obj);

	obj  = obj_get_root(obj);
	xy_obj = objxm_comp_get_subobj(obj, AB_CFG_POSITION_OBJ);
	xy_widget = (Widget)xy_obj->ui_handle;
 
        if (xy_widget == NULL)
        {
            if (util_get_verbosity() > 0)
                fprintf(stderr,"abobjP_resize_object_outline: %s :no SIZE widget\n",
			util_strsafe(obj_get_name(obj)));
            return ERROR;
        }
 
        parent  = XtParent(xy_widget);
        dpy     = XtDisplay(xy_widget);
        rootwin = RootWindowOfScreen(XtScreen(xy_widget));

        x_get_widget_rect(xy_widget, &orig_r);
	if (obj_has_border_frame(obj)) /* We have a border-frame to deal with */
	{
	    XRectangle pane_r;

            s_obj = objxm_comp_get_subobj(obj, AB_CFG_SIZE_OBJ);

	    /* Determine width of border */
	    x_get_widget_rect(objxm_get_widget(s_obj), &pane_r);
	    border_w = ((int)(orig_r.width - pane_r.width))/2;
	}
	else
	    border_w = 0;

	orig_r.width--;
	orig_r.height--;

        r = orig_r;

        orig_x = (int)orig_r.x;
        orig_y = (int)orig_r.y;

        XTranslateCoordinates(dpy, XtWindow(parent),
            rootwin, orig_x , orig_y, &trans_x, &trans_y,
            &win);

        r.x = (short)trans_x;
        r.y = (short)trans_y;

        first_move = FALSE;
    }
    else     /* erase previous outline */    
    {
        make_rect(&resize_rect, &r, last_x, last_y, dir);
        x_fullscreen_box(xy_widget, rootwin, 
                resize_rect.x, resize_rect.y,
                rect_right(&resize_rect), 
                rect_bottom(&resize_rect));

    }

    make_rect(&resize_rect, &r, x, y, dir);
    x_fullscreen_box(xy_widget, rootwin, 
                resize_rect.x, resize_rect.y,
                                rect_right(&resize_rect), 
                rect_bottom(&resize_rect));

    sprintf(buf, "%3.3dx%3.3d", resize_rect.width,
                                resize_rect.height);

    /* REMIND: aim, update status region on ab palette win */

    last_x = x;
    last_y = y;

    return OK;

}
Exemplo n.º 26
0
static int
scale_prop_load(
    ABObjPtr 	 obj,
    AB_PROP_TYPE type,
    unsigned long loadkey
)
{
    PropScaleSettingsRec 	*pss = &(prop_scale_settings_rec[type]);
    AB_ORIENTATION		orient;
    BOOL			load_all = (loadkey & LoadAll);
 
    if (obj == NULL)
    {
        if (pss->current_obj != NULL)
            obj = pss->current_obj;
        else
            return ERROR;
    }
    else if (!obj_is_scale(obj))
        return ERROR;
    else
        pss->current_obj = obj;

    /* Load Name */
    if (load_all || loadkey & LoadName)
    	prop_field_set_value(&(pss->name), obj_get_name(obj), False);

    if (load_all)
    {
	/* Load Label Type/Position */
	prop_options_set_value(&(pss->label_type), (XtPointer)obj->label_type, False);
	prop_options_set_value(&(pss->label_pos), (XtPointer)obj_get_label_position(obj), False);

	/* Load Label */
	prop_setup_label_field(&(pss->label), NULL,
				obj->label_type, obj_get_label(obj), AB_LINE_UNDEF);

	/* Load Scale Type */
	prop_radiobox_set_value(&(pss->scale_type),
                                (XtPointer)obj_get_read_only(obj), False);

	/* Load Orientation */
	orient = obj_get_orientation(obj);
	prop_radiobox_set_value(&(pss->orient), (XtPointer)orient, False); 
	setup_direction_setting(type, orient);

	/* Load Direction */
	prop_options_set_value(&(pss->dir), (XtPointer)obj_get_direction(obj), False);

	/* Load Value Range */
	prop_field_set_numeric_value(&(pss->min), obj_get_min_value(obj), False);
	prop_field_set_numeric_value(&(pss->max), obj_get_max_value(obj), False);
	prop_field_set_numeric_value(&(pss->incr), obj_get_increment(obj), False);

	/* Load Decimal Points */
	prop_field_set_numeric_value(&(pss->decimal), 
		obj_get_decimal_points(obj), False);

	/* Load Initial Value/Show Value */
	prop_field_set_numeric_value(&(pss->ivalue), 
		obj_get_initial_value_int(obj), False);
	prop_checkbox_set_value(&(pss->show_value), SHOW_VALUE_KEY,
		obj_get_show_value(obj), False);

	/* Load Initial State */
	prop_checkbox_set_value(&(pss->init_state), AB_STATE_VISIBLE,
		obj_is_initially_visible(obj), False);
    	prop_checkbox_set_value(&(pss->init_state), AB_STATE_ACTIVE,
		obj_is_initially_active(obj), False);

    	/* Load Color */
    	prop_colorfield_set_value(&(pss->bg_color), obj_get_bg_color(obj), False); 
    	prop_colorfield_set_value(&(pss->fg_color), obj_get_fg_color(obj), False);
 
    	turnoff_changebars(type);
    }

    /* Load Geometry */
    if (load_all || loadkey & LoadPosition)
        prop_load_obj_position(obj, &(pss->geometry)); 

    if (load_all || loadkey & LoadSize)
        prop_load_obj_size(obj, &(pss->geometry)); 

    return OK;
}
Exemplo n.º 27
0
/********************************************************************
* FUNCTION send_discard_changes_pdu_to_server
* 
* Send a <discard-changes> operation to the server
*
* INPUTS:
*   server_cb == server control block to use
*
* RETURNS:
*    status
*********************************************************************/
status_t
    send_discard_changes_pdu_to_server (server_cb_t *server_cb)
{
    obj_template_t        *rpc;
    mgr_rpc_req_t         *req;
    val_value_t           *reqdata;
    ses_cb_t              *scb;
    status_t               res;
    xmlns_id_t             obj_nsid;

    req = NULL;
    reqdata = NULL;
    res = NO_ERR;

    if (LOGDEBUG) {
        log_debug("\nSending <discard-changes> request");
    }
    
    rpc = ncx_find_object(get_netconf_mod(server_cb), 
                          NCX_EL_DISCARD_CHANGES);
    if (!rpc) {
        return SET_ERROR(ERR_NCX_DEF_NOT_FOUND);
    }

    obj_nsid = obj_get_nsid(rpc);

    /* construct a method node */
    reqdata = xml_val_new_flag(obj_get_name(rpc), 
                               obj_nsid);
    if (!reqdata) {
        log_error("\nError allocating a new RPC request");
        return ERR_INTERNAL_MEM;
    }

    scb = mgr_ses_get_scb(server_cb->mysid);
    if (!scb) {
        res = SET_ERROR(ERR_INTERNAL_PTR);
    } else {
        req = mgr_rpc_new_request(scb);
        if (!req) {
            res = ERR_INTERNAL_MEM;
            log_error("\nError allocating a new RPC request");
        } else {
            req->data = reqdata;
            req->rpc = rpc;
            req->timeout = server_cb->timeout;
        }
    }
        
    /* if all OK, send the RPC request */
    if (res == NO_ERR) {
        if (LOGDEBUG2) {
            log_debug2("\nabout to send RPC request with reqdata:");
            val_dump_value_max(reqdata, 
                               0,
                               server_cb->defindent,
                               DUMP_VAL_LOG,
                               server_cb->display_mode,
                               FALSE,
                               FALSE);
        }

        /* the request will be stored if this returns NO_ERR */
        res = mgr_rpc_send_request(scb, req, yangcli_reply_handler);
        if (res == NO_ERR) {
            server_cb->command_mode = CMD_MODE_AUTODISCARD;
        }
    }

    /* cleanup and set next state */
    if (res != NO_ERR) {
        if (req) {
            mgr_rpc_free_request(req);
        } else if (reqdata) {
            val_free_value(reqdata);
        }
    } else {
        server_cb->state = MGR_IO_ST_CONN_RPYWAIT;
    }

    return res;

} /* send_discard_changes_pdu_to_server */
Exemplo n.º 28
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;
}
Exemplo n.º 29
0
static int
choice_prop_load(
    ABObjPtr 	 obj,
    AB_PROP_TYPE type,
    unsigned long loadkey
)
{
    PropChoiceSettingsRec 	*pcs = &(prop_choice_settings_rec[type]);
    AB_CHOICE_TYPE		ctype;
    BOOL                        load_all = (loadkey & LoadAll);

    if (obj == NULL)
    {
        if (pcs->current_obj != NULL)
            obj = pcs->current_obj;
        else
            return ERROR;
    }
    else if (!obj_is_choice(obj))
        return ERROR;
    else
        pcs->current_obj = obj;

    /* Load Name */
    if (load_all || loadkey & LoadName)
        prop_field_set_value(&(pcs->name), obj_get_name(obj), False);

    if (load_all)
    {
        /* Load Label Type/Position */
        prop_options_set_value(&(pcs->label_type), (XtPointer)obj->label_type, False);
        prop_options_set_value(&(pcs->label_pos), (XtPointer)obj_get_label_position(obj), False);

        /* Load Label */
        prop_setup_label_field(&(pcs->label), NULL,
                               obj->label_type, obj_get_label(obj), AB_LINE_UNDEF);
        /* Load Choice Type */
        ctype = obj_get_choice_type(obj);
        prop_options_set_value(&(pcs->choice_type), (XtPointer)ctype, False);
        setup_type_settings(type, ctype);

        /* Load Row/Column*/
        prop_radiobox_set_value(&(pcs->row_col), (XtPointer)obj_get_orientation(obj), False);
        prop_field_set_numeric_value(&(pcs->row_col_count), obj_get_num_columns(obj), False);

        /* Load Initial State */
        prop_checkbox_set_value(&(pcs->init_state), AB_STATE_VISIBLE,
                                obj_is_initially_visible(obj), False);
        prop_checkbox_set_value(&(pcs->init_state), AB_STATE_ACTIVE,
                                obj_is_initially_active(obj), False);

        /* Load Color */
        prop_colorfield_set_value(&(pcs->bg_color), obj_get_bg_color(obj), False);
        prop_colorfield_set_value(&(pcs->fg_color), obj_get_fg_color(obj), False);

        /* Load Choice Items */
        prop_item_editor_load(&(pcs->items), obj);

        turnoff_changebars(type);
    }

    /* Load Position */
    if (load_all || loadkey & LoadPosition)
        prop_load_obj_position(obj, &(pcs->pos));

    return OK;

}
Exemplo n.º 30
0
int
abmfP_write_action_function(
    GenCodeInfo	genCodeInfo,
    ABObj		action
)
{
    int			rc = 0;			/* return code */
    BOOL		isTTCB = FALSE;
    BOOL		ss_cb = FALSE;
    File                codeFile = genCodeInfo->code_file;
    BOOL		topUserSegWritten = FALSE;
    BOOL		bottomUserSegWritten = FALSE;
    BOOL		funcBodyWritten = FALSE;
    BOOL		funcEndWritten = FALSE;
    BOOL		actionPrintfWritten = FALSE;
    int                 return_value = 0;
    ABObj               fromObj = obj_get_from(action);
    ABObj		actualFromObj = NULL;
    ABObj		toObj = obj_get_to(action);
    ABObj		module = NULL;
    char		actionName[1024];
    char		actionPrintf[1024];

    abmfP_gencode_enter_func(genCodeInfo);
    abmfP_ip_obj(genCodeInfo) = obj_get_to(action);
    util_strncpy(actionName, abmfP_get_action_name(action), 1024);
    sprintf(actionPrintf, "printf(\"action: %s()\\n\");\n", actionName);

    /***
     *** START OF FUNCTION
     ***/

    switch (obj_get_when(action))
    {
    case AB_WHEN_AFTER_CREATED:
        /*
         * post-create procs have the signature of an Xt Callback,
         * although they are called as conventional functions.
         */
        fromObj = obj_get_from(action);
        actualFromObj = get_actual_from_obj(action);
        abmfP_write_xm_callback_begin(genCodeInfo, FALSE, actionName);
        write_instance_ptr_var(genCodeInfo, actualFromObj,
                               get_from_var_name(), "callData", TRUE, NULL);
        abio_puts(genCodeInfo->code_file, nlstr);

        break;

    case AB_WHEN_DRAGGED_FROM:
    {
        abio_printf(genCodeInfo->code_file,
                    abmfP_lib_default_dragCB->def,	/* this is a format string */
                    actionName,actionName,actionName,
                    actionName,actionName, actionName);
        abio_puts(genCodeInfo->code_file, "\n\n");

        /* these are all in the "library" definition */
        topUserSegWritten = TRUE;
        bottomUserSegWritten = TRUE;
        funcBodyWritten = TRUE;
        funcEndWritten = TRUE;
        actionPrintfWritten = TRUE;
    }
    break;

    case AB_WHEN_DROPPED_ON:
    {
        abio_printf(genCodeInfo->code_file,
                    abmfP_lib_default_dropCB->def,	/* this is a format string */
                    actionName,actionName,actionName,actionName);
        abio_puts(genCodeInfo->code_file, "\n\n");

        /* these are all in the "library" definition */
        topUserSegWritten = TRUE;
        bottomUserSegWritten = TRUE;
        funcBodyWritten = TRUE;
        funcEndWritten = TRUE;
        actionPrintfWritten = TRUE;
    }
    break;

    case AB_WHEN_TOOLTALK_QUIT:
    case AB_WHEN_TOOLTALK_DO_COMMAND:
    case AB_WHEN_TOOLTALK_GET_STATUS:
    case AB_WHEN_TOOLTALK_PAUSE_RESUME:
        isTTCB = TRUE;
        abio_printf(codeFile, begin_tt_callback_body, actionName);
        abmfP_write_c_block_begin(genCodeInfo);
        write_tooltalk_cb_vars(genCodeInfo, action);
        break;

    case AB_WHEN_SESSION_RESTORE:
        ss_cb = TRUE;
        abio_printf(codeFile, begin_ss_restore_callback_body,
                    abmfP_get_action_name(action));
        abmfP_write_c_block_begin(genCodeInfo);
        write_ss_cb_vars(genCodeInfo, action);
        break;

    case AB_WHEN_SESSION_SAVE:
        ss_cb = TRUE;
        abio_printf(codeFile, begin_ss_save_callback_body,
                    abmfP_get_action_name(action));
        abmfP_write_c_block_begin(genCodeInfo);
        write_ss_cb_vars(genCodeInfo, action);
        break;

    default:
        abmfP_write_xm_callback_begin(genCodeInfo, FALSE, actionName);
        break;

    } /* switch obj_get_when() */


    /*****
     ***** TOP USER SEGMENT
     *****/

    if (!topUserSegWritten)
    {
        STRING	contents =
            (actionPrintfWritten? NULL:(isTTCB? actionPrintf:NULL));
        abmfP_write_user_var_and_code_seg(genCodeInfo, contents);
        abio_puts(codeFile, nlstr);
        topUserSegWritten = TRUE;
        if (contents != NULL)
        {
            actionPrintfWritten = TRUE;
        }
    }

    /***
     *** FUNCTION BODY
     ***/

    if (isTTCB)
    {
        write_tooltalk_cb_body1(genCodeInfo, action);
        abmfP_write_user_code_seg(genCodeInfo, NULL);
        write_tooltalk_cb_body2(genCodeInfo, action);
        funcBodyWritten = TRUE;
        bottomUserSegWritten = TRUE;
    }
    else if (ss_cb)
    {
        write_ss_cb_body1(genCodeInfo, action);
        abmfP_write_user_code_seg(genCodeInfo, NULL);
        write_ss_cb_body2(genCodeInfo, action);
        funcBodyWritten = TRUE;
        bottomUserSegWritten = TRUE;
    }
    else if (!funcBodyWritten) switch (obj_get_func_type(action))
        {
        case AB_FUNC_BUILTIN:
            rc = abmfP_write_builtin_action(genCodeInfo, action, TRUE);
            return_if_err(rc,rc);
            funcBodyWritten = TRUE;
            break;

        case AB_FUNC_USER_DEF:
            abmfP_write_user_start_comment(genCodeInfo, "vvv Add C code below vvv");
            abmfP_write_user_end_comment(genCodeInfo, "^^^ Add C code above ^^^");
            bottomUserSegWritten = TRUE;
            funcBodyWritten = TRUE;
            break;

        case AB_FUNC_CODE_FRAG:
            abio_puts(codeFile, obj_get_func_code(action));
            funcBodyWritten = TRUE;
            break;

        case AB_FUNC_ON_ITEM_HELP:
            abio_printf(codeFile, "dtb_do_onitem_help();\n");
            funcBodyWritten = TRUE;
            break;

        case AB_FUNC_HELP_VOLUME:
            abio_printf(codeFile,
                        "dtb_show_help_volume_info(\"%s\", \"%s\");\n",
                        istr_string(action->info.action.volume_id),
                        istr_string(action->info.action.location));
            funcBodyWritten = TRUE;
            break;

        default:
        {
            char *obj_name_string = obj_get_name(fromObj);
            util_printf_err(catgets(Dtb_project_catd, 1, 78,
                                    "unknown function type for action from object, %s"),
                            obj_name_string);
            return_code(ERR);
        }
        break;
        }

    /*****
     ***** BOTTOM USER SEGMENT
     *****/

    if (!bottomUserSegWritten)
    {
        STRING	contents = (actionPrintfWritten? NULL:actionPrintf);
        abmfP_write_user_code_seg(genCodeInfo, contents);
        bottomUserSegWritten = TRUE;
        if (contents != NULL)
        {
            actionPrintfWritten = TRUE;
        }
    }

    /*****
     ***** FUNCTION END
     *****/

    if (!funcEndWritten)
    {
        abmfP_write_c_func_end(genCodeInfo, NULL);
        funcEndWritten = TRUE;
    }

epilogue:
    abmfP_gencode_exit_func(genCodeInfo);
    return return_value;
}