+
+void
+Controls::show_extended_player_controls (bool s)
+{
+ _cpl->Show (s);
+ if (s) {
+ update_dcp_directory ();
+ }
+ _spl_view->Show (s);
+ _log->Show (s);
+ _add_button->Show (s);
+ _v_sizer->Layout ();
+}
+
+void
+Controls::add_cpl_to_list (shared_ptr<dcp::CPL> cpl, wxListCtrl* ctrl)
+{
+ list<shared_ptr<dcp::Reel> > reels = cpl->reels ();
+
+ int const N = ctrl->GetItemCount();
+
+ wxListItem it;
+ if (!reels.empty() && reels.front()->main_picture()) {
+ it.SetId(N);
+ it.SetColumn(0);
+ int seconds = rint(double(cpl->duration()) / reels.front()->main_picture()->frame_rate().as_float());
+ int minutes = seconds / 60;
+ seconds -= minutes * 60;
+ int hours = minutes / 60;
+ minutes -= hours * 60;
+ it.SetText(wxString::Format("%02d:%02d:%02d", hours, minutes, seconds));
+ ctrl->InsertItem(it);
+ }
+
+ it.SetId(N);
+ it.SetColumn(1);
+ it.SetText(std_to_wx(dcp::content_kind_to_string(cpl->content_kind())));
+ ctrl->SetItem(it);
+
+ it.SetId(N);
+ it.SetColumn(2);
+ it.SetText(std_to_wx(cpl->annotation_text()));
+ ctrl->SetItem(it);
+}
+
+void
+Controls::update_dcp_directory ()
+{
+ if (!_cpl->IsShown()) {
+ return;
+ }
+
+ using namespace boost::filesystem;
+
+ _cpl->DeleteAllItems ();
+ _cpls.clear ();
+ optional<path> dir = Config::instance()->player_dcp_directory();
+ if (!dir) {
+ return;
+ }
+
+ for (directory_iterator i = directory_iterator(*dir); i != directory_iterator(); ++i) {
+ try {
+ if (is_directory(*i) && (is_regular_file(*i / "ASSETMAP") || is_regular_file(*i / "ASSETMAP.xml"))) {
+ string const x = i->path().string().substr(dir->string().length() + 1);
+ dcp::DCP dcp (*i);
+ dcp.read ();
+ BOOST_FOREACH (shared_ptr<dcp::CPL> j, dcp.cpls()) {
+ add_cpl_to_list (j, _cpl);
+ _cpls.push_back (make_pair(j, *i));
+ }
+ }
+ } catch (boost::filesystem::filesystem_error& e) {
+ /* Never mind */
+ }
+ }
+}
+
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+void
+Controls::pause_clicked ()
+{
+ _viewer->stop ();
+}
+
+void
+Controls::stop_clicked ()
+{
+ _viewer->stop ();
+ _viewer->seek (DCPTime(), true);
+}
+#endif
+
+void
+Controls::log (wxString s)
+{
+ struct timeval time;
+ gettimeofday (&time, 0);
+ char buffer[64];
+ time_t const sec = time.tv_sec;
+ struct tm* t = localtime (&sec);
+ strftime (buffer, 64, "%c", t);
+ wxString ts = std_to_wx(string(buffer)) + N_(": ");
+ _log->SetValue(_log->GetValue() + ts + s + "\n");
+}
+
+void
+Controls::image_changed (boost::weak_ptr<PlayerVideo> weak_pv)
+{
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+ shared_ptr<PlayerVideo> pv = weak_pv.lock ();
+ if (!pv) {
+ return;
+ }
+
+ shared_ptr<Content> c = pv->content().lock();
+ if (!c) {
+ return;
+ }
+
+ shared_ptr<DCPContent> dc = dynamic_pointer_cast<DCPContent> (c);
+ if (!dc) {
+ return;
+ }
+
+ if (!_current_kind || *_current_kind != dc->content_kind()) {
+ _current_kind = dc->content_kind ();
+ setup_sensitivity ();
+ }
+#endif
+}