OSDN Git Service

Setting dialog, remote list work.
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / Settings / SettingGitRemote.cpp
index 0329290..7c51ad8 100644 (file)
@@ -4,7 +4,10 @@
 #include "stdafx.h"\r
 #include "TortoiseProc.h"\r
 #include "SettingGitRemote.h"\r
-\r
+#include "Settings.h"\r
+#include "GitAdminDir.h"\r
+#include "MessageBox.h"\r
+#include "git.h"\r
 \r
 // CSettingGitRemote dialog\r
 \r
@@ -16,7 +19,7 @@ CSettingGitRemote::CSettingGitRemote()
     , m_strUrl(_T(""))\r
     , m_strPuttyKeyfile(_T(""))\r
 {\r
-\r
+       m_bChanged=FALSE;\r
 }\r
 \r
 CSettingGitRemote::~CSettingGitRemote()\r
@@ -38,9 +41,44 @@ BEGIN_MESSAGE_MAP(CSettingGitRemote, CPropertyPage)
     ON_BN_CLICKED(IDC_BUTTON_BROWSE, &CSettingGitRemote::OnBnClickedButtonBrowse)\r
     ON_BN_CLICKED(IDC_BUTTON_ADD, &CSettingGitRemote::OnBnClickedButtonAdd)\r
     ON_LBN_SELCHANGE(IDC_LIST_REMOTE, &CSettingGitRemote::OnLbnSelchangeListRemote)\r
+    ON_EN_CHANGE(IDC_EDIT_REMOTE, &CSettingGitRemote::OnEnChangeEditRemote)\r
+    ON_EN_CHANGE(IDC_EDIT_URL, &CSettingGitRemote::OnEnChangeEditUrl)\r
+    ON_BN_CLICKED(IDC_CHECK_ISAUTOLOADPUTTYKEY, &CSettingGitRemote::OnBnClickedCheckIsautoloadputtykey)\r
+    ON_EN_CHANGE(IDC_EDIT_PUTTY_KEY, &CSettingGitRemote::OnEnChangeEditPuttyKey)\r
 END_MESSAGE_MAP()\r
 \r
+BOOL CSettingGitRemote::OnInitDialog()\r
+{\r
+       ISettingsPropPage::OnInitDialog();\r
+\r
+       CString str=((CSettings*)GetParent())->m_CmdPath.GetWinPath();\r
+       CString proj;\r
+       if(     g_GitAdminDir.HasAdminDir(str,&proj) )\r
+       {\r
+               this->SetWindowText(CString(_T("Config - "))+proj);\r
+       }\r
 \r
+       CString cmd,out;\r
+       cmd=_T("git.exe remote");\r
+       if(g_Git.Run(cmd,&out,CP_ACP))\r
+       {\r
+               CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+               return FALSE;\r
+       }\r
+       int start =0;\r
+       m_ctrlRemoteList.ResetContent();\r
+       do\r
+       {\r
+               CString one;\r
+               one=out.Tokenize(_T("\n"),start);\r
+               if(!one.IsEmpty())\r
+                       this->m_ctrlRemoteList.AddString(one);\r
+\r
+       }while(start>=0);\r
+               \r
+       this->UpdateData(FALSE);\r
+       return TRUE;\r
+}\r
 // CSettingGitRemote message handlers\r
 \r
 void CSettingGitRemote::OnBnClickedButtonBrowse()\r
@@ -56,4 +94,107 @@ void CSettingGitRemote::OnBnClickedButtonAdd()
 void CSettingGitRemote::OnLbnSelchangeListRemote()\r
 {\r
     // TODO: Add your control notification handler code here\r
+       if(m_bChanged)\r
+       {\r
+               if(CMessageBox::Show(NULL,_T("Remote Config Changed\nDo you want to save change now or discard change"),\r
+                                                                _T("TortoiseGit"),MB_YESNO) == IDYES)\r
+               {\r
+                       OnApply();\r
+               }\r
+       }\r
+       SetModified(FALSE);\r
+       \r
+       CString cmd,output;\r
+       int index;\r
+       index = this->m_ctrlRemoteList.GetCurSel();\r
+       if(index<0)\r
+               return;\r
+\r
+       CString remote;\r
+       m_ctrlRemoteList.GetText(index,remote);\r
+       this->m_strRemote=remote;\r
+\r
+       cmd.Format(_T("git.exe config remote.%s.url"),remote);\r
+       m_strUrl.Empty();\r
+       if( g_Git.Run(cmd,&m_strUrl,CP_ACP) )\r
+       {\r
+               //CMessageBox::Show(NULL,output,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+               //return;\r
+       }\r
+       \r
+       int start=0;\r
+       m_strUrl = m_strUrl.Tokenize(_T("\n"),start);\r
+\r
+\r
+       cmd.Format(_T("git.exe config remote.%s.puttykey"),remote);\r
+       this->m_strPuttyKeyfile.Empty();\r
+       if( g_Git.Run(cmd,&m_strPuttyKeyfile,CP_ACP) )\r
+       {\r
+               //CMessageBox::Show(NULL,output,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+               //return;\r
+       }\r
+       start=0;\r
+       m_strPuttyKeyfile = m_strPuttyKeyfile.Tokenize(_T("\n"),start);\r
+       \r
+\r
+       cmd.Format(_T("git.exe config remote.%s.puttykeyautoload"),remote);\r
+       CString autoload;\r
+       if( g_Git.Run(cmd,&autoload,CP_ACP) )\r
+       {\r
+               //CMessageBox::Show(NULL,output,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+               //return;\r
+       }\r
+\r
+       start=0;\r
+       autoload = autoload.Tokenize(_T("\n"),start);\r
+       m_bAutoLoad.SetCheck(false);\r
+       if( autoload == _T("true"))\r
+       {\r
+               m_bAutoLoad.SetCheck(true);\r
+       }\r
+       \r
+       this->UpdateData(FALSE);\r
+\r
 }\r
+\r
+void CSettingGitRemote::OnEnChangeEditRemote()\r
+{\r
+    // TODO:  If this is a RICHEDIT control, the control will not\r
+    // send this notification unless you override the ISettingsPropPage::OnInitDialog()\r
+    // function and call CRichEditCtrl().SetEventMask()\r
+    // with the ENM_CHANGE flag ORed into the mask.\r
+\r
+    // TODO:  Add your control notification handler code here\r
+}\r
+\r
+void CSettingGitRemote::OnEnChangeEditUrl()\r
+{\r
+    // TODO:  If this is a RICHEDIT control, the control will not\r
+    // send this notification unless you override the ISettingsPropPage::OnInitDialog()\r
+    // function and call CRichEditCtrl().SetEventMask()\r
+    // with the ENM_CHANGE flag ORed into the mask.\r
+\r
+    // TODO:  Add your control notification handler code here\r
+}\r
+\r
+void CSettingGitRemote::OnBnClickedCheckIsautoloadputtykey()\r
+{\r
+    // TODO: Add your control notification handler code here\r
+}\r
+\r
+void CSettingGitRemote::OnEnChangeEditPuttyKey()\r
+{\r
+    // TODO:  If this is a RICHEDIT control, the control will not\r
+    // send this notification unless you override the ISettingsPropPage::OnInitDialog()\r
+    // function and call CRichEditCtrl().SetEventMask()\r
+    // with the ENM_CHANGE flag ORed into the mask.\r
+\r
+    // TODO:  Add your control notification handler code here\r
+}\r
+\r
+BOOL CSettingGitRemote::OnApply()\r
+{\r
+  \r
+    SetModified(FALSE);\r
+       return ISettingsPropPage::OnApply();\r
+}
\ No newline at end of file