X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fmatita%2FmatitaGui.ml;h=9226ea7b680e78c05eacb771fa179b038a34f52e;hb=275727242ccdce9df01af65f3bfb2d65283fa197;hp=95882a0f1f4fd57ab558d93ef525efe575ccdca4;hpb=56415e42c04f40e9c8f7cfc59a3a3d87c3d373f7;p=helm.git diff --git a/helm/matita/matitaGui.ml b/helm/matita/matitaGui.ml index 95882a0f1..9226ea7b6 100644 --- a/helm/matita/matitaGui.ml +++ b/helm/matita/matitaGui.ml @@ -41,8 +41,11 @@ class stringListModel' uriChoiceDialog = end *) +open Printf + open MatitaGeneratedGui open MatitaGtkMisc +open MatitaMisc class gui file = (* creation order _is_ relevant for windows placement *) @@ -51,23 +54,45 @@ class gui file = let about = new aboutWin ~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 console = MatitaConsole.console ~packing:main#scrolledConsole#add () in + let script_buf = script#scriptTextView#buffer in object (self) + val mutable chosen_file = None + + (** text mark and tag representing locked part of a script *) + val locked_mark = + script_buf#create_mark ~name:"locked" ~left_gravity:true + script_buf#start_iter + val locked_tag = + script_buf#create_tag [`BACKGROUND "green"; `EDITABLE false] + 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 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)); @@ -75,21 +100,41 @@ 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)); + (* script *) (* menus *) List.iter (fun w -> w#misc#set_sensitive false) [ main#saveMenuItem; main#saveAsMenuItem ]; main#helpMenu#set_right_justified true; (* console *) - console#echo_message "message"; - console#echo_error "error"; + console#echo_message (sprintf "\tMatita version %s\n" + BuildTimeConf.version); console#echo_prompt (); console#misc#grab_focus () method about = about + method check = check method console = console method fileSel = fileSel method main = main method proof = proof + method script = script method toolbar = toolbar method newUriDialog () = @@ -123,5 +168,42 @@ 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 + + method lockScript offset = + let mark = `MARK locked_mark in + script_buf#move_mark mark ~where:(script_buf#get_iter_at_char offset); + script_buf#remove_tag locked_tag ~start:script_buf#start_iter + ~stop:script_buf#end_iter; + script_buf#apply_tag locked_tag ~start:script_buf#start_iter + ~stop:(script_buf#get_iter_at_mark mark) + end +let instance = + let gui = lazy (new gui (Helm_registry.get "matita.glade_file")) in + fun () -> Lazy.force gui +