--- /dev/null
+// PathListCtrl.cpp : implementation file\r
+//\r
+\r
+#include "stdafx.h"\r
+#include "TortoiseProc.h"\r
+#include "PatchListCtrl.h"\r
+#include "iconmenu.h"\r
+#include "AppUtils.h"\r
+#include "git.h"\r
+#include "PathUtils.h"\r
+#include "AppUtils.h"\r
+// CPatchListCtrl\r
+\r
+IMPLEMENT_DYNAMIC(CPatchListCtrl, CListCtrl)\r
+\r
+CPatchListCtrl::CPatchListCtrl()\r
+{\r
+ m_ContextMenuMask=0xFFFFFFFF;\r
+}\r
+\r
+CPatchListCtrl::~CPatchListCtrl()\r
+{\r
+}\r
+\r
+\r
+BEGIN_MESSAGE_MAP(CPatchListCtrl, CListCtrl)\r
+ ON_NOTIFY_REFLECT(NM_DBLCLK, &CPatchListCtrl::OnNMDblclk)\r
+ ON_WM_CONTEXTMENU()\r
+END_MESSAGE_MAP()\r
+\r
+\r
+\r
+// CPatchListCtrl message handlers\r
+\r
+\r
+\r
+void CPatchListCtrl::OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult)\r
+{\r
+ LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);\r
+ // TODO: Add your control notification handler code here\r
+ CString path=GetItemText(pNMItemActivate->iItem,0);\r
+ CTGitPath gitpath;\r
+ gitpath.SetFromWin(path);\r
+ \r
+ CAppUtils::StartUnifiedDiffViewer(path,gitpath.GetFilename());\r
+\r
+ *pResult = 0;\r
+\r
+}\r
+\r
+void CPatchListCtrl::OnContextMenu(CWnd* /*pWnd*/, CPoint point)\r
+{\r
+ // TODO: Add your message handler code here\r
+ int selected=this->GetSelectedCount();\r
+ int index=0;\r
+ POSITION pos=this->GetFirstSelectedItemPosition();\r
+ index=this->GetNextSelectedItem(pos);\r
+\r
+ CIconMenu popup;\r
+ if (popup.CreatePopupMenu())\r
+ {\r
+ if(selected == 1)\r
+ {\r
+ if( m_ContextMenuMask&GetMenuMask(MENU_VIEWPATCH))\r
+ popup.AppendMenuIcon(MENU_VIEWPATCH, IDS_MENU_VIEWPATCH, 0);\r
+\r
+ if( m_ContextMenuMask&GetMenuMask(MENU_VIEWWITHMERGE))\r
+ popup.AppendMenuIcon(MENU_VIEWWITHMERGE, IDS_MENU_VIEWWITHMERGE, 0);\r
+\r
+ popup.SetDefaultItem(MENU_VIEWPATCH, FALSE);\r
+ }\r
+ if(selected >= 1)\r
+ {\r
+ if( m_ContextMenuMask&GetMenuMask(MENU_SENDMAIL))\r
+ popup.AppendMenuIcon(MENU_SENDMAIL, IDS_MENU_SENDMAIL, IDI_MENUSENDMAIL);\r
+\r
+ if( m_ContextMenuMask&GetMenuMask(MENU_APPLY))\r
+ popup.AppendMenuIcon(MENU_APPLY, IDS_MENU_APPLY, 0);\r
+ }\r
+\r
+ int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);\r
+\r
+ switch (cmd)\r
+ {\r
+ case MENU_VIEWPATCH:\r
+ {\r
+\r
+ CString path=GetItemText(index,0);\r
+ CTGitPath gitpath;\r
+ gitpath.SetFromWin(path);\r
+ \r
+ CAppUtils::StartUnifiedDiffViewer(path,gitpath.GetFilename());\r
+ break;\r
+ }\r
+ case MENU_VIEWWITHMERGE:\r
+ {\r
+ CString path=GetItemText(index,0);\r
+ CTGitPath gitpath;\r
+ gitpath.SetFromWin(path);\r
+\r
+ CTGitPath dir;\r
+ dir.SetFromGit(g_Git.m_CurrentDir);\r
+\r
+ CAppUtils::StartExtPatch(gitpath,dir);\r
+ break;\r
+ }\r
+ case MENU_SENDMAIL:\r
+ {\r
+ LaunchProc(CString(_T("sendmail")));\r
+ break;\r
+ }\r
+ case MENU_APPLY:\r
+ {\r
+ LaunchProc(CString(_T("importpatch")));\r
+\r
+ break;\r
+ }\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+}\r
+\r
+int CPatchListCtrl::LaunchProc(CString& command)\r
+{\r
+ CString tempfile=GetTempFile();\r
+ POSITION pos=this->GetFirstSelectedItemPosition();\r
+ CFile file;\r
+ file.Open(tempfile,CFile::modeWrite|CFile::modeCreate);\r
+\r
+ while(pos)\r
+ {\r
+ int index = this->GetNextSelectedItem(pos);\r
+ CString one=this->GetItemText(index,0);\r
+ file.Write(one.GetBuffer(),sizeof(TCHAR)*one.GetLength());\r
+ file.Write(_T("\n"),sizeof(TCHAR)*1);\r
+ }\r
+\r
+ file.Close();\r
+\r
+ CString cmd;\r
+ cmd = CPathUtils::GetAppDirectory();\r
+ cmd += _T("TortoiseProc.exe /command:");\r
+ cmd += command;\r
+ cmd +=_T(" /pathfile:\"");\r
+ cmd += tempfile;\r
+ cmd += _T("\" /deletepathfile");\r
+ CAppUtils::LaunchApplication(cmd, IDS_ERR_PROC,false);\r
+ return 0;\r
+}\r
>\r
</File>\r
<File\r
- RelativePath="..\Resources\copy.ico"\r
+ RelativePath=".\copy.ico"\r
>\r
</File>\r
<File\r
- RelativePath=".\copy.ico"\r
+ RelativePath="..\Resources\copy.ico"\r
>\r
</File>\r
<File\r
>\r
</File>\r
<File\r
- RelativePath=".\explorer.ico"\r
+ RelativePath="..\Resources\explorer.ico"\r
>\r
</File>\r
<File\r
- RelativePath="..\Resources\explorer.ico"\r
+ RelativePath=".\explorer.ico"\r
>\r
</File>\r
<File\r
>\r
</File>\r
<File\r
- RelativePath="..\Resources\newfolder.ico"\r
+ RelativePath=".\newfolder.ico"\r
>\r
</File>\r
<File\r
- RelativePath=".\newfolder.ico"\r
+ RelativePath="..\Resources\newfolder.ico"\r
>\r
</File>\r
<File\r
>\r
</File>\r
<File\r
- RelativePath="..\Resources\refresh.ico"\r
+ RelativePath=".\refresh.ico"\r
>\r
</File>\r
<File\r
- RelativePath=".\refresh.ico"\r
+ RelativePath="..\Resources\refresh.ico"\r
>\r
</File>\r
<File\r
>\r
</File>\r
<File\r
- RelativePath=".\save.ico"\r
+ RelativePath="..\Resources\save.ico"\r
>\r
</File>\r
<File\r
- RelativePath="..\Resources\save.ico"\r
+ RelativePath=".\save.ico"\r
>\r
</File>\r
<File\r
>\r
</File>\r
<File\r
- RelativePath="..\Resources\up.ico"\r
+ RelativePath=".\up.ico"\r
>\r
</File>\r
<File\r
- RelativePath=".\up.ico"\r
+ RelativePath="..\Resources\up.ico"\r
>\r
</File>\r
<File\r
</File>\r
</Filter>\r
<Filter\r
- Name="Stash"\r
- >\r
- <File\r
- RelativePath=".\Commands\StashCommand.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Commands\StashCommand.h"\r
- >\r
- </File>\r
- </Filter>\r
- <Filter\r
Name="Clean"\r
>\r
<File\r
>\r
</File>\r
</Filter>\r
+ <Filter\r
+ Name="Stash"\r
+ >\r
+ <File\r
+ RelativePath=".\Commands\StashCommand.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\Commands\StashCommand.h"\r
+ >\r
+ </File>\r
+ </Filter>\r
</Filter>\r
<Filter\r
Name="Utility Dialogs"\r
>\r
</File>\r
<File\r
+ RelativePath=".\PatchListCtrl.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\PatchListCtrl.h"\r
+ >\r
+ </File>\r
+ <File\r
RelativePath=".\SwitchDlg.cpp"\r
>\r
</File>\r