method on_tab_destroy c new_c =
      match self#tab_of_contents c with
        None -> ()
      | Some n ->
          tabs <- List.filter
              (fun (_,c2) -> id_of_contents c2 <> id_of_contents c) tabs;
          nb#remove_page n;
          match new_c, tabs with
            None, []
          | None, [_] -> self#destroy
          | None, _ -> ()
          | Some new_c, [] ->
              on_destroy (Some new_c);
              nb#destroy ()
          | Some new_c, _ ->
              self#add_tab (Some n) new_c