Update sensitivity of Set File button correctly.
authorCarl Hetherington <cth@carlh.net>
Sat, 7 Feb 2015 22:49:27 +0000 (22:49 +0000)
committerCarl Hetherington <cth@carlh.net>
Sat, 7 Feb 2015 22:49:27 +0000 (22:49 +0000)
src/wx/fonts_dialog.cc
src/wx/fonts_dialog.h

index 99d570263c12a88dcccb486a3fea70e23890b5a6..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
@@ -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);
+}
index c7ca789b8e069fcbfd82e9ecd40053d694e5eb3e..76eae3ec2a4518ca0687bba7489ea2a8ed272882 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
@@ -31,6 +31,8 @@ public:
 private:
        void setup ();
        void set_file_clicked ();
+       void update_sensitivity ();
+       void selection_changed ();
        
        boost::weak_ptr<SubtitleContent> _content;
        wxListCtrl* _fonts;