]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/matita/matitaGui.ml
fixed save/exit stuff
[helm.git] / helm / matita / matitaGui.ml
index dc81593c54cddffc035aa0c30bc81e951e8e5d36..fa6059d1ea0eebb8139ac900f86e767074daeacd 100644 (file)
@@ -251,17 +251,21 @@ class gui () =
       in
         (* quit *)
       self#setQuitCallback (fun () -> 
-        if 
-          MatitaGtkMisc.ask_confirmation 
-            ~parent:main#toplevel
-            ~title:"Unsaved work!" 
-            ~message:("Your work is <b>unsaved</b>!\n\n"^
-                 "<i>Do you want to save the script before exiting?</i>")
-            ()
-        then 
-          (saveScript ();prerr_endline "SAVE";GMain.Main.quit ())
-        else
-          GMain.Main.quit ());
+        if source_view#buffer#modified then
+          begin
+            let rc =  
+              MatitaGtkMisc.ask_confirmation 
+                ~parent:main#toplevel
+                ~title:"Unsaved work!" 
+                ~message:("Your work is <b>unsaved</b>!\n\n"^
+                     "<i>Do you want to save the script before exiting?</i>")
+                ()
+            in
+            match rc with
+            | `YES -> saveScript ();GMain.Main.quit ()
+            | `NO -> GMain.Main.quit ()
+            | `CANCEL -> ()
+          end else GMain.Main.quit ());
       connect_button self#main#scriptAdvanceButton advance;
       connect_button self#main#scriptRetractButton retract;
       connect_button self#main#scriptTopButton top;