]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/matita/matitaMathView.ml
snapshot:
[helm.git] / helm / matita / matitaMathView.ml
index b83c9b37fa9abe3c21fc28bdae1b266581e021b7..cdbc51e41f98488bb1c20a4081be158ec3d3e782 100644 (file)
@@ -44,6 +44,25 @@ let list_map_fail f =
  in
   aux
 
+let choose_selection mmlwidget (element : Gdome.element option) =
+  let rec aux element =
+    if element#hasAttributeNS
+       ~namespaceURI:Misc.helmns
+       ~localName:(Gdome.domString "xref")
+    then
+      mmlwidget#set_selection (Some element)
+    else
+      try
+        match element#get_parentNode with
+        | None -> assert false
+        | Some p -> aux (new Gdome.element_of_node p)
+      with GdomeInit.DOMCastException _ ->
+        debug_print "trying to select above the document root"
+  in
+  match element with
+  | Some x -> aux x
+  | None   -> mmlwidget#set_selection None
+
 class proof_viewer obj =
  object(self)
 
@@ -59,11 +78,7 @@ class proof_viewer obj =
           prerr_endline (gdome_elt#get_nodeName#to_string);
           ignore (self#action_toggle gdome_elt)
       | None -> ()));
-      (* bugfix: until mapping gtkmathview doesn't draw anything *)
-    ignore (self#misc#connect#after#map (fun _ ->
-      match current_mathml with
-      | None -> ()
-      | Some mathml -> self#load_root ~root:mathml#get_documentElement))
+    ignore (self#connect#selection_changed (choose_selection self))
 
   method load_proof ((uri_opt, _, _, _) as proof, (goal_opt: int option)) =
     let (annobj, ids_to_terms, ids_to_father_ids, ids_to_inner_sorts,
@@ -93,6 +108,9 @@ class sequent_viewer obj =
 
   inherit GMathViewAux.multi_selection_math_view obj
 
+  initializer
+    ignore (self#connect#selection_changed (choose_selection self))
+
   val mutable current_infos = None
 
   method get_selected_terms =
@@ -187,7 +205,7 @@ class sequents_viewer ~(notebook:GPack.notebook)
       let win metano =
         let w =
           GBin.scrolled_window ~hpolicy:`AUTOMATIC ~vpolicy:`AUTOMATIC
-            ~show:true ()
+            ~shadow_type:`IN ~show:true ()
         in
         let reparent () =
           match sequent_viewer#misc#parent with
@@ -206,7 +224,7 @@ class sequents_viewer ~(notebook:GPack.notebook)
           notebook#append_page ~tab_label:(tab_label metano) (win metano))
         metasenv;
       switch_page_callback <-
-        Some (notebook#connect#after#switch_page ~callback:(fun page ->
+        Some (notebook#connect#switch_page ~callback:(fun page ->
           let goal =
             try
               List.assoc page page2goal
@@ -253,11 +271,7 @@ let proof_viewer ?hadjustment ?vadjustment ?font_size ?log_verbosity =
 let proof_viewer_instance =
   let instance = lazy (
     let gui = MatitaGui.instance () in
-    let frame =
-      GBin.frame ~packing:(gui#proof#scrolledProof#add_with_viewport)
-        ~show:true ()
-    in
-    proof_viewer ~show:true ~packing:(frame#add) ()
+    proof_viewer ~show:true ~packing:gui#proof#scrolledProof#add ()
   ) in
   fun () -> Lazy.force instance