#include <wx/aboutdlg.h>
#include <wx/stdpaths.h>
+#include <wx/cmdline.h>
#include <wx/wx.h>
#include "lib/version.h"
#include "lib/compose.hpp"
#include "wx/wx_ui_signaller.h"
#include "wx/job_manager_view.h"
+using std::exception;
using boost::shared_ptr;
+static std::string film_to_load;
+
enum {
ID_file_add_film = 1,
ID_file_quit,
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));
+ Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_add_film, this), ID_file_add_film);
+ Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_quit, this), ID_file_quit);
+ Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::help_about, this), ID_help_about);
wxPanel* panel = new wxPanel (this);
wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
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));
+ add->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&Frame::add_film, this));
buttons->Add (add, 1, wxALL, 6);
sizer->Add (buttons, 0, wxALL, 6);
panel->SetSizer (sizer);
- Connect (wxID_ANY, wxEVT_CLOSE_WINDOW, wxCloseEventHandler (Frame::close));
+ Bind (wxEVT_CLOSE_WINDOW, boost::bind (&Frame::close, this, _1));
}
private:
ev.Skip ();
}
- void file_add_film (wxCommandEvent& ev)
+ void file_add_film ()
{
- add_film (ev);
+ add_film ();
}
- void file_quit (wxCommandEvent &)
+ void file_quit ()
{
if (should_close ()) {
Close (true);
}
}
- void help_about (wxCommandEvent &)
+ void help_about ()
{
wxAboutDialogInfo info;
info.SetName (_("DCP-o-matic Batch Converter"));
wxAboutBox (info);
}
- void add_film (wxCommandEvent &)
+ void add_film ()
{
wxDirDialog* c = new wxDirDialog (this, _("Select film to open"), wxStandardPaths::Get().GetDocumentsDir(), wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST);
+ if (_last_parent) {
+ c->SetPath (std_to_wx (_last_parent.get().string ()));
+ }
+
int r;
while (1) {
r = c->ShowModal ();
if (r == wxID_OK) {
try {
shared_ptr<Film> film (new Film (wx_to_std (c->GetPath ())));
+ film->read_metadata ();
film->make_dcp ();
} catch (std::exception& e) {
wxString p = c->GetPath ();
}
}
+ _last_parent = boost::filesystem::path (wx_to_std (c->GetPath ())).parent_path ();
+
c->Destroy ();
}
+
+ boost::optional<boost::filesystem::path> _last_parent;
+};
+
+static const wxCmdLineEntryDesc command_line_description[] = {
+ { wxCMD_LINE_PARAM, 0, 0, "film to load", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL },
+ { wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 }
};
class App : public wxApp
return false;
}
-#ifdef DCPOMATIC_POSIX
+#ifdef DCPOMATIC_LINUX
unsetenv ("UBUNTU_MENUPROXY");
#endif
f->Show ();
ui_signaller = new wxUISignaller (this);
- this->Connect (-1, wxEVT_IDLE, wxIdleEventHandler (App::idle));
+ this->Bind (wxEVT_IDLE, boost::bind (&App::idle, this));
+
+ shared_ptr<Film> film;
+ if (!film_to_load.empty() && boost::filesystem::is_directory (film_to_load)) {
+ try {
+ film.reset (new Film (film_to_load));
+ film->read_metadata ();
+ film->make_dcp ();
+ } catch (exception& e) {
+ error_dialog (0, std_to_wx (String::compose (wx_to_std (_("Could not load film %1 (%2)")), film_to_load, e.what())));
+ }
+ }
return true;
}
- void idle (wxIdleEvent &)
+ void idle ()
{
ui_signaller->ui_idle ();
}
+
+ void OnInitCmdLine (wxCmdLineParser& parser)
+ {
+ parser.SetDesc (command_line_description);
+ parser.SetSwitchChars (wxT ("-"));
+ }
+
+ bool OnCmdLineParsed (wxCmdLineParser& parser)
+ {
+ if (parser.GetParamCount() > 0) {
+ film_to_load = wx_to_std (parser.GetParam(0));
+ }
+
+ return true;
+ }
};
IMPLEMENT_APP (App)