Hand-apply c165ea8ccadf5bb8c4401a23bb2e998fabdc8a9b from master.
[dcpomatic.git] / src / wx / fonts_dialog.cc
index 1edfcf100821bbbaa48e2539cb66dcea31980fcc..a4a3d26c449f895a3aa24a2422b2373833cdc75f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -70,8 +70,11 @@ FontsDialog::FontsDialog (wxWindow* parent, shared_ptr<SubtitleContent> content)
        SetSizerAndFit (overall_sizer);
 
        _set_file->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&FontsDialog::set_file_clicked, this));
+       _fonts->Bind (wxEVT_COMMAND_LIST_ITEM_SELECTED, boost::bind (&FontsDialog::selection_changed, this));
+       _fonts->Bind (wxEVT_COMMAND_LIST_ITEM_DESELECTED, boost::bind (&FontsDialog::selection_changed, this));
 
        setup ();
+       update_sensitivity ();
 }
 
 void
@@ -89,7 +92,7 @@ FontsDialog::setup ()
                wxListItem item;
                item.SetId (n);
                _fonts->InsertItem (item);
-               _fonts->SetItem (n, 0, (*i)->id.get_value_or (wx_to_std (_("[Default]"))));
+               _fonts->SetItem (n, 0, std_to_wx ((*i)->id));
                if ((*i)->file) {
                        _fonts->SetItem (n, 1, (*i)->file.get().leaf().string ());
                }
@@ -134,3 +137,16 @@ FontsDialog::set_file_clicked ()
 
        setup ();
 }
+
+void
+FontsDialog::selection_changed ()
+{
+       update_sensitivity ();
+}
+
+void
+FontsDialog::update_sensitivity ()
+{
+       int const item = _fonts->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+       _set_file->Enable (item != -1);
+}