From 9ac2687b441decf0fca4f6b95ebdf56b5669b313 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Tue, 1 Feb 2011 15:36:56 +0100 Subject: [PATCH] centralized starting code for notepad2 Signed-off-by: Sven Strickroth --- src/Git/GitStatusListCtrl.cpp | 8 ++------ src/TortoiseProc/AppUtils.cpp | 9 +++++++++ src/TortoiseProc/AppUtils.h | 7 ++++++- src/TortoiseProc/Settings/SettingGitConfig.cpp | 10 ++-------- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/Git/GitStatusListCtrl.cpp b/src/Git/GitStatusListCtrl.cpp index 6709da3ab..a4a757d79 100644 --- a/src/Git/GitStatusListCtrl.cpp +++ b/src/Git/GitStatusListCtrl.cpp @@ -5912,12 +5912,8 @@ void CGitStatusListCtrl::OpenFile(CTGitPath*filepath,int mode) } if(mode == NOTEPAD2) { - CString sCmd; - sCmd.Format(_T("\"%s\" \"%s\""), - (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("notepad2.exe")), file); - - CAppUtils::LaunchApplication(sCmd, NULL, false); - return ; + CAppUtils::LaunchNotepad2(file); + return; } int ret = HINSTANCE_ERROR; diff --git a/src/TortoiseProc/AppUtils.cpp b/src/TortoiseProc/AppUtils.cpp index 10ec07cfa..da305052a 100644 --- a/src/TortoiseProc/AppUtils.cpp +++ b/src/TortoiseProc/AppUtils.cpp @@ -706,6 +706,15 @@ bool CAppUtils::LaunchPAgent(CString *keyfile,CString * pRemote) ::DeleteFile(tempfile); return true; } +bool CAppUtils::LaunchNotepad2(const CString& filename) +{ + CString sCmd; + sCmd.Format(_T("\"%s\" \"%s\""), + (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("notepad2.exe")), filename); + + LaunchApplication(sCmd, NULL, false); + return true; +} bool CAppUtils::LaunchRemoteSetting() { CSettings dlg(IDS_PROC_SETTINGS_TITLE, &CTGitPath(g_Git.m_CurrentDir)); diff --git a/src/TortoiseProc/AppUtils.h b/src/TortoiseProc/AppUtils.h index 3796ae202..76b4978b8 100644 --- a/src/TortoiseProc/AppUtils.h +++ b/src/TortoiseProc/AppUtils.h @@ -118,7 +118,12 @@ public: */ static bool LaunchTortoiseBlame( const CString& sBlameFile, CString Rev, const CString& sParams = CString()); - + + /** + * Launch notepad2 + */ + static bool LaunchNotepad2(const CString& filename); + /** * Formats text in a rich edit control (version 2). * text in between * chars is formatted bold diff --git a/src/TortoiseProc/Settings/SettingGitConfig.cpp b/src/TortoiseProc/Settings/SettingGitConfig.cpp index 526f6aa86..e44ee0c68 100644 --- a/src/TortoiseProc/Settings/SettingGitConfig.cpp +++ b/src/TortoiseProc/Settings/SettingGitConfig.cpp @@ -157,20 +157,14 @@ void CSettingGitConfig::OnBnClickedEditglobalgitconfig() SHGetFolderPath(NULL, CSIDL_PROFILE, NULL, SHGFP_TYPE_CURRENT, buf); CString path = buf; path += _T("\\.gitconfig"); - CString sCmd; // use Notepad2 because of LineEndings - sCmd.Format(_T("\"%s\" \"%s\""), - (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("notepad2.exe")), path); - CAppUtils::LaunchApplication(sCmd, NULL, false); + CAppUtils::LaunchNotepad2(path); } void CSettingGitConfig::OnBnClickedEditlocalgitconfig() { CString path = g_Git.m_CurrentDir; path += _T("\\.git\\config"); - CString sCmd; // use Notepad2 because of LineEndings - sCmd.Format(_T("\"%s\" \"%s\""), - (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("notepad2.exe")), path); - CAppUtils::LaunchApplication(sCmd, NULL, false); + CAppUtils::LaunchNotepad2(path); } -- 2.11.4.GIT