]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.0/test/test.ml
- the mathql interpreter is not helm-dependent any more
[helm.git] / helm / DEVEL / lablgtk_gtkmathview / lablgtk-20000829_gtkmathview-0.2.0 / test / test.ml
index 731acea33f8f89f36a6c259257c257a8e97d8557..af65d7485db1b7f3ac27a9175a839177689f385a 100644 (file)
@@ -8,26 +8,43 @@
 
 (* Callbacks *)
 let jump node =
-(*
- print_string ("jump: " ^ s ^ "\n") ;
- flush stdout
-*) ()
+ let module M = Minidom in
+  print_string ("jump: " ^
+   (match
+     M.node_get_attribute node
+      (M.mDOMString_of_string "href")
+    with
+       None   -> "DOES NOT WORKS (if you have clicked on the hyperlink)!!!!!" 
+     | Some s -> M.string_of_mDOMString s
+   ) ^ "\n");
+  flush stdout
 ;;
 
 let selection_changed node =
-(*
- print_string ("jump: " ^ s ^ "\n") ;
- flush stdout
-*) ()
+ let module M = Minidom in
+  print_string ("selection_changed: " ^
+   (match node with
+       None -> "selection_changed on nothing"
+     | Some node ->
+        match M.node_get_name node with
+           None   -> "selection_changed on a node without name" 
+         | Some s -> "selection changed on " ^ M.string_of_mDOMString s
+   ) ^ "\n");
+  flush stdout
 ;;
 
+
 let clicked node =
-(*
- print_string "clicked: IT WORKS\n" ;
- flush stdout
-*) ()
+ let module M = Minidom in
+  print_string ("clicked: " ^
+   (match M.node_get_name node with
+       None   -> "Nothing clicked (???)" 
+     | Some s -> M.string_of_mDOMString s ^ " clicked"
+   ) ^ "\n");
+  flush stdout
 ;;
 
+
 let activate_t1 mathview sw () =
  sw#remove !mathview#coerce ;
  mathview :=
@@ -45,29 +62,35 @@ let load mathview () =
  flush stdout
 ;;
 
-exception Ok;;
 let get_selection mathview () =
-(*
  let selection =
   match !mathview#get_selection with
      None -> "NO SELECTION"
-   | Some s -> s
+   | Some node ->
+      match Minidom.node_get_name node with
+        None   -> "selection is on nothing" 
+      | Some s -> "selection is on " ^ Minidom.string_of_mDOMString s
  in
   print_string ("get_selection: " ^ selection ^ "\n") ;
   flush stdout
-*) ()
 ;;
 
 let set_selection mathview () =
-(*
- let selection =
-  match !mathview#get_selection with
-     None -> "NO SELECTION"
-   | Some s -> s
- in
-  print_string ("get_selection: " ^ selection ^ "\n") ;
-  flush stdout
-*) ()
+ begin
+  try
+   match !mathview#get_selection with
+      None -> raise Not_found
+    | Some node ->
+       match Minidom.node_get_parent node with
+          None -> raise Not_found
+        | Some node ->
+           !mathview#set_selection (Some node) ;
+           print_string "set_selection: SEEMS TO WORK\n"
+  with
+   Not_found ->
+    print_string "set_selection: YOU MUST PREVIOUSLY SELECT A NON-ROOT NODE" 
+ end ;
+ flush stdout
 ;;
 
 let unload mathview () =
@@ -198,7 +221,6 @@ let main_window = GWindow.window ~title:"GtkMathView test" () in
 let vbox = GPack.vbox ~packing:main_window#add () in
 let sw = GBin.scrolled_window ~width:50 ~height:50 ~packing:vbox#pack () in
 let mathview= ref (GMathView.math_view ~packing:sw#add ~width:50 ~height:50 ()) in
-(*let hbox = GPack.hbox ~packing:vbox#pack () in*)
 let table = GPack.table ~rows:5 ~columns:5 ~packing:vbox#pack () in
 let button_t1=GButton.button ~label:"activate t1 fonts" ~packing:(table#attach ~left:0 ~top:0) () in
 let button_load = GButton.button ~label:"load" ~packing:(table#attach ~left:1 ~top:0) () in