Index: trunk/src_plugins/drc_query/dlg.c =================================================================== --- trunk/src_plugins/drc_query/dlg.c (revision 30259) +++ trunk/src_plugins/drc_query/dlg.c (revision 30260) @@ -30,3 +30,107 @@ #include +typedef struct{ + PCB_DAD_DECL_NOINIT(dlg) + conf_role_t role; + char *rule; + int wtype, wtitle, wdisable, wdesc, wrule; +} rule_edit_ctx_t; + +rule_edit_ctx_t rule_edit_ctx; + +static void rule_edit_close_cb(void *caller_data, pcb_hid_attr_ev_t ev) +{ + rule_edit_ctx_t *ctx = caller_data; + + free(ctx->rule); + PCB_DAD_FREE(ctx->dlg); + free(ctx); +} + +static void drc_rule_pcb2dlg(rule_edit_ctx_t *ctx) +{ + +} + +static int pcb_dlg_rule_edit(conf_role_t role, const char *rule) +{ + pcb_hid_dad_buttons_t clbtn[] = {{"Close", 0}, {NULL, 0}}; + char *info; + rule_edit_ctx_t *ctx = calloc(sizeof(rule_edit_ctx_t), 1); + + ctx->role = role; + ctx->rule = pcb_strdup(rule); + + info = pcb_strdup_printf("DRC rule edit: %s on role %s", rule, pcb_conf_role_name(role)); + PCB_DAD_BEGIN_VBOX(ctx->dlg); + PCB_DAD_COMPFLAG(ctx->dlg, PCB_HATF_EXPFILL); + PCB_DAD_LABEL(ctx->dlg, info); + PCB_DAD_BEGIN_HBOX(ctx->dlg); + PCB_DAD_LABEL(ctx->dlg, "DRC violation type (group):"); + PCB_DAD_STRING(ctx->dlg); + PCB_DAD_WIDTH_CHR(ctx->dlg, 24); + ctx->wtype = PCB_DAD_CURRENT(ctx->dlg); + PCB_DAD_END(ctx->dlg); + PCB_DAD_BEGIN_HBOX(ctx->dlg); + PCB_DAD_LABEL(ctx->dlg, "DRC violation title:"); + PCB_DAD_STRING(ctx->dlg); + PCB_DAD_WIDTH_CHR(ctx->dlg, 32); + ctx->wtitle = PCB_DAD_CURRENT(ctx->dlg); + PCB_DAD_END(ctx->dlg); + PCB_DAD_BEGIN_HBOX(ctx->dlg); + PCB_DAD_LABEL(ctx->dlg, "Disable drc rule:"); + PCB_DAD_BOOL(ctx->dlg, ""); + ctx->wdisable = PCB_DAD_CURRENT(ctx->dlg); + PCB_DAD_END(ctx->dlg); + PCB_DAD_LABEL(ctx->dlg, "DRC violation description:"); + PCB_DAD_STRING(ctx->dlg); + PCB_DAD_WIDTH_CHR(ctx->dlg, 48); + ctx->wdesc = PCB_DAD_CURRENT(ctx->dlg); + + PCB_DAD_LABEL(ctx->dlg, "DRC rule query script:"); + PCB_DAD_TEXT(ctx->dlg, ctx); + PCB_DAD_COMPFLAG(ctx->dlg, PCB_HATF_EXPFILL | PCB_HATF_SCROLL); + /*PCB_DAD_CHANGE_CB(ctx->dlg, rule_chg_cb);*/ + ctx->wrule = PCB_DAD_CURRENT(ctx->dlg); + + + PCB_DAD_BEGIN_HBOX(ctx->dlg); + PCB_DAD_BUTTON(ctx->dlg, "Run"); + PCB_DAD_BEGIN_VBOX(ctx->dlg); + PCB_DAD_COMPFLAG(ctx->dlg, PCB_HATF_EXPFILL); + PCB_DAD_END(ctx->dlg); + PCB_DAD_BUTTON_CLOSES(ctx->dlg, clbtn); + PCB_DAD_END(ctx->dlg); + PCB_DAD_END(ctx->dlg); + free(info); + + PCB_DAD_DEFSIZE(ctx->dlg, 200, 400); + + drc_rule_pcb2dlg(ctx); + + PCB_DAD_NEW("drc_query_rule_edit", ctx->dlg, "drc_query: rule editor", ctx, pcb_false, rule_edit_close_cb); + return 0; +} + +static const char pcb_acts_DrcQueryEditRule[] = "DrcQueryEditRule(role, path, rule)\nDrcQueryEditRule(role, path, rule)\n"; +static const char pcb_acth_DrcQueryEditRule[] = "Interactive, GUI based DRC rule editor"; +static fgw_error_t pcb_act_DrcQueryEditRule(fgw_arg_t *res, int argc, fgw_arg_t *argv) +{ + const char *srole, *spath, *srule = NULL; + conf_role_t role; + + PCB_ACT_CONVARG(1, FGW_STR, DrcQueryEditRule, srole = argv[1].val.str); + PCB_ACT_CONVARG(2, FGW_STR, DrcQueryEditRule, spath = argv[2].val.str); + PCB_ACT_MAY_CONVARG(3, FGW_STR, DrcQueryEditRule, srule = argv[3].val.str); + + if (srule == NULL) + srule = spath; + + role = pcb_conf_role_parse(srole); + if (role == CFR_invalid) + PCB_ACT_FAIL(DrcQueryEditRule); + + PCB_ACT_IRES(pcb_dlg_rule_edit(role, srule)); + return 0; +} Index: trunk/src_plugins/drc_query/drc_query.c =================================================================== --- trunk/src_plugins/drc_query/drc_query.c (revision 30259) +++ trunk/src_plugins/drc_query/drc_query.c (revision 30260) @@ -31,6 +31,7 @@ #include "config.h" #include +#include #include #include #include @@ -221,7 +222,7 @@ if (nat_rules == NULL) { if (strncmp(cfg->hash_path, "plugins/drc_query/rules", 23) == 0) { nat_rules = cfg; - nat_rules->gui_edit_act = "drc_query_edit_rules"; + nat_rules->gui_edit_act = "DrcQueryEditRule"; } } @@ -285,6 +286,10 @@ #include "dlg.c" +static pcb_action_t drc_query_action_list[] = { + {"DrcQueryEditRule", pcb_act_DrcQueryEditRule, pcb_acth_DrcQueryEditRule, pcb_acts_DrcQueryEditRule}, +}; + int pplg_check_ver_drc_query(int ver_needed) { return 0; } void pplg_uninit_drc_query(void) @@ -299,6 +304,8 @@ for(n = 0; n < free_drc_conf_nodes.used; n++) pcb_conf_unreg_field(free_drc_conf_nodes.array[n]); vtp0_uninit(&free_drc_conf_nodes); + + pcb_remove_actions_by_cookie(drc_query_cookie); } static conf_hid_callbacks_t cbs; @@ -317,6 +324,8 @@ pcb_conf_reg_field(conf_drc_query, field,isarray,type_name,cpath,cname,desc,flags); #include "drc_query_conf_fields.h" + PCB_REGISTER_ACTIONS(drc_query_action_list, drc_query_cookie) + return 0; }