Missing check_gl_error() calls.
[dcpomatic.git] / src / wx / i18n_hook.cc
index f7bc4829ddf908555781f478602b949880161ed5..f6b9636227f4a33196cc7453c87708ce27a23674 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
 */
 
+
 #include "i18n_hook.h"
 #include "instant_i18n_dialog.h"
 #include "wx_util.h"
 #include "lib/cross.h"
 #include <wx/wx.h>
-#include <boost/bind.hpp>
-#include <boost/filesystem.hpp>
+#include <boost/bind/bind.hpp>
+
+
+using std::map;
+using std::string;
+#if BOOST_VERSION >= 106100
+using namespace boost::placeholders;
+#endif
+
+
+map<string, string> I18NHook::_translations;
 
-I18NHook::I18NHook (wxWindow* window)
+I18NHook::I18NHook (wxWindow* window, wxString original)
        : _window (window)
+       , _original (original)
 {
        _window->Bind (wxEVT_MIDDLE_DOWN, bind(&I18NHook::handle, this, _1));
 }
 
+
 void
 I18NHook::handle (wxMouseEvent& ev)
 {
-       wxString const original = get_text ();
-
-       InstantI18NDialog* d = new InstantI18NDialog (_window, get_text());
+       auto d = new InstantI18NDialog (_window, get_text());
        d->ShowModal();
        set_text (d->get());
+       d->Destroy ();
 
-       wxWindow* w = _window;
+       auto w = _window;
        while (w) {
                if (w->GetContainingSizer()) {
                        w->GetContainingSizer()->Layout();
@@ -51,14 +62,5 @@ I18NHook::handle (wxMouseEvent& ev)
 
        ev.Skip ();
 
-       boost::filesystem::path file = "instant_i18n";
-
-       FILE* f = fopen_boost (file, "a");
-       if (!f) {
-               error_dialog (_window, wxString::Format(_("Could not open translation file %s"), std_to_wx(file.string()).data()));
-               return;
-       }
-       fprintf (f, "%s\n", wx_to_std(original).c_str());
-       fprintf (f, "%s\n", wx_to_std(get_text()).c_str());
-       fclose (f);
+       _translations[wx_to_std(_original)] = wx_to_std(get_text());
 }