From 592e22afa11706f61f39eeb038be56adea09cbc8 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 14 Nov 2018 16:58:02 +0000 Subject: [PATCH] Playlist editor stub. --- run/dcpomatic_playlist | 25 ++++ src/tools/dcpomatic_playlist.cc | 201 ++++++++++++++++++++++++++++++++ src/tools/wscript | 2 +- 3 files changed, 227 insertions(+), 1 deletion(-) create mode 100755 run/dcpomatic_playlist create mode 100644 src/tools/dcpomatic_playlist.cc diff --git a/run/dcpomatic_playlist b/run/dcpomatic_playlist new file mode 100755 index 000000000..033e72677 --- /dev/null +++ b/run/dcpomatic_playlist @@ -0,0 +1,25 @@ +#!/bin/bash + +export LD_LIBRARY_PATH=build/src/lib:build/src/wx:build/src/asdcplib/src:/home/c.hetherington/lib:$LD_LIBRARY_PATH +export DYLD_LIBRARY_PATH=build/src/lib:build/src/wx:build/src/asdcplib/src:/carl/Environment/64/lib +if [ "$1" == "--debug" ]; then + shift + gdb --args build/src/tools/dcpomatic2_playlist $* +elif [ "$1" == "--valgrind" ]; then + shift + valgrind --tool="memcheck" --suppressions=suppressions --track-fds=yes build/src/tools/dcpomatic2_playlist $* +elif [ "$1" == "--callgrind" ]; then + shift + valgrind --tool="callgrind" build/src/tools/dcpomatic2_playlist $* +elif [ "$1" == "--massif" ]; then + shift + valgrind --tool="massif" build/src/tools/dcpomatic2_playlist $* +elif [ "$1" == "--i18n" ]; then + shift + LANGUAGE=fr_FR.UTF8 LANG=fr_FR.UTF8 LC_ALL=fr_FR.UTF8 build/src/tools/dcpomatic2_playlist "$*" +elif [ "$1" == "--perf" ]; then + shift + perf record build/src/tools/dcpomatic2_playlist $* +else + build/src/tools/dcpomatic2_playlist $* +fi diff --git a/src/tools/dcpomatic_playlist.cc b/src/tools/dcpomatic_playlist.cc new file mode 100644 index 000000000..889ed6b17 --- /dev/null +++ b/src/tools/dcpomatic_playlist.cc @@ -0,0 +1,201 @@ +/* + Copyright (C) 2018 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + +#include "../wx/wx_util.h" +#include "../wx/wx_signal_manager.h" +#include "../lib/util.h" +#include "../lib/config.h" +#include +#include +#include + +using std::exception; + +class DOMFrame : public wxFrame +{ +public: + explicit DOMFrame (wxString const & title) + : wxFrame (0, -1, title) + { + /* Use a panel as the only child of the Frame so that we avoid + the dark-grey background on Windows. + */ + wxPanel* overall_panel = new wxPanel (this, wxID_ANY); + wxBoxSizer* main_sizer = new wxBoxSizer (wxHORIZONTAL); + + _list = new wxListCtrl ( + overall_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL + ); + + _list->AppendColumn (_("Name"), wxLIST_FORMAT_LEFT, 400); + _list->AppendColumn (_("CPL"), wxLIST_FORMAT_LEFT, 400); + _list->AppendColumn (_("Type"), wxLIST_FORMAT_LEFT, 75); + _list->AppendColumn (_("Format"), wxLIST_FORMAT_LEFT, 75); + _list->AppendColumn (_("Encrypted"), wxLIST_FORMAT_LEFT, 90); + _list->AppendColumn (_("Skippable"), wxLIST_FORMAT_LEFT, 90); + _list->AppendColumn (_("Disable timeline"), wxLIST_FORMAT_LEFT, 125); + _list->AppendColumn (_("Stop after play"), wxLIST_FORMAT_LEFT, 125); + + /* + wxImageList* images = new wxImageList (16, 16); + wxIcon icon; + icon.LoadFile ("test.png", wxBITMAP_TYPE_PNG); + images->Add (icon); + _list->SetImageList (images, wxIMAGE_LIST_SMALL); + */ + + wxListItem item; + item.SetId (0); + item.SetImage (0); + _list->InsertItem (item); + + main_sizer->Add (_list, 1, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP); + + wxBoxSizer* button_sizer = new wxBoxSizer (wxVERTICAL); + _up = new wxButton (overall_panel, wxID_ANY, _("Up")); + button_sizer->Add (_up, 0, wxALL, DCPOMATIC_SIZER_GAP); + + main_sizer->Add (button_sizer, 0, wxALL, DCPOMATIC_SIZER_GAP); + overall_panel->SetSizer (main_sizer); + + setup_sensitivity (); + } + + void setup_sensitivity () + { + + } + + wxListCtrl* _list; + wxButton* _up; +}; + +/** @class App + * @brief The magic App class for wxWidgets. + */ +class App : public wxApp +{ +public: + App () + : wxApp () + , _frame (0) + {} + +private: + + bool OnInit () + try + { + SetAppName (_("DCP-o-matic KDM Creator")); + + if (!wxApp::OnInit()) { + return false; + } + +#ifdef DCPOMATIC_LINUX + unsetenv ("UBUNTU_MENUPROXY"); +#endif + + #ifdef __WXOSX__ + ProcessSerialNumber serial; + GetCurrentProcess (&serial); + TransformProcessType (&serial, kProcessTransformToForegroundApplication); +#endif + + dcpomatic_setup_path_encoding (); + + /* Enable i18n; this will create a Config object + to look for a force-configured language. This Config + object will be wrong, however, because dcpomatic_setup + hasn't yet been called and there aren't any filters etc. + set up yet. + */ + dcpomatic_setup_i18n (); + + /* Set things up, including filters etc. + which will now be internationalised correctly. + */ + dcpomatic_setup (); + + /* Force the configuration to be re-loaded correctly next + time it is needed. + */ + Config::drop (); + + _frame = new DOMFrame (_("DCP-o-matic KDM Creator")); + SetTopWindow (_frame); + _frame->Maximize (); + _frame->Show (); + + signal_manager = new wxSignalManager (this); + Bind (wxEVT_IDLE, boost::bind (&App::idle, this)); + + return true; + } + catch (exception& e) + { + error_dialog (0, _("DCP-o-matic could not start"), std_to_wx(e.what())); + return true; + } + + /* An unhandled exception has occurred inside the main event loop */ + bool OnExceptionInMainLoop () + { + try { + throw; + } catch (FileError& e) { + error_dialog ( + 0, + wxString::Format ( + _("An exception occurred: %s (%s)\n\n") + REPORT_PROBLEM, + std_to_wx (e.what()), + std_to_wx (e.file().string().c_str ()) + ) + ); + } catch (exception& e) { + error_dialog ( + 0, + wxString::Format ( + _("An exception occurred: %s.\n\n") + " " + REPORT_PROBLEM, + std_to_wx (e.what ()) + ) + ); + } catch (...) { + error_dialog (0, _("An unknown exception occurred.") + " " + REPORT_PROBLEM); + } + + /* This will terminate the program */ + return false; + } + + void OnUnhandledException () + { + error_dialog (0, _("An unknown exception occurred.") + " " + REPORT_PROBLEM); + } + + void idle () + { + signal_manager->ui_idle (); + } + + DOMFrame* _frame; +}; + +IMPLEMENT_APP (App) diff --git a/src/tools/wscript b/src/tools/wscript index d0c8a8cd2..29cca533a 100644 --- a/src/tools/wscript +++ b/src/tools/wscript @@ -49,7 +49,7 @@ def build(bld): gui_tools = [] if not bld.env.DISABLE_GUI: if bld.env.VARIANT == 'swaroop': - gui_tools = ['dcpomatic_player'] + gui_tools = ['dcpomatic_player', 'dcpomatic_playlist'] else: gui_tools = ['dcpomatic', 'dcpomatic_batch', 'dcpomatic_server', 'dcpomatic_kdm', 'dcpomatic_player'] -- 2.30.2