summaryrefslogtreecommitdiff
path: root/test/editor.cxx
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2024-02-06 20:27:18 +0100
committerGitHub <noreply@github.com>2024-02-06 20:27:18 +0100
commit6d98c6a8b120e00670336b9857e19d10591969eb (patch)
tree465e1c7353f1d4cc94be081169d391a10eb8d66b /test/editor.cxx
parenta651c89c8540eddfe0351599a5b3b930fc08cdf5 (diff)
Restore 3-way close window dialog (#900)
Diffstat (limited to 'test/editor.cxx')
-rw-r--r--test/editor.cxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/editor.cxx b/test/editor.cxx
index 5e5eba3b6..6b6d51c50 100644
--- a/test/editor.cxx
+++ b/test/editor.cxx
@@ -52,6 +52,7 @@ int main (int argc, char **argv) {
Fl_Menu_Bar *app_menu_bar = NULL;
bool text_changed = false;
+#if TUTORIAL_CHAPTER < 4
void menu_quit_callback(Fl_Widget *, void *) {
if (text_changed) {
int c = fl_choice("Changes in your text have not been saved.\n"
@@ -61,6 +62,9 @@ void menu_quit_callback(Fl_Widget *, void *) {
}
Fl::hide_all_windows();
}
+#else
+void menu_quit_callback(Fl_Widget *, void *);
+#endif
void tut2_build_app_menu_bar() {
app_window->begin();
@@ -184,6 +188,21 @@ void menu_save_callback(Fl_Widget*, void*) {
}
}
+void menu_quit_callback(Fl_Widget *, void *) {
+ if (text_changed) {
+ int r = fl_choice("The current file has not been saved.\n"
+ "Would you like to save it now?",
+ "Cancel", "Save", "Don't Save");
+ if (r == 0) // cancel
+ return;
+ if (r == 1) { // save
+ menu_save_callback(NULL, NULL);
+ return;
+ }
+ }
+ Fl::hide_all_windows();
+}
+
void load(const char *filename) {
if (app_text_buffer->loadfile(filename) == 0) {
strncpy(app_filename, filename, FL_PATH_MAX-1);