+void
+FontsDialog::set_file_clicked ()
+{
+ shared_ptr<SubtitleContent> content = _content.lock ();
+ if (!content) {
+ return;
+ }
+
+ int item = _fonts->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ if (item == -1) {
+ return;
+ }
+
+ /* The wxFD_CHANGE_DIR here prevents a `could not set working directory' error 123 on Windows when using
+ non-Latin filenames or paths.
+ */
+ wxFileDialog* d = new wxFileDialog (this, _("Choose a font file"), wxT (""), wxT (""), wxT ("*.ttf"), wxFD_CHANGE_DIR);
+ int const r = d->ShowModal ();
+
+ if (r != wxID_OK) {
+ d->Destroy ();
+ return;
+ }
+
+ string id = wx_to_std (_fonts->GetItemText (item, 0));
+
+ list<shared_ptr<Font> > fonts = content->fonts ();
+ for (list<shared_ptr<Font> >::iterator i = fonts.begin(); i != fonts.end(); ++i) {
+ if ((*i)->id == id) {
+ (*i)->file = wx_to_std (d->GetPath ());
+ }
+ }
+
+ d->Destroy ();
+
+ setup ();
+}