Dynamically remove/insert the Options for encryption in the menus.
authorMatt Corallo <matt@bluematt.me>
Tue, 28 Jun 2011 23:08:48 +0000 (01:08 +0200)
committerMatt Corallo <matt@bluematt.me>
Wed, 13 Jul 2011 00:11:25 +0000 (02:11 +0200)
share/uiproject.fbp
src/ui.cpp
src/uibase.cpp
src/uibase.h

index cc735c6..d5e6b1e 100644 (file)
                         <property name="kind">wxITEM_NORMAL</property>\r
                         <property name="label">&amp;Encrypt Wallet...</property>\r
                         <property name="name">m_menuOptionsEncryptWallet</property>\r
-                        <property name="permission">none</property>\r
+                        <property name="permission">public</property>\r
                         <property name="shortcut"></property>\r
                         <property name="unchecked_bitmap"></property>\r
                         <event name="OnMenuSelection">OnMenuOptionsEncryptWallet</event>\r
                         <property name="kind">wxITEM_NORMAL</property>\r
                         <property name="label">&amp;Change Wallet Encryption Passphrase...</property>\r
                         <property name="name">m_menuOptionsChangeWalletPassphrase</property>\r
-                        <property name="permission">none</property>\r
+                        <property name="permission">public</property>\r
                         <property name="shortcut"></property>\r
                         <property name="unchecked_bitmap"></property>\r
                         <event name="OnMenuSelection">OnMenuOptionsChangeWalletPassphrase</event>\r
index 52315e1..9e099ae 100644 (file)
@@ -368,6 +368,11 @@ CMainFrame::CMainFrame(wxWindow* parent) : CMainFrameBase(parent)
     if (CWalletDB(pwalletMain->strWalletFile,"r").ReadDefaultKey(vchPubKey))
         m_textCtrlAddress->SetValue(PubKeyToAddress(vchPubKey));
 
+    if (pwalletMain->IsCrypted())
+        m_menuOptions->Remove(m_menuOptionsEncryptWallet);
+    else
+        m_menuOptions->Remove(m_menuOptionsChangeWalletPassphrase);
+
     // Fill listctrl with wallet transactions
     RefreshListCtrl();
 }
@@ -1217,6 +1222,9 @@ void CMainFrame::OnMenuOptionsEncryptWallet(wxCommandEvent& event)
     munlock(&strWalletPass[0], strWalletPass.capacity());
     munlock(&strWalletPassTest[0], strWalletPassTest.capacity());
     wxMessageBox(_("Wallet Encrypted.\nRemember that encrypting your wallet cannot fully protect your bitcoins from being stolen by malware infecting your computer."), "Bitcoin");
+
+    m_menuOptions->Remove(m_menuOptionsEncryptWallet);
+    m_menuOptions->Insert(m_menuOptions->GetMenuItemCount() - 1, m_menuOptionsChangeWalletPassphrase);
 }
 
 void CMainFrame::OnMenuOptionsChangeWalletPassphrase(wxCommandEvent& event)
index 9ac4ec8..18eec44 100644 (file)
@@ -32,11 +32,9 @@ CMainFrameBase::CMainFrameBase( wxWindow* parent, wxWindowID id, const wxString&
        m_menuOptionsChangeYourAddress = new wxMenuItem( m_menuOptions, wxID_ANY, wxString( _("&Your Receiving Addresses...") ) , wxEmptyString, wxITEM_NORMAL );
        m_menuOptions->Append( m_menuOptionsChangeYourAddress );
        
-       wxMenuItem* m_menuOptionsEncryptWallet;
        m_menuOptionsEncryptWallet = new wxMenuItem( m_menuOptions, wxID_ANY, wxString( _("&Encrypt Wallet...") ) , wxEmptyString, wxITEM_NORMAL );
        m_menuOptions->Append( m_menuOptionsEncryptWallet );
        
-       wxMenuItem* m_menuOptionsChangeWalletPassphrase;
        m_menuOptionsChangeWalletPassphrase = new wxMenuItem( m_menuOptions, wxID_ANY, wxString( _("&Change Wallet Encryption Passphrase...") ) , wxEmptyString, wxITEM_NORMAL );
        m_menuOptions->Append( m_menuOptionsChangeWalletPassphrase );
        
index e2dbb0b..ca0730b 100644 (file)
@@ -117,6 +117,8 @@ class CMainFrameBase : public wxFrame
        
        public:
                wxMenu* m_menuOptions;
+               wxMenuItem* m_menuOptionsEncryptWallet;
+               wxMenuItem* m_menuOptionsChangeWalletPassphrase;
                wxStatusBar* m_statusBar;
                wxTextCtrl* m_textCtrlAddress;
                wxListCtrl* m_listCtrlAll;