+ void add_clicked ()
+ {
+ int const r = _content_dialog->ShowModal ();
+ if (r == wxID_OK) {
+ shared_ptr<Content> content = _content_dialog->selected ();
+ if (content) {
+ add (SPLEntry(content));
+ }
+ }
+ }
+
+ void up_clicked ()
+ {
+ long int s = _list->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ if (s < 1) {
+ return;
+ }
+
+ SPLEntry tmp = _playlist[s];
+ _playlist[s] = _playlist[s-1];
+ _playlist[s-1] = tmp;
+
+ set_item (s - 1, _playlist[s-1]);
+ set_item (s, _playlist[s]);
+ }
+
+ void down_clicked ()
+ {
+ long int s = _list->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ if (s > (_list->GetItemCount() - 1)) {
+ return;
+ }
+
+ SPLEntry tmp = _playlist[s];
+ _playlist[s] = _playlist[s+1];
+ _playlist[s+1] = tmp;
+
+ set_item (s + 1, _playlist[s+1]);
+ set_item (s, _playlist[s]);
+ }
+
+ void remove_clicked ()
+ {
+ long int s = _list->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ if (s == -1) {
+ return;
+ }
+
+ _playlist.remove (s);
+ _list->DeleteItem (s);
+ }
+
+ void save_clicked ()
+ {
+ Config* c = Config::instance ();
+ wxString default_dir = c->player_playlist_directory() ? std_to_wx(c->player_playlist_directory()->string()) : wxString(wxEmptyString);
+ wxFileDialog* d = new wxFileDialog (this, _("Select playlist file"), default_dir, wxEmptyString, wxT("XML files (*.xml)|*.xml"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
+ if (d->ShowModal() == wxID_OK) {
+ _playlist.write (wx_to_std(d->GetPath()));
+ }
+ }
+
+ void load_clicked ()
+ {
+ Config* c = Config::instance ();
+ wxString default_dir = c->player_playlist_directory() ? std_to_wx(c->player_playlist_directory()->string()) : wxString(wxEmptyString);
+ wxFileDialog* d = new wxFileDialog (this, _("Select playlist file"), default_dir, wxEmptyString, wxT("XML files (*.xml)|*.xml"));
+ if (d->ShowModal() == wxID_OK) {
+ _list->DeleteAllItems ();
+ if (!_playlist.read (wx_to_std(d->GetPath()), _content_dialog)) {
+ BOOST_FOREACH (SPLEntry i, _playlist.get()) {
+ add (i);
+ }
+ } else {
+ error_dialog (this, _("Some content in this playlist was not found."));
+ }
+ }
+ }
+