]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/matitaGui.ml
snapshot (notably: implemented "check")
[helm.git] / helm / matita / matitaGui.ml
1 (* Copyright (C) 2004, HELM Team.
2  * 
3  * This file is part of HELM, an Hypertextual, Electronic
4  * Library of Mathematics, developed at the Computer Science
5  * Department, University of Bologna, Italy.
6  * 
7  * HELM is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * 
12  * HELM is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with HELM; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
26 (*
27 class stringListModel' uriChoiceDialog =
28   let tree_view = uriChoiceDialog#uriChoiceTreeView in
29   let column_list = new GTree.column_list in
30   let text_column = column_list#add Gobject.Data.string in
31   let list_store = GTree.list_store column_list in
32   let renderer = (GTree.cell_renderer_text [], ["text", text_column]) in
33   let view_column = GTree.view_column ~renderer () in
34   let _ = tree_view#set_model (Some (list_store :> GTree.model)) in
35   let _ = tree_view#append_column view_column in
36   object
37     method append s =
38       let tree_iter = list_store#append () in
39       list_store#set ~row:tree_iter ~column:text_column s
40     method clear () = list_store#clear ()
41   end
42 *)
43
44 open Printf
45
46 open MatitaGeneratedGui
47 open MatitaGtkMisc
48
49 class gui file =
50     (* creation order _is_ relevant for windows placement *)
51   let toolbar = new toolBarWin ~file () in
52   let main = new mainWin ~file () in
53   let about = new aboutWin ~file () in
54   let fileSel = new fileSelectionWin ~file () in
55   let proof = new proofWin ~file () in
56   let check = new checkWin ~file () in
57   let keyBindingBoxes = (* event boxes which should receive global key events *)
58     [ toolbar#toolBarEventBox; proof#proofWinEventBox; main#mainWinEventBox ]
59   in
60   let console =
61     MatitaConsole.console ~evbox:main#consoleEventBox
62       ~packing:main#scrolledConsole#add ()
63   in
64   object (self)
65     initializer
66         (* glade's check widgets *)
67       List.iter (fun w -> w#check_widgets ())
68         (let c w = (w :> <check_widgets: unit -> unit>) in
69          [ c about; c fileSel; c main; c proof; c toolbar; c check ]);
70         (* show/hide commands *)
71       toggle_visibility toolbar#toolBarWin main#showToolBarMenuItem;
72       toggle_visibility proof#proofWin main#showProofMenuItem;
73       toggle_visibility check#checkWin main#showCheckMenuItem;
74         (* "global" key bindings *)
75       List.iter (fun (key, callback) -> self#addKeyBinding key callback)
76         [ GdkKeysyms._F3,
77             toggle_win ~check:main#showProofMenuItem proof#proofWin;
78         ];
79         (* about win *)
80       ignore (about#aboutWin#event#connect#delete (fun _ -> true));
81       ignore (main#aboutMenuItem#connect#activate (fun _ ->
82         about#aboutWin#show ()));
83       ignore (about#aboutDismissButton#connect#clicked (fun _ ->
84         about#aboutWin#misc#hide ()));
85       about#aboutLabel#set_label (Pcre.replace ~pat:"@VERSION@"
86         ~templ:BuildTimeConf.version about#aboutLabel#label);
87         (* menus *)
88       List.iter (fun w -> w#misc#set_sensitive false)
89         [ main#saveMenuItem; main#saveAsMenuItem ];
90       main#helpMenu#set_right_justified true;
91         (* console *)
92       console#echo_message (sprintf "\tMatita version %s\n"
93         BuildTimeConf.version);
94       console#echo_prompt ();
95       console#misc#grab_focus ()
96
97     method about = about
98     method check = check
99     method console = console
100     method fileSel = fileSel
101     method main = main
102     method proof = proof
103     method toolbar = toolbar
104
105     method newUriDialog () =
106       let dialog = new uriChoiceDialog ~file () in
107       dialog#check_widgets ();
108       dialog
109
110     method newInterpDialog () =
111       let dialog = new interpChoiceDialog ~file () in
112       dialog#check_widgets ();
113       dialog
114
115     method newConfirmationDialog () =
116       let dialog = new confirmationDialog ~file () in
117       dialog#check_widgets ();
118       dialog
119
120     method newEmptyDialog () =
121       let dialog = new emptyDialog ~file () in
122       dialog#check_widgets ();
123       dialog
124
125     method private addKeyBinding key callback =
126       List.iter (fun evbox -> add_key_binding key callback evbox)
127         keyBindingBoxes
128
129     method setQuitCallback callback =
130       ignore (main#toplevel#connect#destroy callback);
131       ignore (main#quitMenuItem#connect#activate callback);
132       self#addKeyBinding GdkKeysyms._q callback
133
134     method setPhraseCallback = console#set_callback
135
136   end
137
138 let instance =
139   let gui = lazy (new gui (Helm_registry.get "matita.glade_file")) in
140   fun () -> Lazy.force gui
141