X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic.cc;h=891c4623ca9b6e1ea1ac995d41108d119468e72f;hb=ad49361b303d1ceff7048fa0e89ba609ca9ce376;hp=4972654b27aabd28ed39674c0f672f2575f7c914;hpb=0c5e306508b1ef7287b6024be919fdda50e3c111;p=dcpomatic.git diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 4972654b2..891c4623c 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -40,6 +40,8 @@ #include "wx/wx_ui_signaller.h" #include "wx/about_dialog.h" #include "wx/kdm_dialog.h" +#include "wx/servers_list_dialog.h" +#include "wx/hints_dialog.h" #include "lib/film.h" #include "lib/config.h" #include "lib/util.h" @@ -51,6 +53,8 @@ #include "lib/exceptions.h" #include "lib/cinema.h" #include "lib/kdm.h" +#include "lib/send_kdm_email_job.h" +#include "lib/server_finder.h" using std::cout; using std::string; @@ -60,7 +64,6 @@ using std::map; using std::make_pair; using std::list; using std::exception; -using std::ofstream; using boost::shared_ptr; using boost::dynamic_pointer_cast; @@ -180,6 +183,8 @@ enum { ID_jobs_make_kdms, ID_jobs_send_dcp_to_tms, ID_jobs_show_dcp, + ID_tools_hints, + ID_tools_encoding_servers, }; void @@ -216,6 +221,10 @@ setup_menu (wxMenuBar* m) add_item (jobs_menu, _("&Send DCP to TMS"), ID_jobs_send_dcp_to_tms, NEEDS_FILM | NOT_DURING_DCP_CREATION | NEEDS_DCP); add_item (jobs_menu, _("S&how DCP"), ID_jobs_show_dcp, NEEDS_FILM | NOT_DURING_DCP_CREATION | NEEDS_DCP); + wxMenu* tools = new wxMenu; + add_item (tools, _("Hints..."), ID_tools_hints, 0); + add_item (tools, _("Encoding Servers..."), ID_tools_encoding_servers, 0); + wxMenu* help = new wxMenu; #ifdef __WXOSX__ add_item (help, _("About DCP-o-matic"), wxID_ABOUT, ALWAYS); @@ -228,6 +237,7 @@ setup_menu (wxMenuBar* m) m->Append (edit, _("&Edit")); #endif m->Append (jobs_menu, _("&Jobs")); + m->Append (tools, _("&Tools")); m->Append (help, _("&Help")); } @@ -236,22 +246,42 @@ class Frame : public wxFrame public: Frame (wxString const & title) : wxFrame (NULL, -1, title) + , _hints_dialog (0) + , _servers_list_dialog (0) { +#ifdef DCPOMATIC_WINDOWS_CONSOLE + AllocConsole(); + + HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE); + int hCrt = _open_osfhandle((intptr_t) handle_out, _O_TEXT); + FILE* hf_out = _fdopen(hCrt, "w"); + setvbuf(hf_out, NULL, _IONBF, 1); + *stdout = *hf_out; + + HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE); + hCrt = _open_osfhandle((intptr_t) handle_in, _O_TEXT); + FILE* hf_in = _fdopen(hCrt, "r"); + setvbuf(hf_in, NULL, _IONBF, 128); + *stdin = *hf_in; +#endif + wxMenuBar* bar = new wxMenuBar; setup_menu (bar); SetMenuBar (bar); - Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_new, this), ID_file_new); - Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_open, this), ID_file_open); - Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_save, this), ID_file_save); - Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_properties, this), ID_file_properties); - Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_exit, this), wxID_EXIT); - Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::edit_preferences, this), wxID_PREFERENCES); - Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_make_dcp, this), ID_jobs_make_dcp); - Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_make_kdms, this), ID_jobs_make_kdms); - Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_send_dcp_to_tms, this), ID_jobs_send_dcp_to_tms); - Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_show_dcp, this), ID_jobs_show_dcp); - Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::help_about, this), wxID_ABOUT); + Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_new, this), ID_file_new); + Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_open, this), ID_file_open); + Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_save, this), ID_file_save); + Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_properties, this), ID_file_properties); + Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_exit, this), wxID_EXIT); + Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::edit_preferences, this), wxID_PREFERENCES); + Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_make_dcp, this), ID_jobs_make_dcp); + Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_make_kdms, this), ID_jobs_make_kdms); + Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_send_dcp_to_tms, this), ID_jobs_send_dcp_to_tms); + Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_show_dcp, this), ID_jobs_show_dcp); + Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::tools_hints, this), ID_tools_hints); + Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::tools_encoding_servers, this), ID_tools_encoding_servers); + Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::help_about, this), wxID_ABOUT); Bind (wxEVT_CLOSE_WINDOW, boost::bind (&Frame::close, this, _1)); @@ -320,7 +350,7 @@ private: std_to_wx ( String::compose (wx_to_std (_("The directory %1 already exists and is not empty. " "Are you sure you want to use it?")), - d->get_path().c_str()) + d->get_path().string().c_str()) ) )) { return; @@ -346,7 +376,13 @@ private: void file_open () { - wxDirDialog* c = new wxDirDialog (this, _("Select film to open"), wxStandardPaths::Get().GetDocumentsDir(), wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST); + wxDirDialog* c = new wxDirDialog ( + this, + _("Select film to open"), + std_to_wx (Config::instance()->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir())).string ()), + wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST + ); + int r; while (1) { r = c->ShowModal (); @@ -425,7 +461,9 @@ private: if (d->write_to ()) { write_kdm_files (film, d->screens (), d->dcp (), d->from (), d->until (), d->directory ()); } else { - email_kdms (film, d->screens (), d->dcp (), d->from (), d->until ()); + JobManager::instance()->add ( + shared_ptr (new SendKDMEmailJob (film, d->screens (), d->dcp (), d->from (), d->until ())) + ); } } catch (KDMError& e) { error_dialog (this, e.what ()); @@ -465,6 +503,24 @@ private: #endif } + void tools_hints () + { + if (!_hints_dialog) { + _hints_dialog = new HintsDialog (this, film); + } + + _hints_dialog->Show (); + } + + void tools_encoding_servers () + { + if (!_servers_list_dialog) { + _servers_list_dialog = new ServersListDialog (this); + } + + _servers_list_dialog->Show (); + } + void help_about () { AboutDialog* d = new AboutDialog (this); @@ -497,8 +553,13 @@ private: return; } + maybe_save_then_delete_film (); + ev.Skip (); - } + } + + HintsDialog* _hints_dialog; + ServersListDialog* _servers_list_dialog; }; static const wxCmdLineEntryDesc command_line_description[] = { @@ -572,8 +633,12 @@ class App : public wxApp f->Show (); ui_signaller = new wxUISignaller (this); - this->Bind (wxEVT_IDLE, boost::bind (&App::idle, this)); + Bind (wxEVT_IDLE, boost::bind (&App::idle, this)); + Bind (wxEVT_TIMER, boost::bind (&App::check, this)); + _timer.reset (new wxTimer (this)); + _timer->Start (1000); + return true; } catch (exception& e) @@ -610,6 +675,17 @@ class App : public wxApp { ui_signaller->ui_idle (); } + + void check () + { + try { + ServerFinder::instance()->rethrow (); + } catch (exception& e) { + error_dialog (0, std_to_wx (e.what ())); + } + } + + shared_ptr _timer; }; IMPLEMENT_APP (App)