1 // PathListCtrl.cpp : implementation file
\r
5 #include "TortoiseProc.h"
\r
6 #include "PatchListCtrl.h"
\r
7 #include "iconmenu.h"
\r
8 #include "AppUtils.h"
\r
10 #include "PathUtils.h"
\r
11 #include "AppUtils.h"
\r
14 IMPLEMENT_DYNAMIC(CPatchListCtrl, CListCtrl)
\r
16 CPatchListCtrl::CPatchListCtrl()
\r
18 m_ContextMenuMask=0xFFFFFFFF;
\r
21 CPatchListCtrl::~CPatchListCtrl()
\r
26 BEGIN_MESSAGE_MAP(CPatchListCtrl, CListCtrl)
\r
27 ON_NOTIFY_REFLECT(NM_DBLCLK, &CPatchListCtrl::OnNMDblclk)
\r
33 // CPatchListCtrl message handlers
\r
37 void CPatchListCtrl::OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult)
\r
39 LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
\r
40 // TODO: Add your control notification handler code here
\r
41 CString path=GetItemText(pNMItemActivate->iItem,0);
\r
43 gitpath.SetFromWin(path);
\r
45 CAppUtils::StartUnifiedDiffViewer(path,gitpath.GetFilename());
\r
51 void CPatchListCtrl::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
\r
53 // TODO: Add your message handler code here
\r
54 int selected=this->GetSelectedCount();
\r
56 POSITION pos=this->GetFirstSelectedItemPosition();
\r
57 index=this->GetNextSelectedItem(pos);
\r
60 if (popup.CreatePopupMenu())
\r
64 if( m_ContextMenuMask&GetMenuMask(MENU_VIEWPATCH))
\r
65 popup.AppendMenuIcon(MENU_VIEWPATCH, IDS_MENU_VIEWPATCH, 0);
\r
67 if( m_ContextMenuMask&GetMenuMask(MENU_VIEWWITHMERGE))
\r
68 popup.AppendMenuIcon(MENU_VIEWWITHMERGE, IDS_MENU_VIEWWITHMERGE, 0);
\r
70 popup.SetDefaultItem(MENU_VIEWPATCH, FALSE);
\r
74 if( m_ContextMenuMask&GetMenuMask(MENU_SENDMAIL))
\r
75 popup.AppendMenuIcon(MENU_SENDMAIL, IDS_MENU_SENDMAIL, IDI_MENUSENDMAIL);
\r
77 if( m_ContextMenuMask&GetMenuMask(MENU_APPLY))
\r
78 popup.AppendMenuIcon(MENU_APPLY, IDS_MENU_APPLY, 0);
\r
81 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
85 case MENU_VIEWPATCH:
\r
88 CString path=GetItemText(index,0);
\r
90 gitpath.SetFromWin(path);
\r
92 CAppUtils::StartUnifiedDiffViewer(path,gitpath.GetFilename());
\r
95 case MENU_VIEWWITHMERGE:
\r
97 CString path=GetItemText(index,0);
\r
99 gitpath.SetFromWin(path);
\r
102 dir.SetFromGit(g_Git.m_CurrentDir);
\r
104 CAppUtils::StartExtPatch(gitpath,dir);
\r
107 case MENU_SENDMAIL:
\r
109 LaunchProc(CString(_T("sendmail")));
\r
114 LaunchProc(CString(_T("importpatch")));
\r
124 int CPatchListCtrl::LaunchProc(CString& command)
\r
126 CString tempfile=GetTempFile();
\r
127 POSITION pos=this->GetFirstSelectedItemPosition();
\r
129 file.Open(tempfile,CFile::modeWrite|CFile::modeCreate);
\r
133 int index = this->GetNextSelectedItem(pos);
\r
134 CString one=this->GetItemText(index,0);
\r
135 file.Write(one.GetBuffer(),sizeof(TCHAR)*one.GetLength());
\r
136 file.Write(_T("\n"),sizeof(TCHAR)*1);
\r
142 cmd = CPathUtils::GetAppDirectory();
\r
143 cmd += _T("TortoiseProc.exe /command:");
\r
145 cmd +=_T(" /pathfile:\"");
\r
147 cmd += _T("\" /deletepathfile");
\r
148 CAppUtils::LaunchApplication(cmd, IDS_ERR_PROC,false);
\r