Index: dlg_export_pcb.c =================================================================== --- dlg_export_pcb.c (revision 36310) +++ dlg_export_pcb.c (nonexistent) @@ -1,56 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 2018,2022 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") - */ - -#include "config.h" -#include -#include "board.h" -#include "data.h" -#include "layer_vis.h" -#include "event.h" - -static int have_gui, currly; -static int save_l_ons[PCB_MAX_LAYER], save_g_ons[PCB_MAX_LAYERGRP]; - -static void export_sess_pre(void) -{ - currly = PCB_CURRLID(PCB); - have_gui = (rnd_gui != NULL) && rnd_gui->gui; - if (have_gui) { - pcb_hid_save_and_show_layer_ons(save_l_ons); - pcb_hid_save_and_show_layergrp_ons(save_g_ons); - } -} - -static void export_sess_post(void) -{ - if (have_gui) { - pcb_hid_restore_layer_ons(save_l_ons); - pcb_hid_restore_layergrp_ons(save_g_ons); - pcb_layervis_change_group_vis(&PCB->hidlib, currly, 1, 1); - rnd_event(&PCB->hidlib, PCB_EVENT_LAYERVIS_CHANGED, NULL); - } -} - Index: Plug.tmpasm =================================================================== --- Plug.tmpasm (revision 36310) +++ Plug.tmpasm (revision 36311) @@ -14,6 +14,7 @@ $(PLUGDIR)/dialogs/dlg_padstack.o $(PLUGDIR)/dialogs/dlg_pref_apptab.o $(PLUGDIR)/dialogs/dlg_view.o + $(PLUGDIR)/dialogs/pcb_export.o @] put /local/pcb/mod/CONFFILE {adialogs.conf} Index: dialogs.c =================================================================== --- dialogs.c (revision 36310) +++ dialogs.c (revision 36311) @@ -53,6 +53,7 @@ #include "dlg_library.h" #include "dlg_loadsave.h" #include "dlg_padstack.h" +#include "pcb_export.h" #include "dlg_pinout.c" #include "dlg_undo.c" #include "dlg_fpmap.c" @@ -100,6 +101,7 @@ void pplg_uninit_dialogs(void) { + pcb_export_uninit(); pcb_dlg_library_uninit(); pcb_dlg_netlist_uninit(); pcb_dlg_undo_uninit(); @@ -134,6 +136,7 @@ pcb_view_dlg_init(); pcb_dlg_fontsel_init(); pcb_dlg_library_init(); + pcb_export_init(); return 0; } Index: dlg_export.c =================================================================== --- dlg_export.c (revision 36310) +++ dlg_export.c (revision 36311) @@ -65,9 +65,6 @@ return r; } -static void export_sess_pre(void); -static void export_sess_post(void); - static void export_cb(void *hid_ctx, void *caller_data, rnd_hid_attribute_t *attr) { export_ctx_t *export_ctx = caller_data; @@ -74,7 +71,6 @@ rnd_hidlib_t *hl = rnd_gui->get_dad_hidlib(hid_ctx); int h, wid; - export_sess_pre(); wid = attr - export_ctx->dlg; for(h = 0; h < export_ctx->len; h++) { @@ -91,8 +87,6 @@ rnd_message(RND_MSG_ERROR, "Internal error: can not find which exporter to call\n"); done:; - - export_sess_post(); } /* copy back the attribute values from the DAD dialog to exporter dialog so @@ -264,4 +258,3 @@ return 0; } -#include "dlg_export_pcb.c" Index: pcb_export.c =================================================================== --- pcb_export.c (nonexistent) +++ pcb_export.c (revision 36311) @@ -0,0 +1,70 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 2018,2022 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") + */ + +#include "config.h" +#include +#include "board.h" +#include "data.h" +#include "layer_vis.h" +#include "event.h" + +#include "pcb_export.h" + +static const char pcb_export_cookie[] = "dialogs/pcb_export.c"; + +static int have_gui, currly; +static int save_l_ons[PCB_MAX_LAYER], save_g_ons[PCB_MAX_LAYERGRP]; + +static void pcb_export_begin_ev(rnd_hidlib_t *hidlib, void *user_data, int argc, rnd_event_arg_t argv[]) +{ + currly = PCB_CURRLID(PCB); + have_gui = (rnd_gui != NULL) && rnd_gui->gui; + if (have_gui) { + pcb_hid_save_and_show_layer_ons(save_l_ons); + pcb_hid_save_and_show_layergrp_ons(save_g_ons); + } +} + +static void pcb_export_end_ev(rnd_hidlib_t *hidlib, void *user_data, int argc, rnd_event_arg_t argv[]) +{ + if (have_gui) { + pcb_hid_restore_layer_ons(save_l_ons); + pcb_hid_restore_layergrp_ons(save_g_ons); + pcb_layervis_change_group_vis(&PCB->hidlib, currly, 1, 1); + rnd_event(&PCB->hidlib, PCB_EVENT_LAYERVIS_CHANGED, NULL); + } +} + +void pcb_export_uninit(void) +{ + rnd_event_unbind_allcookie(pcb_export_cookie); +} + +void pcb_export_init(void) +{ + rnd_event_bind(RND_EVENT_EXPORT_SESSION_BEGIN, pcb_export_begin_ev, NULL, pcb_export_cookie); + rnd_event_bind(RND_EVENT_EXPORT_SESSION_END, pcb_export_end_ev, NULL, pcb_export_cookie); +} Index: pcb_export.h =================================================================== --- pcb_export.h (nonexistent) +++ pcb_export.h (revision 36311) @@ -0,0 +1,2 @@ +void pcb_export_uninit(void); +void pcb_export_init(void);