+ auto dir = Config::instance()->player_playlist_directory();
+ if (!dir) {
+ return;
+ }
+
+ boost::filesystem::remove (*dir / (_playlists[selected]->id() + ".xml"));
+ _list->DeleteItem (selected);
+ _playlists.erase (_playlists.begin() + selected);
+
+ Edit (shared_ptr<SignalSPL>());
+ }
+
+ void selection_changed ()
+ {
+ long int selected = _list->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ if (selected < 0 || selected >= int(_playlists.size())) {
+ Edit (shared_ptr<SignalSPL>());
+ } else {
+ Edit (_playlists[selected]);
+ }
+ }
+
+ wxBoxSizer* _sizer;
+ wxListCtrl* _list;
+ wxButton* _new;
+ wxButton* _delete;
+ vector<shared_ptr<SignalSPL>> _playlists;
+ ContentStore* _content_store;
+};
+
+
+class PlaylistContent
+{
+public:
+ PlaylistContent (wxPanel* parent, ContentDialog* content_dialog)
+ : _content_dialog (content_dialog)
+ , _sizer (new wxBoxSizer(wxVERTICAL))
+ {
+ auto title = new wxBoxSizer (wxHORIZONTAL);
+ auto label = new wxStaticText (parent, wxID_ANY, wxEmptyString);
+ label->SetLabelMarkup (_("<b>Playlist:</b>"));
+ 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);
+ _sizer->Add (title, 0, wxTOP | wxLEFT, DCPOMATIC_SIZER_GAP * 2);
+
+ auto list = new wxBoxSizer (wxHORIZONTAL);
+
+ _list = new wxListCtrl (
+ parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL
+ );
+
+ _list->AppendColumn (_("Name"), wxLIST_FORMAT_LEFT, 400);
+ _list->AppendColumn (_("CPL"), wxLIST_FORMAT_LEFT, 350);
+ _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"), wxBITMAP_TYPE_PNG);
+ no_tick_icon.LoadFile (bitmap_path("no_tick"), 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);
+ _up = new Button (parent, _("Up"));
+ _down = new Button (parent, _("Down"));
+ _add = new Button (parent, _("Add"));
+ _remove = new Button (parent, _("Remove"));
+ button_sizer->Add (_up, 0, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
+ button_sizer->Add (_down, 0, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
+ button_sizer->Add (_add, 0, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
+ button_sizer->Add (_remove, 0, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
+
+ list->Add (button_sizer, 0, wxALL, DCPOMATIC_SIZER_GAP);
+
+ _sizer->Add (list);
+
+ _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));
+ _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));
+ _remove->Bind (wxEVT_BUTTON, bind(&PlaylistContent::remove_clicked, this));
+ }
+
+ wxSizer* sizer ()
+ {
+ return _sizer;
+ }
+
+ void set (shared_ptr<SignalSPL> playlist)
+ {
+ _playlist = playlist;
+ _list->DeleteAllItems ();
+ if (_playlist) {
+ for (auto i: _playlist->get()) {
+ add (i);
+ }
+ _name->SetValue (std_to_wx(_playlist->name()));
+ } else {
+ _name->SetValue (wxT(""));
+ }