#endif
+static
+void
+save_playlist(shared_ptr<const SPL> playlist)
+{
+ if (auto dir = Config::instance()->player_playlist_directory()) {
+ playlist->write(*dir / (playlist->id() + ".xml"));
+ }
+}
+
+
class ContentDialog : public wxDialog, public ContentStore
{
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));
}
PlaylistList (wxPanel* parent, ContentStore* content_store)
: _sizer (new wxBoxSizer(wxVERTICAL))
, _content_store (content_store)
+ , _parent(parent)
{
auto label = new wxStaticText (parent, wxID_ANY, wxEmptyString);
label->SetLabelMarkup (_("<b>Playlists</b>"));
break;
}
case SignalSPL::Change::CONTENT:
- if (auto dir = Config::instance()->player_playlist_directory()) {
- playlist->write(*dir / (playlist->id() + ".xml"));
- }
+ save_playlist(playlist);
break;
}
}
void new_playlist ()
{
+ auto dir = Config::instance()->player_playlist_directory();
+ if (!dir) {
+ error_dialog(_parent, _("No playlist folder is specified in preferences. Please set one and then try again."));
+ return;
+ }
+
shared_ptr<SignalSPL> spl (new SignalSPL(wx_to_std(_("New Playlist"))));
add_playlist_to_model (spl);
add_playlist_to_view (spl);
wxButton* _delete;
vector<shared_ptr<SignalSPL>> _playlists;
ContentStore* _content_store;
+ wxWindow* _parent;
};
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);
_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));
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)
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));
ContentDialog* _content_dialog;
wxBoxSizer* _sizer;
wxTextCtrl* _name;
+ Button* _save_name;
wxListCtrl* _list;
wxButton* _up;
wxButton* _down;
_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;