1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2016 - TortoiseGit
4 // Copyright (C) 2003-2007, 2009, 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"
22 #include "ToolAssocDlg.h"
25 IMPLEMENT_DYNAMIC(CToolAssocDlg
, CDialog
)
26 CToolAssocDlg::CToolAssocDlg(const CString
& type
, bool add
, CWnd
* pParent
/*=nullptr*/)
27 : CDialog(CToolAssocDlg::IDD
, pParent
)
33 CToolAssocDlg::~CToolAssocDlg()
37 void CToolAssocDlg::DoDataExchange(CDataExchange
* pDX
)
39 CDialog::DoDataExchange(pDX
);
40 DDX_Text(pDX
, IDC_EXTEDIT
, m_sExtension
);
41 DDX_Text(pDX
, IDC_TOOLEDIT
, m_sTool
);
43 if (pDX
->m_bSaveAndValidate
)
45 if (m_sExtension
.Find(L
'/') < 0)
46 m_sExtension
.TrimLeft(L
'*');
51 BEGIN_MESSAGE_MAP(CToolAssocDlg
, CDialog
)
52 ON_BN_CLICKED(IDC_TOOLBROWSE
, OnBnClickedToolbrowse
)
55 BOOL
CToolAssocDlg::OnInitDialog()
57 CDialog::OnInitDialog();
60 m_tooltips
.Create(this);
63 if (m_sType
== L
"Diff")
65 title
.LoadString(m_bAdd
? IDS_DLGTITLE_ADD_DIFF_TOOL
: IDS_DLGTITLE_EDIT_DIFF_TOOL
);
66 m_tooltips
.AddTool(IDC_TOOLEDIT
, IDS_SETTINGS_EXTDIFF_TT
);
70 title
.LoadString(m_bAdd
? IDS_DLGTITLE_ADD_MERGE_TOOL
: IDS_DLGTITLE_EDIT_MERGE_TOOL
);
71 m_tooltips
.AddTool(IDC_TOOLEDIT
, IDS_SETTINGS_EXTMERGE_TT
);
75 SHAutoComplete(::GetDlgItem(m_hWnd
, IDC_TOOLEDIT
), SHACF_FILESYSTEM
| SHACF_FILESYS_ONLY
);
81 BOOL
CToolAssocDlg::PreTranslateMessage(MSG
* pMsg
)
83 m_tooltips
.RelayEvent(pMsg
);
84 return CDialog::PreTranslateMessage(pMsg
);
87 void CToolAssocDlg::OnBnClickedToolbrowse()
90 CString filename
= m_sTool
;
91 if (!PathFileExists(filename
))
93 if (!CAppUtils::FileOpenSave(filename
, nullptr, IDS_SETTINGS_SELECTDIFF
, IDS_PROGRAMSFILEFILTER
, true, m_hWnd
))