X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Ftools%2Fdvdomatic.cc;h=b5c81da07f2ba8cbcb42318532704264c7f45884;hb=110d7d4e111c2db31489296587d855328c5d8b34;hp=02e2423a2bfdb3a39b5e52d6fd55e5237d1b48bb;hpb=14dd3b728f204906ba29e86b384fed53c2f280cb;p=dcpomatic.git diff --git a/src/tools/dvdomatic.cc b/src/tools/dvdomatic.cc index 02e2423a2..b5c81da07 100644 --- a/src/tools/dvdomatic.cc +++ b/src/tools/dvdomatic.cc @@ -20,16 +20,18 @@ #include #include #include +#include +#include #include "wx/film_viewer.h" #include "wx/film_editor.h" -#ifndef DVDOMATIC_DISABLE_PLAYER -#include "wx/film_player.h" -#endif #include "wx/job_manager_view.h" #include "wx/config_dialog.h" #include "wx/job_wrapper.h" //#include "gtk/dvd_title_dialog.h" #include "wx/wx_util.h" +#include "wx/new_film_dialog.h" +#include "wx/properties_dialog.h" +#include "wx/wx_ui_signaller.h" #include "lib/film.h" #include "lib/format.h" #include "lib/config.h" @@ -37,18 +39,19 @@ #include "lib/util.h" #include "lib/scaler.h" #include "lib/exceptions.h" +#include "lib/version.h" +#include "lib/ui_signaller.h" -using namespace std; -using namespace boost; +using std::string; +using std::stringstream; +using std::map; +using std::make_pair; +using boost::shared_ptr; -static wxFrame* frame = 0; static FilmEditor* film_editor = 0; static FilmViewer* film_viewer = 0; -#ifndef DVDOMATIC_DISABLE_PLAYER -static FilmPlayer* film_player = 0; -#endif -static Film* film = 0; +static shared_ptr film; static void set_menu_sensitivity (); @@ -59,7 +62,7 @@ public: { stringstream s; s << "Save changes to film \"" << film->name() << "\" before closing?"; - _dialog = new wxMessageDialog (frame, std_to_wx (s.str()), wxT ("Film changed"), wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION); + _dialog = new wxMessageDialog (0, std_to_wx (s.str()), wxT ("Film changed"), wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION); } ~FilmChangedDialog () @@ -95,8 +98,7 @@ maybe_save_then_delete_film () } } - delete film; - film = 0; + film.reset (); } enum Sensitivity { @@ -129,6 +131,7 @@ enum { ID_file_new = 1, ID_file_open, ID_file_save, + ID_file_properties, ID_file_quit, ID_edit_preferences, ID_jobs_make_dcp, @@ -148,6 +151,8 @@ setup_menu (wxMenuBar* m) file->AppendSeparator (); add_item (file, "&Save", ID_file_save, NEEDS_FILM); file->AppendSeparator (); + add_item (file, "&Properties...", ID_file_properties, NEEDS_FILM); + file->AppendSeparator (); add_item (file, "&Quit", ID_file_quit, ALWAYS); wxMenu* edit = new wxMenu; @@ -156,7 +161,9 @@ setup_menu (wxMenuBar* m) wxMenu* jobs = new wxMenu; add_item (jobs, "&Make DCP", ID_jobs_make_dcp, NEEDS_FILM); add_item (jobs, "&Send DCP to TMS", ID_jobs_send_dcp_to_tms, NEEDS_FILM); +#ifdef DVDOMATIC_POSIX add_item (jobs, "Copy from &DVD...", ID_jobs_copy_from_dvd, NEEDS_FILM); +#endif jobs->AppendSeparator (); add_item (jobs, "&Examine content", ID_jobs_examine_content, NEEDS_FILM); add_item (jobs, "Make DCP from existing &transcode", ID_jobs_make_dcp_from_existing_transcode, NEEDS_FILM); @@ -177,18 +184,6 @@ window_closed (wxCommandEvent &) return false; } -void -file_changed (string f) -{ - stringstream s; - s << "DVD-o-matic"; - if (!f.empty ()) { - s << " - " << f; - } - - frame->SetTitle (std_to_wx (s.str())); -} - class Frame : public wxFrame { public: @@ -198,40 +193,101 @@ public: wxMenuBar* bar = new wxMenuBar; setup_menu (bar); SetMenuBar (bar); + + Connect (ID_file_new, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_new)); + Connect (ID_file_open, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_open)); + Connect (ID_file_save, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_save)); + Connect (ID_file_properties, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_properties)); + Connect (ID_file_quit, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_quit)); + Connect (ID_edit_preferences, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::edit_preferences)); + Connect (ID_jobs_make_dcp, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_make_dcp)); + Connect (ID_jobs_send_dcp_to_tms, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_send_dcp_to_tms)); + Connect (ID_jobs_copy_from_dvd, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_copy_from_dvd)); + Connect (ID_jobs_examine_content, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_examine_content)); + Connect (ID_jobs_make_dcp_from_existing_transcode, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_make_dcp_from_existing_transcode)); + Connect (ID_help_about, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::help_about)); + + wxPanel* panel = new wxPanel (this); + wxSizer* s = new wxBoxSizer (wxHORIZONTAL); + s->Add (panel, 1, wxEXPAND); + SetSizer (s); + + film_editor = new FilmEditor (film, panel); + film_viewer = new FilmViewer (film, panel); + JobManagerView* job_manager_view = new JobManagerView (panel); + + wxSizer* rhs_sizer = new wxBoxSizer (wxVERTICAL); + rhs_sizer->Add (film_viewer, 3, wxEXPAND | wxALL); + rhs_sizer->Add (job_manager_view, 1, wxEXPAND | wxALL); + + wxBoxSizer* main_sizer = new wxBoxSizer (wxHORIZONTAL); + main_sizer->Add (film_editor, 0, wxALL, 6); + main_sizer->Add (rhs_sizer, 1, wxEXPAND | wxALL, 6); + panel->SetSizer (main_sizer); + + set_menu_sensitivity (); + + /* XXX: calling these here is a bit of a hack */ + film_editor->setup_visibility (); + film_viewer->setup_visibility (); + + film_editor->FileChanged.connect (bind (&Frame::file_changed, this, _1)); + if (film) { + file_changed (film->directory ()); + } else { + file_changed (""); + } + + set_film (); } + void set_film () + { + film_viewer->set_film (film); + film_editor->set_film (film); + set_menu_sensitivity (); + } + + void file_changed (string f) + { + stringstream s; + s << "DVD-o-matic"; + if (!f.empty ()) { + s << " - " << f; + } + + SetTitle (std_to_wx (s.str())); + } + void file_new (wxCommandEvent &) { - wxDirDialog* c = new wxDirDialog (frame, wxT ("New Film")); - int const r = c->ShowModal (); - c->Destroy (); + NewFilmDialog* d = new NewFilmDialog (this); + int const r = d->ShowModal (); if (r == wxID_OK) { maybe_save_then_delete_film (); - film = new Film (wx_to_std (c->GetPath ())); + film.reset (new Film (d->get_path (), false)); #if BOOST_FILESYSTEM_VERSION == 3 - film->set_name (filesystem::path (wx_to_std (c->GetPath())).filename().generic_string()); + film->set_name (boost::filesystem::path (d->get_path()).filename().generic_string()); #else - film->set_name (filesystem::path (wx_to_std (c->GetPath())).filename()); -#endif - film_viewer->set_film (film); - film_editor->set_film (film); - set_menu_sensitivity (); + film->set_name (boost::filesystem::path (d->get_path()).filename()); +#endif + set_film (); } + + d->Destroy (); } void file_open (wxCommandEvent &) { - wxDirDialog* c = new wxDirDialog (frame, wxT ("Open Film"), wxT (""), wxDD_DIR_MUST_EXIST); + wxDirDialog* c = new wxDirDialog (this, wxT ("Select film to open"), wxStandardPaths::Get().GetDocumentsDir(), wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST); int const r = c->ShowModal (); c->Destroy (); if (r == wxID_OK) { maybe_save_then_delete_film (); - film = new Film (wx_to_std (c->GetPath ())); - film_viewer->set_film (film); - film_editor->set_film (film); - set_menu_sensitivity (); + film.reset (new Film (wx_to_std (c->GetPath ()))); + set_film (); } } @@ -239,11 +295,18 @@ public: { film->write_metadata (); } + + void file_properties (wxCommandEvent &) + { + PropertiesDialog* d = new PropertiesDialog (this, film); + d->ShowModal (); + d->Destroy (); + } void file_quit (wxCommandEvent &) { maybe_save_then_delete_film (); - frame->Close (true); + Close (true); } void edit_preferences (wxCommandEvent &) @@ -266,15 +329,16 @@ public: void jobs_copy_from_dvd (wxCommandEvent &) { -// try { + try { + // DVDTitleDialog d; // if (d.run () != Gtk::RESPONSE_OK) { // return; // } -// film->copy_from_dvd (); -// } catch (DVDError& e) { -// error_dialog (e.what ()); -// } + film->copy_from_dvd (); + } catch (DVDError& e) { + error_dialog (this, e.what ()); + } } void jobs_send_dcp_to_tms (wxCommandEvent &) @@ -291,13 +355,14 @@ public: { wxAboutDialogInfo info; info.SetName (_("DVD-o-matic")); - info.SetVersion (wxT (DVDOMATIC_VERSION)); - info.SetDescription (_("DCP generation from arbitrary formats")); - info.SetCopyright (_("(C) Carl Hetherington, Terrence Meiczinger, Paul Davis")); + info.SetVersion (std_to_wx (String::compose ("version %1 git %2", dvdomatic_version, dvdomatic_git_commit))); + info.SetDescription (_("Free, open-source DCP generation from almost anything.")); + info.SetCopyright (_("(C) Carl Hetherington, Terrence Meiczinger, Paul Davis, Ole Laursen")); wxArrayString authors; authors.Add (wxT ("Carl Hetherington")); authors.Add (wxT ("Terrence Meiczinger")); authors.Add (wxT ("Paul Davis")); + authors.Add (wxT ("Ole Laursen")); info.SetDevelopers (authors); info.SetWebSite (wxT ("http://carlh.net/software/dvdomatic")); wxAboutBox (info); @@ -308,70 +373,29 @@ class App : public wxApp { bool OnInit () { - if (!wxApp::OnInit ()) { - return false; - } - wxInitAllImageHandlers (); dvdomatic_setup (); -// if (argc == 2 && boost::filesystem::is_directory (argv[1])) { -// film = new Film (argv[1]); -// } - - frame = new Frame (_("DVD-o-matic")); - frame->Show (true); - - frame->Connect (ID_file_new, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_new)); - frame->Connect (ID_file_open, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_open)); - frame->Connect (ID_file_save, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_save)); - frame->Connect (ID_file_quit, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_quit)); - frame->Connect (ID_edit_preferences, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::edit_preferences)); - frame->Connect (ID_jobs_make_dcp, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_make_dcp)); - frame->Connect (ID_jobs_send_dcp_to_tms, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_send_dcp_to_tms)); - frame->Connect (ID_jobs_copy_from_dvd, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_copy_from_dvd)); - frame->Connect (ID_jobs_examine_content, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_examine_content)); - frame->Connect (ID_jobs_make_dcp_from_existing_transcode, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::jobs_make_dcp_from_existing_transcode)); - frame->Connect (ID_help_about, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::help_about)); - - film_editor = new FilmEditor (film, frame); - film_viewer = new FilmViewer (film, frame); -#ifndef DVDOMATIC_DISABLE_PLAYER - film_player = new FilmPlayer (film, frame); -#endif - JobManagerView* job_manager_view = new JobManagerView (frame); - - wxSizer* rhs_sizer = new wxBoxSizer (wxVERTICAL); - rhs_sizer->Add (film_viewer, 3, wxEXPAND | wxALL); - rhs_sizer->Add (job_manager_view, 1, wxEXPAND | wxALL); - - wxBoxSizer* main_sizer = new wxBoxSizer (wxHORIZONTAL); - main_sizer->Add (film_editor, 0, wxALL, 6); - main_sizer->Add (rhs_sizer, 1, wxEXPAND | wxALL, 6); - frame->SetSizer (main_sizer); + if (argc == 2 && boost::filesystem::is_directory (wx_to_std (argv[1]))) { + film.reset (new Film (wx_to_std (argv[1]))); + } - SetTopWindow (frame); - frame->Maximize (); + Frame* f = new Frame (_("DVD-o-matic")); + SetTopWindow (f); + f->Maximize (); + f->Show (); - set_menu_sensitivity (); + ui_signaller = new wxUISignaller (this); + this->Connect (-1, wxEVT_IDLE, wxIdleEventHandler (App::idle)); - /* XXX: calling these here is a bit of a hack */ - film_editor->setup_visibility (); -#ifndef DVDOMATIC_DISABLE_PLAYER - film_player->setup_visibility (); -#endif - film_viewer->setup_visibility (); - - film_editor->FileChanged.connect (ptr_fun (file_changed)); - if (film) { - file_changed (film->directory ()); - } else { - file_changed (""); - } - return true; } + + void idle (wxIdleEvent &) + { + ui_signaller->ui_idle (); + } }; IMPLEMENT_APP (App)