]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/lablgtkmathview/test/test.ml
* removed *-config script invocations, now using pkg-config
[helm.git] / helm / DEVEL / lablgtkmathview / test / test.ml
index ca9abd84bbab42645173c0b57e0a0347c5874fdf..936f962b596016dbbb8941c459e5b11a2c0395f4 100644 (file)
 (*                             MathView widget                                *)
 (******************************************************************************)
 
+let helmns = Gdome.domString "http://www.cs.unibo.it/helm";;
+
+(*
+let choose_selection mmlwidget (element : Gdome.element option) =
+ let module G = Gdome in
+  let rec aux element =
+   if element#hasAttributeNS
+       ~namespaceURI:Misc.helmns
+       ~localName:(G.domString "xref")
+   then
+     mmlwidget#set_selection (Some element)
+   else
+    try
+      match element#get_parentNode with
+         None -> assert false
+       (*CSC: OCAML DIVERGES!
+       | Some p -> aux (new G.element_of_node p)
+       *)
+       | Some p -> aux (new Gdome.element_of_node p)
+    with
+       GdomeInit.DOMCastException _ ->
+        prerr_endline
+         "******* trying to select above the document root ********"
+  in 
+   match element with
+     Some x -> aux x
+   | None   -> mmlwidget#set_selection None
+;;     
+*)
+
 (* Callbacks *)
 let selection_changed mathview (element : Gdome.element option) =
+ let rec aux element =
+  if element#hasAttributeNS
+      ~namespaceURI:helmns
+      ~localName:(Gdome.domString "xref")
+  then
+   mathview#set_selection (Some element)
+  else
+   try
+     match element#get_parentNode with
+        None -> mathview#set_selection None
+      | Some p -> aux (new Gdome.element_of_node p)
+   with
+      GdomeInit.DOMCastException _ ->
+       prerr_endline "******* trying to select above the document root ********"
+ in
  print_endline ("selection_changed: " ^
   (match element with
       None -> "selection_changed on nothing"
     | Some element -> element#get_tagName#to_string
   )
  ) ;
- mathview#set_selection element;
+ match element with
+   None -> ()
+ | Some el -> aux el;
  flush stdout
 ;;