Use $HOME rather than hard-coded user name.
[dcpomatic.git] / src / tools / dcpomatic_editor.cc
index a61a17ce4ff74eb8cd80680b07c7392cdac43937..14ff6da7f04129f8188cb70d9d7e01ee337966a3 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "wx/about_dialog.h"
 #include "wx/editable_list.h"
+#include "wx/id.h"
 #include "wx/wx_signal_manager.h"
 #include "wx/wx_util.h"
 #include "lib/constants.h"
@@ -59,7 +60,7 @@ using namespace boost::placeholders;
 
 
 enum {
-       ID_file_open = 1,
+       ID_file_open = DCPOMATIC_MAIN_MENU,
        ID_file_save,
 };
 
@@ -147,10 +148,10 @@ public:
        ReelEditor(wxWindow* parent)
                : wxDialog(parent, wxID_ANY, _("Edit reel"))
        {
-               auto sizer = new wxBoxSizer(wxVERTICAL);
+               _sizer = new wxBoxSizer(wxVERTICAL);
                _notebook = new wxNotebook(this, wxID_ANY);
-               sizer->Add(_notebook, wxEXPAND | wxALL, 1, DCPOMATIC_DIALOG_BORDER);
-               SetSizerAndFit(sizer);
+               _sizer->Add(_notebook, wxEXPAND | wxALL, 1, DCPOMATIC_DIALOG_BORDER);
+               SetSizerAndFit(_sizer);
        }
 
        optional<shared_ptr<dcp::Reel>> get() {
@@ -171,10 +172,14 @@ public:
                if (_reel->main_subtitle()) {
                        _notebook->AddPage(new AssetPanel(_notebook, _reel->main_subtitle()), _("Subtitle"));
                }
+
+               _sizer->Layout();
+               _sizer->SetSizeHints(this);
        }
 
 private:
        wxNotebook* _notebook = nullptr;
+       wxSizer* _sizer = nullptr;
        shared_ptr<dcp::Reel> _reel;
 };
 
@@ -324,10 +329,15 @@ public:
 
        void load_dcp (boost::filesystem::path path)
        {
-               _notebook->DeleteAllPages();
+               try {
+                       _dcp = dcp::DCP(path);
+                       _dcp->read();
+               } catch (std::runtime_error& e) {
+                       error_dialog(this, _("Could not load DCP"), std_to_wx(e.what()));
+                       return;
+               }
 
-               _dcp = dcp::DCP(path);
-               _dcp->read();
+               _notebook->DeleteAllPages();
                for (auto cpl: _dcp->cpls()) {
                        _notebook->AddPage(new CPLPanel(_notebook, cpl), wx_to_std(cpl->annotation_text().get_value_or(cpl->id())));
                }