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