+ BOOST_FOREACH (ContentSubPanel* i, panels()) {
+ i->content_selection_changed ();
+ }
+
+ optional<DCPTime> go_to;
+ BOOST_FOREACH (shared_ptr<Content> i, selected()) {
+ DCPTime p;
+ p = i->position();
+ if (dynamic_pointer_cast<StringTextFileContent>(i) && i->paths_valid()) {
+ /* Rather special case; if we select a text subtitle file jump to its
+ first subtitle.
+ */
+ StringTextFile ts (dynamic_pointer_cast<StringTextFileContent>(i));
+ if (ts.first()) {
+ p += DCPTime(ts.first().get(), _film->active_frame_rate_change(i->position()));
+ }
+ }
+ if (!go_to || p < go_to.get()) {
+ go_to = p;
+ }
+ }
+
+ if (go_to && Config::instance()->jump_to_selected() && signal_manager) {
+ shared_ptr<FilmViewer> fv = _film_viewer.lock ();
+ DCPOMATIC_ASSERT (fv);
+ signal_manager->when_idle(boost::bind(&FilmViewer::seek, fv.get(), go_to.get().ceil(_film->video_frame_rate()), true));
+ }
+
+ if (_timeline_dialog) {
+ _timeline_dialog->set_selection (selected());
+ }
+
+ /* Make required tabs visible */
+
+ if (_notebook->GetPageCount() > 1) {
+ /* There's more than one tab in the notebook so the current selection could be meaningful
+ to the user; store it so that we can try to restore it later.
+ */
+ _last_selected_tab = 0;
+ if (_notebook->GetSelection() != wxNOT_FOUND) {
+ _last_selected_tab = _notebook->GetPage(_notebook->GetSelection());
+ }
+ }
+
+ bool have_video = false;
+ bool have_audio = false;
+ bool have_text[TEXT_COUNT] = { false, false };
+ BOOST_FOREACH (shared_ptr<Content> i, selected()) {
+ if (i->video) {
+ have_video = true;
+ }
+ if (i->audio) {
+ have_audio = true;
+ }
+ BOOST_FOREACH (shared_ptr<TextContent> j, i->text) {
+ have_text[j->original_type()] = true;
+ }
+ }
+
+ int off = 0;
+
+ if (have_video && !_video_panel) {
+ _video_panel = new VideoPanel (this);
+ _notebook->InsertPage (off, _video_panel, _video_panel->name());
+ } else if (!have_video && _video_panel) {
+ _notebook->DeletePage (off);
+ _video_panel = 0;
+ }
+
+ if (have_video) {
+ ++off;
+ }
+
+ if (have_audio && !_audio_panel) {
+ _audio_panel = new AudioPanel (this);
+ _notebook->InsertPage (off, _audio_panel, _audio_panel->name());
+ } else if (!have_audio && _audio_panel) {
+ _notebook->DeletePage (off);
+ _audio_panel = 0;
+ }
+
+ if (have_audio) {
+ ++off;
+ }
+
+ for (int i = 0; i < TEXT_COUNT; ++i) {
+ if (have_text[i] && !_text_panel[i]) {
+ _text_panel[i] = new TextPanel (this, static_cast<TextType>(i));
+ _notebook->InsertPage (off, _text_panel[i], _text_panel[i]->name());
+ } else if (!have_text[i] && _text_panel[i]) {
+ _notebook->DeletePage (off);
+ _text_panel[i] = 0;
+ }
+ if (have_text[i]) {
+ ++off;
+ }
+ }
+
+ /* Set up the tab selection */
+
+ bool done = false;
+ for (size_t i = 0; i < _notebook->GetPageCount(); ++i) {
+ if (_notebook->GetPage(i) == _last_selected_tab) {
+ _notebook->SetSelection (i);
+ done = true;
+ }