+ selection_changed <- self#set_selection ;
+
+ ignore
+ (self#connect#select_begin
+ (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), _, _, _) ->
+ let new_selected =
+ match first_selected, elem with
+ Some first', Some last' ->
+ (Some
+ (new Gdome.element_of_node
+ (common_ancestor (first' :> Gdome.node) (last' :> Gdome.node))))
+ | _ -> None
+ in
+ if not (same_element root_selected new_selected) then
+ selection_changed new_selected)) ;
+
+ ignore
+ (self#connect#select_end
+ (fun ((elem : Gdome.element option), _, _, _) -> first_selected <- None)) ;
+