Make sounds for indicating a warning or error work
[TortoiseGit.git] / src / TortoiseProc / Settings / ToolAssocDlg.cpp
blobe1a54c620280355c4acb44c89e2b5e13755114af
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2007, 2009, 2011 - 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.
19 #include "stdafx.h"
20 #include "TortoiseProc.h"
21 #include "ToolAssocDlg.h"
22 #include "AppUtils.h"
23 #include "StringUtils.h"
25 IMPLEMENT_DYNAMIC(CToolAssocDlg, CDialog)
26 CToolAssocDlg::CToolAssocDlg(const CString& type, bool add, CWnd* pParent /*=NULL*/)
27 : CDialog(CToolAssocDlg::IDD, pParent)
28 , m_sType(type)
29 , m_bAdd(add)
30 , m_sExtension(_T(""))
31 , m_sTool(_T(""))
35 CToolAssocDlg::~CToolAssocDlg()
39 void CToolAssocDlg::DoDataExchange(CDataExchange* pDX)
41 CDialog::DoDataExchange(pDX);
42 DDX_Text(pDX, IDC_EXTEDIT, m_sExtension);
43 DDX_Text(pDX, IDC_TOOLEDIT, m_sTool);
45 if (pDX->m_bSaveAndValidate)
47 if (m_sExtension.Find('/')<0)
49 m_sExtension.TrimLeft(_T("*"));
55 BEGIN_MESSAGE_MAP(CToolAssocDlg, CDialog)
56 ON_BN_CLICKED(IDC_TOOLBROWSE, OnBnClickedToolbrowse)
57 END_MESSAGE_MAP()
59 BOOL CToolAssocDlg::OnInitDialog()
61 CDialog::OnInitDialog();
63 EnableToolTips();
64 m_tooltips.Create(this);
66 CString title;
67 if (m_sType == _T("Diff"))
69 title.LoadString(m_bAdd ? IDS_DLGTITLE_ADD_DIFF_TOOL : IDS_DLGTITLE_EDIT_DIFF_TOOL);
70 m_tooltips.AddTool(IDC_TOOLEDIT, IDS_SETTINGS_EXTDIFF_TT);
72 else
74 title.LoadString(m_bAdd ? IDS_DLGTITLE_ADD_MERGE_TOOL : IDS_DLGTITLE_EDIT_MERGE_TOOL);
75 m_tooltips.AddTool(IDC_TOOLEDIT, IDS_SETTINGS_EXTMERGE_TT);
78 SetWindowText(title);
79 SHAutoComplete(::GetDlgItem(m_hWnd, IDC_TOOLEDIT), SHACF_FILESYSTEM | SHACF_FILESYS_ONLY);
81 UpdateData(FALSE);
82 return TRUE;
85 BOOL CToolAssocDlg::PreTranslateMessage(MSG* pMsg)
87 m_tooltips.RelayEvent(pMsg);
88 return CDialog::PreTranslateMessage(pMsg);
91 void CToolAssocDlg::OnBnClickedToolbrowse()
93 UpdateData(TRUE);
94 if (CAppUtils::FileOpenSave(m_sTool, NULL, IDS_SETTINGS_SELECTDIFF, IDS_PROGRAMSFILEFILTER, true, m_hWnd))
96 UpdateData(FALSE);