1 (******************************************************************************)
5 (* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
8 (* This is a simple gtk interface to the Coq-like pretty printer cicPp for *)
9 (* cic terms exported in xml. It uses directly the modules cicPp and *)
10 (* cicCcache and indirectly all the other modules (cicParser, cicParser2, *)
11 (* cicParser3, getter). *)
12 (* The syntax is "gtkInterface[.opt] filename1 ... filenamen" where *)
13 (* filenamei is the path-name of an xml file describing a cic term. *)
14 (* The terms are loaded in cache and then pretty-printed one at a time and *)
15 (* only once, when the user wants to look at it: if the user wants to look at *)
16 (* a term again, then the pretty-printed term is showed again, but not *)
19 (******************************************************************************)
21 (* DEFINITION OF THE URI TREE AND USEFUL FUNCTIONS ON IT *)
24 Dir of string * item list ref
25 | File of string * UriManager.uri
29 let theoryuritree = ref []
34 | File (name,_) -> name
40 | File (_,uri) -> Some uri
43 (* STUFF TO BUILD THE URI TREE *)
46 exception DuplicatedUri
47 exception ConflictingUris
49 let insert_in_uri_tree uri =
54 let _ = List.find (fun item -> name = get_name item) !l in
57 Not_found -> l := (File (name,uri))::!l
61 match List.find (fun item -> name = get_name item) !l with
62 Dir (_,children) -> aux children tl
63 | File _ -> raise ConflictingUris
66 let children = ref [] in
67 l := (Dir (name,children))::!l ;
70 | [] -> raise EmptyUri
75 (* Imperative procedure that builds the two uri trees *)
76 let build_uri_tree () =
77 let dbh = Dbm.opendbm Configuration.uris_dbm [Dbm.Dbm_rdonly] 0 in
80 let cicregexp = Str.regexp "cic:"
81 and theoryregexp = Str.regexp "theory:" in
82 if Str.string_match cicregexp uri 0 then
83 let s = Str.replace_first cicregexp "" uri in
84 let l = Str.split (Str.regexp "/") s in
85 insert_in_uri_tree (UriManager.uri_of_string uri) uritree l
86 else if Str.string_match theoryregexp uri 0 then
87 let s = Str.replace_first theoryregexp "" uri in
88 let l = Str.split (Str.regexp "/") s in
89 insert_in_uri_tree (UriManager.uri_of_string uri) theoryuritree l
94 (* GLOBAL REFERENCES (USED BY CALLBACKS) *)
96 let annotated_obj = ref None;; (* reference to a couple option where *)
97 (* the first component is the current *)
98 (* annotated object and the second is *)
99 (* the map from ids to annotated targets *)
100 let ann = ref (ref None);; (* current annotation *)
101 let radio_some_status = ref false;; (* is the radio_some button selected? *)
103 let theory_visited_uris = ref [];;
104 let theory_to_visit_uris = ref [];;
105 let visited_uris = ref [];;
106 let to_visit_uris = ref [];;
110 exception NoCurrentUri;;
111 exception NoNextOrPrevUri;;
112 exception GtkInterfaceInternalError;;
114 let theory_get_current_uri () =
115 match !theory_visited_uris with
116 [] -> raise NoCurrentUri
120 let get_current_uri () =
121 match !visited_uris with
122 [] -> raise NoCurrentUri
126 let get_annotated_obj () =
127 match !annotated_obj with
129 let (annobj, ids_to_targets,_) =
130 (CicCache.get_annobj (get_current_uri ()))
132 annotated_obj := Some (annobj, ids_to_targets) ;
133 (annobj, ids_to_targets)
134 | Some annobj -> annobj
137 let filename_of_uri uri =
141 let theory_update_output rendering_window uri =
142 rendering_window#label#set_text (UriManager.string_of_uri uri) ;
143 ignore (rendering_window#errors#delete_text 0 rendering_window#errors#length) ;
144 let mmlfile = XsltProcessor.process uri true "theory" in
145 rendering_window#output#load mmlfile
148 let update_output rendering_window uri =
149 rendering_window#label#set_text (UriManager.string_of_uri uri) ;
150 ignore (rendering_window#errors#delete_text 0 rendering_window#errors#length) ;
151 let mmlfile = XsltProcessor.process uri true "cic" in
152 rendering_window#output#load mmlfile
155 let theory_next rendering_window () =
156 match !theory_to_visit_uris with
157 [] -> raise NoNextOrPrevUri
159 theory_to_visit_uris := tl ;
160 theory_visited_uris := uri::!theory_visited_uris ;
161 theory_update_output rendering_window uri ;
162 rendering_window#prevb#misc#set_sensitive true ;
164 rendering_window#nextb#misc#set_sensitive false
167 let next rendering_window () =
168 match !to_visit_uris with
169 [] -> raise NoNextOrPrevUri
171 to_visit_uris := tl ;
172 visited_uris := uri::!visited_uris ;
173 annotated_obj := None ;
174 update_output rendering_window uri ;
175 rendering_window#prevb#misc#set_sensitive true ;
177 rendering_window#nextb#misc#set_sensitive false
180 let theory_prev rendering_window () =
181 match !theory_visited_uris with
182 [] -> raise NoCurrentUri
183 | [_] -> raise NoNextOrPrevUri
184 | uri::(uri'::tl as newvu) ->
185 theory_visited_uris := newvu ;
186 theory_to_visit_uris := uri::!theory_to_visit_uris ;
187 theory_update_output rendering_window uri' ;
188 rendering_window#nextb#misc#set_sensitive true ;
190 rendering_window#prevb#misc#set_sensitive false
193 let prev rendering_window () =
194 match !visited_uris with
195 [] -> raise NoCurrentUri
196 | [_] -> raise NoNextOrPrevUri
197 | uri::(uri'::tl as newvu) ->
198 visited_uris := newvu ;
199 to_visit_uris := uri::!to_visit_uris ;
200 annotated_obj := None ;
201 update_output rendering_window uri' ;
202 rendering_window#nextb#misc#set_sensitive true ;
204 rendering_window#prevb#misc#set_sensitive false
207 (* called when an hyperlink is clicked *)
208 let jump rendering_window (node : Ominidom.o_mDOMNode) =
209 let module O = Ominidom in
210 let s = (node#get_attribute (O.o_mDOMString_of_string "href"))#get_string in
211 let uri = UriManager.uri_of_string s in
212 rendering_window#show () ;
213 rendering_window#prevb#misc#set_sensitive true ;
214 rendering_window#nextb#misc#set_sensitive false ;
215 visited_uris := uri::!visited_uris ;
216 to_visit_uris := [] ;
217 annotated_obj := None ;
218 update_output rendering_window uri
221 let choose_selection rendering_window (node : Ominidom.o_mDOMNode option) =
222 let module O = Ominidom in
225 let _ = node#get_attribute (O.o_mDOMString_of_string "xref") in
226 rendering_window#output#set_selection node
228 O.Minidom_exception _ ->
229 aux (node#get_parent)
232 None -> rendering_window#output#reset_selection
233 | Some node -> aux node
237 let theory_selection_changed rendering_window uri () =
241 if !theory_visited_uris <> [] then
242 rendering_window#prevb#misc#set_sensitive true ;
243 rendering_window#nextb#misc#set_sensitive false ;
244 theory_visited_uris := uri'::!theory_visited_uris ;
245 theory_to_visit_uris := [] ;
246 rendering_window#show () ;
247 theory_update_output rendering_window uri'
250 let selection_changed rendering_window uri () =
254 if !visited_uris <> [] then
255 rendering_window#prevb#misc#set_sensitive true ;
256 rendering_window#nextb#misc#set_sensitive false ;
257 visited_uris := uri'::!visited_uris ;
258 to_visit_uris := [] ;
259 annotated_obj := None ;
260 rendering_window#show () ;
261 update_output rendering_window uri'
264 (* CSC: unificare con la creazione la prima volta *)
265 let rec updateb_pressed theory_rendering_window rendering_window
266 (sw1, sw ,(hbox : GPack.box)) mktree ()
269 (* let's empty the uri trees and rebuild them *)
271 theoryuritree := [] ;
273 hbox#remove !sw1#coerce ;
274 hbox#remove !sw#coerce ;
277 GBin.scrolled_window ~width:250 ~height:600
278 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
280 GTree.tree ~selection_mode:`BROWSE ~packing:sw3#add_with_viewport () in
281 let tree_item1 = GTree.tree_item ~label:"theory:/" ~packing:tree1#append () in
283 ignore(tree_item1#connect#select
284 (theory_selection_changed theory_rendering_window None)) ;
285 mktree theory_selection_changed theory_rendering_window tree_item1
286 (Dir ("theory:/",theoryuritree)) ;
289 GBin.scrolled_window ~width:250 ~height:600
290 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
292 GTree.tree ~selection_mode:`BROWSE ~packing:sw2#add_with_viewport () in
293 let tree_item = GTree.tree_item ~label:"cic:/" ~packing:tree#append () in
295 ignore(tree_item#connect#select (selection_changed rendering_window None)) ;
296 mktree selection_changed rendering_window tree_item (Dir ("cic:/",uritree))
299 let theory_check rendering_window () =
302 TheoryTypeChecker.typecheck (theory_get_current_uri ());
303 "Type Checking was successful"
305 TheoryTypeChecker.NotWellTyped s ->
306 "Type Checking was NOT successful:\n\t" ^ s
308 (* next "cast" can't got rid of, but I don't know why *)
309 let errors = (rendering_window#errors : GEdit.text) in
310 let _ = errors#delete_text 0 errors#length in
314 let check rendering_window () =
317 CicTypeChecker.typecheck (get_current_uri ());
318 "Type Checking was successful"
320 CicTypeChecker.NotWellTyped s -> "Type Checking was NOT successful:\n\t" ^ s
322 (* next "cast" can't got rid of, but I don't know why *)
323 let errors = (rendering_window#errors : GEdit.text) in
324 let _ = errors#delete_text 0 errors#length in
328 let annotateb_pressed rendering_window annotation_window () =
329 let module O = Ominidom in
331 let node = rendering_window#output#get_selection in
333 (node#get_attribute (O.o_mDOMString_of_string "xref"))#get_string
336 let annobj = get_annotated_obj ()
337 (* next "cast" can't got rid of, but I don't know why *)
338 and annotation = (annotation_window#annotation : GEdit.text) in
339 ann := CicXPath.get_annotation annobj xpath ;
340 CicAnnotationHinter.create_hints annotation_window annobj xpath ;
341 annotation#delete_text 0 annotation#length ;
345 annotation#misc#set_sensitive false ;
346 annotation_window#radio_none#set_active true ;
347 radio_some_status := false
349 annotation#insert ann' ;
350 annotation#misc#set_sensitive true ;
351 annotation_window#radio_some#set_active true ;
352 radio_some_status := true
354 GMain.Grab.add (annotation_window#window_to_annotate#coerce) ;
355 annotation_window#show () ;
358 (* next "cast" can't got rid of, but I don't know why *)
359 let errors = (rendering_window#errors : GEdit.text) in
360 errors#insert ("\n" ^ Printexc.to_string e ^ "\n")
362 O.Minidom_exception _ ->
363 (rendering_window#errors : GEdit.text)#insert "\nNo selection!\n"
366 (* called when the annotation is confirmed *)
367 let save_annotation annotation =
368 if !radio_some_status then
369 !ann := Some (annotation#get_chars 0 annotation#length)
372 match !annotated_obj with
373 None -> raise GtkInterfaceInternalError
375 let uri = get_current_uri () in
376 let annxml = Annotation2Xml.pp_annotation annobj uri in
377 Xml.pp annxml (Some (fst (Getter.get_ann_file_name_and_uri uri)))
380 let parse_no_cache uri =
381 let module U = UriManager in
382 XsltProcessor.process uri false "cic"
386 (* STUFF TO BUILD THE GTK INTERFACE *)
388 (* Stuff to build the tree window *)
390 (* selection_changed is actually selection_changed or theory_selection_changed*)
391 let mktree selection_changed rendering_window =
392 let rec aux treeitem =
394 Dir (dirname, content) ->
395 let subtree = GTree.tree () in
396 treeitem#set_subtree subtree ;
399 let label = get_name ti
400 and uri = get_uri ti in
401 let treeitem2 = GTree.tree_item ~label:label () in
402 subtree#append treeitem2 ;
403 ignore(treeitem2#connect#select
404 (selection_changed rendering_window uri)) ;
406 ) (List.sort compare !content)
412 (* Stuff for the widget settings *)
414 let export_to_postscript output () =
415 output#export_to_postscript ~width:595 ~height:822 ~x_margin:72
416 ~y_margin:72 ~disable_colors:false "output.ps" ;
419 let activate_t1 output button_set_anti_aliasing button_set_kerning
420 button_export_to_postscript button_t1 ()
422 let is_set = button_t1#active in
423 output#set_font_manager_type
425 GtkMathView.MathView.FontManagerT1
427 GtkMathView.MathView.FontManagerGtk) ;
430 button_set_anti_aliasing#misc#set_sensitive true ;
431 button_set_kerning#misc#set_sensitive true ;
432 button_export_to_postscript#misc#set_sensitive true ;
436 button_set_anti_aliasing#misc#set_sensitive false ;
437 button_set_kerning#misc#set_sensitive false ;
438 button_export_to_postscript#misc#set_sensitive false ;
442 let set_anti_aliasing output button_set_anti_aliasing () =
443 output#set_anti_aliasing button_set_anti_aliasing#active
446 let set_kerning output button_set_kerning () =
447 output#set_kerning button_set_kerning#active
450 let changefont output font_size_spinb () =
451 output#set_font_size font_size_spinb#value_as_int
454 let set_log_verbosity output log_verbosity_spinb () =
455 output#set_log_verbosity log_verbosity_spinb#value_as_int
458 class settings_window output sw button_export_to_postscript jump_callback
459 selection_changed_callback
461 let settings_window = GWindow.window ~title:"GtkMathView settings" () in
463 GPack.vbox ~packing:settings_window#add () in
466 ~rows:1 ~columns:3 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
467 ~border_width:5 ~packing:vbox#add () in
469 GButton.toggle_button ~label:"activate t1 fonts"
470 ~packing:(table#attach ~left:0 ~top:0) () in
471 let button_set_anti_aliasing =
472 GButton.toggle_button ~label:"set_anti_aliasing"
473 ~packing:(table#attach ~left:1 ~top:0) () in
474 let button_set_kerning =
475 GButton.toggle_button ~label:"set_kerning"
476 ~packing:(table#attach ~left:2 ~top:0) () in
479 ~rows:2 ~columns:2 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
480 ~border_width:5 ~packing:vbox#add () in
481 let font_size_label =
482 GMisc.label ~text:"font size:"
483 ~packing:(table#attach ~left:0 ~top:0 ~expand:`NONE) () in
484 let font_size_spinb =
486 GData.adjustment ~value:14.0 ~lower:5.0 ~upper:50.0 ~step_incr:1.0 ()
489 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:0 ~fill:`NONE) () in
490 let log_verbosity_label =
491 GMisc.label ~text:"log verbosity:"
492 ~packing:(table#attach ~left:0 ~top:1) () in
493 let log_verbosity_spinb =
495 GData.adjustment ~value:0.0 ~lower:0.0 ~upper:3.0 ~step_incr:1.0 ()
498 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:1) () in
500 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
502 GButton.button ~label:"Close"
503 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
505 method show = settings_window#show
507 button_set_anti_aliasing#misc#set_sensitive false ;
508 button_set_kerning#misc#set_sensitive false ;
509 (* Signals connection *)
510 ignore(button_t1#connect#clicked
511 (activate_t1 output button_set_anti_aliasing button_set_kerning
512 button_export_to_postscript button_t1)) ;
513 ignore(font_size_spinb#connect#changed (changefont output font_size_spinb)) ;
514 ignore(button_set_anti_aliasing#connect#toggled
515 (set_anti_aliasing output button_set_anti_aliasing));
516 ignore(button_set_kerning#connect#toggled
517 (set_kerning output button_set_kerning)) ;
518 ignore(log_verbosity_spinb#connect#changed
519 (set_log_verbosity output log_verbosity_spinb)) ;
520 ignore(closeb#connect#clicked settings_window#misc#hide)
525 class annotation_window output label =
526 let window_to_annotate =
527 GWindow.window ~title:"Annotating environment" ~border_width:2 () in
529 GPack.hbox ~packing:window_to_annotate#add () in
531 GPack.vbox ~packing:(hbox1#pack ~padding:5) () in
533 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
534 let radio_some = GButton.radio_button ~label:"Annotation below"
535 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
536 let radio_none = GButton.radio_button ~label:"No annotation"
537 ~group:radio_some#group
538 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5)
540 let annotation = GEdit.text ~editable:true ~width:400 ~height:180
541 ~packing:(vbox1#pack ~padding:5) () in
543 GPack.table ~rows:3 ~columns:3 ~packing:(vbox1#pack ~padding:5) () in
544 let annotation_hints =
547 GButton.button ~label:("Hint " ^ string_of_int i)
548 ~packing:(table#attach ~left:(i mod 3) ~top:(i / 3)) ()
551 GPack.vbox ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
553 GButton.button ~label:"O.K."
554 ~packing:(vbox2#pack ~expand:false ~fill:false ~padding:5) () in
556 GButton.button ~label:"Abort"
557 ~packing:(vbox2#pack ~expand:false ~fill:false ~padding:5) () in
559 method window_to_annotate = window_to_annotate
560 method annotation = annotation
561 method radio_some = radio_some
562 method radio_none = radio_none
563 method annotation_hints = annotation_hints
564 method output = (output : GMathView.math_view)
565 method show () = window_to_annotate#show ()
567 (* signal handlers here *)
568 ignore (window_to_annotate#event#connect#delete
570 window_to_annotate#misc#hide () ;
571 GMain.Grab.remove (window_to_annotate#coerce) ;
574 ignore (confirmb#connect#clicked
576 window_to_annotate#misc#hide () ;
577 save_annotation annotation ;
578 GMain.Grab.remove (window_to_annotate#coerce) ;
579 let new_current_uri =
580 (snd (Getter.get_ann_file_name_and_uri (get_current_uri ())))
582 visited_uris := new_current_uri::(List.tl !visited_uris) ;
583 label#set_text (UriManager.string_of_uri new_current_uri) ;
584 let mmlfile = parse_no_cache new_current_uri in
587 ignore (abortb#connect#clicked
589 window_to_annotate#misc#hide () ;
590 GMain.Grab.remove (window_to_annotate#coerce)
592 ignore (radio_some#connect#clicked
593 (fun () -> annotation#misc#set_sensitive true ; radio_some_status := true)) ;
594 ignore (radio_none #connect#clicked
596 annotation#misc#set_sensitive false;
597 radio_some_status := false)
601 class rendering_window annotation_window output (label : GMisc.label) =
603 GWindow.window ~title:"MathML viewer" ~border_width:2 () in
605 GPack.vbox ~packing:window#add () in
606 let _ = vbox#pack ~expand:false ~fill:false ~padding:5 label#coerce in
608 GPack.paned `HORIZONTAL ~packing:(vbox#pack ~expand:true ~padding:5) () in
609 let scrolled_window0 =
610 GBin.scrolled_window ~border_width:10 ~packing:paned#add1 () in
611 let _ = scrolled_window0#add output#coerce in
612 let scrolled_window =
614 ~border_width:10 ~packing:paned#add2 ~width:240 ~height:100 () in
615 let errors = GEdit.text ~packing:scrolled_window#add_with_viewport () in
617 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
619 GButton.button ~label:"Prev"
620 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
622 GButton.button ~label:"Next"
623 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
625 GButton.button ~label:"Check"
626 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
628 GButton.button ~label:"Annotate"
629 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
631 GButton.button ~label:"Settings"
632 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
633 let button_export_to_postscript =
634 GButton.button ~label:"export_to_postscript"
635 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
637 GButton.button ~label:"Close"
638 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
643 method output = (output : GMathView.math_view)
644 method errors = errors
645 method show () = window#show ()
647 nextb#misc#set_sensitive false ;
648 prevb#misc#set_sensitive false ;
649 button_export_to_postscript#misc#set_sensitive false ;
651 (* signal handlers here *)
652 ignore(output#connect#jump (jump self)) ;
653 ignore(output#connect#selection_changed (choose_selection self)) ;
654 ignore(nextb#connect#clicked (next self)) ;
655 ignore(prevb#connect#clicked (prev self)) ;
656 ignore(checkb#connect#clicked (check self)) ;
657 ignore(closeb#connect#clicked window#misc#hide) ;
658 ignore(annotateb#connect#clicked (annotateb_pressed self annotation_window)) ;
659 let settings_window = new settings_window output scrolled_window0
660 button_export_to_postscript (jump self) (choose_selection self) in
661 ignore(settingsb#connect#clicked settings_window#show) ;
662 ignore(button_export_to_postscript#connect#clicked (export_to_postscript output)) ;
663 ignore(window#event#connect#delete (fun _ -> window#misc#hide () ; true ))
666 class theory_rendering_window rendering_window =
668 GWindow.window ~title:"MathML theory viewer" ~border_width:2 () in
670 GPack.vbox ~packing:window#add () in
672 GMisc.label ~text:"???"
673 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
675 GPack.paned `HORIZONTAL ~packing:(vbox#pack ~expand:true ~padding:5) () in
676 let scrolled_window0 =
677 GBin.scrolled_window ~border_width:10 ~packing:paned#add1 () in
679 GMathView.math_view ~width:400 ~height:380 ~packing:scrolled_window0#add () in
680 let scrolled_window =
682 ~border_width:10 ~packing:paned#add2 ~width:240 ~height:100 () in
683 let errors = GEdit.text ~packing:scrolled_window#add_with_viewport () in
685 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
687 GButton.button ~label:"Prev"
688 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
690 GButton.button ~label:"Next"
691 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
693 GButton.button ~label:"Check"
694 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
696 GButton.button ~label:"Settings"
697 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
698 let button_export_to_postscript =
699 GButton.button ~label:"export_to_postscript"
700 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
702 GButton.button ~label:"Close"
703 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
708 method output = (output : GMathView.math_view)
709 method errors = errors
710 method show () = window#show ()
712 nextb#misc#set_sensitive false ;
713 prevb#misc#set_sensitive false ;
714 button_export_to_postscript#misc#set_sensitive false ;
716 (* signal handlers here *)
717 ignore(output#connect#jump (jump rendering_window)) ;
718 ignore(output#connect#selection_changed (choose_selection self)) ;
719 ignore(nextb#connect#clicked (theory_next self)) ;
720 ignore(prevb#connect#clicked (theory_prev self)) ;
721 ignore(checkb#connect#clicked (theory_check self)) ;
722 let settings_window = new settings_window output scrolled_window0
723 button_export_to_postscript (jump rendering_window)(choose_selection self) in
724 ignore(settingsb#connect#clicked settings_window#show) ;
725 ignore(button_export_to_postscript#connect#clicked (export_to_postscript output)) ;
726 ignore(closeb#connect#clicked window#misc#hide) ;
727 ignore(window#event#connect#delete (fun _ -> window#misc#hide () ; true ))
730 (* CSC: fare in modo che i due alberi vengano svuotati invece che distrutti *)
731 class selection_window theory_rendering_window rendering_window =
732 let label = "cic:/" in
733 let theorylabel = "theory:/" in
734 let win = GWindow.window ~title:"Known uris" ~border_width:2 () in
735 let vbox = GPack.vbox ~packing:win#add () in
736 let hbox1 = GPack.hbox ~packing:(vbox#pack ~padding:5) () in
737 let sw1 = GBin.scrolled_window ~width:250 ~height:600
738 ~packing:(hbox1#pack ~padding:5) () in
740 GTree.tree ~selection_mode:`BROWSE ~packing:sw1#add_with_viewport () in
742 GTree.tree_item ~label:theorylabel ~packing:tree1#append () in
743 let sw = GBin.scrolled_window ~width:250 ~height:600
744 ~packing:(hbox1#pack ~padding:5) () in
746 GTree.tree ~selection_mode:`BROWSE ~packing:sw#add_with_viewport () in
748 GTree.tree_item ~label:label ~packing:tree#append () in
750 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
752 GButton.button ~label:"Update"
753 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
755 GButton.button ~label:"Quit"
756 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
758 method show () = win#show ()
760 mktree theory_selection_changed theory_rendering_window tree_item1
761 (Dir ("theory:/",theoryuritree));
762 mktree selection_changed rendering_window tree_item
763 (Dir ("cic:/",uritree));
765 (* signal handlers here *)
766 ignore (tree_item1#connect#select
767 ~callback:(theory_selection_changed theory_rendering_window None)) ;
768 ignore (tree_item#connect#select
769 ~callback:(selection_changed rendering_window None)) ;
770 ignore (win#connect#destroy ~callback:GMain.Main.quit) ;
771 ignore (quitb#connect#clicked GMain.Main.quit) ;
772 ignore(updateb#connect#clicked (updateb_pressed
773 theory_rendering_window rendering_window (ref sw1, ref sw, hbox1) mktree))
781 let output = GMathView.math_view ~width:400 ~height:380 ()
782 and label = GMisc.label ~text:"???" () in
783 let annotation_window = new annotation_window output label in
784 let rendering_window = new rendering_window annotation_window output label in
785 let theory_rendering_window = new theory_rendering_window rendering_window in
786 let selection_window =
787 new selection_window theory_rendering_window rendering_window
789 selection_window#show () ;