Merge master.
[dcpomatic.git] / src / tools / dvdomatic.cc
index 212d4848edd4f6b293f1f448deed86a5d594ee99..3fc19a91cfc0447170e8177a6f5fb47cdbf72074 100644 (file)
@@ -59,6 +59,7 @@ static FilmViewer* film_viewer = 0;
 static shared_ptr<Film> film;
 static std::string log_level;
 static std::string film_to_load;
+static std::string film_to_create;
 static wxMenu* jobs_menu = 0;
 static wxLocale* locale = 0;
 
@@ -236,9 +237,6 @@ public:
 
                set_menu_sensitivity ();
 
-               /* XXX: calling these here is a bit of a hack */
-               film_editor->setup_visibility ();
-               
                film_editor->FileChanged.connect (bind (&Frame::file_changed, this, _1));
                if (film) {
                        file_changed (film->directory ());
@@ -442,13 +440,15 @@ private:
 #if wxMINOR_VERSION == 9
 static const wxCmdLineEntryDesc command_line_description[] = {
        { wxCMD_LINE_OPTION, "l", "log", "set log level (silent, verbose or timing)", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
-        { wxCMD_LINE_PARAM, 0, 0, "film to load", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL },
+       { wxCMD_LINE_SWITCH, "n", "new", "create new film", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
+        { wxCMD_LINE_PARAM, 0, 0, "film to load or create", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL },
        { wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 }
 };
 #else
 static const wxCmdLineEntryDesc command_line_description[] = {
        { wxCMD_LINE_OPTION, wxT("l"), wxT("log"), wxT("set log level (silent, verbose or timing)"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
-        { wxCMD_LINE_PARAM, 0, 0, wxT("film to load"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL },
+       { wxCMD_LINE_SWITCH, wxT("n"), wxT("new"), wxT("create new film"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
+        { wxCMD_LINE_PARAM, 0, 0, wxT("film to load or create"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL },
        { wxCMD_LINE_NONE, wxT(""), wxT(""), wxT(""), wxCmdLineParamType (0), 0 }
 };
 #endif
@@ -528,6 +528,12 @@ class App : public wxApp
                        }
                }
 
+               if (!film_to_create.empty ()) {
+                       film.reset (new Film (film_to_create, false));
+                       film->log()->set_level (log_level);
+                       film->set_name (boost::filesystem::path (film_to_create).filename().generic_string ());
+               }
+
                Frame* f = new Frame (_("DVD-o-matic"));
                SetTopWindow (f);
                f->Maximize ();
@@ -548,11 +554,15 @@ class App : public wxApp
        bool OnCmdLineParsed (wxCmdLineParser& parser)
        {
                if (parser.GetParamCount() > 0) {
-                       film_to_load = wx_to_std (parser.GetParam(0));
+                       if (parser.FoundSwitch (wxT ("new"))) {
+                               film_to_create = wx_to_std (parser.GetParam (0));
+                       } else {
+                               film_to_load = wx_to_std (parser.GetParam(0));
+                       }
                }
 
                wxString log;
-               if (parser.Found(wxT("log"), &log)) {
+               if (parser.Found (wxT ("log"), &log)) {
                        log_level = wx_to_std (log);
                }