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 exception SomethingWrong
209 (* called when an hyperlink is clicked *)
210 let jump rendering_window (node : Ominidom.o_mDOMNode) =
211 let module O = Ominidom in
212 match (node#get_attribute (O.o_mDOMString_of_string "href")) with
214 let s = str#get_string in
215 let uri = UriManager.uri_of_string s in
216 rendering_window#show () ;
217 rendering_window#prevb#misc#set_sensitive true ;
218 rendering_window#nextb#misc#set_sensitive false ;
219 visited_uris := uri::!visited_uris ;
220 to_visit_uris := [] ;
221 annotated_obj := None ;
222 update_output rendering_window uri
223 | None -> raise SomethingWrong
226 let choose_selection rendering_window (node : Ominidom.o_mDOMNode option) =
227 let module O = Ominidom in
229 match node#get_attribute (O.o_mDOMString_of_string "xref") with
230 | Some _ -> rendering_window#output#set_selection (Some node)
231 | None -> aux (node#get_parent)
235 | None -> rendering_window#output#set_selection None
239 let theory_selection_changed rendering_window uri () =
243 if !theory_visited_uris <> [] then
244 rendering_window#prevb#misc#set_sensitive true ;
245 rendering_window#nextb#misc#set_sensitive false ;
246 theory_visited_uris := uri'::!theory_visited_uris ;
247 theory_to_visit_uris := [] ;
248 rendering_window#show () ;
249 theory_update_output rendering_window uri'
252 let selection_changed rendering_window uri () =
256 if !visited_uris <> [] then
257 rendering_window#prevb#misc#set_sensitive true ;
258 rendering_window#nextb#misc#set_sensitive false ;
259 visited_uris := uri'::!visited_uris ;
260 to_visit_uris := [] ;
261 annotated_obj := None ;
262 rendering_window#show () ;
263 update_output rendering_window uri'
266 (* CSC: unificare con la creazione la prima volta *)
267 let rec updateb_pressed theory_rendering_window rendering_window
268 (sw1, sw ,(hbox : GPack.box)) mktree ()
271 (* let's empty the uri trees and rebuild them *)
273 theoryuritree := [] ;
275 hbox#remove !sw1#coerce ;
276 hbox#remove !sw#coerce ;
279 GBin.scrolled_window ~width:250 ~height:600
280 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
282 GTree.tree ~selection_mode:`BROWSE ~packing:sw3#add_with_viewport () in
283 let tree_item1 = GTree.tree_item ~label:"theory:/" ~packing:tree1#append () in
285 ignore(tree_item1#connect#select
286 (theory_selection_changed theory_rendering_window None)) ;
287 mktree theory_selection_changed theory_rendering_window tree_item1
288 (Dir ("theory:/",theoryuritree)) ;
291 GBin.scrolled_window ~width:250 ~height:600
292 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
294 GTree.tree ~selection_mode:`BROWSE ~packing:sw2#add_with_viewport () in
295 let tree_item = GTree.tree_item ~label:"cic:/" ~packing:tree#append () in
297 ignore(tree_item#connect#select (selection_changed rendering_window None)) ;
298 mktree selection_changed rendering_window tree_item (Dir ("cic:/",uritree))
301 let theory_check rendering_window () =
304 TheoryTypeChecker.typecheck (theory_get_current_uri ());
305 "Type Checking was successful"
307 TheoryTypeChecker.NotWellTyped s ->
308 "Type Checking was NOT successful:\n\t" ^ s
310 (* next "cast" can't got rid of, but I don't know why *)
311 let errors = (rendering_window#errors : GEdit.text) in
312 let _ = errors#delete_text 0 errors#length in
316 let check rendering_window () =
319 CicTypeChecker.typecheck (get_current_uri ());
320 "Type Checking was successful"
322 CicTypeChecker.NotWellTyped s -> "Type Checking was NOT successful:\n\t" ^ s
324 (* next "cast" can't got rid of, but I don't know why *)
325 let errors = (rendering_window#errors : GEdit.text) in
326 let _ = errors#delete_text 0 errors#length in
330 let annotateb_pressed rendering_window annotation_window () =
331 let module O = Ominidom in
332 match rendering_window#output#get_selection with
335 match (node#get_attribute (O.o_mDOMString_of_string "xref")) with
337 let annobj = get_annotated_obj ()
338 (* next "cast" can't got rid of, but I don't know why *)
339 and annotation = (annotation_window#annotation : GEdit.text) in
340 ann := CicXPath.get_annotation annobj (xpath#get_string) ;
341 CicAnnotationHinter.create_hints annotation_window annobj (xpath#get_string) ;
342 annotation#delete_text 0 annotation#length ;
346 annotation#misc#set_sensitive false ;
347 annotation_window#radio_none#set_active true ;
348 radio_some_status := false
350 annotation#insert ann' ;
351 annotation#misc#set_sensitive true ;
352 annotation_window#radio_some#set_active true ;
353 radio_some_status := true
355 GMain.Grab.add (annotation_window#window_to_annotate#coerce) ;
356 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 ("\nNo xref found\n")
362 | None -> (rendering_window#errors : GEdit.text)#insert "\nNo selection!\n"
365 (* called when the annotation is confirmed *)
366 let save_annotation annotation =
367 if !radio_some_status then
368 !ann := Some (annotation#get_chars 0 annotation#length)
371 match !annotated_obj with
372 None -> raise GtkInterfaceInternalError
374 let uri = get_current_uri () in
375 let annxml = Annotation2Xml.pp_annotation annobj uri in
376 Xml.pp annxml (Some (fst (Getter.get_ann_file_name_and_uri uri)))
379 let parse_no_cache uri =
380 let module U = UriManager in
381 XsltProcessor.process uri false "cic"
385 (* STUFF TO BUILD THE GTK INTERFACE *)
387 (* Stuff to build the tree window *)
389 (* selection_changed is actually selection_changed or theory_selection_changed*)
390 let mktree selection_changed rendering_window =
391 let rec aux treeitem =
393 Dir (dirname, content) ->
394 let subtree = GTree.tree () in
395 treeitem#set_subtree subtree ;
398 let label = get_name ti
399 and uri = get_uri ti in
400 let treeitem2 = GTree.tree_item ~label:label () in
401 subtree#append treeitem2 ;
402 ignore(treeitem2#connect#select
403 (selection_changed rendering_window uri)) ;
405 ) (List.sort compare !content)
411 (* Stuff for the widget settings *)
413 let export_to_postscript (output : GMathView.math_view) () =
414 output#export_to_postscript ~filename:"output.ps" ();
417 let activate_t1 output button_set_anti_aliasing button_set_kerning
418 button_export_to_postscript button_t1 ()
420 let is_set = button_t1#active in
421 output#set_font_manager_type
422 (if is_set then `font_manager_t1 else `font_manager_gtk) ;
425 button_set_anti_aliasing#misc#set_sensitive true ;
426 button_set_kerning#misc#set_sensitive true ;
427 button_export_to_postscript#misc#set_sensitive true ;
431 button_set_anti_aliasing#misc#set_sensitive false ;
432 button_set_kerning#misc#set_sensitive false ;
433 button_export_to_postscript#misc#set_sensitive false ;
437 let set_anti_aliasing output button_set_anti_aliasing () =
438 output#set_anti_aliasing button_set_anti_aliasing#active
441 let set_kerning output button_set_kerning () =
442 output#set_kerning button_set_kerning#active
445 let changefont output font_size_spinb () =
446 output#set_font_size font_size_spinb#value_as_int
449 let set_log_verbosity output log_verbosity_spinb () =
450 output#set_log_verbosity log_verbosity_spinb#value_as_int
453 class settings_window output sw button_export_to_postscript jump_callback
454 selection_changed_callback
456 let settings_window = GWindow.window ~title:"GtkMathView settings" () in
458 GPack.vbox ~packing:settings_window#add () in
461 ~rows:1 ~columns:3 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
462 ~border_width:5 ~packing:vbox#add () in
464 GButton.toggle_button ~label:"activate t1 fonts"
465 ~packing:(table#attach ~left:0 ~top:0) () in
466 let button_set_anti_aliasing =
467 GButton.toggle_button ~label:"set_anti_aliasing"
468 ~packing:(table#attach ~left:1 ~top:0) () in
469 let button_set_kerning =
470 GButton.toggle_button ~label:"set_kerning"
471 ~packing:(table#attach ~left:2 ~top:0) () in
474 ~rows:2 ~columns:2 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
475 ~border_width:5 ~packing:vbox#add () in
476 let font_size_label =
477 GMisc.label ~text:"font size:"
478 ~packing:(table#attach ~left:0 ~top:0 ~expand:`NONE) () in
479 let font_size_spinb =
481 GData.adjustment ~value:14.0 ~lower:5.0 ~upper:50.0 ~step_incr:1.0 ()
484 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:0 ~fill:`NONE) () in
485 let log_verbosity_label =
486 GMisc.label ~text:"log verbosity:"
487 ~packing:(table#attach ~left:0 ~top:1) () in
488 let log_verbosity_spinb =
490 GData.adjustment ~value:0.0 ~lower:0.0 ~upper:3.0 ~step_incr:1.0 ()
493 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:1) () in
495 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
497 GButton.button ~label:"Close"
498 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
500 method show = settings_window#show
502 button_set_anti_aliasing#misc#set_sensitive false ;
503 button_set_kerning#misc#set_sensitive false ;
504 (* Signals connection *)
505 ignore(button_t1#connect#clicked
506 (activate_t1 output button_set_anti_aliasing button_set_kerning
507 button_export_to_postscript button_t1)) ;
508 ignore(font_size_spinb#connect#changed (changefont output font_size_spinb)) ;
509 ignore(button_set_anti_aliasing#connect#toggled
510 (set_anti_aliasing output button_set_anti_aliasing));
511 ignore(button_set_kerning#connect#toggled
512 (set_kerning output button_set_kerning)) ;
513 ignore(log_verbosity_spinb#connect#changed
514 (set_log_verbosity output log_verbosity_spinb)) ;
515 ignore(closeb#connect#clicked settings_window#misc#hide)
520 class annotation_window output label =
521 let window_to_annotate =
522 GWindow.window ~title:"Annotating environment" ~border_width:2 () in
524 GPack.hbox ~packing:window_to_annotate#add () in
526 GPack.vbox ~packing:(hbox1#pack ~padding:5) () in
528 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
529 let radio_some = GButton.radio_button ~label:"Annotation below"
530 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
531 let radio_none = GButton.radio_button ~label:"No annotation"
532 ~group:radio_some#group
533 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5)
535 let annotation = GEdit.text ~editable:true ~width:400 ~height:180
536 ~packing:(vbox1#pack ~padding:5) () in
538 GPack.table ~rows:3 ~columns:3 ~packing:(vbox1#pack ~padding:5) () in
539 let annotation_hints =
542 GButton.button ~label:("Hint " ^ string_of_int i)
543 ~packing:(table#attach ~left:(i mod 3) ~top:(i / 3)) ()
546 GPack.vbox ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
548 GButton.button ~label:"O.K."
549 ~packing:(vbox2#pack ~expand:false ~fill:false ~padding:5) () in
551 GButton.button ~label:"Abort"
552 ~packing:(vbox2#pack ~expand:false ~fill:false ~padding:5) () in
554 method window_to_annotate = window_to_annotate
555 method annotation = annotation
556 method radio_some = radio_some
557 method radio_none = radio_none
558 method annotation_hints = annotation_hints
559 method output = (output : GMathView.math_view)
560 method show () = window_to_annotate#show ()
562 (* signal handlers here *)
563 ignore (window_to_annotate#event#connect#delete
565 window_to_annotate#misc#hide () ;
566 GMain.Grab.remove (window_to_annotate#coerce) ;
569 ignore (confirmb#connect#clicked
571 window_to_annotate#misc#hide () ;
572 save_annotation annotation ;
573 GMain.Grab.remove (window_to_annotate#coerce) ;
574 let new_current_uri =
575 (snd (Getter.get_ann_file_name_and_uri (get_current_uri ())))
577 visited_uris := new_current_uri::(List.tl !visited_uris) ;
578 label#set_text (UriManager.string_of_uri new_current_uri) ;
579 let mmlfile = parse_no_cache new_current_uri in
582 ignore (abortb#connect#clicked
584 window_to_annotate#misc#hide () ;
585 GMain.Grab.remove (window_to_annotate#coerce)
587 ignore (radio_some#connect#clicked
588 (fun () -> annotation#misc#set_sensitive true ; radio_some_status := true)) ;
589 ignore (radio_none #connect#clicked
591 annotation#misc#set_sensitive false;
592 radio_some_status := false)
596 class rendering_window annotation_window output (label : GMisc.label) =
598 GWindow.window ~title:"MathML viewer" ~border_width:2 () in
600 GPack.vbox ~packing:window#add () in
601 let _ = vbox#pack ~expand:false ~fill:false ~padding:5 label#coerce in
603 GPack.paned `HORIZONTAL ~packing:(vbox#pack ~expand:true ~padding:5) () in
604 let scrolled_window0 =
605 GBin.scrolled_window ~border_width:10 ~packing:paned#add1 () in
606 let _ = scrolled_window0#add output#coerce in
607 let scrolled_window =
609 ~border_width:10 ~packing:paned#add2 ~width:240 ~height:100 () in
610 let errors = GEdit.text ~packing:scrolled_window#add_with_viewport () in
612 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
614 GButton.button ~label:"Prev"
615 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
617 GButton.button ~label:"Next"
618 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
620 GButton.button ~label:"Check"
621 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
623 GButton.button ~label:"Annotate"
624 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
626 GButton.button ~label:"Settings"
627 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
628 let button_export_to_postscript =
629 GButton.button ~label:"export_to_postscript"
630 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
632 GButton.button ~label:"Close"
633 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
638 method output = (output : GMathView.math_view)
639 method errors = errors
640 method show () = window#show ()
642 nextb#misc#set_sensitive false ;
643 prevb#misc#set_sensitive false ;
644 button_export_to_postscript#misc#set_sensitive false ;
646 (* signal handlers here *)
647 ignore(output#connect#jump (jump self)) ;
648 ignore(output#connect#selection_changed (choose_selection self)) ;
649 ignore(nextb#connect#clicked (next self)) ;
650 ignore(prevb#connect#clicked (prev self)) ;
651 ignore(checkb#connect#clicked (check self)) ;
652 ignore(closeb#connect#clicked window#misc#hide) ;
653 ignore(annotateb#connect#clicked (annotateb_pressed self annotation_window)) ;
654 let settings_window = new settings_window output scrolled_window0
655 button_export_to_postscript (jump self) (choose_selection self) in
656 ignore(settingsb#connect#clicked settings_window#show) ;
657 ignore(button_export_to_postscript#connect#clicked (export_to_postscript output)) ;
658 ignore(window#event#connect#delete (fun _ -> window#misc#hide () ; true ))
661 class theory_rendering_window rendering_window =
663 GWindow.window ~title:"MathML theory viewer" ~border_width:2 () in
665 GPack.vbox ~packing:window#add () in
667 GMisc.label ~text:"???"
668 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
670 GPack.paned `HORIZONTAL ~packing:(vbox#pack ~expand:true ~padding:5) () in
671 let scrolled_window0 =
672 GBin.scrolled_window ~border_width:10 ~packing:paned#add1 () in
674 GMathView.math_view ~width:400 ~height:380 ~packing:scrolled_window0#add () in
675 let scrolled_window =
677 ~border_width:10 ~packing:paned#add2 ~width:240 ~height:100 () in
678 let errors = GEdit.text ~packing:scrolled_window#add_with_viewport () in
680 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
682 GButton.button ~label:"Prev"
683 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
685 GButton.button ~label:"Next"
686 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
688 GButton.button ~label:"Check"
689 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
691 GButton.button ~label:"Settings"
692 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
693 let button_export_to_postscript =
694 GButton.button ~label:"export_to_postscript"
695 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
697 GButton.button ~label:"Close"
698 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
703 method output = (output : GMathView.math_view)
704 method errors = errors
705 method show () = window#show ()
707 nextb#misc#set_sensitive false ;
708 prevb#misc#set_sensitive false ;
709 button_export_to_postscript#misc#set_sensitive false ;
711 (* signal handlers here *)
712 ignore(output#connect#jump (jump rendering_window)) ;
713 ignore(output#connect#selection_changed (choose_selection self)) ;
714 ignore(nextb#connect#clicked (theory_next self)) ;
715 ignore(prevb#connect#clicked (theory_prev self)) ;
716 ignore(checkb#connect#clicked (theory_check self)) ;
717 let settings_window = new settings_window output scrolled_window0
718 button_export_to_postscript (jump rendering_window)(choose_selection self) in
719 ignore(settingsb#connect#clicked settings_window#show) ;
720 ignore(button_export_to_postscript#connect#clicked (export_to_postscript output)) ;
721 ignore(closeb#connect#clicked window#misc#hide) ;
722 ignore(window#event#connect#delete (fun _ -> window#misc#hide () ; true ))
725 (* CSC: fare in modo che i due alberi vengano svuotati invece che distrutti *)
726 class selection_window theory_rendering_window rendering_window =
727 let label = "cic:/" in
728 let theorylabel = "theory:/" in
729 let win = GWindow.window ~title:"Known uris" ~border_width:2 () in
730 let vbox = GPack.vbox ~packing:win#add () in
731 let hbox1 = GPack.hbox ~packing:(vbox#pack ~padding:5) () in
732 let sw1 = GBin.scrolled_window ~width:250 ~height:600
733 ~packing:(hbox1#pack ~padding:5) () in
735 GTree.tree ~selection_mode:`BROWSE ~packing:sw1#add_with_viewport () in
737 GTree.tree_item ~label:theorylabel ~packing:tree1#append () in
738 let sw = GBin.scrolled_window ~width:250 ~height:600
739 ~packing:(hbox1#pack ~padding:5) () in
741 GTree.tree ~selection_mode:`BROWSE ~packing:sw#add_with_viewport () in
743 GTree.tree_item ~label:label ~packing:tree#append () in
745 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
747 GButton.button ~label:"Update"
748 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
750 GButton.button ~label:"Quit"
751 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
753 method show () = win#show ()
755 mktree theory_selection_changed theory_rendering_window tree_item1
756 (Dir ("theory:/",theoryuritree));
757 mktree selection_changed rendering_window tree_item
758 (Dir ("cic:/",uritree));
760 (* signal handlers here *)
761 ignore (tree_item1#connect#select
762 ~callback:(theory_selection_changed theory_rendering_window None)) ;
763 ignore (tree_item#connect#select
764 ~callback:(selection_changed rendering_window None)) ;
765 ignore (win#connect#destroy ~callback:GMain.Main.quit) ;
766 ignore (quitb#connect#clicked GMain.Main.quit) ;
767 ignore(updateb#connect#clicked (updateb_pressed
768 theory_rendering_window rendering_window (ref sw1, ref sw, hbox1) mktree))
776 let output = GMathView.math_view ~width:400 ~height:380 ()
777 and label = GMisc.label ~text:"???" () in
778 let annotation_window = new annotation_window output label in
779 let rendering_window = new rendering_window annotation_window output label in
780 let theory_rendering_window = new theory_rendering_window rendering_window in
781 let selection_window =
782 new selection_window theory_rendering_window rendering_window
784 selection_window#show () ;