method add_view (v : Ed_view.gui_view) =
match topwin#active_view with
None -> ()
| Some av ->
let res =
match child1 with
Some (`View v1) when Oo.id v1 = Oo.id av -> Some (1, v1)
| _ ->
match child2 with
Some (`View v2) when Oo.id v2 = Oo.id av -> Some (2, v2)
| _ -> None
in
match res with
None -> prerr_endline "Can't insert view here, we should not be here in this paned"
| Some (n, cur_view) ->
paned#remove cur_view#box;
let gp = new gui_paned topwin orientation () in
(if n = 1 then paned#add1 else paned#add2) gp#paned#coerce;
gp#set_on_destroy (self#on_child_destroy n);
gp#set_on_label_change (fun _ -> self#on_child_label_change);
if n = 1 then
child1 <- Some (`Paned gp)
else
child2 <- Some (`Paned gp);
gp#set_children_views cur_view v;
v#grab_focus