From cd82ace8c05648fbfcc19b78f17fbe6536fa10a2 Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Wed, 8 Nov 2000 14:29:55 +0000 Subject: [PATCH] Fixing the selections --- .../gtkMathView.ml | 17 +++++++------ .../minidom/ml_minidom.h | 1 + .../ml_gtk_mathview.c | 24 ++++++++++++++++--- .../test/test.ml | 17 ++++++------- 4 files changed, 41 insertions(+), 18 deletions(-) diff --git a/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.0/gtkMathView.ml b/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.0/gtkMathView.ml index 62cd5409d..97ae38e32 100644 --- a/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.0/gtkMathView.ml +++ b/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.0/gtkMathView.ml @@ -4,8 +4,13 @@ open Tags 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" @@ -17,11 +22,9 @@ module MathView = struct "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" @@ -82,7 +85,7 @@ module MathView = struct 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 } diff --git a/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.0/minidom/ml_minidom.h b/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.0/minidom/ml_minidom.h index 318b7f067..2a812ae0f 100644 --- a/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.0/minidom/ml_minidom.h +++ b/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.0/minidom/ml_minidom.h @@ -3,3 +3,4 @@ #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) diff --git a/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.0/ml_gtk_mathview.c b/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.0/ml_gtk_mathview.c index 184977e5e..84e21a6c8 100644 --- a/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.0/ml_gtk_mathview.c +++ b/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.0/ml_gtk_mathview.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -25,8 +26,8 @@ ML_3 (gtk_math_view_new,GtkAdjustment_val, GtkAdjustment_val, Bool_val, Val_GtkW 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) @@ -84,7 +85,7 @@ value ml_gtk_math_view_mDOMNode_of_bodex_option (value arg1) CAMLlocal1 (tmp); if (arg1==Val_int(0)) { - nr = NULL; + assert(0); } else { tmp = Field(arg1, 0); nr = (mDOMNodeRef) Field(tmp, 1); @@ -92,3 +93,20 @@ value ml_gtk_math_view_mDOMNode_of_bodex_option (value arg1) 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)); +} diff --git a/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.0/test/test.ml b/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.0/test/test.ml index 4f9af18e5..1550a0642 100644 --- a/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.0/test/test.ml +++ b/helm/DEVEL/lablgtk_gtkmathview/lablgtk-20000829_gtkmathview-0.2.0/test/test.ml @@ -32,9 +32,12 @@ let jump node = 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 ;; @@ -70,10 +73,9 @@ let load mathview () = 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 @@ -85,14 +87,13 @@ let get_selection mathview () = 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 -> -- 2.39.2