X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fmatita%2FmatitaGui.ml;h=d50a2f31964d5fe50865e9c24e674abf0672488a;hb=6b7f04b45232e6c690cacf5815c85c39de1f52b3;hp=212e4e4d9b1a2e4b62547203a69dc1b3949b2fef;hpb=3705200c998538c28d8cd9d3ca557616837daf05;p=helm.git diff --git a/helm/matita/matitaGui.ml b/helm/matita/matitaGui.ml index 212e4e4d9..d50a2f319 100644 --- a/helm/matita/matitaGui.ml +++ b/helm/matita/matitaGui.ml @@ -45,6 +45,7 @@ open Printf open MatitaGeneratedGui open MatitaGtkMisc +open MatitaMisc class gui file = (* creation order _is_ relevant for windows placement *) @@ -54,30 +55,36 @@ class gui file = 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; main#mainWinEventBox; - check#checkWinEventBox ] + check#checkWinEventBox; script#scriptWinEventBox ] in let console = - MatitaConsole.console ~evbox:main#consoleEventBox + MatitaConsole.console ~evbox:main#consoleEventBox ~phrase_sep:";;" ~packing:main#scrolledConsole#add () in object (self) + val mutable chosen_file = None + initializer (* glade's check widgets *) List.iter (fun w -> w#check_widgets ()) (let c w = (w :> unit>) in - [ c about; c fileSel; c main; c proof; c toolbar; c check ]); + [ 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)); @@ -87,6 +94,21 @@ class gui file = 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 ]; @@ -103,6 +125,7 @@ class gui file = method fileSel = fileSel method main = main method proof = proof + method script = script method toolbar = toolbar method newUriDialog () = @@ -136,6 +159,31 @@ class gui file = method setPhraseCallback = console#set_callback + method chooseFile () = + fileSel#fileSelectionWin#show (); + GtkThread.main (); + chosen_file + + method askText ?(title = "") ?(msg = "") () = + let dialog = new textDialog () in + dialog#textDialog#set_title title; + dialog#textDialogLabel#set_label msg; + let text = ref None in + let return v = + text := v; + dialog#textDialog#destroy (); + GMain.Main.quit () + in + ignore (dialog#textDialog#event#connect#delete (fun _ -> true)); + ignore (dialog#textDialogCancelButton#connect#clicked (fun _ -> + return None)); + ignore (dialog#textDialogOkButton#connect#clicked (fun _ -> + let text = dialog#textDialogTextView#buffer#get_text () in + return (Some text))); + dialog#textDialog#show (); + GtkThread.main (); + !text + end let instance =