Index: src_plugins/dialogs/dlg_pref.c =================================================================== --- src_plugins/dialogs/dlg_pref.c (revision 35845) +++ src_plugins/dialogs/dlg_pref.c (revision 35846) @@ -62,6 +62,8 @@ PREF_INIT_FUNC(ctx, PREF_TAB-1); \ } while(0) +#define PREF_TABDATA(ctx) (ctx->tab[PREF_TAB].tabdata) + /* application tabs */ #undef PREF_TAB #define PREF_TAB 0 Index: src_plugins/dialogs/dlg_pref.h =================================================================== --- src_plugins/dialogs/dlg_pref.h (revision 35845) +++ src_plugins/dialogs/dlg_pref.h (revision 35846) @@ -59,11 +59,7 @@ int tabs; /* number of app-specific tabs used */ int tabs_total; /* number of tabs used (app-specific and built-in combined) */ - pref_sizes_t sizes; - pref_board_t board; - pref_general_t general; - pref_lib_t lib; - pref_color_t color; + /* builtin tabs */ pref_win_t win; pref_key_t key; pref_menu_t menu; Index: src_plugins/dialogs/dlg_pref_board.c =================================================================== --- src_plugins/dialogs/dlg_pref_board.c (revision 35845) +++ src_plugins/dialogs/dlg_pref_board.c (revision 35846) @@ -31,14 +31,23 @@ #include "board.h" #include "conf_core.h" +typedef struct { + int wname, wthermscale, wtype; +} pref_board_t; + #define RND_EMPTY(a) ((a) ? (a) : "") +#undef DEF_TABDATA +#define DEF_TABDATA pref_board_t *tabdata = PREF_TABDATA(ctx) + /* Actual board meta to dialog box */ static void pref_board_brd2dlg(pref_ctx_t *ctx) { - RND_DAD_SET_VALUE(ctx->dlg_hid_ctx, ctx->board.wname, str, RND_EMPTY(PCB->hidlib.name)); - RND_DAD_SET_VALUE(ctx->dlg_hid_ctx, ctx->board.wthermscale, dbl, PCB->ThermScale); - RND_DAD_SET_VALUE(ctx->dlg_hid_ctx, ctx->board.wtype, str, (PCB->is_footprint ? "footprint" : "PCB board")); + DEF_TABDATA; + + RND_DAD_SET_VALUE(ctx->dlg_hid_ctx, tabdata->wname, str, RND_EMPTY(PCB->hidlib.name)); + RND_DAD_SET_VALUE(ctx->dlg_hid_ctx, tabdata->wthermscale, dbl, PCB->ThermScale); + RND_DAD_SET_VALUE(ctx->dlg_hid_ctx, tabdata->wtype, str, (PCB->is_footprint ? "footprint" : "PCB board")); } /* Dialog box to actual board meta */ @@ -48,8 +57,9 @@ const char *newname, *oldname; double newtherm; pref_ctx_t *ctx = caller_data; + DEF_TABDATA; - newname = RND_EMPTY(ctx->dlg[ctx->board.wname].val.str); + newname = RND_EMPTY(ctx->dlg[tabdata->wname].val.str); oldname = RND_EMPTY(PCB->hidlib.name); if (strcmp(oldname, newname) != 0) { free(PCB->hidlib.name); @@ -57,7 +67,7 @@ changed = 1; } - newtherm = ctx->dlg[ctx->board.wthermscale].val.dbl; + newtherm = ctx->dlg[tabdata->wthermscale].val.dbl; if (PCB->ThermScale != newtherm) { PCB->ThermScale = newtherm; changed = 1; @@ -76,22 +86,24 @@ void pcb_dlg_pref_board_create(pref_ctx_t *ctx) { + DEF_TABDATA; + RND_DAD_BEGIN_TABLE(ctx->dlg, 2); RND_DAD_LABEL(ctx->dlg, "Board name"); RND_DAD_STRING(ctx->dlg); - ctx->board.wname = RND_DAD_CURRENT(ctx->dlg); - ctx->dlg[ctx->board.wname].val.str = rnd_strdup(RND_EMPTY(PCB->hidlib.name)); + tabdata->wname = RND_DAD_CURRENT(ctx->dlg); + ctx->dlg[tabdata->wname].val.str = rnd_strdup(RND_EMPTY(PCB->hidlib.name)); RND_DAD_CHANGE_CB(ctx->dlg, pref_board_dlg2brd); RND_DAD_LABEL(ctx->dlg, "Thermal scale"); RND_DAD_REAL(ctx->dlg); - ctx->board.wthermscale = RND_DAD_CURRENT(ctx->dlg); + tabdata->wthermscale = RND_DAD_CURRENT(ctx->dlg); RND_DAD_MINMAX(ctx->dlg, 0.01, 100); - ctx->dlg[ctx->board.wthermscale].val.dbl = PCB->ThermScale; + ctx->dlg[tabdata->wthermscale].val.dbl = PCB->ThermScale; RND_DAD_CHANGE_CB(ctx->dlg, pref_board_dlg2brd); RND_DAD_LABEL(ctx->dlg, "Type"); RND_DAD_LABEL(ctx->dlg, ""); - ctx->board.wtype = RND_DAD_CURRENT(ctx->dlg); - ctx->dlg[ctx->board.wtype].name = rnd_strdup((PCB->is_footprint ? "footprint" : "PCB board")); + tabdata->wtype = RND_DAD_CURRENT(ctx->dlg); + ctx->dlg[tabdata->wtype].name = rnd_strdup((PCB->is_footprint ? "footprint" : "PCB board")); RND_DAD_CHANGE_CB(ctx->dlg, pref_board_dlg2brd); RND_DAD_LABEL(ctx->dlg, "Board attributes"); RND_DAD_BUTTON(ctx->dlg, "Edit..."); @@ -109,6 +121,8 @@ static void pcb_dlg_pref_board_init(pref_ctx_t *ctx, int tab) { PREF_INIT(ctx, &pref_board); + PREF_TABDATA(ctx) = calloc(sizeof(pref_board_t), 1); + rnd_trace("INIT pref board tab %d\n", tab); } #undef PREF_INIT_FUNC Index: src_plugins/dialogs/dlg_pref_board.h =================================================================== --- src_plugins/dialogs/dlg_pref_board.h (revision 35845) +++ src_plugins/dialogs/dlg_pref_board.h (revision 35846) @@ -1,8 +1,4 @@ #ifndef PCB_DLG_PREF_BOARD_H #define PCB_DLG_PREF_BOARD_H -typedef struct { - int wname, wthermscale, wtype; -} pref_board_t; - #endif Index: src_plugins/dialogs/dlg_pref_color.c =================================================================== --- src_plugins/dialogs/dlg_pref_color.c (revision 35845) +++ src_plugins/dialogs/dlg_pref_color.c (revision 35846) @@ -30,19 +30,28 @@ #include #include "conf_core.h" +typedef struct { + int *wgen, *wlayer; + int ngen; +} pref_color_t; + +#undef DEF_TABDATA +#define DEF_TABDATA pref_color_t *tabdata = PREF_TABDATA(ctx) + static void pref_color_brd2dlg(pref_ctx_t *ctx) { + DEF_TABDATA; rnd_conf_native_t *nat; int n; - if (ctx->color.wlayer != NULL) { + if (tabdata->wlayer != NULL) { nat = rnd_conf_get_field("appearance/color/layer"); for (n = 0; n < nat->used; n++) - RND_DAD_SET_VALUE(ctx->dlg_hid_ctx, ctx->color.wlayer[n], clr, nat->val.color[n]); + RND_DAD_SET_VALUE(ctx->dlg_hid_ctx, tabdata->wlayer[n], clr, nat->val.color[n]); } - for(n = 0; n < ctx->color.ngen; n++) { - int w = ctx->color.wgen[n]; + for(n = 0; n < tabdata->ngen; n++) { + int w = tabdata->wgen[n]; const char *path = ctx->dlg[w].user_data; nat = rnd_conf_get_field(path); if (nat != NULL) @@ -58,15 +67,16 @@ void pcb_dlg_pref_color_close(pref_ctx_t *ctx) { + DEF_TABDATA; int n; - for(n = 0; n < ctx->color.ngen; n++) { - int w = ctx->color.wgen[n]; + for(n = 0; n < tabdata->ngen; n++) { + int w = tabdata->wgen[n]; free(ctx->dlg[w].user_data); } - free(ctx->color.wgen); - free(ctx->color.wlayer); + free(tabdata->wgen); + free(tabdata->wlayer); } static void pref_color_gen_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) @@ -87,7 +97,8 @@ static void pref_color_layer_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) { pref_ctx_t *ctx = caller_data; - int idx = (int *)attr->user_data - ctx->color.wlayer; + DEF_TABDATA; + int idx = (int *)attr->user_data - tabdata->wlayer; if (pref_dlg2conf_pre(ctx) == NULL) return; @@ -105,6 +116,7 @@ htsp_entry_t *e; int n, pl, w; const char *path_prefix = "appearance/color"; + DEF_TABDATA; RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL); @@ -115,13 +127,13 @@ RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL | RND_HATF_SCROLL); pl = strlen(path_prefix); - ctx->color.ngen = 0; + tabdata->ngen = 0; rnd_conf_fields_foreach(e) { nat = e->value; if ((strncmp(e->key, path_prefix, pl) == 0) && (nat->type == RND_CFN_COLOR) && (nat->array_size == 1)) - ctx->color.ngen++; + tabdata->ngen++; } - ctx->color.wgen = calloc(sizeof(int), ctx->color.ngen); + tabdata->wgen = calloc(sizeof(int), tabdata->ngen); n = 0; rnd_conf_fields_foreach(e) { @@ -130,7 +142,7 @@ RND_DAD_BEGIN_HBOX(ctx->dlg); RND_DAD_BEGIN_VBOX(ctx->dlg); RND_DAD_COLOR(ctx->dlg); - ctx->color.wgen[n] = w = RND_DAD_CURRENT(ctx->dlg); + tabdata->wgen[n] = w = RND_DAD_CURRENT(ctx->dlg); ctx->dlg[w].user_data = rnd_strdup(e->key); RND_DAD_CHANGE_CB(ctx->dlg, pref_color_gen_cb); RND_DAD_END(ctx->dlg); @@ -146,13 +158,13 @@ nat = rnd_conf_get_field("appearance/color/layer"); if (nat->type == RND_CFN_COLOR) { RND_DAD_LABEL(ctx->dlg, "NOTE: these colors are used only\nwhen creating new layers."); - ctx->color.wlayer = calloc(sizeof(int), nat->used); + tabdata->wlayer = calloc(sizeof(int), nat->used); RND_DAD_BEGIN_TABLE(ctx->dlg, 2); for (n = 0; n < nat->used; n++) { char tmp[32]; RND_DAD_COLOR(ctx->dlg); - ctx->color.wlayer[n] = w = RND_DAD_CURRENT(ctx->dlg); - ctx->dlg[w].user_data = &ctx->color.wlayer[n]; + tabdata->wlayer[n] = w = RND_DAD_CURRENT(ctx->dlg); + ctx->dlg[w].user_data = &tabdata->wlayer[n]; RND_DAD_CHANGE_CB(ctx->dlg, pref_color_layer_cb); sprintf(tmp, "Layer %d", n); RND_DAD_LABEL(ctx->dlg, tmp); @@ -160,7 +172,7 @@ RND_DAD_END(ctx->dlg); } else { - ctx->color.wlayer = NULL; + tabdata->wlayer = NULL; RND_DAD_LABEL(ctx->dlg, "Broken internal configuration:\nno layer colors"); } RND_DAD_END(ctx->dlg); @@ -178,6 +190,7 @@ static void pcb_dlg_pref_color_init(pref_ctx_t *ctx, int tab) { PREF_INIT(ctx, &pref_color); + PREF_TABDATA(ctx) = calloc(sizeof(pref_color_t), 1); rnd_trace("INIT pref color tab %d\n", tab); } #undef PREF_INIT_FUNC Index: src_plugins/dialogs/dlg_pref_color.h =================================================================== --- src_plugins/dialogs/dlg_pref_color.h (revision 35845) +++ src_plugins/dialogs/dlg_pref_color.h (revision 35846) @@ -1,9 +1,4 @@ #ifndef PCB_DLG_PREF_COLOR_H #define PCB_DLG_PREF_COLOR_H -typedef struct { - int *wgen, *wlayer; - int ngen; -} pref_color_t; - #endif Index: src_plugins/dialogs/dlg_pref_general.h =================================================================== --- src_plugins/dialogs/dlg_pref_general.h (revision 35845) +++ src_plugins/dialogs/dlg_pref_general.h (revision 35846) @@ -1,9 +1,4 @@ #ifndef PCB_DLG_PREF_GENERAL_H #define PCB_DLG_PREF_GENERAL_H -typedef struct { - int dummy; -} pref_general_t; - - #endif Index: src_plugins/dialogs/dlg_pref_lib.c =================================================================== --- src_plugins/dialogs/dlg_pref_lib.c (revision 35845) +++ src_plugins/dialogs/dlg_pref_lib.c (revision 35846) @@ -32,6 +32,21 @@ #include "conf_core.h" #include +typedef struct pref_libhelp_ctx_s { + RND_DAD_DECL_NOINIT(dlg) + int active; /* already open - allow only one instance */ +} pref_libhelp_ctx_t; + +typedef struct { + int wlist, whsbutton, wmoveup, wmovedown, wedit, wremove; + int lock; /* a change in on the dialog box causes a change on the board but this shouldn't in turn casue a changein the dialog */ + char *cursor_path; + pref_libhelp_ctx_t help; +} pref_lib_t; + +#undef DEF_TABDATA +#define DEF_TABDATA pref_lib_t *tabdata = PREF_TABDATA(ctx) + static const char *SRC_BRD = ""; static void libhelp_btn(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr); @@ -38,14 +53,16 @@ static void pref_lib_update_buttons(void) { - rnd_hid_attribute_t *attr = &pref_ctx.dlg[pref_ctx.lib.wlist]; + pref_ctx_t *ctx = &pref_ctx; + DEF_TABDATA; + rnd_hid_attribute_t *attr = &ctx->dlg[tabdata->wlist]; rnd_hid_row_t *r = rnd_dad_tree_get_selected(attr); int en = (r != NULL); - rnd_gui->attr_dlg_widget_state(pref_ctx.dlg_hid_ctx, pref_ctx.lib.wedit, en); - rnd_gui->attr_dlg_widget_state(pref_ctx.dlg_hid_ctx, pref_ctx.lib.wremove, en); - rnd_gui->attr_dlg_widget_state(pref_ctx.dlg_hid_ctx, pref_ctx.lib.wmoveup, en); - rnd_gui->attr_dlg_widget_state(pref_ctx.dlg_hid_ctx, pref_ctx.lib.wmovedown, en); + rnd_gui->attr_dlg_widget_state(ctx->dlg_hid_ctx, tabdata->wedit, en); + rnd_gui->attr_dlg_widget_state(ctx->dlg_hid_ctx, tabdata->wremove, en); + rnd_gui->attr_dlg_widget_state(ctx->dlg_hid_ctx, tabdata->wmoveup, en); + rnd_gui->attr_dlg_widget_state(ctx->dlg_hid_ctx, tabdata->wmovedown, en); } static void pref_lib_select_cb(rnd_hid_attribute_t *attrib, void *hid_ctx, rnd_hid_row_t *row) @@ -65,20 +82,22 @@ the widget first */ static void pref_lib_conf2dlg_pre(rnd_conf_native_t *cfg, int arr_idx) { + pref_ctx_t *ctx = &pref_ctx; + DEF_TABDATA; rnd_hid_attribute_t *attr; rnd_hid_tree_t *tree; rnd_hid_row_t *r; - if ((pref_ctx.lib.lock) || (!pref_ctx.active)) + if ((tabdata->lock) || (!ctx->active)) return; - attr = &pref_ctx.dlg[pref_ctx.lib.wlist]; + attr = &ctx->dlg[tabdata->wlist]; tree = attr->wdata; r = rnd_dad_tree_get_selected(attr); if (r != NULL) { - free(pref_ctx.lib.cursor_path); - pref_ctx.lib.cursor_path = rnd_strdup(r->cell[0]); + free(tabdata->cursor_path); + tabdata->cursor_path = rnd_strdup(r->cell[0]); } /* remove all existing entries */ @@ -98,6 +117,8 @@ in all widget rows from the conf */ static void pref_lib_conf2dlg_post(rnd_conf_native_t *cfg, int arr_idx) { + pref_ctx_t *ctx = &pref_ctx; + DEF_TABDATA; rnd_conf_listitem_t *i; int idx; const char *s; @@ -105,10 +126,10 @@ rnd_hid_attribute_t *attr; rnd_hid_attr_val_t hv; - if ((pref_ctx.lib.lock) || (!pref_ctx.active)) + if ((tabdata->lock) || (!ctx->active)) return; - attr = &pref_ctx.dlg[pref_ctx.lib.wlist]; + attr = &ctx->dlg[tabdata->wlist]; /* copy everything from the config tree to the dialog */ rnd_conf_loop_list_str(&conf_core.rc.library_search_paths, i, s, idx) { @@ -121,10 +142,10 @@ rnd_dad_tree_append(attr, NULL, cell); } - hv.str = pref_ctx.lib.cursor_path; - if (rnd_gui->attr_dlg_set_value(pref_ctx.dlg_hid_ctx, pref_ctx.lib.wlist, &hv) == 0) { - free(pref_ctx.lib.cursor_path); - pref_ctx.lib.cursor_path = NULL; + hv.str = tabdata->cursor_path; + if (rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, tabdata->wlist, &hv) == 0) { + free(tabdata->cursor_path); + tabdata->cursor_path = NULL; } pref_lib_update_buttons(); } @@ -133,6 +154,7 @@ static void pref_lib_dlg2conf(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) { pref_ctx_t *ctx = caller_data; + DEF_TABDATA; rnd_hid_tree_t *tree = attr->wdata; lht_node_t *m, *lst, *nd; rnd_hid_row_t *r; @@ -142,7 +164,7 @@ if (m == NULL) return; - ctx->lib.lock++; + tabdata->lock++; /* get the list and clean it */ lst = lht_tree_path_(m->doc, m, "rc/library_search_paths", 1, 0, NULL); @@ -166,12 +188,14 @@ pref_dlg2conf_post(ctx); - ctx->lib.lock--; + tabdata->lock--; } static void lib_btn_remove(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *btn_attr) { - rnd_hid_attribute_t *attr = &pref_ctx.dlg[pref_ctx.lib.wlist]; + pref_ctx_t *ctx = caller_data; + DEF_TABDATA; + rnd_hid_attribute_t *attr = &ctx->dlg[tabdata->wlist]; rnd_hid_row_t *r = rnd_dad_tree_get_selected(attr); if (r == NULL) @@ -185,7 +209,9 @@ static void lib_btn_up(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *btn_attr) { - rnd_hid_attribute_t *attr = &pref_ctx.dlg[pref_ctx.lib.wlist]; + pref_ctx_t *ctx = caller_data; + DEF_TABDATA; + rnd_hid_attribute_t *attr = &ctx->dlg[tabdata->wlist]; rnd_hid_row_t *prev, *r = rnd_dad_tree_get_selected(attr); rnd_hid_tree_t *tree = attr->wdata; char *cell[4]; @@ -206,13 +232,15 @@ rnd_dad_tree_insert(attr, prev, cell); pref_lib_dlg2conf(hid_ctx, caller_data, attr); hv.str = cell[0]; - rnd_gui->attr_dlg_set_value(pref_ctx.dlg_hid_ctx, pref_ctx.lib.wlist, &hv); + rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, tabdata->wlist, &hv); } } static void lib_btn_down(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *btn_attr) { - rnd_hid_attribute_t *attr = &pref_ctx.dlg[pref_ctx.lib.wlist]; + pref_ctx_t *ctx = caller_data; + DEF_TABDATA; + rnd_hid_attribute_t *attr = &ctx->dlg[tabdata->wlist]; rnd_hid_row_t *next, *r = rnd_dad_tree_get_selected(attr); rnd_hid_tree_t *tree = attr->wdata; char *cell[4]; @@ -233,7 +261,7 @@ rnd_dad_tree_append(attr, next, cell); pref_lib_dlg2conf(hid_ctx, caller_data, attr); hv.str = cell[0]; - rnd_gui->attr_dlg_set_value(pref_ctx.dlg_hid_ctx, pref_ctx.lib.wlist, &hv); + rnd_gui->attr_dlg_set_value(ctx->dlg_hid_ctx, tabdata->wlist, &hv); } } @@ -299,7 +327,8 @@ static void lib_btn_insert(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *btn_attr, int pos) { pref_ctx_t *ctx = caller_data; - rnd_hid_attribute_t *attr = &pref_ctx.dlg[pref_ctx.lib.wlist]; + DEF_TABDATA; + rnd_hid_attribute_t *attr = &ctx->dlg[tabdata->wlist]; rnd_hid_row_t *r = rnd_dad_tree_get_selected(attr); char *cell[4]; @@ -372,8 +401,9 @@ void pcb_dlg_pref_lib_close(pref_ctx_t *ctx) { - if (ctx->lib.help.active) - RND_DAD_FREE(ctx->lib.help.dlg); + DEF_TABDATA; + if (tabdata->help.active) + RND_DAD_FREE(tabdata->help.dlg); } static void pref_libhelp_close_cb(void *caller_data, rnd_hid_attr_ev_t ev) @@ -415,11 +445,14 @@ static void libhelp_btn(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) { - pref_libhelp_open(&pref_ctx.lib.help); + pref_ctx_t *ctx = caller_data; + DEF_TABDATA; + pref_libhelp_open(&tabdata->help); } void pcb_dlg_pref_lib_create(pref_ctx_t *ctx) { + DEF_TABDATA; static const char *hdr[] = {"configured path", "actual path on the filesystem", "config source", NULL}; rnd_hid_tree_t *tree; @@ -431,8 +464,8 @@ RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_FRAME | RND_HATF_SCROLL | RND_HATF_EXPFILL); RND_DAD_TREE(ctx->dlg, 3, 0, hdr); RND_DAD_COMPFLAG(ctx->dlg, RND_HATF_EXPFILL); - ctx->lib.wlist = RND_DAD_CURRENT(ctx->dlg); - tree = ctx->dlg[ctx->lib.wlist].wdata; + tabdata->wlist = RND_DAD_CURRENT(ctx->dlg); + tree = ctx->dlg[tabdata->wlist].wdata; tree->user_free_cb = pref_lib_row_free; RND_DAD_TREE_SET_CB(ctx->dlg, selected_cb, pref_lib_select_cb); RND_DAD_END(ctx->dlg); @@ -440,10 +473,10 @@ RND_DAD_BEGIN_HBOX(ctx->dlg); RND_DAD_BUTTON(ctx->dlg, "Move up"); RND_DAD_CHANGE_CB(ctx->dlg, lib_btn_up); - ctx->lib.wmoveup = RND_DAD_CURRENT(ctx->dlg); + tabdata->wmoveup = RND_DAD_CURRENT(ctx->dlg); RND_DAD_BUTTON(ctx->dlg, "Move down"); RND_DAD_CHANGE_CB(ctx->dlg, lib_btn_down); - ctx->lib.wmovedown = RND_DAD_CURRENT(ctx->dlg); + tabdata->wmovedown = RND_DAD_CURRENT(ctx->dlg); RND_DAD_BUTTON(ctx->dlg, "Insert before"); RND_DAD_CHANGE_CB(ctx->dlg, lib_btn_insert_before); RND_DAD_BUTTON(ctx->dlg, "Insert after"); @@ -450,12 +483,12 @@ RND_DAD_CHANGE_CB(ctx->dlg, lib_btn_insert_after); RND_DAD_BUTTON(ctx->dlg, "Remove"); RND_DAD_CHANGE_CB(ctx->dlg, lib_btn_remove); - ctx->lib.wremove = RND_DAD_CURRENT(ctx->dlg); + tabdata->wremove = RND_DAD_CURRENT(ctx->dlg); RND_DAD_BUTTON(ctx->dlg, "Edit..."); RND_DAD_CHANGE_CB(ctx->dlg, lib_btn_edit); - ctx->lib.wedit = RND_DAD_CURRENT(ctx->dlg); + tabdata->wedit = RND_DAD_CURRENT(ctx->dlg); RND_DAD_BUTTON(ctx->dlg, "Help..."); - ctx->lib.whsbutton = RND_DAD_CURRENT(ctx->dlg); + tabdata->whsbutton = RND_DAD_CURRENT(ctx->dlg); RND_DAD_CHANGE_CB(ctx->dlg, libhelp_btn); RND_DAD_END(ctx->dlg); @@ -480,6 +513,8 @@ rnd_conf_native_t *cn = rnd_conf_get_field("rc/library_search_paths"); PREF_INIT(ctx, &pref_lib); + PREF_TABDATA(ctx) = calloc(sizeof(pref_lib_t), 1); + rnd_trace("INIT pref lib tab %d\n", tab); if (cn != NULL) { Index: src_plugins/dialogs/dlg_pref_lib.h =================================================================== --- src_plugins/dialogs/dlg_pref_lib.h (revision 35845) +++ src_plugins/dialogs/dlg_pref_lib.h (revision 35846) @@ -1,16 +1,4 @@ #ifndef PCB_DLG_PREF_LIB_H #define PCB_DLG_PREF_LIB_H -typedef struct pref_libhelp_ctx_s { - RND_DAD_DECL_NOINIT(dlg) - int active; /* already open - allow only one instance */ -} pref_libhelp_ctx_t; - -typedef struct { - int wlist, whsbutton, wmoveup, wmovedown, wedit, wremove; - int lock; /* a change in on the dialog box causes a change on the board but this shouldn't in turn casue a changein the dialog */ - char *cursor_path; - pref_libhelp_ctx_t help; -} pref_lib_t; - #endif Index: src_plugins/dialogs/dlg_pref_sizes.c =================================================================== --- src_plugins/dialogs/dlg_pref_sizes.c (revision 35845) +++ src_plugins/dialogs/dlg_pref_sizes.c (revision 35846) @@ -32,13 +32,24 @@ #include "conf_core.h" #include "drc.h" +typedef struct { + int wwidth, wheight; + int wisle; + int lock; /* a change in on the dialog box causes a change on the board but this shouldn't in turn casue a changein the dialog */ +} pref_sizes_t; + +#undef DEF_TABDATA +#define DEF_TABDATA pref_sizes_t *tabdata = PREF_TABDATA(ctx) + /* Actual board size to dialog box */ static void pref_sizes_brd2dlg(pref_ctx_t *ctx) { - if (ctx->sizes.lock) + DEF_TABDATA; + + if (tabdata->lock) return; - RND_DAD_SET_VALUE(ctx->dlg_hid_ctx, ctx->sizes.wwidth, crd, PCB->hidlib.size_x); - RND_DAD_SET_VALUE(ctx->dlg_hid_ctx, ctx->sizes.wheight, crd, PCB->hidlib.size_y); + RND_DAD_SET_VALUE(ctx->dlg_hid_ctx, tabdata->wwidth, crd, PCB->hidlib.size_x); + RND_DAD_SET_VALUE(ctx->dlg_hid_ctx, tabdata->wheight, crd, PCB->hidlib.size_y); } /* Dialog box to actual board size */ @@ -45,11 +56,12 @@ static void pref_sizes_dlg2brd(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) { pref_ctx_t *ctx = caller_data; + DEF_TABDATA; - ctx->sizes.lock++; - if ((PCB->hidlib.size_x != ctx->dlg[ctx->sizes.wwidth].val.crd) || (PCB->hidlib.size_y != ctx->dlg[ctx->sizes.wheight].val.crd)) - pcb_board_resize(ctx->dlg[ctx->sizes.wwidth].val.crd, ctx->dlg[ctx->sizes.wheight].val.crd, 0); - ctx->sizes.lock--; + tabdata->lock++; + if ((PCB->hidlib.size_x != ctx->dlg[tabdata->wwidth].val.crd) || (PCB->hidlib.size_y != ctx->dlg[tabdata->wheight].val.crd)) + pcb_board_resize(ctx->dlg[tabdata->wwidth].val.crd, ctx->dlg[tabdata->wheight].val.crd, 0); + tabdata->lock--; } static void drc_rules_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) @@ -78,19 +90,23 @@ static void pref_isle_brd2dlg(rnd_conf_native_t *cfg, int arr_idx) { - if ((pref_ctx.sizes.lock) || (!pref_ctx.active)) + pref_ctx_t *ctx = &pref_ctx; + DEF_TABDATA; + + if ((tabdata->lock) || (!ctx->active)) return; - RND_DAD_SET_VALUE(pref_ctx.dlg_hid_ctx, pref_ctx.sizes.wisle, dbl, conf_core.design.poly_isle_area / 1000000.0); + RND_DAD_SET_VALUE(ctx->dlg_hid_ctx, tabdata->wisle, dbl, conf_core.design.poly_isle_area / 1000000.0); } static void pref_isle_dlg2brd(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) { pref_ctx_t *ctx = caller_data; - double v = ctx->dlg[ctx->sizes.wisle].val.dbl * 1000000.0; + DEF_TABDATA; + double v = ctx->dlg[tabdata->wisle].val.dbl * 1000000.0; - ctx->sizes.lock++; + tabdata->lock++; rnd_conf_setf(ctx->role, "design/poly_isle_area", -1, "%f", v); - ctx->sizes.lock--; + tabdata->lock--; } void pcb_dlg_pref_sizes_close(pref_ctx_t *ctx) @@ -100,6 +116,7 @@ void pcb_dlg_pref_sizes_create(pref_ctx_t *ctx) { + DEF_TABDATA; pcb_drc_impl_t *di; int drcs; @@ -109,13 +126,13 @@ RND_DAD_BEGIN_HBOX(ctx->dlg); RND_DAD_LABEL(ctx->dlg, "Width="); RND_DAD_COORD(ctx->dlg); - ctx->sizes.wwidth = RND_DAD_CURRENT(ctx->dlg); + tabdata->wwidth = RND_DAD_CURRENT(ctx->dlg); RND_DAD_MINMAX(ctx->dlg, RND_MM_TO_COORD(1), RND_MAX_COORD); RND_DAD_DEFAULT_NUM(ctx->dlg, PCB->hidlib.size_x); RND_DAD_CHANGE_CB(ctx->dlg, pref_sizes_dlg2brd); RND_DAD_LABEL(ctx->dlg, "Height="); RND_DAD_COORD(ctx->dlg); - ctx->sizes.wheight = RND_DAD_CURRENT(ctx->dlg); + tabdata->wheight = RND_DAD_CURRENT(ctx->dlg); RND_DAD_MINMAX(ctx->dlg, RND_MM_TO_COORD(1), RND_MAX_COORD); RND_DAD_DEFAULT_NUM(ctx->dlg, PCB->hidlib.size_y); RND_DAD_CHANGE_CB(ctx->dlg, pref_sizes_dlg2brd); @@ -133,9 +150,9 @@ RND_DAD_BEGIN_TABLE(ctx->dlg, 2); RND_DAD_LABEL(ctx->dlg, "polygon isle minimum size\n[square um]"); RND_DAD_REAL(ctx->dlg); - ctx->sizes.wisle = RND_DAD_CURRENT(ctx->dlg); + tabdata->wisle = RND_DAD_CURRENT(ctx->dlg); RND_DAD_MINMAX(ctx->dlg, 0, RND_MAX_COORD); - ctx->dlg[ctx->sizes.wisle].val.dbl = (conf_core.design.poly_isle_area / 1000000.0); + ctx->dlg[tabdata->wisle].val.dbl = (conf_core.design.poly_isle_area / 1000000.0); RND_DAD_CHANGE_CB(ctx->dlg, pref_isle_dlg2brd); RND_DAD_END(ctx->dlg); @@ -170,6 +187,8 @@ rnd_conf_native_t *cn = rnd_conf_get_field("design/poly_isle_area"); PREF_INIT(ctx, &pref_sizes); + PREF_TABDATA(ctx) = calloc(sizeof(pref_sizes_t), 1); + rnd_trace("INIT pref sizes tab %d\n", tab); if (cn != NULL) { Index: src_plugins/dialogs/dlg_pref_sizes.h =================================================================== --- src_plugins/dialogs/dlg_pref_sizes.h (revision 35845) +++ src_plugins/dialogs/dlg_pref_sizes.h (revision 35846) @@ -1,11 +1,6 @@ #ifndef PCB_DLG_PREF_SIZES_H #define PCB_DLG_PREF_SIZES_H -typedef struct { - int wwidth, wheight; - int wisle; - int lock; /* a change in on the dialog box causes a change on the board but this shouldn't in turn casue a changein the dialog */ -} pref_sizes_t; #endif