+ wxButton* _down;
+ wxButton* _add;
+ wxButton* _remove;
+ shared_ptr<SignalSPL> _playlist;
+};
+
+
+class DOMFrame : public wxFrame
+{
+public:
+ explicit DOMFrame (wxString const & title)
+ : wxFrame (nullptr, wxID_ANY, title)
+ , _content_dialog (new ContentDialog(this))
+ , _config_dialog (nullptr)
+ {
+ auto bar = new wxMenuBar;
+ setup_menu (bar);
+ SetMenuBar (bar);
+
+ /* Use a panel as the only child of the Frame so that we avoid
+ the dark-grey background on Windows.
+ */
+ auto overall_panel = new wxPanel (this, wxID_ANY);
+ auto sizer = new wxBoxSizer (wxVERTICAL);
+
+ _playlist_list = new PlaylistList (overall_panel, _content_dialog);
+ _playlist_content = new PlaylistContent (overall_panel, _content_dialog);
+
+ sizer->Add (_playlist_list->sizer());
+ sizer->Add (_playlist_content->sizer());
+
+ overall_panel->SetSizer (sizer);
+
+ _playlist_list->Edit.connect (bind(&DOMFrame::change_playlist, this, _1));
+
+ _playlist_content->set (_playlist_list->first_playlist());
+
+ Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_exit, this), wxID_EXIT);
+ Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_about, this), wxID_ABOUT);
+ Bind (wxEVT_MENU, boost::bind (&DOMFrame::edit_preferences, this), wxID_PREFERENCES);
+
+ _config_changed_connection = Config::instance()->Changed.connect(boost::bind(&DOMFrame::config_changed, this));
+ }
+
+private:
+
+ void file_exit ()
+ {
+ /* false here allows the close handler to veto the close request */
+ Close (false);
+ }
+
+ void help_about ()
+ {
+ auto d = new AboutDialog (this);
+ d->ShowModal ();
+ d->Destroy ();
+ }
+
+ void edit_preferences ()
+ {
+ if (!_config_dialog) {
+ _config_dialog = create_playlist_editor_config_dialog ();
+ }
+ _config_dialog->Show (this);
+ }
+
+ void change_playlist (shared_ptr<SignalSPL> playlist)
+ {
+ auto old = _playlist_content->playlist ();
+ if (old) {
+ save_playlist (old);
+ }
+ _playlist_content->set (playlist);
+ }
+
+ void save_playlist (shared_ptr<SignalSPL> playlist)
+ {
+ auto dir = Config::instance()->player_playlist_directory();
+ if (!dir) {
+ error_dialog (this, _("No playlist folder is specified in preferences. Please set one and then try again."));
+ return;
+ }
+ playlist->write (*dir / (playlist->id() + ".xml"));
+ }
+
+ void setup_menu (wxMenuBar* m)
+ {
+ auto file = new wxMenu;
+#ifdef __WXOSX__
+ file->Append (wxID_EXIT, _("&Exit"));
+#else
+ file->Append (wxID_EXIT, _("&Quit"));
+#endif
+
+#ifndef __WXOSX__
+ auto edit = new wxMenu;
+ edit->Append (wxID_PREFERENCES, _("&Preferences...\tCtrl-P"));
+#endif
+
+ auto help = new wxMenu;
+#ifdef __WXOSX__
+ help->Append (wxID_ABOUT, _("About DCP-o-matic"));
+#else
+ help->Append (wxID_ABOUT, _("About"));
+#endif
+
+ m->Append (file, _("&File"));
+#ifndef __WXOSX__
+ m->Append (edit, _("&Edit"));
+#endif
+ m->Append (help, _("&Help"));
+ }
+
+
+ void config_changed ()
+ {
+ try {
+ Config::instance()->write_config();
+ } catch (exception& e) {
+ error_dialog (
+ this,
+ wxString::Format (
+ _("Could not write to config file at %s. Your changes have not been saved."),
+ std_to_wx (Config::instance()->cinemas_file().string()).data()
+ )
+ );
+ }
+ }
+
+ ContentDialog* _content_dialog;
+ PlaylistList* _playlist_list;
+ PlaylistContent* _playlist_content;
+ wxPreferencesEditor* _config_dialog;
+ boost::signals2::scoped_connection _config_changed_connection;