std::shared_ptr
[dcpomatic.git] / src / tools / dcpomatic_playlist.cc
index f8f2a8bba834c36918fb02d66ce42d4a63847945..261f0897267d9fc834f4daadf9ab6f832cbc6232 100644 (file)
@@ -36,9 +36,6 @@
 #include <wx/imaglist.h>
 #include <wx/spinctrl.h>
 #include <wx/preferences.h>
-#ifdef __WXOSX__
-#include <ApplicationServices/ApplicationServices.h>
-#endif
 #include <boost/foreach.hpp>
 
 using std::exception;
@@ -48,10 +45,13 @@ using std::map;
 using std::make_pair;
 using std::vector;
 using boost::optional;
-using boost::shared_ptr;
-using boost::weak_ptr;
+using std::shared_ptr;
+using std::weak_ptr;
 using boost::bind;
-using boost::dynamic_pointer_cast;
+using std::dynamic_pointer_cast;
+#if BOOST_VERSION >= 106100
+using namespace boost::placeholders;
+#endif
 
 class ContentDialog : public wxDialog, public ContentStore
 {
@@ -73,6 +73,8 @@ public:
                }
 
                overall_sizer->Layout ();
+
+               _config_changed_connection = Config::instance()->Changed.connect(boost::bind(&ContentView::update, _content_view));
        }
 
        shared_ptr<Content> selected () const
@@ -87,6 +89,7 @@ public:
 
 private:
        ContentView* _content_view;
+       boost::signals2::scoped_connection _config_changed_connection;
 };
 
 
@@ -273,15 +276,8 @@ public:
                wxImageList* images = new wxImageList (16, 16);
                wxIcon tick_icon;
                wxIcon no_tick_icon;
-#ifdef DCPOMATIC_OSX
-               tick_icon.LoadFile ("tick.png", wxBITMAP_TYPE_PNG_RESOURCE);
-               no_tick_icon.LoadFile ("no_tick.png", wxBITMAP_TYPE_PNG_RESOURCE);
-#else
-               boost::filesystem::path tick_path = shared_path() / "tick.png";
-               tick_icon.LoadFile (std_to_wx(tick_path.string()), wxBITMAP_TYPE_PNG);
-               boost::filesystem::path no_tick_path = shared_path() / "no_tick.png";
-               no_tick_icon.LoadFile (std_to_wx(no_tick_path.string()), wxBITMAP_TYPE_PNG);
-#endif
+               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);
 
@@ -480,6 +476,8 @@ public:
                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);
+
+               _config_changed_connection = Config::instance()->Changed.connect(boost::bind(&DOMFrame::config_changed, this));
        }
 
 private:
@@ -518,7 +516,7 @@ private:
        {
                optional<boost::filesystem::path> dir = Config::instance()->player_playlist_directory();
                if (!dir) {
-                       error_dialog (this, _("No playlist folder is specified in preferences.  Please set on and then try again."));
+                       error_dialog (this, _("No playlist folder is specified in preferences.  Please set one and then try again."));
                        return;
                }
                playlist->write (*dir / (playlist->id() + ".xml"));
@@ -552,10 +550,28 @@ private:
                m->Append (help, _("&Help"));
        }
 
+
+       void config_changed ()
+       {
+               try {
+                       Config::instance()->write_config();
+               } catch (exception& e) {
+                       error_dialog (
+                               this,
+                               wxString::Format (
+                                       _("Could not write to config file at %s.  Your changes have not been saved."),
+                                       std_to_wx (Config::instance()->cinemas_file().string()).data()
+                                       )
+                               );
+               }
+       }
+
+
        ContentDialog* _content_dialog;
        PlaylistList* _playlist_list;
        PlaylistContent* _playlist_content;
        wxPreferencesEditor* _config_dialog;
+       boost::signals2::scoped_connection _config_changed_connection;
 };
 
 /** @class App
@@ -574,7 +590,8 @@ private:
        bool OnInit ()
        try
        {
-               SetAppName (_("DCP-o-matic KDM Creator"));
+               wxInitAllImageHandlers ();
+               SetAppName (_("DCP-o-matic Playlist Editor"));
 
                if (!wxApp::OnInit()) {
                        return false;
@@ -584,10 +601,8 @@ private:
                unsetenv ("UBUNTU_MENUPROXY");
 #endif
 
-#ifdef __WXOSX__
-               ProcessSerialNumber serial;
-               GetCurrentProcess (&serial);
-               TransformProcessType (&serial, kProcessTransformToForegroundApplication);
+#ifdef DCPOMATIC_OSX
+               make_foreground_application ();
 #endif
 
                dcpomatic_setup_path_encoding ();