let jump (node : Ominidom.o_mDOMNode) =
let module O = Ominidom in
print_string ("jump: " ^
- (try
- let href = node#get_attribute (O.o_mDOMString_of_string "href") in
- href#get_string
- with
- O.Minidom_exception s -> "EXCEPTION: " ^ s
+ (match node#get_attribute (O.o_mDOMString_of_string "href") with
+ | Some x -> x#get_string
+ | None -> "NO HREF FOR THIS NODE"
) ^ "\n");
flush stdout
;;
(match node with
None -> "selection_changed on nothing"
| Some node ->
- try
- mathview#set_selection node ;
- let node_name = node#get_name in
- node_name#get_string
- with
- O.Minidom_exception s -> "EXCEPTION: " ^ s
+ match node#get_name with
+ | Some x -> x#get_string
+ | None -> "on element without name"
) ^ "\n");
+ mathview#set_selection node;
flush stdout
;;
let clicked (node : Ominidom.o_mDOMNode) =
let module O = Ominidom in
print_string ("clicked: " ^
- (try
- let node_name = node#get_name in
- node_name#get_string
- with
- O.Minidom_exception s -> "EXCEPTION: " ^ s
+ (match node#get_name with
+ | Some x -> x#get_string
+ | None -> "no name"
) ^ "\n");
flush stdout
;;
let activate_t1 mathview () =
- mathview#set_font_manager_type GtkMathView.MathView.FontManagerT1;
+ mathview#set_font_manager_type `font_manager_t1;
print_string "WIDGET SET WITH T1 FONTS\n" ;
flush stdout
;;
let activate_gtk mathview () =
- mathview#set_font_manager_type GtkMathView.MathView.FontManagerGtk;
+ mathview#set_font_manager_type `font_manager_gtk;
print_string "WIDGET SET WITH GTK FONTS\n" ;
flush stdout
;;
print_string "CURRENT FONT MANAGER TYPE: ";
begin
match mathview#get_font_manager_type with
- | GtkMathView.MathView.FontManagerT1 -> print_string "T1"
- | GtkMathView.MathView.FontManagerGtk -> print_string "GTK"
+ | `font_manager_t1 -> print_string "T1"
+ | `font_manager_gtk -> print_string "GTK"
end;
print_newline();
flush stdout
let get_selection mathview () =
let module O = Ominidom in
let selection =
- if not mathview#has_selection then "nothing"
- else
- let node = mathview#get_selection in
- (try node#get_name#get_string
- with
- O.Minidom_exception s -> "EXCEPTION: " ^ s
- )
+ match mathview#get_selection with
+ | Some node ->
+ begin
+ match node#get_name with
+ | Some name -> name#get_string
+ | None -> "element with no name!"
+ end
+ | None -> "no selection!"
in
print_string ("get_selection: " ^ selection ^ "\n") ;
flush stdout
let set_selection mathview () =
let module O = Ominidom in
begin
- try
- let selected_node = mathview#get_selection in
- try
- let parent_node = selected_node#get_parent in
- mathview#set_selection parent_node;
- print_string "set selection: SEEMS TO WORK\n"
- with
- O.Minidom_exception s ->
- print_string ("EXCEPTION: " ^ s ^ "\n")
- with
- GtkMathView.MathView.NoSelection ->
- print_string "set_selection: YOU MUST PREVIOUSLY SELECT A NON-ROOT NODE\n"
+ match mathview#get_selection with
+ | Some node ->
+ begin
+ try
+ let parent_node = node#get_parent in
+ mathview#set_selection (Some parent_node);
+ print_string "set selection: SEEMS TO WORK\n"
+ with
+ _ -> print_string "EXCEPTION: no parent\n"
+ end
+ | None ->
+ mathview#set_selection None;
+ print_string "no selection\n"
end ;
flush stdout
;;
-let reset_selection mathview () =
- mathview#reset_selection ;
- print_string "reset_selection: SEEMS TO WORK\n" ;
- flush stdout
-;;
-
let unload mathview () =
mathview#unload ;
print_string "unload: SEEMS TO WORK\n" ;
flush stdout
;;
-let export_to_postscript mathview () =
- mathview#export_to_postscript 595 822 72 72 false "test.ps" ;
+let export_to_postscript (mathview : GMathView.math_view) () =
+ mathview#export_to_postscript ~filename:"test.ps" ();
print_string "expor_to_postscript: SEEMS TO WORK (hint: look at test.ps)\n";
flush stdout
;;
let button_export_to_postscript = GButton.button ~label:"export_to_postscript" ~packing:(table#attach ~left:2 ~top:4) () in
let button_t1 = GButton.button ~label:"activate T1 fonts" ~packing:(table#attach ~left:3 ~top:4) () in
let button_get_font_manager_type = GButton.button ~label:"get_font_manager" ~packing:(table#attach ~left:4 ~top:4) () in
-let button_reset_selection = GButton.button ~label:"reset_selection" ~packing:(table#attach ~left:0 ~top:5) () in
(* Signals connection *)
ignore(button_gtk#connect#clicked (activate_gtk mathview)) ;
ignore(button_load#connect#clicked (load mathview)) ;
ignore(button_unload#connect#clicked (unload mathview)) ;
ignore(button_get_selection#connect#clicked (get_selection mathview)) ;
ignore(button_set_selection#connect#clicked (set_selection mathview)) ;
-ignore(button_reset_selection#connect#clicked (reset_selection mathview)) ;
ignore(button_get_width#connect#clicked (get_width mathview)) ;
ignore(button_get_height#connect#clicked (get_height mathview)) ;
ignore(button_get_top#connect#clicked (get_top mathview)) ;