Merge master.
[dcpomatic.git] / src / tools / dcpomatic.cc
index 79f9144b5c6c37f76eabb19d5d3c21895002ec1d..edd04fd517a78cf105053f5192c1cf45c924e0ac 100644 (file)
@@ -30,7 +30,7 @@
 #include <wx/stdpaths.h>
 #include <wx/cmdline.h>
 #include <wx/preferences.h>
-#include <libdcp/exceptions.h>
+#include <dcp/exceptions.h>
 #include "wx/film_viewer.h"
 #include "wx/film_editor.h"
 #include "wx/job_manager_view.h"
@@ -45,6 +45,7 @@
 #include "wx/servers_list_dialog.h"
 #include "wx/hints_dialog.h"
 #include "wx/update_dialog.h"
+#include "wx/content_panel.h"
 #include "lib/film.h"
 #include "lib/config.h"
 #include "lib/util.h"
@@ -72,8 +73,6 @@ using std::exception;
 using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
 
-// #define DCPOMATIC_WINDOWS_CONSOLE 1
-
 class FilmChangedDialog
 {
 public:
@@ -127,7 +126,9 @@ enum {
        ID_jobs_show_dcp,
        ID_tools_hints,
        ID_tools_encoding_servers,
-       ID_tools_check_for_updates
+       ID_tools_check_for_updates,
+       /* IDs for shortcuts (with no associated menu item) */
+       ID_add_file
 };
 
 class Frame : public wxFrame
@@ -143,20 +144,24 @@ public:
                , _history_position (0)
                , _history_separator (0)
        {
-#if defined(DCPOMATIC_WINDOWS) && defined(DCPOMATIC_WINDOWS_CONSOLE)
-                AllocConsole();
-               
-               HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);
-               int hCrt = _open_osfhandle((intptr_t) handle_out, _O_TEXT);
-               FILE* hf_out = _fdopen(hCrt, "w");
-               setvbuf(hf_out, NULL, _IONBF, 1);
-               *stdout = *hf_out;
-               
-               HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE);
-               hCrt = _open_osfhandle((intptr_t) handle_in, _O_TEXT);
-               FILE* hf_in = _fdopen(hCrt, "r");
-               setvbuf(hf_in, NULL, _IONBF, 128);
-               *stdin = *hf_in;
+#if defined(DCPOMATIC_WINDOWS)
+               if (Config::instance()->win32_console ()) {
+                       AllocConsole();
+                       
+                       HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);
+                       int hCrt = _open_osfhandle((intptr_t) handle_out, _O_TEXT);
+                       FILE* hf_out = _fdopen(hCrt, "w");
+                       setvbuf(hf_out, NULL, _IONBF, 1);
+                       *stdout = *hf_out;
+                       
+                       HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE);
+                       hCrt = _open_osfhandle((intptr_t) handle_in, _O_TEXT);
+                       FILE* hf_in = _fdopen(hCrt, "r");
+                       setvbuf(hf_in, NULL, _IONBF, 128);
+                       *stdin = *hf_in;
+
+                       cout << "DCP-o-matic is starting." << "\n";
+               }
 #endif
 
                wxMenuBar* bar = new wxMenuBar;
@@ -193,7 +198,7 @@ public:
 
                _film_editor = new FilmEditor (overall_panel);
                _film_viewer = new FilmViewer (overall_panel);
-               JobManagerView* job_manager_view = new JobManagerView (overall_panel, static_cast<JobManagerView::Buttons> (0));
+               JobManagerView* job_manager_view = new JobManagerView (overall_panel);
 
                wxBoxSizer* right_sizer = new wxBoxSizer (wxVERTICAL);
                right_sizer->Add (_film_viewer, 2, wxEXPAND | wxALL, 6);
@@ -211,6 +216,12 @@ public:
                JobManager::instance()->ActiveJobsChanged.connect (boost::bind (&Frame::set_menu_sensitivity, this));
 
                overall_panel->SetSizer (main_sizer);
+
+               wxAcceleratorEntry accel[1];
+               accel[0].Set (wxACCEL_CTRL, static_cast<int>('A'), ID_add_file);
+               Bind (wxEVT_MENU, boost::bind (&ContentPanel::add_file_clicked, _film_editor->content_panel()), ID_add_file);
+               wxAcceleratorTable accel_table (1, accel);
+               SetAcceleratorTable (accel_table);
        }
 
        void new_film (boost::filesystem::path path)
@@ -402,12 +413,12 @@ private:
                                        shared_ptr<Job> (new SendKDMEmailJob (_film, d->screens (), d->cpl (), d->from (), d->until (), d->formulation ()))
                                        );
                        }
-               } catch (libdcp::NotEncryptedError& e) {
+               } catch (dcp::NotEncryptedError& e) {
                        error_dialog (this, _("CPL's content is not encrypted."));
                } catch (exception& e) {
                        error_dialog (this, e.what ());
                } catch (...) {
-                       error_dialog (this, _("An unknown exeception occurred."));
+                       error_dialog (this, _("An unknown exception occurred."));
                }
        
                d->Destroy ();
@@ -415,7 +426,7 @@ private:
 
        void content_scale_to_fit_width ()
        {
-               VideoContentList vc = _film_editor->selected_video_content ();
+               VideoContentList vc = _film_editor->content_panel()->selected_video ();
                for (VideoContentList::iterator i = vc.begin(); i != vc.end(); ++i) {
                        (*i)->scale_and_crop_to_fit_width ();
                }
@@ -423,7 +434,7 @@ private:
 
        void content_scale_to_fit_height ()
        {
-               VideoContentList vc = _film_editor->selected_video_content ();
+               VideoContentList vc = _film_editor->content_panel()->selected_video ();
                for (VideoContentList::iterator i = vc.begin(); i != vc.end(); ++i) {
                        (*i)->scale_and_crop_to_fit_height ();
                }
@@ -534,7 +545,7 @@ private:
                }
                bool const dcp_creation = (i != jobs.end ()) && !(*i)->finished ();
                bool const have_cpl = _film && !_film->cpls().empty ();
-               bool const have_selected_video_content = !_film_editor->selected_video_content().empty();
+               bool const have_selected_video_content = !_film_editor->content_panel()->selected_video().empty();
                
                for (map<wxMenuItem*, int>::iterator j = menu_items.begin(); j != menu_items.end(); ++j) {
                        
@@ -609,10 +620,10 @@ private:
 #endif 
        
 #ifdef __WXOSX__       
-               add_item (_file_menu, _("&Preferences..."), wxID_PREFERENCES, ALWAYS);
+               add_item (_file_menu, _("&Preferences...\tCtrl-P"), wxID_PREFERENCES, ALWAYS);
 #else
                wxMenu* edit = new wxMenu;
-               add_item (edit, _("&Preferences..."), wxID_PREFERENCES, ALWAYS);
+               add_item (edit, _("&Preferences...\tCtrl-P"), wxID_PREFERENCES, ALWAYS);
 #endif
 
                wxMenu* content = new wxMenu;
@@ -699,6 +710,9 @@ static const wxCmdLineEntryDesc command_line_description[] = {
        { wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 }
 };
 
+/** @class App
+ *  @brief The magic App class for wxWidgets.
+ */
 class App : public wxApp
 {
        bool OnInit ()