]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/matitaGui.ml
first moogle template checkin
[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 MatitaGeneratedGui
45 open MatitaGtkMisc
46
47 class gui file =
48     (* creation order _is_ relevant for windows placement *)
49   let toolbar = new toolBarWin ~file () in
50   let main = new mainWin ~file () in
51   let about = new aboutWin ~file () in
52   let fileSel = new fileSelectionWin ~file () in
53   let proof = new proofWin ~file () in
54   let keyBindingBoxes = (* event boxes which should receive global key events *)
55     [ toolbar#toolBarEventBox; proof#proofWinEventBox ]
56   in
57   let console = MatitaConsole.console ~packing:main#scrolledConsole#add () in
58   object (self)
59     initializer
60         (* glade's check widgets *)
61       List.iter (fun w -> w#check_widgets ())
62         (let c w = (w :> <check_widgets: unit -> unit>) in
63          [ c about; c fileSel; c main; c proof; c toolbar ]);
64         (* show/hide commands *)
65       toggle_visibility toolbar#toolBarWin main#showToolBarMenuItem;
66       toggle_visibility proof#proofWin main#showProofMenuItem;
67         (* "global" key bindings *)
68       List.iter (fun (key, callback) -> self#addKeyBinding key callback)
69         [ GdkKeysyms._F3,
70             toggle_win ~check:main#showProofMenuItem proof#proofWin;
71         ];
72         (* about win *)
73       ignore (about#aboutWin#event#connect#delete (fun _ -> true));
74       ignore (main#aboutMenuItem#connect#activate (fun _ ->
75         about#aboutWin#show ()));
76       ignore (about#aboutDismissButton#connect#clicked (fun _ ->
77         about#aboutWin#misc#hide ()));
78         (* menus *)
79       List.iter (fun w -> w#misc#set_sensitive false)
80         [ main#saveMenuItem; main#saveAsMenuItem ];
81       main#helpMenu#set_right_justified true;
82         (* console *)
83       console#echo_message "\tMatita version 0.0.1\n";
84       console#echo_prompt ();
85       console#misc#grab_focus ()
86
87     method about = about
88     method console = console
89     method fileSel = fileSel
90     method main = main
91     method proof = proof
92     method toolbar = toolbar
93
94     method newUriDialog () =
95       let dialog = new uriChoiceDialog ~file () in
96       dialog#check_widgets ();
97       dialog
98
99     method newInterpDialog () =
100       let dialog = new interpChoiceDialog ~file () in
101       dialog#check_widgets ();
102       dialog
103
104     method newConfirmationDialog () =
105       let dialog = new confirmationDialog ~file () in
106       dialog#check_widgets ();
107       dialog
108
109     method newEmptyDialog () =
110       let dialog = new emptyDialog ~file () in
111       dialog#check_widgets ();
112       dialog
113
114     method private addKeyBinding key callback =
115       List.iter (fun evbox -> add_key_binding key callback evbox)
116         keyBindingBoxes
117
118     method setQuitCallback callback =
119       ignore (main#toplevel#connect#destroy callback);
120       ignore (main#quitMenuItem#connect#activate callback);
121       self#addKeyBinding GdkKeysyms._q callback
122
123     method setPhraseCallback = console#set_callback
124
125   end
126