open GtkBase
open Gpointer
-external mDOMNode_of_boxed_option : Gpointer.boxed option -> Minidom.mDOMNode =
- "ml_gtk_math_view_mDOMNode_of_bodex_option"
+external mDOMNode_of_boxed_option :
+ Gpointer.boxed option -> Minidom.mDOMNode =
+ "ml_gtk_math_view_mDOMNode_of_bodex_option"
+
+external mDOMNode_option_of_boxed_option :
+ Gpointer.boxed option -> Minidom.mDOMNode option =
+ "ml_gtk_math_view_mDOMNode_option_of_bodex_option"
module MathView = struct
let cast w : math_view obj = Object.try_cast w "GtkMathView"
"ml_gtk_math_view_load"
external unload : [>`math_view] obj -> unit =
"ml_gtk_math_view_unload"
- (*external dump : [>`math_view] obj -> unit =
- "ml_gtk_math_view_dump"*)
- external get_selection : [>`math_view] obj -> Minidom.mDOMNode =
+ external get_selection : [>`math_view] obj -> Minidom.mDOMNode option =
"ml_gtk_math_view_get_selection"
- external set_selection : [>`math_view] obj -> Minidom.mDOMNode -> unit =
+ external set_selection : [>`math_view] obj -> Minidom.mDOMNode option -> unit=
"ml_gtk_math_view_set_selection"
external get_width : [>`math_view] obj -> int =
"ml_gtk_math_view_get_width"
let selection_changed : ([>`math_view],_) t =
let marshal_selection_changed f _ =
function
- [GtkArgv.POINTER node] -> f (mDOMNode_of_boxed_option node)
+ [GtkArgv.POINTER node] -> f (mDOMNode_option_of_boxed_option node)
| _ -> invalid_arg "GtkMathView.MathView.Signals.marshal_selection_changed"
in
{ name = "selection_changed"; marshaller = marshal_selection_changed }
#define Val_mDOMString(s) (copy_string((char*) (s)))
#define mDOMString_val(v) ((mDOMStringRef) String_val(v))
#define mDOMNode_val(v) ((mDOMNodeRef) v)
+#define Val_mDOMNode_option(p) ((p != NULL) ? ml_some((value) p) : Val_unit)
#include <string.h>
+#include <assert.h>
#include <gtk/gtk.h>
#include <caml/mlvalues.h>
#include <caml/alloc.h>
ML_2 (gtk_math_view_load, GtkMathView_val, String_val, Val_bool)
ML_1 (gtk_math_view_unload, GtkMathView_val, Unit)
/*ML_1 (gtk_math_view_dump, GtkMathView_val, Unit)*/
-ML_1 (gtk_math_view_get_selection, GtkMathView_val, Val_ptr)
-ML_2 (gtk_math_view_set_selection, GtkMathView_val, mDOMNode_val, Unit)
+ML_1 (gtk_math_view_get_selection, GtkMathView_val, Val_mDOMNode_option)
+ML_2 (gtk_math_view_set_selection, GtkMathView_val, mDOMNode_option_val, Unit)
ML_1 (gtk_math_view_get_width, GtkMathView_val, Val_int)
ML_1 (gtk_math_view_get_height, GtkMathView_val, Val_int)
ML_3 (gtk_math_view_set_top, GtkMathView_val, Int_val, Int_val, Unit)
CAMLlocal1 (tmp);
if (arg1==Val_int(0)) {
- nr = NULL;
+ assert(0);
} else {
tmp = Field(arg1, 0);
nr = (mDOMNodeRef) Field(tmp, 1);
CAMLreturn((value) nr);
}
+
+value ml_gtk_math_view_mDOMNode_option_of_bodex_option (value arg1)
+{
+ CAMLparam1(arg1);
+
+ mDOMNodeRef nr;
+ CAMLlocal1 (tmp);
+
+ if (arg1==Val_int(0)) {
+ nr = NULL;
+ } else {
+ tmp = Field(arg1, 0);
+ nr = (mDOMNodeRef) Field(tmp, 1);
+ }
+
+ CAMLreturn(Val_option(nr, Val_ptr));
+}
let selection_changed node =
let module M = Minidom in
print_string ("selection_changed: " ^
- (match M.node_get_name node with
- None -> "selection_changed on nothing"
- | Some s -> "selection changed on " ^ M.string_of_mDOMString s
+ (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 get_selection mathview () =
let selection =
-(* match !mathview#get_selection with
+ match !mathview#get_selection with
None -> "NO SELECTION"
| Some node ->
-*) let node = !mathview#get_selection in
match Minidom.node_get_name node with
None -> "selection is on nothing"
| Some s -> "selection is on " ^ Minidom.string_of_mDOMString s
let set_selection mathview () =
begin
try
-(* match !mathview#get_selection with
+ match !mathview#get_selection with
None -> raise Not_found
| Some node ->
-*) let node = !mathview#get_selection in
match Minidom.node_get_parent node with
None -> raise Not_found
| Some node ->
- !mathview#set_selection node ;
+ !mathview#set_selection (Some node) ;
print_string "set_selection: SEEMS TO WORK\n"
with
Not_found ->