#include "lib/transcode_job.h"
#include "lib/util.h"
#include "lib/version.h"
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
#include <wx/aboutdlg.h>
#include <wx/cmdline.h>
#include <wx/preferences.h>
#include <wx/splash.h>
#include <wx/stdpaths.h>
#include <wx/wx.h>
+LIBDCP_ENABLE_WARNINGS
#include <iostream>
#include <set>
class DOMFrame : public wxFrame
{
public:
+ enum class Tool {
+ ADD,
+ PAUSE
+ };
+
explicit DOMFrame (wxString const & title)
: wxFrame (nullptr, -1, title)
, _sizer (new wxBoxSizer(wxVERTICAL))
s->Add (panel, 1, wxEXPAND);
SetSizer (s);
- auto job_manager_view = new JobManagerView (panel, true);
- _sizer->Add (job_manager_view, 1, wxALL | wxEXPAND, 6);
+ wxBitmap add(icon_path("add"), wxBITMAP_TYPE_PNG);
+ wxBitmap pause(icon_path("pause"), wxBITMAP_TYPE_PNG);
- auto buttons = new wxBoxSizer (wxHORIZONTAL);
- auto add = new Button (panel, _("Add Film..."));
- add->Bind (wxEVT_BUTTON, boost::bind(&DOMFrame::add_film, this));
- buttons->Add (add, 1, wxALL, 6);
- _pause = new Button (panel, _("Pause"));
- _pause->Bind (wxEVT_BUTTON, boost::bind(&DOMFrame::pause, this));
- buttons->Add (_pause, 1, wxALL, 6);
- _resume = new Button (panel, _("Resume"));
- _resume->Bind (wxEVT_BUTTON, boost::bind(&DOMFrame::resume, this));
- buttons->Add (_resume, 1, wxALL, 6);
+ auto toolbar = new wxToolBar(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL);
+ toolbar->SetMargins(4, 4);
+ toolbar->SetToolBitmapSize(wxSize(32, 32));
+ toolbar->AddTool(static_cast<int>(Tool::ADD), _("Add film"), add, _("Add film for conversion"));
+ toolbar->AddCheckTool(static_cast<int>(Tool::PAUSE), _("Pause/resume"), pause, wxNullBitmap, _("Pause or resume conversion"));
+ toolbar->Realize();
+ _sizer->Add(toolbar, 0, wxALL, 6);
- setup_sensitivity ();
+ toolbar->Bind(wxEVT_TOOL, bind(&DOMFrame::tool_clicked, this, _1));
- _sizer->Add (buttons, 0, wxALL, 6);
+ auto job_manager_view = new JobManagerView (panel, true);
+ _sizer->Add (job_manager_view, 1, wxALL | wxEXPAND, 6);
panel->SetSizer (_sizer);
Bind (wxEVT_SIZE, boost::bind(&DOMFrame::sized, this, _1));
}
- void setup_sensitivity ()
+ void tool_clicked(wxCommandEvent& ev)
{
- _pause->Enable (!JobManager::instance()->paused());
- _resume->Enable (JobManager::instance()->paused());
- }
-
- void pause ()
- {
- JobManager::instance()->pause();
- setup_sensitivity ();
- }
-
- void resume ()
- {
- JobManager::instance()->resume();
- setup_sensitivity ();
+ switch (static_cast<Tool>(ev.GetId())) {
+ case Tool::ADD:
+ add_film();
+ break;
+ case Tool::PAUSE:
+ {
+ auto jm = JobManager::instance();
+ if (jm->paused()) {
+ jm->resume();
+ } else {
+ jm->pause();
+ }
+ break;
+ }
+ }
}
void start_job (boost::filesystem::path path)
wxSizer* _sizer;
wxPreferencesEditor* _config_dialog = nullptr;
ServersListDialog* _servers_list_dialog = nullptr;
- wxButton* _pause;
- wxButton* _resume;
};
SetAppName (_("DCP-o-matic Batch Converter"));
is_batch_converter = true;
- Config::FailedToLoad.connect (boost::bind(&App::config_failed_to_load, this));
+ Config::FailedToLoad.connect(boost::bind(&App::config_failed_to_load, this, _1));
Config::Warning.connect (boost::bind(&App::config_warning, this, _1));
auto splash = maybe_show_splash ();
}
_frame->Show ();
- auto server = new JobServer (_frame);
- new thread (boost::bind (&JobServer::run, server));
+ try {
+ auto server = new JobServer (_frame);
+ new thread (boost::bind (&JobServer::run, server));
+ } catch (boost::system::system_error& e) {
+ error_dialog(_frame, _("Could not listen for new batch jobs. Perhaps another instance of the DCP-o-matic Batch Converter is running."));
+ }
signal_manager = new wxSignalManager (this);
this->Bind (wxEVT_IDLE, boost::bind (&App::idle, this));
return true;
}
- void config_failed_to_load ()
+ void config_failed_to_load(Config::LoadFailure what)
{
- message_dialog (_frame, _("The existing configuration failed to load. Default values will be used instead. These may take a short time to create."));
+ report_config_load_failure(_frame, what);
}
void config_warning (string m)