]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/matita/matitaGui.ml
renamed Http_client to Http_user_agent to avoid clashes with Gerd's
[helm.git] / helm / matita / matitaGui.ml
index 16af244349b40bbaf69027b8a83a55663c94b209..6b70a498f05e43bd9b93d6f09b13cd7661683e08 100644 (file)
@@ -41,37 +41,50 @@ class stringListModel' uriChoiceDialog =
   end
 *)
 
+open Printf
+
 open MatitaGeneratedGui
 open MatitaGtkMisc
+open MatitaMisc
 
 class gui file =
     (* creation order _is_ relevant for windows placement *)
   let toolbar = new toolBarWin ~file () in
   let main = new mainWin ~file () in
   let about = new aboutWin ~file () in
-  let dialog = new genericDialog ~file () in
-  let uriChoice = new uriChoiceDialog ~file () in
-  let interpChoice = new interpChoiceDialog ~file () in
   let fileSel = new fileSelectionWin ~file () in
   let proof = new proofWin ~file () in
+  let check = new checkWin ~file () in
+  let script = new scriptWin ~file () in
   let keyBindingBoxes = (* event boxes which should receive global key events *)
-    [ toolbar#toolBarEventBox; proof#proofWinEventBox ]
+    [ toolbar#toolBarEventBox; proof#proofWinEventBox; main#mainWinEventBox;
+      check#checkWinEventBox; script#scriptWinEventBox ]
+  in
+  let console =
+    MatitaConsole.console ~evbox:main#consoleEventBox ~phrase_sep:";;"
+      ~packing:main#scrolledConsole#add ()
   in
-  let uriChoices = new stringListModel uriChoice#uriChoiceTreeView in
   object (self)
+    val mutable chosen_file = None
+
     initializer
         (* glade's check widgets *)
       List.iter (fun w -> w#check_widgets ())
         (let c w = (w :> <check_widgets: unit -> unit>) in
-         [ c about; c dialog; c fileSel; c main; c proof; c toolbar;
-           c uriChoice; c interpChoice ]);
+         [ c about; c fileSel; c main; c proof; c toolbar; c check; c script ]);
         (* show/hide commands *)
       toggle_visibility toolbar#toolBarWin main#showToolBarMenuItem;
       toggle_visibility proof#proofWin main#showProofMenuItem;
+      toggle_visibility check#checkWin main#showCheckMenuItem;
+      toggle_visibility script#scriptWin main#showScriptMenuItem;
         (* "global" key bindings *)
       List.iter (fun (key, callback) -> self#addKeyBinding key callback)
         [ GdkKeysyms._F3,
             toggle_win ~check:main#showProofMenuItem proof#proofWin;
+          GdkKeysyms._F4,
+            toggle_win ~check:main#showCheckMenuItem check#checkWin;
+          GdkKeysyms._F5,
+            toggle_win ~check:main#showScriptMenuItem script#scriptWin;
         ];
         (* about win *)
       ignore (about#aboutWin#event#connect#delete (fun _ -> true));
@@ -79,21 +92,61 @@ class gui file =
         about#aboutWin#show ()));
       ignore (about#aboutDismissButton#connect#clicked (fun _ ->
         about#aboutWin#misc#hide ()));
+      about#aboutLabel#set_label (Pcre.replace ~pat:"@VERSION@"
+        ~templ:BuildTimeConf.version about#aboutLabel#label);
+        (* file selection win *)
+      ignore (fileSel#fileSelectionWin#event#connect#delete (fun _ -> true));
+      ignore (fileSel#fileSelectionWin#connect#response (fun event ->
+        let return r =
+          chosen_file <- r;
+          fileSel#fileSelectionWin#misc#hide ();
+          GMain.Main.quit ()
+        in
+        match event with
+        | `OK ->
+            let fname = fileSel#fileSelectionWin#filename in
+            if is_regular fname then return (Some fname)
+        | `CANCEL -> return None
+        | `HELP -> ()
+        | `DELETE_EVENT -> return None));
         (* menus *)
       List.iter (fun w -> w#misc#set_sensitive false)
         [ main#saveMenuItem; main#saveAsMenuItem ];
       main#helpMenu#set_right_justified true;
-        (* uri choice *)
-      ()
+        (* console *)
+      console#echo_message (sprintf "\tMatita version %s\n"
+        BuildTimeConf.version);
+      console#echo_prompt ();
+      console#misc#grab_focus ()
 
-    method toolbar = toolbar
-    method main = main
     method about = about
-    method dialog = dialog
-    method uriChoice = uriChoice
-    method interpChoice = interpChoice
+    method check = check
+    method console = console
     method fileSel = fileSel
+    method main = main
     method proof = proof
+    method script = script
+    method toolbar = toolbar
+
+    method newUriDialog () =
+      let dialog = new uriChoiceDialog ~file () in
+      dialog#check_widgets ();
+      dialog
+
+    method newInterpDialog () =
+      let dialog = new interpChoiceDialog ~file () in
+      dialog#check_widgets ();
+      dialog
+
+    method newConfirmationDialog () =
+      let dialog = new confirmationDialog ~file () in
+      dialog#check_widgets ();
+      dialog
+
+    method newEmptyDialog () =
+      let dialog = new emptyDialog ~file () in
+      dialog#check_widgets ();
+      dialog
 
     method private addKeyBinding key callback =
       List.iter (fun evbox -> add_key_binding key callback evbox)
@@ -104,7 +157,16 @@ class gui file =
       ignore (main#quitMenuItem#connect#activate callback);
       self#addKeyBinding GdkKeysyms._q callback
 
-    method uriChoices = uriChoices
+    method setPhraseCallback = console#set_callback
+
+    method chooseFile () =
+      fileSel#fileSelectionWin#show ();
+      GtkThread.main ();
+      chosen_file
 
   end
 
+let instance =
+  let gui = lazy (new gui (Helm_registry.get "matita.glade_file")) in
+  fun () -> Lazy.force gui
+