From 6a9a80d3c988c355e8067013cb9d34d92404454b Mon Sep 17 00:00:00 2001 From: Luca Padovani Date: Fri, 30 Jul 2004 08:56:16 +0000 Subject: [PATCH] * fixed bug of multiple selections * minor code cleanup --- helm/DEVEL/lablgtkmathview/gMathView.mli | 10 +++++----- helm/DEVEL/lablgtkmathview/gMathViewAux.ml | 19 ++++++++++--------- helm/DEVEL/lablgtkmathview/gtkMathView.props | 8 ++++---- helm/DEVEL/lablgtkmathview/test/test.ml | 6 +++--- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/helm/DEVEL/lablgtkmathview/gMathView.mli b/helm/DEVEL/lablgtkmathview/gMathView.mli index 9ec204d51..bf5b56e2a 100644 --- a/helm/DEVEL/lablgtkmathview/gMathView.mli +++ b/helm/DEVEL/lablgtkmathview/gMathView.mli @@ -32,15 +32,15 @@ class math_view_signals : val after: bool val obj: 'b Gtk.obj method click : - callback:(Gdome.element option -> int -> unit) -> GtkSignal.id + callback:(Gdome.element option * int * int * int -> unit) -> GtkSignal.id method element_over : - callback:(Gdome.element option -> int -> unit) -> GtkSignal.id + callback:(Gdome.element option * int * int * int -> unit) -> GtkSignal.id method select_begin : - callback:(Gdome.element option -> int -> unit) -> GtkSignal.id + callback:(Gdome.element option * int * int * int -> unit) -> GtkSignal.id method select_over : - callback:(Gdome.element option -> int -> unit) -> GtkSignal.id + callback:(Gdome.element option * int * int * int -> unit) -> GtkSignal.id method select_end : - callback:(Gdome.element option -> int -> unit) -> GtkSignal.id + callback:(Gdome.element option * int * int * int -> unit) -> GtkSignal.id method select_abort : callback:(unit -> unit) -> GtkSignal.id end diff --git a/helm/DEVEL/lablgtkmathview/gMathViewAux.ml b/helm/DEVEL/lablgtkmathview/gMathViewAux.ml index 01465cb0a..8dfb919ba 100644 --- a/helm/DEVEL/lablgtkmathview/gMathViewAux.ml +++ b/helm/DEVEL/lablgtkmathview/gMathViewAux.ml @@ -156,13 +156,13 @@ class single_selection_math_view obj = ignore (self#connect#select_begin - (fun (elem : Gdome.element option) _ -> + (fun ((elem : Gdome.element option), _, _, _) -> if not (same_element root_selected elem) then selection_changed elem ; first_selected <- elem)) ; ignore (self#connect#select_over - (fun (elem : Gdome.element option) _ -> + (fun ((elem : Gdome.element option), _, _, _) -> let new_selected = match first_selected, elem with Some first', Some last' -> @@ -176,7 +176,7 @@ class single_selection_math_view obj = ignore (self#connect#select_end - (fun (elem : Gdome.element option) _ -> first_selected <- None)) ; + (fun ((elem : Gdome.element option), _, _, _) -> first_selected <- None)) ; ignore (self#connect#select_abort @@ -184,7 +184,7 @@ class single_selection_math_view obj = first_selected <- None ; selection_changed None)) ; - ignore (self#connect#click (fun _ _ -> self#set_selection None)) + ignore (self#connect#click (fun _ -> self#set_selection None)) end ;; @@ -226,8 +226,9 @@ class multi_selection_math_view obj = self#thaw method add_selection (elem : Gdome.element) = + List.iter self#unselect selected ; selected <- elem::(remove_descendants_of elem selected) ; - self#select elem + List.iter self#select selected method get_selections = selected @@ -249,13 +250,13 @@ class multi_selection_math_view obj = initializer ignore (self#connect#select_begin - (fun _ state -> + (fun (_,_,_,state) -> if not (List.mem `CONTROL (Gdk.Convert.modifier state)) then self#remove_selections)) ; ignore (self#connect#select_over - (fun _ state -> + (fun (_,_,_,state) -> let c = function `SHIFT -> "shift " @@ -270,7 +271,7 @@ class multi_selection_math_view obj = ignore (self#connect#select_end - (fun _ state -> + (fun (_,_,_,state) -> if not (List.mem `CONTROL (Gdk.Convert.modifier state)) then self#remove_selections ; match root_selected with @@ -279,7 +280,7 @@ class multi_selection_math_view obj = ignore (self#connect#click - (fun _ _ -> self#remove_selections)) + (fun _ -> self#remove_selections)) end ;; diff --git a/helm/DEVEL/lablgtkmathview/gtkMathView.props b/helm/DEVEL/lablgtkmathview/gtkMathView.props index cd4c5b190..d26050ce4 100644 --- a/helm/DEVEL/lablgtkmathview/gtkMathView.props +++ b/helm/DEVEL/lablgtkmathview/gtkMathView.props @@ -16,9 +16,9 @@ external gdome_element_option_of_boxed_option : "ml_gtk_math_view_gdome_element_option_of_boxed_option" ;; -external model_event_of_boxed_option model_event : - Gpointer.boxed -> TElement.t option * gint * gint * gint = - "ml_gtk_math_view_model_event_of_boxed" +external model_event_of_boxed_option : + Gpointer.boxed option -> TElement.t option * int * int * int = + "ml_gtk_math_view_model_event_of_boxed_option" let option_element_of_option = function @@ -32,7 +32,7 @@ let option_element_of_boxed_option x = let model_event_of_boxed model_event = let id,x,y,state = model_event_of_boxed_option model_event in - option_element_of_boxed_option id,x,y,state + option_element_of_option id,x,y,state ;; let gdome_element_option_conv = diff --git a/helm/DEVEL/lablgtkmathview/test/test.ml b/helm/DEVEL/lablgtkmathview/test/test.ml index 3561c551c..6a54c3463 100644 --- a/helm/DEVEL/lablgtkmathview/test/test.ml +++ b/helm/DEVEL/lablgtkmathview/test/test.ml @@ -88,7 +88,7 @@ let selection_changed mathview (element : Gdome.element option) = flush stdout ;; -let element_over mathview (element : Gdome.element option) _ = +let element_over mathview ((element : Gdome.element option), _, _, _) = print_endline ("element_over: " ^ (match element with None -> "element_over on nothing" @@ -150,7 +150,7 @@ let rec action mathview (element : Gdome.element) = end | None -> assert false (* every element has a parent *) -let click mathview (element : Gdome.element option) _ = +let click mathview ((element : Gdome.element option), _, _, _) = let module G = Gdome in match element with None -> print_string "CLICKED ON NOTHING\n" ; flush stdout @@ -177,7 +177,7 @@ let test_get_selection mathview () = let selection = match mathview#get_selection with Some element -> element#get_tagName#to_string - | None -> "no selection!" + | None -> "no selection! but there are " ^ (string_of_int (List.length mathview#get_selections)) ^ " multiple selections!" in print_string ("selection: " ^ selection ^ "\n") ; flush stdout -- 2.39.2