Index: scconfig/Rev.h =================================================================== --- scconfig/Rev.h (revision 35848) +++ scconfig/Rev.h (revision 35849) @@ -1 +1 @@ -static const int myrev = 35621; +static const int myrev = 35849; Index: scconfig/Rev.tab =================================================================== --- scconfig/Rev.tab (revision 35848) +++ scconfig/Rev.tab (revision 35849) @@ -1,3 +1,4 @@ +35849 configure preferences dialog generalization 35621 configure ar_extern: new module for freerouting.cli 35240 configure io_dsn: merge import_dsn (as ses import) and export_dsn 35181 configure io_dsn: padstack proto hash Index: src_plugins/dialogs/Plug.tmpasm =================================================================== --- src_plugins/dialogs/Plug.tmpasm (revision 35848) +++ src_plugins/dialogs/Plug.tmpasm (revision 35849) @@ -13,6 +13,7 @@ $(PLUGDIR)/dialogs/dlg_loadsave.o $(PLUGDIR)/dialogs/dlg_padstack.o $(PLUGDIR)/dialogs/dlg_pref.o + $(PLUGDIR)/dialogs/dlg_pref_apptab.o $(PLUGDIR)/dialogs/dlg_view.o @] Index: src_plugins/dialogs/dialogs.c =================================================================== --- src_plugins/dialogs/dialogs.c (revision 35848) +++ src_plugins/dialogs/dialogs.c (revision 35849) @@ -120,6 +120,9 @@ rnd_conf_unreg_fields("plugins/dialogs/"); } +extern int pcb_dlg_pref_tab; +extern void (*pcb_dlg_pref_first_init)(pref_ctx_t *ctx, int tab); + int pplg_init_dialogs(void) { RND_API_CHK_VER; @@ -131,7 +134,7 @@ rnd_conf_reg_intern(adialogs_conf_internal); RND_REGISTER_ACTIONS(dialogs_action_list, dialogs_cookie) - pcb_dlg_pref_init(); + pcb_dlg_pref_init(pcb_dlg_pref_tab, pcb_dlg_pref_first_init); pcb_dlg_pstklib_init(); pcb_dlg_undo_init(); pcb_dlg_netlist_init(); Index: src_plugins/dialogs/dlg_pref.c =================================================================== --- src_plugins/dialogs/dlg_pref.c (revision 35848) +++ src_plugins/dialogs/dlg_pref.c (revision 35849) @@ -48,47 +48,9 @@ static const char *bi_pref_tabs[] = { "Window", "Key", "Menu", "Config tree", NULL }; static const int bi_pref_tab_cfgs[] = { 1, 0, 0, 0 }; -static lht_node_t *pref_dlg2conf_pre(pref_ctx_t *ctx); -static void pref_dlg2conf_post(pref_ctx_t *ctx); - void Rnd_pref_init_func_dummy(pref_ctx_t *ctx, int tab) { } -#define PREF_INIT_FUNC Rnd_pref_init_func_dummy - -#define PREF_INIT(ctx, hooks_) \ - do { \ - ctx->tab[PREF_TAB].hooks = hooks_; \ - 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 -#include "dlg_pref_general.c" - -#undef PREF_TAB -#define PREF_TAB 1 -#include "dlg_pref_board.c" - -#undef PREF_TAB -#define PREF_TAB 2 -#include "dlg_pref_sizes.c" - -#undef PREF_TAB -#define PREF_TAB 3 -#include "dlg_pref_lib.c" - -#undef PREF_TAB -#define PREF_TAB 4 -#include "dlg_pref_layer.c" - -#undef PREF_TAB -#define PREF_TAB 5 -#include "dlg_pref_color.c" - /* built-in tabs */ #include "dlg_pref_win.c" #include "dlg_pref_key.c" @@ -115,7 +77,7 @@ return &pref_ctx; } -static lht_node_t *pref_dlg2conf_pre(pref_ctx_t *ctx) +lht_node_t *Rnd_pref_dlg2conf_pre(pref_ctx_t *ctx) { lht_node_t *m; @@ -147,7 +109,7 @@ return m; } -static void pref_dlg2conf_post(pref_ctx_t *ctx) +void Rnd_pref_dlg2conf_post(pref_ctx_t *ctx) { if ((ctx->role == RND_CFR_USER) || (ctx->role == RND_CFR_PROJECT)) rnd_conf_save_file(&PCB->hidlib, NULL, (PCB == NULL ? NULL : PCB->hidlib.filename), ctx->role, NULL); @@ -487,7 +449,7 @@ } static rnd_conf_hid_callbacks_t pref_conf_cb; -void pcb_dlg_pref_init(void) +void pcb_dlg_pref_init(int pref_tab, void (*first_init)(pref_ctx_t *ctx, int tab)) { int i, t; @@ -496,8 +458,10 @@ rnd_event_bind(RND_EVENT_BOARD_META_CHANGED, pref_ev_board_meta_changed, &pref_ctx, pref_cookie); rnd_event_bind(RND_EVENT_MENU_CHANGED, pref_ev_menu_changed, &pref_ctx, pref_cookie); pref_hid = rnd_conf_hid_reg(pref_cookie, &pref_conf_cb); - PREF_INIT_FUNC(&pref_ctx, PREF_TAB); - pref_ctx.tabs = PREF_TAB+1; + if (first_init != NULL) { + first_init(&pref_ctx, pref_tab); + pref_ctx.tabs = pref_tab+1; + } for(t = 0; t < pref_ctx.tabs; t++) { pref_tabs[t] = pref_ctx.tab[t].hooks->tab_label; Index: src_plugins/dialogs/dlg_pref.h =================================================================== --- src_plugins/dialogs/dlg_pref.h (revision 35848) +++ src_plugins/dialogs/dlg_pref.h (revision 35849) @@ -5,6 +5,7 @@ #include #include +#include #include "dlg_pref_win.h" #include "dlg_pref_key.h" #include "dlg_pref_menu.h" @@ -85,7 +86,7 @@ extern rnd_conf_hid_id_t pref_hid; /*** pulbic API for the caller ***/ -void pcb_dlg_pref_init(void); +void pcb_dlg_pref_init(int pref_tab, void (*first_init)(pref_ctx_t *ctx, int tab)); void pcb_dlg_pref_uninit(void); extern const char pcb_acts_Preferences[]; @@ -92,8 +93,24 @@ extern const char pcb_acth_Preferences[]; fgw_error_t pcb_act_Preferences(fgw_arg_t *res, int argc, fgw_arg_t *argv); +lht_node_t *Rnd_pref_dlg2conf_pre(pref_ctx_t *ctx); +void Rnd_pref_dlg2conf_post(pref_ctx_t *ctx); + +void Rnd_pref_init_func_dummy(pref_ctx_t *ctx, int tab); + + /* In event callbacks no context is available; return context baed on hidlib */ pref_ctx_t *Rnd_pref_get_ctx(rnd_hidlib_t *hidlib); +#define PREF_INIT_FUNC Rnd_pref_init_func_dummy +#define PREF_INIT(ctx, hooks_) \ + do { \ + ctx->tab[PREF_TAB].hooks = hooks_; \ + PREF_INIT_FUNC(ctx, PREF_TAB-1); \ + } while(0) + +#define PREF_TABDATA(ctx) (ctx->tab[PREF_TAB].tabdata) + + #endif Index: src_plugins/dialogs/dlg_pref_apptab.c =================================================================== --- src_plugins/dialogs/dlg_pref_apptab.c (nonexistent) +++ src_plugins/dialogs/dlg_pref_apptab.c (revision 35849) @@ -0,0 +1,60 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 2021 Tibor 'Igor2' Palinkas + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + */ + +/* The preferences dialog, application specific tabs */ + +#include "config.h" + +#include "dlg_pref.h" + +/* application tabs */ +#undef PREF_TAB +#define PREF_TAB 0 +#include "dlg_pref_general.c" + +#undef PREF_TAB +#define PREF_TAB 1 +#include "dlg_pref_board.c" + +#undef PREF_TAB +#define PREF_TAB 2 +#include "dlg_pref_sizes.c" + +#undef PREF_TAB +#define PREF_TAB 3 +#include "dlg_pref_lib.c" + +#undef PREF_TAB +#define PREF_TAB 4 +#include "dlg_pref_layer.c" + +#undef PREF_TAB +#define PREF_TAB 5 +#include "dlg_pref_color.c" + +int pcb_dlg_pref_tab = PREF_TAB; +void (*pcb_dlg_pref_first_init)(pref_ctx_t *ctx, int tab) = PREF_INIT_FUNC; + Index: src_plugins/dialogs/dlg_pref_board.c =================================================================== --- src_plugins/dialogs/dlg_pref_board.c (revision 35848) +++ src_plugins/dialogs/dlg_pref_board.c (revision 35849) @@ -28,7 +28,9 @@ #include "dlg_pref.h" #include +#include #include "board.h" +#include "event.h" #include "conf_core.h" typedef struct { Index: src_plugins/dialogs/dlg_pref_color.c =================================================================== --- src_plugins/dialogs/dlg_pref_color.c (revision 35848) +++ src_plugins/dialogs/dlg_pref_color.c (revision 35849) @@ -84,12 +84,12 @@ pref_ctx_t *ctx = caller_data; const char *path = attr->user_data; - if (pref_dlg2conf_pre(ctx) == NULL) + if (Rnd_pref_dlg2conf_pre(ctx) == NULL) return; rnd_conf_setf(ctx->role, path, -1, "%s", attr->val.clr.str); - pref_dlg2conf_post(ctx); + Rnd_pref_dlg2conf_post(ctx); rnd_gui->invalidate_all(rnd_gui); } @@ -100,12 +100,12 @@ DEF_TABDATA; int idx = (int *)attr->user_data - tabdata->wlayer; - if (pref_dlg2conf_pre(ctx) == NULL) + if (Rnd_pref_dlg2conf_pre(ctx) == NULL) return; rnd_conf_setf(ctx->role, "appearance/color/layer", idx, "%s", attr->val.clr.str); - pref_dlg2conf_post(ctx); + Rnd_pref_dlg2conf_post(ctx); } Index: src_plugins/dialogs/dlg_pref_confedit.c =================================================================== --- src_plugins/dialogs/dlg_pref_confedit.c (revision 35848) +++ src_plugins/dialogs/dlg_pref_confedit.c (revision 35849) @@ -28,6 +28,9 @@ #include +TODO("This should be removed before the librnd move") +#include "board.h" + #define is_read_only(ctx) rnd_conf_is_read_only(ctx->role) typedef struct { Index: src_plugins/dialogs/dlg_pref_general.c =================================================================== --- src_plugins/dialogs/dlg_pref_general.c (revision 35848) +++ src_plugins/dialogs/dlg_pref_general.c (revision 35849) @@ -48,7 +48,7 @@ { pref_ctx_t *ctx = caller_data; - if (pref_dlg2conf_pre(ctx) == NULL) + if (Rnd_pref_dlg2conf_pre(ctx) == NULL) return; pcb_pref_dlg2conf_table(ctx, perf_topwin, attr); @@ -55,7 +55,7 @@ pcb_pref_dlg2conf_table(ctx, perf_backup, attr); pcb_pref_dlg2conf_table(ctx, perf_cli, attr); - pref_dlg2conf_post(ctx); + Rnd_pref_dlg2conf_post(ctx); } void pcb_dlg_pref_general_close(pref_ctx_t *ctx) Index: src_plugins/dialogs/dlg_pref_key.c =================================================================== --- src_plugins/dialogs/dlg_pref_key.c (revision 35848) +++ src_plugins/dialogs/dlg_pref_key.c (revision 35849) @@ -31,6 +31,7 @@ #include "conf_core.h" #include #include +#include static void pref_key_brd2dlg(pref_ctx_t *ctx) { @@ -85,7 +86,7 @@ save = ctx->role; ctx->role = RND_CFR_USER; - m = pref_dlg2conf_pre(ctx); + m = Rnd_pref_dlg2conf_pre(ctx); if (m == NULL) { ctx->role = save; return NULL; @@ -116,7 +117,7 @@ rnd_conf_update("editor/translate_key", -1); rnd_conf_makedirty(ctx->role); /* low level lht_dom_node_alloc() wouldn't make user config to be saved! */ - pref_dlg2conf_post(ctx); + Rnd_pref_dlg2conf_post(ctx); ctx->role = save; ctx->key.lock--; Index: src_plugins/dialogs/dlg_pref_lib.c =================================================================== --- src_plugins/dialogs/dlg_pref_lib.c (revision 35848) +++ src_plugins/dialogs/dlg_pref_lib.c (revision 35849) @@ -31,6 +31,7 @@ #include #include "conf_core.h" #include +#include typedef struct pref_libhelp_ctx_s { RND_DAD_DECL_NOINIT(dlg) @@ -160,7 +161,7 @@ rnd_hid_row_t *r; - m = pref_dlg2conf_pre(ctx); + m = Rnd_pref_dlg2conf_pre(ctx); if (m == NULL) return; @@ -186,7 +187,7 @@ rnd_conf_update("rc/library_search_paths", -1); rnd_conf_makedirty(ctx->role); /* low level lht_dom_node_alloc() wouldn't make user config to be saved! */ - pref_dlg2conf_post(ctx); + Rnd_pref_dlg2conf_post(ctx); tabdata->lock--; } Index: src_plugins/dialogs/dlg_pref_sizes.c =================================================================== --- src_plugins/dialogs/dlg_pref_sizes.c (revision 35848) +++ src_plugins/dialogs/dlg_pref_sizes.c (revision 35849) @@ -80,12 +80,12 @@ { pref_ctx_t *ctx = caller_data; - if (pref_dlg2conf_pre(ctx) == NULL) + if (Rnd_pref_dlg2conf_pre(ctx) == NULL) return; pcb_pref_dlg2conf_table(ctx, limit_sizes, attr); - pref_dlg2conf_post(ctx); + Rnd_pref_dlg2conf_post(ctx); } static void pref_isle_brd2dlg(rnd_conf_native_t *cfg, int arr_idx) Index: src_plugins/dialogs/dlg_pref_win.c =================================================================== --- src_plugins/dialogs/dlg_pref_win.c (revision 35848) +++ src_plugins/dialogs/dlg_pref_win.c (revision 35849) @@ -70,12 +70,12 @@ { pref_ctx_t *ctx = caller_data; - if (pref_dlg2conf_pre(ctx) == NULL) + if (Rnd_pref_dlg2conf_pre(ctx) == NULL) return; rnd_conf_setf(ctx->role, "plugins/dialogs/auto_save_window_geometry/to_project", -1, "%d", attr->val.lng); - pref_dlg2conf_post(ctx); + Rnd_pref_dlg2conf_post(ctx); pref_win_brd2dlg(ctx); }