1 // SettingGitConfig.cpp : implementation file
\r
5 #include "TortoiseProc.h"
\r
6 #include "SettingGitConfig.h"
\r
8 #include "Settings.h"
\r
9 #include "GitAdminDir.h"
\r
10 #include "MessageBox.h"
\r
11 #include "ProjectProperties.h"
\r
12 // CSettingGitConfig dialog
\r
14 IMPLEMENT_DYNAMIC(CSettingGitConfig, ISettingsPropPage)
\r
16 CSettingGitConfig::CSettingGitConfig()
\r
17 : ISettingsPropPage(CSettingGitConfig::IDD)
\r
18 , m_UserName(_T(""))
\r
19 , m_UserEmail(_T(""))
\r
21 , m_bAutoCrlf(FALSE)
\r
22 , m_bSafeCrLf(FALSE)
\r
27 CSettingGitConfig::~CSettingGitConfig()
\r
31 void CSettingGitConfig::DoDataExchange(CDataExchange* pDX)
\r
33 CPropertyPage::DoDataExchange(pDX);
\r
34 DDX_Text(pDX, IDC_GIT_USERNAME, m_UserName);
\r
35 DDX_Text(pDX, IDC_GIT_USEREMAIL, m_UserEmail);
\r
36 DDX_Check(pDX, IDC_CHECK_GLOBAL, m_bGlobal);
\r
37 DDX_Check(pDX, IDC_CHECK_AUTOCRLF, m_bAutoCrlf);
\r
38 DDX_Check(pDX, IDC_CHECK_SAFECRLF, m_bSafeCrLf);
\r
42 BEGIN_MESSAGE_MAP(CSettingGitConfig, CPropertyPage)
\r
43 ON_BN_CLICKED(IDC_CHECK_GLOBAL, &CSettingGitConfig::OnBnClickedCheckGlobal)
\r
44 ON_EN_CHANGE(IDC_GIT_USERNAME, &CSettingGitConfig::OnEnChangeGitUsername)
\r
45 ON_EN_CHANGE(IDC_GIT_USEREMAIL, &CSettingGitConfig::OnEnChangeGitUseremail)
\r
46 ON_BN_CLICKED(IDC_CHECK_AUTOCRLF, &CSettingGitConfig::OnBnClickedCheckAutocrlf)
\r
47 ON_BN_CLICKED(IDC_CHECK_SAFECRLF, &CSettingGitConfig::OnBnClickedCheckSafecrlf)
\r
50 BOOL CSettingGitConfig::OnInitDialog()
\r
52 ISettingsPropPage::OnInitDialog();
\r
54 m_UserName=g_Git.GetUserName();
\r
55 m_UserEmail=g_Git.GetUserEmail();
\r
57 ProjectProperties::GetBOOLProps(this->m_bAutoCrlf,_T("core.autocrlf"));
\r
58 ProjectProperties::GetBOOLProps(this->m_bSafeCrLf, _T("core.safecrlf"));
\r
60 CString str=((CSettings*)GetParent())->m_CmdPath.GetWinPath();
\r
62 if( g_GitAdminDir.HasAdminDir(str,&proj) )
\r
64 this->SetWindowText(CString(_T("Config - "))+proj);
\r
65 this->GetDlgItem(IDC_CHECK_GLOBAL)->EnableWindow(TRUE);
\r
70 this->GetDlgItem(IDC_CHECK_GLOBAL)->EnableWindow(FALSE);
\r
73 this->UpdateData(FALSE);
\r
76 // CSettingGitConfig message handlers
\r
78 void CSettingGitConfig::OnBnClickedCheckGlobal()
\r
80 // TODO: Add your control notification handler code here
\r
84 void CSettingGitConfig::OnEnChangeGitUsername()
\r
86 // TODO: If this is a RICHEDIT control, the control will not
\r
87 // send this notification unless you override the ISettingsPropPage::OnInitDialog()
\r
88 // function and call CRichEditCtrl().SetEventMask()
\r
89 // with the ENM_CHANGE flag ORed into the mask.
\r
91 // TODO: Add your control notification handler code here
\r
95 void CSettingGitConfig::OnEnChangeGitUseremail()
\r
97 // TODO: If this is a RICHEDIT control, the control will not
\r
98 // send this notification unless you override the ISettingsPropPage::OnInitDialog()
\r
99 // function and call CRichEditCtrl().SetEventMask()
\r
100 // with the ENM_CHANGE flag ORed into the mask.
\r
102 // TODO: Add your control notification handler code here
\r
106 BOOL CSettingGitConfig::OnApply()
\r
108 CString cmd, out,global;
\r
109 this->UpdateData(FALSE);
\r
111 if(this->m_bGlobal)
\r
112 global = _T(" --global ");
\r
114 cmd.Format(_T("git.exe config %s user.name \"%s\""),global,this->m_UserName);
\r
115 if(g_Git.Run(cmd,&out,CP_ACP))
\r
117 CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
\r
121 cmd.Format(_T("git.exe config %s user.email \"%s\""),global,this->m_UserEmail);
\r
122 if(g_Git.Run(cmd,&out,CP_ACP))
\r
124 CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
\r
129 cmd.Format(_T("git.exe config %s core.autocrlf \"%s\""),global,this->m_bAutoCrlf?_T("true"):_T("false"));
\r
130 if(g_Git.Run(cmd,&out,CP_ACP))
\r
132 CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
\r
137 cmd.Format(_T("git.exe config %s core.safecrlf \"%s\""),global,this->m_bSafeCrLf?_T("true"):_T("false"));
\r
138 if(g_Git.Run(cmd,&out,CP_ACP))
\r
140 CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
\r
143 SetModified(FALSE);
\r
144 return ISettingsPropPage::OnApply();
\r
146 void CSettingGitConfig::OnBnClickedCheckAutocrlf()
\r
148 // TODO: Add your control notification handler code here
\r
152 void CSettingGitConfig::OnBnClickedCheckSafecrlf()
\r
154 // TODO: Add your control notification handler code here
\r