diff options
| -rw-r--r-- | test/editor.cxx | 19 |
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); |
