+
+ if (go_to && Config::instance()->jump_to_selected ()) {
+ _film_viewer->set_position (go_to.get().ceil(_film->video_frame_rate()));
+ }
+
+ 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_caption[CAPTION_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<CaptionContent> j, i->caption) {
+ have_caption[j->original_type()] = true;
+ }
+ }
+
+ bool video_panel = false;
+ bool audio_panel = false;
+ bool caption_panel[CAPTION_COUNT] = { false, false };
+ for (size_t i = 0; i < _notebook->GetPageCount(); ++i) {
+ if (_notebook->GetPage(i) == _video_panel) {
+ video_panel = true;
+ } else if (_notebook->GetPage(i) == _audio_panel) {
+ audio_panel = true;
+ }
+ for (int j = 0; j < CAPTION_COUNT; ++j) {
+ if (_notebook->GetPage(i) == _caption_panel[j]) {
+ caption_panel[j] = true;
+ }
+ }
+ }
+
+ int off = 0;
+
+ if (have_video != video_panel) {
+ if (video_panel) {
+ _notebook->RemovePage (off);
+ }
+ if (have_video) {
+ _notebook->InsertPage (off, _video_panel, _video_panel->name());
+ }
+ }
+
+ if (have_video) {
+ ++off;
+ }
+
+ if (have_audio != audio_panel) {
+ if (audio_panel) {
+ _notebook->RemovePage (off);
+ }
+ if (have_audio) {
+ _notebook->InsertPage (off, _audio_panel, _audio_panel->name());
+ }
+ }
+
+ if (have_audio) {
+ ++off;
+ }
+
+ for (int i = 0; i < CAPTION_COUNT; ++i) {
+ if (have_caption[i] != caption_panel[i]) {
+ if (caption_panel[i]) {
+ _notebook->RemovePage (off);
+ }
+ if (have_caption[i]) {
+ _notebook->InsertPage (off, _caption_panel[i], _caption_panel[i]->name());
+ }
+ }
+ if (have_caption[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;
+ }
+ }
+
+ if (!done) {
+ _notebook->SetSelection (0);
+ }
+
+ SelectionChanged ();