method new_tab c =
match topwin#active_view with
None -> ()
| Some v ->
let res =
match child1 with
Some (`View v1) when Oo.id v1 = Oo.id v -> Some (1, v1)
| _ ->
match child2 with
Some (`View v2) when Oo.id v2 = Oo.id v -> Some (2, v2)
| _ -> None
in
match res with
None -> prerr_endline "Can't insert tab here, we should not be here in this paned"
| Some (n, cur_view) ->
paned#remove cur_view#box;
let gn = new gui_notebook topwin () in
(if n = 1 then paned#add1 else paned#add2) gn#notebook#coerce;
gn#set_on_destroy (self#on_child_destroy n);
gn#set_on_label_change (fun _ -> self#on_child_label_change);
if n = 1 then
child1 <- Some (`Notebook gn)
else
child2 <- Some (`Notebook gn);
gn#add_tab None (`View cur_view);
gn#add_tab None c;