1 // SettingGitRemote.cpp : implementation file
\r
5 #include "TortoiseProc.h"
\r
6 #include "SettingGitRemote.h"
\r
7 #include "Settings.h"
\r
8 #include "GitAdminDir.h"
\r
9 #include "MessageBox.h"
\r
12 // CSettingGitRemote dialog
\r
14 IMPLEMENT_DYNAMIC(CSettingGitRemote, ISettingsPropPage)
\r
16 CSettingGitRemote::CSettingGitRemote()
\r
17 : ISettingsPropPage(CSettingGitRemote::IDD)
\r
18 , m_strRemote(_T(""))
\r
20 , m_strPuttyKeyfile(_T(""))
\r
25 CSettingGitRemote::~CSettingGitRemote()
\r
29 void CSettingGitRemote::DoDataExchange(CDataExchange* pDX)
\r
31 CPropertyPage::DoDataExchange(pDX);
\r
32 DDX_Control(pDX, IDC_LIST_REMOTE, m_ctrlRemoteList);
\r
33 DDX_Text(pDX, IDC_EDIT_REMOTE, m_strRemote);
\r
34 DDX_Text(pDX, IDC_EDIT_URL, m_strUrl);
\r
35 DDX_Control(pDX, IDC_CHECK_ISAUTOLOADPUTTYKEY, m_bAutoLoad);
\r
36 DDX_Text(pDX, IDC_EDIT_PUTTY_KEY, m_strPuttyKeyfile);
\r
40 BEGIN_MESSAGE_MAP(CSettingGitRemote, CPropertyPage)
\r
41 ON_BN_CLICKED(IDC_BUTTON_BROWSE, &CSettingGitRemote::OnBnClickedButtonBrowse)
\r
42 ON_BN_CLICKED(IDC_BUTTON_ADD, &CSettingGitRemote::OnBnClickedButtonAdd)
\r
43 ON_LBN_SELCHANGE(IDC_LIST_REMOTE, &CSettingGitRemote::OnLbnSelchangeListRemote)
\r
44 ON_EN_CHANGE(IDC_EDIT_REMOTE, &CSettingGitRemote::OnEnChangeEditRemote)
\r
45 ON_EN_CHANGE(IDC_EDIT_URL, &CSettingGitRemote::OnEnChangeEditUrl)
\r
46 ON_BN_CLICKED(IDC_CHECK_ISAUTOLOADPUTTYKEY, &CSettingGitRemote::OnBnClickedCheckIsautoloadputtykey)
\r
47 ON_EN_CHANGE(IDC_EDIT_PUTTY_KEY, &CSettingGitRemote::OnEnChangeEditPuttyKey)
\r
50 BOOL CSettingGitRemote::OnInitDialog()
\r
52 ISettingsPropPage::OnInitDialog();
\r
54 CString str=((CSettings*)GetParent())->m_CmdPath.GetWinPath();
\r
56 if( g_GitAdminDir.HasAdminDir(str,&proj) )
\r
58 this->SetWindowText(CString(_T("Config - "))+proj);
\r
62 cmd=_T("git.exe remote");
\r
63 if(g_Git.Run(cmd,&out,CP_ACP))
\r
65 CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
\r
69 m_ctrlRemoteList.ResetContent();
\r
73 one=out.Tokenize(_T("\n"),start);
\r
75 this->m_ctrlRemoteList.AddString(one);
\r
79 this->UpdateData(FALSE);
\r
82 // CSettingGitRemote message handlers
\r
84 void CSettingGitRemote::OnBnClickedButtonBrowse()
\r
86 // TODO: Add your control notification handler code here
\r
89 void CSettingGitRemote::OnBnClickedButtonAdd()
\r
91 // TODO: Add your control notification handler code here
\r
94 void CSettingGitRemote::OnLbnSelchangeListRemote()
\r
96 // TODO: Add your control notification handler code here
\r
99 if(CMessageBox::Show(NULL,_T("Remote Config Changed\nDo you want to save change now or discard change"),
\r
100 _T("TortoiseGit"),MB_YESNO) == IDYES)
\r
105 SetModified(FALSE);
\r
107 CString cmd,output;
\r
109 index = this->m_ctrlRemoteList.GetCurSel();
\r
114 m_ctrlRemoteList.GetText(index,remote);
\r
115 this->m_strRemote=remote;
\r
117 cmd.Format(_T("git.exe config remote.%s.url"),remote);
\r
119 if( g_Git.Run(cmd,&m_strUrl,CP_ACP) )
\r
121 //CMessageBox::Show(NULL,output,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
\r
126 m_strUrl = m_strUrl.Tokenize(_T("\n"),start);
\r
129 cmd.Format(_T("git.exe config remote.%s.puttykey"),remote);
\r
130 this->m_strPuttyKeyfile.Empty();
\r
131 if( g_Git.Run(cmd,&m_strPuttyKeyfile,CP_ACP) )
\r
133 //CMessageBox::Show(NULL,output,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
\r
137 m_strPuttyKeyfile = m_strPuttyKeyfile.Tokenize(_T("\n"),start);
\r
140 cmd.Format(_T("git.exe config remote.%s.puttykeyautoload"),remote);
\r
142 if( g_Git.Run(cmd,&autoload,CP_ACP) )
\r
144 //CMessageBox::Show(NULL,output,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
\r
149 autoload = autoload.Tokenize(_T("\n"),start);
\r
150 m_bAutoLoad.SetCheck(false);
\r
151 if( autoload == _T("true"))
\r
153 m_bAutoLoad.SetCheck(true);
\r
156 this->UpdateData(FALSE);
\r
160 void CSettingGitRemote::OnEnChangeEditRemote()
\r
162 // TODO: If this is a RICHEDIT control, the control will not
\r
163 // send this notification unless you override the ISettingsPropPage::OnInitDialog()
\r
164 // function and call CRichEditCtrl().SetEventMask()
\r
165 // with the ENM_CHANGE flag ORed into the mask.
\r
167 // TODO: Add your control notification handler code here
\r
170 void CSettingGitRemote::OnEnChangeEditUrl()
\r
172 // TODO: If this is a RICHEDIT control, the control will not
\r
173 // send this notification unless you override the ISettingsPropPage::OnInitDialog()
\r
174 // function and call CRichEditCtrl().SetEventMask()
\r
175 // with the ENM_CHANGE flag ORed into the mask.
\r
177 // TODO: Add your control notification handler code here
\r
180 void CSettingGitRemote::OnBnClickedCheckIsautoloadputtykey()
\r
182 // TODO: Add your control notification handler code here
\r
185 void CSettingGitRemote::OnEnChangeEditPuttyKey()
\r
187 // TODO: If this is a RICHEDIT control, the control will not
\r
188 // send this notification unless you override the ISettingsPropPage::OnInitDialog()
\r
189 // function and call CRichEditCtrl().SetEventMask()
\r
190 // with the ENM_CHANGE flag ORed into the mask.
\r
192 // TODO: Add your control notification handler code here
\r
195 BOOL CSettingGitRemote::OnApply()
\r
198 SetModified(FALSE);
\r
199 return ISettingsPropPage::OnApply();
\r