Index: trunk/src/sch-rnd/Makefile.in =================================================================== --- trunk/src/sch-rnd/Makefile.in (revision 1450) +++ trunk/src/sch-rnd/Makefile.in (revision 1451) @@ -16,6 +16,7 @@ build_run.o main_act.o style.o + file_act.o @] Index: trunk/src/sch-rnd/build_run.c =================================================================== --- trunk/src/sch-rnd/build_run.c (revision 1450) +++ trunk/src/sch-rnd/build_run.c (revision 1451) @@ -44,9 +44,9 @@ /* save data if necessary. It not needed, then don't trigger EmergencySave * via our atexit() registering of csch_emergency_save(). We presumably wanted to * exit here and thus it is not an emergency. */ -TODO("implemnent this:"); +TODO("implemnent this, but for multiple sheets:"); #if 0 - if (PCB->Changed && conf_core.editor.save_in_tmp) + if (sheet->changed && conf_core.editor.save_in_tmp) csch_emergency_save(); else csch_disable_emergency_save(); Index: trunk/src/sch-rnd/file_act.c =================================================================== --- trunk/src/sch-rnd/file_act.c (nonexistent) +++ trunk/src/sch-rnd/file_act.c (revision 1451) @@ -0,0 +1,63 @@ +/* + * COPYRIGHT + * + * cschem - modular/flexible schematics editor - sch-rnd (executable) + * Copyright (C) 2022 Tibor 'Igor2' Palinkas + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version.* + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; 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/cschem + * lead developer: email to cschem (at) igor2.repo.hu + * mailing list: cschem (at) list.repo.hu (send "subscribe") + */ + +/* Generic actions usually related to the currently open file(s) */ + +#include +#include +#include +#include + +#include "build_run.h" + + +static const char csch_acts_Quit[] = "Quit()"; +static const char csch_acth_Quit[] = "Quits sch-rnd after confirming."; +static fgw_error_t csch_act_Quit(fgw_arg_t *res, int argc, fgw_arg_t *argv) +{ + csch_sheet_t *sheet = CSCH_ACT_SHEET; + const char *force = NULL; + RND_ACT_MAY_CONVARG(1, FGW_STR, Quit, force = argv[1].val.str); + + if ((force != NULL) && (rnd_strcasecmp(force, "force") == 0)) + exit(0); + +TODO("need to check all sheets, not just the current one") + if (!sheet->changed || (rnd_hid_message_box(RND_ACT_HIDLIB, "warning", "Close: lose data", "Exiting sch-rnd will lose unsaved sheet modifications.", "cancel", 0, "ok", 1, NULL) == 1)) + csch_quit_app(); + + RND_ACT_IRES(-1); + return 0; +} + +static rnd_action_t file_action_list[] = { + {"Quit", csch_act_Quit, csch_acth_Quit, csch_acts_Quit} +}; + +void sch_rnd_file_act_init2(void) +{ + RND_REGISTER_ACTIONS(file_action_list, NULL); +} Index: trunk/src/sch-rnd/sch-rnd.c =================================================================== --- trunk/src/sch-rnd/sch-rnd.c (revision 1450) +++ trunk/src/sch-rnd/sch-rnd.c (revision 1451) @@ -154,6 +154,8 @@ } extern void csch_main_act_init2(void); +extern void sch_rnd_file_act_init2(void); + /*extern void rnd_main_act_init2(void);*/ static void sch_rnd_main_init(void) @@ -160,6 +162,7 @@ { csch_init_actions(); csch_main_act_init2(); + sch_rnd_file_act_init2(); /* rnd_main_act_init2();*/ }