1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2011,2013 - TortoiseGit
4 // Copyright (C) 2003-2007,2011 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "TortoiseProc.h"
23 #include "StringUtils.h"
24 #include "SettingsProgsDiff.h"
27 IMPLEMENT_DYNAMIC(CSettingsProgsDiff
, ISettingsPropPage
)
28 CSettingsProgsDiff::CSettingsProgsDiff()
29 : ISettingsPropPage(CSettingsProgsDiff::IDD
)
30 , m_dlgAdvDiff(_T("Diff"))
33 , m_sDiffViewerPath(_T(""))
36 m_regDiffPath
= CRegString(_T("Software\\TortoiseGit\\Diff"));
37 m_regDiffViewerPath
= CRegString(_T("Software\\TortoiseGit\\DiffViewer"));
40 CSettingsProgsDiff::~CSettingsProgsDiff()
44 void CSettingsProgsDiff::DoDataExchange(CDataExchange
* pDX
)
46 ISettingsPropPage::DoDataExchange(pDX
);
47 DDX_Text(pDX
, IDC_EXTDIFF
, m_sDiffPath
);
48 DDX_Radio(pDX
, IDC_EXTDIFF_OFF
, m_iExtDiff
);
49 DDX_Text(pDX
, IDC_DIFFVIEWER
, m_sDiffViewerPath
);
50 DDX_Radio(pDX
, IDC_DIFFVIEWER_OFF
, m_iDiffViewer
);
52 GetDlgItem(IDC_EXTDIFF
)->EnableWindow(m_iExtDiff
== 1);
53 GetDlgItem(IDC_EXTDIFFBROWSE
)->EnableWindow(m_iExtDiff
== 1);
54 GetDlgItem(IDC_DIFFVIEWER
)->EnableWindow(m_iDiffViewer
== 1);
55 GetDlgItem(IDC_DIFFVIEWERBROWSE
)->EnableWindow(m_iDiffViewer
== 1);
56 DDX_Control(pDX
, IDC_EXTDIFF
, m_cDiffEdit
);
57 DDX_Control(pDX
, IDC_DIFFVIEWER
, m_cUnifiedDiffEdit
);
61 BEGIN_MESSAGE_MAP(CSettingsProgsDiff
, ISettingsPropPage
)
62 ON_BN_CLICKED(IDC_EXTDIFF_OFF
, OnBnClickedExtdiffOff
)
63 ON_BN_CLICKED(IDC_EXTDIFF_ON
, OnBnClickedExtdiffOn
)
64 ON_BN_CLICKED(IDC_EXTDIFFBROWSE
, OnBnClickedExtdiffbrowse
)
65 ON_BN_CLICKED(IDC_EXTDIFFADVANCED
, OnBnClickedExtdiffadvanced
)
66 ON_EN_CHANGE(IDC_EXTDIFF
, OnEnChangeExtdiff
)
67 ON_BN_CLICKED(IDC_DIFFVIEWER_OFF
, OnBnClickedDiffviewerOff
)
68 ON_BN_CLICKED(IDC_DIFFVIEWER_ON
, OnBnClickedDiffviewerOn
)
69 ON_BN_CLICKED(IDC_DIFFVIEWERBROWSE
, OnBnClickedDiffviewerbrowse
)
70 ON_EN_CHANGE(IDC_DIFFVIEWER
, OnEnChangeDiffviewer
)
74 BOOL
CSettingsProgsDiff::OnInitDialog()
78 m_sDiffPath
= m_regDiffPath
;
79 m_iExtDiff
= IsExternal(m_sDiffPath
);
81 SHAutoComplete(::GetDlgItem(m_hWnd
, IDC_EXTDIFF
), SHACF_FILESYSTEM
| SHACF_FILESYS_ONLY
);
83 m_sDiffViewerPath
= m_regDiffViewerPath
;
84 m_iDiffViewer
= IsExternal(m_sDiffViewerPath
);
86 SHAutoComplete(::GetDlgItem(m_hWnd
, IDC_DIFFVIEWER
), SHACF_FILESYSTEM
| SHACF_FILESYS_ONLY
);
88 m_tooltips
.Create(this);
89 m_tooltips
.AddTool(IDC_EXTDIFF
, IDS_SETTINGS_EXTDIFF_TT
);
90 m_tooltips
.AddTool(IDC_DIFFVIEWER
, IDS_SETTINGS_DIFFVIEWER_TT
);
96 BOOL
CSettingsProgsDiff::PreTranslateMessage(MSG
* pMsg
)
98 m_tooltips
.RelayEvent(pMsg
);
99 return ISettingsPropPage::PreTranslateMessage(pMsg
);
102 BOOL
CSettingsProgsDiff::OnApply()
105 if (m_iExtDiff
== 0 && !m_sDiffPath
.IsEmpty() && m_sDiffPath
.Left(1) != _T("#"))
107 m_sDiffPath
= _T("#") + m_sDiffPath
;
109 m_regDiffPath
= m_sDiffPath
;
111 m_dlgAdvDiff
.SaveData();
113 if (m_iDiffViewer
== 0 && !m_sDiffViewerPath
.IsEmpty() && m_sDiffViewerPath
.Left(1) != _T("#"))
114 m_sDiffViewerPath
= _T("#") + m_sDiffViewerPath
;
116 m_regDiffViewerPath
= m_sDiffViewerPath
;
119 return ISettingsPropPage::OnApply();
122 void CSettingsProgsDiff::OnBnClickedExtdiffOff()
126 GetDlgItem(IDC_EXTDIFF
)->EnableWindow(false);
127 GetDlgItem(IDC_EXTDIFFBROWSE
)->EnableWindow(false);
131 void CSettingsProgsDiff::OnBnClickedExtdiffOn()
135 GetDlgItem(IDC_EXTDIFF
)->EnableWindow(true);
136 GetDlgItem(IDC_EXTDIFFBROWSE
)->EnableWindow(true);
137 GetDlgItem(IDC_EXTDIFF
)->SetFocus();
141 void CSettingsProgsDiff::OnBnClickedExtdiffbrowse()
143 if (CAppUtils::FileOpenSave(m_sDiffPath
, NULL
, IDS_SETTINGS_SELECTDIFF
, IDS_PROGRAMSFILEFILTER
, true, m_hWnd
))
150 void CSettingsProgsDiff::OnBnClickedExtdiffadvanced()
152 if (m_dlgAdvDiff
.DoModal() == IDOK
)
156 void CSettingsProgsDiff::OnEnChangeExtdiff()
161 void CSettingsProgsDiff::CheckProgComment()
164 if (m_iExtDiff
== 0 && !m_sDiffPath
.IsEmpty() && m_sDiffPath
.Left(1) != _T("#"))
165 m_sDiffPath
= _T("#") + m_sDiffPath
;
166 else if (m_iExtDiff
== 1)
167 m_sDiffPath
.TrimLeft('#');
168 if (m_iDiffViewer
== 0 && !m_sDiffViewerPath
.IsEmpty() && m_sDiffViewerPath
.Left(1) != _T("#"))
169 m_sDiffViewerPath
= _T("#") + m_sDiffViewerPath
;
170 else if (m_iDiffViewer
== 1)
171 m_sDiffViewerPath
.TrimLeft('#');
175 void CSettingsProgsDiff::OnBnClickedDiffviewerOff()
179 GetDlgItem(IDC_DIFFVIEWER
)->EnableWindow(FALSE
);
180 GetDlgItem(IDC_DIFFVIEWERBROWSE
)->EnableWindow(FALSE
);
184 void CSettingsProgsDiff::OnBnClickedDiffviewerOn()
188 GetDlgItem(IDC_DIFFVIEWER
)->EnableWindow(TRUE
);
189 GetDlgItem(IDC_DIFFVIEWERBROWSE
)->EnableWindow(TRUE
);
190 GetDlgItem(IDC_DIFFVIEWER
)->SetFocus();
194 void CSettingsProgsDiff::OnEnChangeDiffviewer()
199 void CSettingsProgsDiff::OnBnClickedDiffviewerbrowse()
201 if (CAppUtils::FileOpenSave(m_sDiffViewerPath
, NULL
, IDS_SETTINGS_SELECTDIFFVIEWER
, IDS_PROGRAMSFILEFILTER
, true, m_hWnd
))