summaryrefslogtreecommitdiff
path: root/src/wx/controls.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-10-28 19:44:53 +0000
committerCarl Hetherington <cth@carlh.net>2018-10-28 19:44:53 +0000
commit5feadb30fc839601345c4553c5a954ffc37bc1c7 (patch)
tree118dfc31cecf9dad728a37de370e3a6328d9633f /src/wx/controls.cc
parent47bf227f163b3dca8b07ae593f067793bccaefc8 (diff)
Untested loading of playlists into the list view.
Diffstat (limited to 'src/wx/controls.cc')
-rw-r--r--src/wx/controls.cc50
1 files changed, 48 insertions, 2 deletions
diff --git a/src/wx/controls.cc b/src/wx/controls.cc
index d8df6f2f3..62f75fde3 100644
--- a/src/wx/controls.cc
+++ b/src/wx/controls.cc
@@ -42,6 +42,7 @@
using std::string;
using std::list;
using std::make_pair;
+using std::exception;
using boost::optional;
using boost::shared_ptr;
using boost::weak_ptr;
@@ -200,6 +201,7 @@ Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor
setup_sensitivity ();
update_content_directory ();
+ update_playlist_directory ();
JobManager::instance()->ActiveJobsChanged.connect (
bind (&Controls::active_jobs_changed, this, _2)
@@ -236,7 +238,9 @@ Controls::save_clicked ()
);
if (d->ShowModal() == wxID_OK) {
- _film->write_metadata(wx_to_std(d->GetPath()));
+ boost::filesystem::path p(wx_to_std(d->GetPath()));
+ _film->set_name(p.stem().string());
+ _film->write_metadata(p);
}
d->Destroy ();
@@ -266,6 +270,8 @@ Controls::config_changed (int property)
{
if (property == Config::PLAYER_CONTENT_DIRECTORY) {
update_content_directory ();
+ } else if (property == Config::PLAYER_PLAYLIST_DIRECTORY) {
+ update_playlist_directory ();
} else {
setup_sensitivity ();
}
@@ -581,10 +587,11 @@ void
Controls::show_extended_player_controls (bool s)
{
_content_view->Show (s);
+ _spl_view->Show (s);
if (s) {
update_content_directory ();
+ update_playlist_directory ();
}
- _spl_view->Show (s);
_current_spl_view->Show (s);
_log->Show (s);
_add_button->Show (s);
@@ -625,6 +632,18 @@ Controls::add_content_to_list (shared_ptr<Content> content, wxListCtrl* ctrl)
}
void
+Controls::add_playlist_to_list (shared_ptr<Film> film)
+{
+ int const N = _spl_view->GetItemCount();
+
+ wxListItem it;
+ it.SetId(N);
+ it.SetColumn(0);
+ it.SetText (std_to_wx(film->name()));
+ _spl_view->InsertItem (it);
+}
+
+void
Controls::update_content_directory ()
{
if (!_content_view->IsShown()) {
@@ -677,6 +696,33 @@ Controls::update_content_directory ()
}
}
+void
+Controls::update_playlist_directory ()
+{
+ if (!_spl_view->IsShown()) {
+ return;
+ }
+
+ using namespace boost::filesystem;
+
+ _spl_view->DeleteAllItems ();
+ optional<path> dir = Config::instance()->player_playlist_directory();
+ if (!dir) {
+ return;
+ }
+
+ for (directory_iterator i = directory_iterator(*dir); i != directory_iterator(); ++i) {
+ try {
+ shared_ptr<Film> film (new Film(optional<path>()));
+ film->read_metadata (i->path());
+ _playlists.push_back (film);
+ add_playlist_to_list (film);
+ } catch (exception& e) {
+ /* Never mind */
+ }
+ }
+}
+
#ifdef DCPOMATIC_VARIANT_SWAROOP
void
Controls::pause_clicked ()