]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/matita/matitaGui.ml
name specifications added for elim_intros, elim_intros_simpl and elim_type
[helm.git] / helm / matita / matitaGui.ml
index cdbfc799a054f28e1743e1e941507e240949d22e..5ac24f8f66c9abdd262e6f477dd368188edc01e9 100644 (file)
@@ -156,8 +156,8 @@ class gui () =
       connect_button tbar#introsButton (tac (A.Intros (loc, None, [])));
       connect_button tbar#applyButton (tac_w_term (A.Apply (loc, hole)));
       connect_button tbar#exactButton (tac_w_term (A.Exact (loc, hole)));
-      connect_button tbar#elimButton (tac_w_term (A.Elim (loc, hole, None)));
-      connect_button tbar#elimTypeButton (tac_w_term (A.ElimType (loc, hole)));
+      connect_button tbar#elimButton (tac_w_term (A.Elim (loc, hole, None, None, [])));
+      connect_button tbar#elimTypeButton (tac_w_term (A.ElimType (loc, hole, None, None, [])));
       connect_button tbar#splitButton (tac (A.Split loc));
       connect_button tbar#leftButton (tac (A.Left loc));
       connect_button tbar#rightButton (tac (A.Right loc));
@@ -167,8 +167,8 @@ class gui () =
       connect_button tbar#transitivityButton
         (tac_w_term (A.Transitivity (loc, hole)));
       connect_button tbar#assumptionButton (tac (A.Assumption loc));
-      connect_button tbar#cutButton (tac_w_term (A.Cut (loc, hole)));
-      connect_button tbar#autoButton (tac (A.Auto (loc,None)));
+      connect_button tbar#cutButton (tac_w_term (A.Cut (loc, None, hole)));
+      connect_button tbar#autoButton (tac (A.Auto (loc,None,None)));
       MatitaGtkMisc.toggle_widget_visibility
        ~widget:(self#main#tacticsButtonsHandlebox :> GObj.widget)
        ~check:self#main#tacticsBarMenuItem;
@@ -183,14 +183,10 @@ class gui () =
           | false -> self#main#toplevel#unfullscreen ())
         ~check:self#main#fullscreenMenuItem;
       self#main#fullscreenMenuItem#set_active false;
-        (* quit *)
-      self#setQuitCallback (fun () -> exit 0);
         (* log *)
       MatitaLog.set_log_callback self#console#log_callback;
       GtkSignal.user_handler :=
-        (fun exn ->
-           MatitaLog.error
-             (sprintf "Uncaught exception: %s" (Printexc.to_string exn)));
+        (fun exn -> MatitaLog.error (MatitaExcPp.to_string exn));
         (* script *)
       let _ =
         match GSourceView.source_language_from_file BuildTimeConf.lang_file with
@@ -211,7 +207,8 @@ class gui () =
         match self#chooseFile () with
         | Some f -> 
               script#reset (); 
-              script#loadFrom f; 
+              script#assignFileName f;
+              script#loadFromFile (); 
               console#message ("'"^f^"' loaded.\n");
               self#_enableSaveTo f
         | None -> ()
@@ -220,7 +217,8 @@ class gui () =
         let script = s () in
         match self#chooseFile ~ok_not_exists:true () with
         | Some f -> 
-              script#saveTo f; 
+              script#assignFileName f;
+              script#saveToFile (); 
               console#message ("'"^f^"' saved.\n");
               self#_enableSaveTo f
         | None -> ()
@@ -229,7 +227,8 @@ class gui () =
         match script_fname with
         | None -> saveAsScript ()
         | Some f -> 
-              (s ())#saveTo f;
+              (s ())#assignFileName f;
+              (s ())#saveToFile ();
               console#message ("'"^f^"' saved.\n");
       in
       let newScript () = (s ())#reset (); disableSave () in
@@ -248,6 +247,25 @@ class gui () =
         connect_key self#sourceView#event
           ~modifiers:[`CONTROL] ~stop:true sym f
       in
+        (* quit *)
+      self#setQuitCallback (fun () -> 
+        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 ();
+                      if not source_view#buffer#modified then
+                        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;
@@ -293,9 +311,17 @@ class gui () =
     method loadScript file =       
       let script = MatitaScript.instance () in
       script#reset (); 
-      script#loadFrom file; 
+      script#assignFileName file;
+      script#loadFromFile (); 
       console#message ("'"^file^"' loaded.");
       self#_enableSaveTo file
+      
+    method setStar name b =
+      let l = main#scriptLabel in
+      if b then
+        l#set_text (name ^  " *")
+      else
+        l#set_text (name)
         
     method private _enableSaveTo file =
       script_fname <- Some file;
@@ -345,8 +371,9 @@ class gui () =
         keyBindingBoxes
 
     method setQuitCallback callback =
-      ignore (main#toplevel#connect#destroy callback);
       ignore (main#quitMenuItem#connect#activate callback);
+      ignore (main#toplevel#event#connect#delete 
+        (fun _ -> callback ();true));
       self#addKeyBinding GdkKeysyms._q callback
 
     method chooseFile ?(ok_not_exists = false) () =
@@ -401,11 +428,6 @@ let instance = singleton gui
 
 let non p x = not (p x)
 
-let is_var_uri s =
-  try
-    String.sub s (String.length s - 4) 4 = ".var"
-  with Invalid_argument _ -> false
-
 (* this is a shit and should be changed :-{ *)
 let interactive_uri_choice
   ?(selection_mode:[`SINGLE|`MULTIPLE] = `MULTIPLE) ?(title = "")
@@ -415,7 +437,7 @@ let interactive_uri_choice
   ~id uris
 =
   let gui = instance () in
-  let nonvars_uris = lazy (List.filter (non is_var_uri) uris) in
+  let nonvars_uris = lazy (List.filter (non UriManager.uri_is_var) uris) in
   if (selection_mode <> `SINGLE) &&
     (Helm_registry.get_bool "matita.auto_disambiguation")
   then
@@ -446,7 +468,7 @@ let interactive_uri_choice
           | _ -> ()));
     dialog#uriChoiceDialog#set_title title;
     dialog#uriChoiceLabel#set_text msg;
-    List.iter model#easy_append uris;
+    List.iter model#easy_append (List.map UriManager.string_of_uri uris);
     dialog#uriChoiceConstantsButton#misc#set_sensitive nonvars_button;
     let return v =
       choices := v;
@@ -464,11 +486,11 @@ let interactive_uri_choice
       connect_button dialog#uriChoiceAutoButton (fun _ ->
         match model#easy_selection () with
         | [] -> ()
-        | uris -> return (Some uris));
+        | uris -> return (Some (List.map UriManager.uri_of_string uris)));
     connect_button dialog#uriChoiceSelectedButton (fun _ ->
       match model#easy_selection () with
       | [] -> ()
-      | uris -> return (Some uris));
+      | uris -> return (Some (List.map UriManager.uri_of_string uris)));
     connect_button dialog#uriChoiceAbortButton (fun _ -> return None);
     dialog#uriChoiceDialog#show ();
     GtkThread.main ();