X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic_playlist.cc;h=835582c091d88ceef49f547c8f8a119af99ed8af;hp=5a8ee91267a9cb27aa65dbc42f828a36fe6257fd;hb=05fff51f80d5a2d5728fd40472d1c1e0f9e00300;hpb=bf471e4e6d2502bb3b4e2eb4b1309d87e1003070 diff --git a/src/tools/dcpomatic_playlist.cc b/src/tools/dcpomatic_playlist.cc index 5a8ee9126..835582c09 100644 --- a/src/tools/dcpomatic_playlist.cc +++ b/src/tools/dcpomatic_playlist.cc @@ -176,7 +176,9 @@ private: return; } - if (change == SignalSPL::Change::NAME) { + switch (change) { + case SignalSPL::Change::NAME: + { int N = 0; for (auto i: _playlists) { if (i == playlist) { @@ -184,6 +186,13 @@ private: } ++N; } + break; + } + case SignalSPL::Change::CONTENT: + if (auto dir = Config::instance()->player_playlist_directory()) { + playlist->write(*dir / (playlist->id() + ".xml")); + } + break; } } @@ -217,10 +226,20 @@ private: _list->SetItemState (_list->GetItemCount() - 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); } - void delete_playlist () + boost::optional selected() const { - long int selected = _list->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + long int selected = _list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (selected < 0 || selected >= int(_playlists.size())) { + return {}; + } + + return selected; + } + + void delete_playlist () + { + auto index = selected(); + if (!index) { return; } @@ -229,11 +248,11 @@ private: return; } - boost::filesystem::remove (*dir / (_playlists[selected]->id() + ".xml")); - _list->DeleteItem (selected); - _playlists.erase (_playlists.begin() + selected); + boost::filesystem::remove(*dir / (_playlists[*index]->id() + ".xml")); + _list->DeleteItem(*index); + _playlists.erase(_playlists.begin() + *index); - Edit (shared_ptr()); + Edit(shared_ptr()); } void selection_changed () @@ -314,6 +333,8 @@ public: _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)); + + setup_sensitivity(); } wxSizer* sizer () @@ -475,8 +496,6 @@ public: _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);