Playlist editor stub.
[dcpomatic.git] / src / tools / dcpomatic_playlist.cc
1 /*
2     Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #include "../wx/wx_util.h"
22 #include "../wx/wx_signal_manager.h"
23 #include "../lib/util.h"
24 #include "../lib/config.h"
25 #include <wx/wx.h>
26 #include <wx/listctrl.h>
27 #include <wx/imaglist.h>
28
29 using std::exception;
30
31 class DOMFrame : public wxFrame
32 {
33 public:
34         explicit DOMFrame (wxString const & title)
35                 : wxFrame (0, -1, title)
36         {
37                 /* Use a panel as the only child of the Frame so that we avoid
38                    the dark-grey background on Windows.
39                 */
40                 wxPanel* overall_panel = new wxPanel (this, wxID_ANY);
41                 wxBoxSizer* main_sizer = new wxBoxSizer (wxHORIZONTAL);
42
43                 _list = new wxListCtrl (
44                         overall_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL
45                         );
46
47                 _list->AppendColumn (_("Name"), wxLIST_FORMAT_LEFT, 400);
48                 _list->AppendColumn (_("CPL"), wxLIST_FORMAT_LEFT, 400);
49                 _list->AppendColumn (_("Type"), wxLIST_FORMAT_LEFT, 75);
50                 _list->AppendColumn (_("Format"), wxLIST_FORMAT_LEFT, 75);
51                 _list->AppendColumn (_("Encrypted"), wxLIST_FORMAT_LEFT, 90);
52                 _list->AppendColumn (_("Skippable"), wxLIST_FORMAT_LEFT, 90);
53                 _list->AppendColumn (_("Disable timeline"), wxLIST_FORMAT_LEFT, 125);
54                 _list->AppendColumn (_("Stop after play"), wxLIST_FORMAT_LEFT, 125);
55
56                 /*
57                 wxImageList* images = new wxImageList (16, 16);
58                 wxIcon icon;
59                 icon.LoadFile ("test.png", wxBITMAP_TYPE_PNG);
60                 images->Add (icon);
61                 _list->SetImageList (images, wxIMAGE_LIST_SMALL);
62                 */
63
64                 wxListItem item;
65                 item.SetId (0);
66                 item.SetImage (0);
67                 _list->InsertItem (item);
68
69                 main_sizer->Add (_list, 1, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP);
70
71                 wxBoxSizer* button_sizer = new wxBoxSizer (wxVERTICAL);
72                 _up = new wxButton (overall_panel, wxID_ANY, _("Up"));
73                 button_sizer->Add (_up, 0, wxALL, DCPOMATIC_SIZER_GAP);
74
75                 main_sizer->Add (button_sizer, 0, wxALL, DCPOMATIC_SIZER_GAP);
76                 overall_panel->SetSizer (main_sizer);
77
78                 setup_sensitivity ();
79         }
80
81         void setup_sensitivity ()
82         {
83
84         }
85
86         wxListCtrl* _list;
87         wxButton* _up;
88 };
89
90 /** @class App
91  *  @brief The magic App class for wxWidgets.
92  */
93 class App : public wxApp
94 {
95 public:
96         App ()
97                 : wxApp ()
98                 , _frame (0)
99         {}
100
101 private:
102
103         bool OnInit ()
104         try
105         {
106                 SetAppName (_("DCP-o-matic KDM Creator"));
107
108                 if (!wxApp::OnInit()) {
109                         return false;
110                 }
111
112 #ifdef DCPOMATIC_LINUX
113                 unsetenv ("UBUNTU_MENUPROXY");
114 #endif
115
116                 #ifdef __WXOSX__
117                 ProcessSerialNumber serial;
118                 GetCurrentProcess (&serial);
119                 TransformProcessType (&serial, kProcessTransformToForegroundApplication);
120 #endif
121
122                 dcpomatic_setup_path_encoding ();
123
124                 /* Enable i18n; this will create a Config object
125                    to look for a force-configured language.  This Config
126                    object will be wrong, however, because dcpomatic_setup
127                    hasn't yet been called and there aren't any filters etc.
128                    set up yet.
129                 */
130                 dcpomatic_setup_i18n ();
131
132                 /* Set things up, including filters etc.
133                    which will now be internationalised correctly.
134                 */
135                 dcpomatic_setup ();
136
137                 /* Force the configuration to be re-loaded correctly next
138                    time it is needed.
139                 */
140                 Config::drop ();
141
142                 _frame = new DOMFrame (_("DCP-o-matic KDM Creator"));
143                 SetTopWindow (_frame);
144                 _frame->Maximize ();
145                 _frame->Show ();
146
147                 signal_manager = new wxSignalManager (this);
148                 Bind (wxEVT_IDLE, boost::bind (&App::idle, this));
149
150                 return true;
151         }
152         catch (exception& e)
153         {
154                 error_dialog (0, _("DCP-o-matic could not start"), std_to_wx(e.what()));
155                 return true;
156         }
157
158         /* An unhandled exception has occurred inside the main event loop */
159         bool OnExceptionInMainLoop ()
160         {
161                 try {
162                         throw;
163                 } catch (FileError& e) {
164                         error_dialog (
165                                 0,
166                                 wxString::Format (
167                                         _("An exception occurred: %s (%s)\n\n") + REPORT_PROBLEM,
168                                         std_to_wx (e.what()),
169                                         std_to_wx (e.file().string().c_str ())
170                                         )
171                                 );
172                 } catch (exception& e) {
173                         error_dialog (
174                                 0,
175                                 wxString::Format (
176                                         _("An exception occurred: %s.\n\n") + " " + REPORT_PROBLEM,
177                                         std_to_wx (e.what ())
178                                         )
179                                 );
180                 } catch (...) {
181                         error_dialog (0, _("An unknown exception occurred.") + "  " + REPORT_PROBLEM);
182                 }
183
184                 /* This will terminate the program */
185                 return false;
186         }
187
188         void OnUnhandledException ()
189         {
190                 error_dialog (0, _("An unknown exception occurred.") + "  " + REPORT_PROBLEM);
191         }
192
193         void idle ()
194         {
195                 signal_manager->ui_idle ();
196         }
197
198         DOMFrame* _frame;
199 };
200
201 IMPLEMENT_APP (App)