1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2007 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "TortoiseProc.h"
22 #include "StringUtils.h"
23 #include ".\settingsprogsunidiff.h"
26 IMPLEMENT_DYNAMIC(CSettingsProgsUniDiff
, ISettingsPropPage
)
27 CSettingsProgsUniDiff::CSettingsProgsUniDiff()
28 : ISettingsPropPage(CSettingsProgsUniDiff::IDD
)
29 , m_sDiffViewerPath(_T(""))
32 m_regDiffViewerPath
= CRegString(_T("Software\\TortoiseGit\\DiffViewer"));
35 CSettingsProgsUniDiff::~CSettingsProgsUniDiff()
39 void CSettingsProgsUniDiff::DoDataExchange(CDataExchange
* pDX
)
41 ISettingsPropPage::DoDataExchange(pDX
);
42 DDX_Text(pDX
, IDC_DIFFVIEWER
, m_sDiffViewerPath
);
43 DDX_Radio(pDX
, IDC_DIFFVIEWER_OFF
, m_iDiffViewer
);
45 GetDlgItem(IDC_DIFFVIEWER
)->EnableWindow(m_iDiffViewer
== 1);
46 GetDlgItem(IDC_DIFFVIEWERBROWSE
)->EnableWindow(m_iDiffViewer
== 1);
47 DDX_Control(pDX
, IDC_DIFFVIEWER
, m_cUnifiedDiffEdit
);
51 BEGIN_MESSAGE_MAP(CSettingsProgsUniDiff
, ISettingsPropPage
)
52 ON_BN_CLICKED(IDC_DIFFVIEWER_OFF
, OnBnClickedDiffviewerOff
)
53 ON_BN_CLICKED(IDC_DIFFVIEWER_ON
, OnBnClickedDiffviewerOn
)
54 ON_BN_CLICKED(IDC_DIFFVIEWERBROWSE
, OnBnClickedDiffviewerbrowse
)
55 ON_EN_CHANGE(IDC_DIFFVIEWER
, OnEnChangeDiffviewer
)
58 void CSettingsProgsUniDiff::OnBnClickedDiffviewerOff()
62 GetDlgItem(IDC_DIFFVIEWER
)->EnableWindow(FALSE
);
63 GetDlgItem(IDC_DIFFVIEWERBROWSE
)->EnableWindow(FALSE
);
67 void CSettingsProgsUniDiff::OnBnClickedDiffviewerOn()
71 GetDlgItem(IDC_DIFFVIEWER
)->EnableWindow(TRUE
);
72 GetDlgItem(IDC_DIFFVIEWERBROWSE
)->EnableWindow(TRUE
);
73 GetDlgItem(IDC_DIFFVIEWER
)->SetFocus();
77 void CSettingsProgsUniDiff::OnEnChangeDiffviewer()
82 void CSettingsProgsUniDiff::OnBnClickedDiffviewerbrowse()
84 if (CAppUtils::FileOpenSave(m_sDiffViewerPath
, NULL
, IDS_SETTINGS_SELECTDIFFVIEWER
, IDS_PROGRAMSFILEFILTER
, true, m_hWnd
))
91 BOOL
CSettingsProgsUniDiff::OnInitDialog()
93 ISettingsPropPage::OnInitDialog();
97 m_sDiffViewerPath
= m_regDiffViewerPath
;
98 m_iDiffViewer
= IsExternal(m_sDiffViewerPath
);
100 SHAutoComplete(::GetDlgItem(m_hWnd
, IDC_DIFFVIEWER
), SHACF_FILESYSTEM
| SHACF_FILESYS_ONLY
);
102 m_tooltips
.Create(this);
103 m_tooltips
.AddTool(IDC_DIFFVIEWER
, IDS_SETTINGS_DIFFVIEWER_TT
);
109 BOOL
CSettingsProgsUniDiff::PreTranslateMessage(MSG
* pMsg
)
111 m_tooltips
.RelayEvent(pMsg
);
112 return ISettingsPropPage::PreTranslateMessage(pMsg
);
115 BOOL
CSettingsProgsUniDiff::OnApply()
118 if (m_iDiffViewer
== 0 && !m_sDiffViewerPath
.IsEmpty() && m_sDiffViewerPath
.Left(1) != _T("#"))
119 m_sDiffViewerPath
= _T("#") + m_sDiffViewerPath
;
121 m_regDiffViewerPath
= m_sDiffViewerPath
;
123 return ISettingsPropPage::OnApply();
126 void CSettingsProgsUniDiff::CheckProgComment()
129 if (m_iDiffViewer
== 0 && !m_sDiffViewerPath
.IsEmpty() && m_sDiffViewerPath
.Left(1) != _T("#"))
130 m_sDiffViewerPath
= _T("#") + m_sDiffViewerPath
;
131 else if (m_iDiffViewer
== 1)
132 m_sDiffViewerPath
.TrimLeft('#');