summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-05-04 20:58:31 +0100
committerCarl Hetherington <cth@carlh.net>2013-05-04 20:58:31 +0100
commitdb0ad7242d39f0fbae04bb6983021c60d57fdcf5 (patch)
tree62c52316ff64204b89ba21658dc76ad69009bfec /src/tools
parent0c5590dd0e3f367064a6e4d52835a609adf11a06 (diff)
Make batch converter basically work.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/dvdomatic.cc2
-rw-r--r--src/tools/dvdomatic_batch.cc85
2 files changed, 79 insertions, 8 deletions
diff --git a/src/tools/dvdomatic.cc b/src/tools/dvdomatic.cc
index 2740a0965..ff1560f0e 100644
--- a/src/tools/dvdomatic.cc
+++ b/src/tools/dvdomatic.cc
@@ -224,7 +224,7 @@ public:
film_editor = new FilmEditor (film, panel);
film_viewer = new FilmViewer (film, panel);
- JobManagerView* job_manager_view = new JobManagerView (panel);
+ JobManagerView* job_manager_view = new JobManagerView (panel, static_cast<JobManagerView::Buttons> (0));
_top_sizer = new wxBoxSizer (wxHORIZONTAL);
_top_sizer->Add (film_editor, 0, wxALL, 6);
diff --git a/src/tools/dvdomatic_batch.cc b/src/tools/dvdomatic_batch.cc
index 102f29408..7a3d38d9c 100644
--- a/src/tools/dvdomatic_batch.cc
+++ b/src/tools/dvdomatic_batch.cc
@@ -18,17 +18,23 @@
*/
#include <wx/aboutdlg.h>
+#include <wx/stdpaths.h>
#include <wx/wx.h>
#include "lib/version.h"
#include "lib/compose.hpp"
#include "lib/config.h"
#include "lib/util.h"
+#include "lib/film.h"
+#include "lib/job_manager.h"
#include "wx/wx_util.h"
#include "wx/wx_ui_signaller.h"
-#include "wx/batch_view.h"
+#include "wx/job_manager_view.h"
+
+using boost::shared_ptr;
enum {
- ID_file_quit = 1,
+ ID_file_add_film = 1,
+ ID_file_quit,
ID_help_about
};
@@ -36,6 +42,7 @@ void
setup_menu (wxMenuBar* m)
{
wxMenu* file = new wxMenu;
+ file->Append (ID_file_add_film, _("&Add Film..."));
file->Append (ID_file_quit, _("&Quit"));
wxMenu* help = new wxMenu;
@@ -55,6 +62,7 @@ public:
setup_menu (bar);
SetMenuBar (bar);
+ Connect (ID_file_add_film, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_add_film));
Connect (ID_file_quit, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::file_quit));
Connect (ID_help_about, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (Frame::help_about));
@@ -65,24 +73,60 @@ public:
wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
- BatchView* batch_view = new BatchView (panel);
- sizer->Add (batch_view, 1, wxALL | wxEXPAND, 6);
+ JobManagerView* job_manager_view = new JobManagerView (panel, JobManagerView::PAUSE);
+ sizer->Add (job_manager_view, 1, wxALL | wxEXPAND, 6);
wxSizer* buttons = new wxBoxSizer (wxHORIZONTAL);
wxButton* add = new wxButton (panel, wxID_ANY, _("Add Film..."));
+ add->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (Frame::add_film));
buttons->Add (add, 1, wxALL, 6);
- wxButton* start = new wxButton (panel, wxID_ANY, _("Start..."));
- buttons->Add (start, 1, wxALL, 6);
sizer->Add (buttons, 0, wxALL, 6);
panel->SetSizer (sizer);
+
+ Connect (wxID_ANY, wxEVT_CLOSE_WINDOW, wxCloseEventHandler (Frame::close));
}
private:
+ bool should_close ()
+ {
+ if (!JobManager::instance()->work_to_do ()) {
+ return true;
+ }
+
+ wxMessageDialog* d = new wxMessageDialog (
+ 0,
+ _("There are unfinished jobs; are you sure you want to quit?"),
+ _("Unfinished jobs"),
+ wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION
+ );
+
+ bool const r = d->ShowModal() == wxID_YES;
+ d->Destroy ();
+ return r;
+ }
+
+ void close (wxCloseEvent& ev)
+ {
+ if (!should_close ()) {
+ ev.Veto ();
+ return;
+ }
+
+ ev.Skip ();
+ }
+
+ void file_add_film (wxCommandEvent& ev)
+ {
+ add_film (ev);
+ }
+
void file_quit (wxCommandEvent &)
{
- Close (true);
+ if (should_close ()) {
+ Close (true);
+ }
}
void help_about (wxCommandEvent &)
@@ -116,6 +160,33 @@ private:
info.SetWebSite (wxT ("http://carlh.net/software/dvdomatic"));
wxAboutBox (info);
}
+
+ void add_film (wxCommandEvent &)
+ {
+ wxDirDialog* c = new wxDirDialog (this, _("Select film to open"), wxStandardPaths::Get().GetDocumentsDir(), wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST);
+ int r;
+ while (1) {
+ r = c->ShowModal ();
+ if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) {
+ error_dialog (this, _("You did not select a folder. Make sure that you select a folder before clicking Open."));
+ } else {
+ break;
+ }
+ }
+
+ if (r == wxID_OK) {
+ try {
+ shared_ptr<Film> film (new Film (wx_to_std (c->GetPath ())));
+ film->make_dcp ();
+ } catch (std::exception& e) {
+ wxString p = c->GetPath ();
+ wxCharBuffer b = p.ToUTF8 ();
+ error_dialog (this, wxString::Format (_("Could not open film at %s (%s)"), p.data(), std_to_wx (e.what()).data()));
+ }
+ }
+
+ c->Destroy ();
+ }
};
class App : public wxApp