Supporters update.
[dcpomatic.git] / src / tools / dcpomatic_playlist.cc
index 636a50f8ab9d6a3daafd36e564ba8d2ef65c871e..a373d81e69e518f329bbd69479f78c4b86534544 100644 (file)
 #include "wx/wx_signal_manager.h"
 #include "wx/wx_util.h"
 #include "lib/config.h"
+#include "lib/constants.h"
 #include "lib/cross.h"
 #include "lib/dcp_content.h"
 #include "lib/film.h"
 #include "lib/spl.h"
 #include "lib/spl_entry.h"
-#include "lib/util.h"
+#include <dcp/filesystem.h>
 #include <dcp/warnings.h>
 LIBDCP_DISABLE_WARNINGS
 #include <wx/imaglist.h>
@@ -90,6 +91,7 @@ public:
 
                overall_sizer->Layout ();
 
+               _content_view->Bind(wxEVT_LIST_ITEM_ACTIVATED, boost::bind(&ContentDialog::EndModal, this, wxID_OK));
                _config_changed_connection = Config::instance()->Changed.connect(boost::bind(&ContentView::update, _content_view));
        }
 
@@ -221,13 +223,15 @@ private:
 
                _list->DeleteAllItems ();
                _playlists.clear ();
-               for (auto i: boost::filesystem::directory_iterator(*path)) {
-                       auto spl = make_shared<SignalSPL>();
-                       try {
-                               spl->read (i, _content_store);
-                               add_playlist_to_model (spl);
-                       } catch (...) {}
-               }
+               try {
+                       for (auto i: dcp::filesystem::directory_iterator(*path)) {
+                               auto spl = make_shared<SignalSPL>();
+                               try {
+                                       spl->read (i, _content_store);
+                                       add_playlist_to_model (spl);
+                               } catch (...) {}
+                       }
+               } catch (...) {}
 
                for (auto i: _playlists) {
                        add_playlist_to_view (i);
@@ -270,7 +274,7 @@ private:
                        return;
                }
 
-               boost::filesystem::remove(*dir / (_playlists[*index]->id() + ".xml"));
+               dcp::filesystem::remove(*dir / (_playlists[*index]->id() + ".xml"));
                _list->DeleteItem(*index);
                _playlists.erase(_playlists.begin() + *index);
 
@@ -312,6 +316,8 @@ public:
                title->Add (label, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_GAP);
                _name = new wxTextCtrl (parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(400, -1));
                title->Add (_name, 0, wxRIGHT, DCPOMATIC_SIZER_GAP);
+               _save_name = new Button(parent, _("Save"));
+               title->Add(_save_name);
                _sizer->Add (title, 0, wxTOP | wxLEFT, DCPOMATIC_SIZER_GAP * 2);
 
                auto list = new wxBoxSizer (wxHORIZONTAL);
@@ -325,16 +331,6 @@ public:
                _list->AppendColumn (_("Type"), wxLIST_FORMAT_LEFT, 100);
                _list->AppendColumn (_("Encrypted"), wxLIST_FORMAT_CENTRE, 90);
 
-               auto images = new wxImageList (16, 16);
-               wxIcon tick_icon;
-               wxIcon no_tick_icon;
-               tick_icon.LoadFile (bitmap_path("tick.png"), wxBITMAP_TYPE_PNG);
-               no_tick_icon.LoadFile (bitmap_path("no_tick.png"), wxBITMAP_TYPE_PNG);
-               images->Add (tick_icon);
-               images->Add (no_tick_icon);
-
-               _list->SetImageList (images, wxIMAGE_LIST_SMALL);
-
                list->Add (_list, 1, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP);
 
                auto button_sizer = new wxBoxSizer (wxVERTICAL);
@@ -354,6 +350,7 @@ public:
                _list->Bind (wxEVT_COMMAND_LIST_ITEM_SELECTED, bind(&PlaylistContent::setup_sensitivity, this));
                _list->Bind (wxEVT_COMMAND_LIST_ITEM_DESELECTED, bind(&PlaylistContent::setup_sensitivity, this));
                _name->Bind (wxEVT_TEXT, bind(&PlaylistContent::name_changed, this));
+               _save_name->bind(&PlaylistContent::save_name_clicked, this);
                _up->Bind (wxEVT_BUTTON, bind(&PlaylistContent::up_clicked, this));
                _down->Bind (wxEVT_BUTTON, bind(&PlaylistContent::down_clicked, this));
                _add->Bind (wxEVT_BUTTON, bind(&PlaylistContent::add_clicked, this));
@@ -389,11 +386,18 @@ public:
 
 
 private:
-       void name_changed ()
+       void save_name_clicked()
        {
                if (_playlist) {
-                       _playlist->set_name (wx_to_std(_name->GetValue()));
+                       _playlist->set_name(wx_to_std(_name->GetValue()));
+                       save_playlist(_playlist);
                }
+               setup_sensitivity();
+       }
+
+       void name_changed ()
+       {
+               setup_sensitivity();
        }
 
        void add (SPLEntry e)
@@ -418,6 +422,7 @@ private:
                int const num_selected = _list->GetSelectedItemCount ();
                long int selected = _list->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
                _name->Enable (have_list);
+               _save_name->Enable(_playlist && _playlist->name() != wx_to_std(_name->GetValue()));
                _list->Enable (have_list);
                _up->Enable (have_list && selected > 0);
                _down->Enable (have_list && selected != -1 && selected < (_list->GetItemCount() - 1));
@@ -484,6 +489,7 @@ private:
        ContentDialog* _content_dialog;
        wxBoxSizer* _sizer;
        wxTextCtrl* _name;
+       Button* _save_name;
        wxListCtrl* _list;
        wxButton* _up;
        wxButton* _down;
@@ -538,9 +544,8 @@ private:
 
        void help_about ()
        {
-               auto d = new AboutDialog (this);
+               auto d = make_wx<AboutDialog>(this);
                d->ShowModal ();
-               d->Destroy ();
        }
 
        void edit_preferences ()
@@ -564,6 +569,7 @@ private:
        {
                auto file = new wxMenu;
 #ifdef __WXOSX__
+               file->Append(wxID_PREFERENCES, _("&Preferences...\tCtrl-,"));
                file->Append (wxID_EXIT, _("&Exit"));
 #else
                file->Append (wxID_EXIT, _("&Quit"));