1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2015 - TortoiseGit
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 // ImportPatchDlg.cpp : implementation file
23 #include "TortoiseProc.h"
24 #include "ImportPatchDlg.h"
26 #include "MessageBox.h"
28 #include "SmartHandle.h"
29 #include "LoglistCommonResource.h"
31 // CImportPatchDlg dialog
33 IMPLEMENT_DYNAMIC(CImportPatchDlg
, CResizableStandAloneDialog
)
35 CImportPatchDlg::CImportPatchDlg(CWnd
* pParent
/*=NULL*/)
36 : CResizableStandAloneDialog(CImportPatchDlg::IDD
, pParent
)
37 , m_LoadingThread(FALSE
)
39 m_cList
.m_ContextMenuMask
&=~ m_cList
.GetMenuMask(CPatchListCtrl::MENU_APPLY
);
43 m_bExitThread
= false;
44 m_bThreadRunning
=false;
48 m_bAddSignedOffBy
= FALSE
;
52 CImportPatchDlg::~CImportPatchDlg()
57 void CImportPatchDlg::DoDataExchange(CDataExchange
* pDX
)
59 CDialog::DoDataExchange(pDX
);
60 DDX_Control(pDX
, IDC_LIST_PATCH
,m_cList
);
61 DDX_Control(pDX
, IDC_AM_SPLIT
, m_wndSplitter
);
62 DDX_Check(pDX
, IDC_CHECK_3WAY
, m_b3Way
);
63 DDX_Check(pDX
, IDC_CHECK_IGNORE_SPACE
, m_bIgnoreSpace
);
64 DDX_Check(pDX
, IDC_SIGN_OFF
, m_bAddSignedOffBy
);
65 DDX_Check(pDX
, IDC_KEEP_CR
, m_bKeepCR
);
68 void CImportPatchDlg::AddAmAnchor()
70 AddAnchor(IDC_AM_TAB
,TOP_LEFT
,BOTTOM_RIGHT
);
71 AddAnchor(IDC_LIST_PATCH
, TOP_LEFT
, TOP_RIGHT
);
72 AddAnchor(IDC_AM_SPLIT
, TOP_LEFT
, TOP_RIGHT
);
73 AddAnchor(IDC_BUTTON_ADD
, TOP_RIGHT
);
74 AddAnchor(IDC_BUTTON_UP
, TOP_RIGHT
);
75 AddAnchor(IDC_BUTTON_DOWN
, TOP_RIGHT
);
76 AddAnchor(IDC_BUTTON_REMOVE
, TOP_RIGHT
);
78 AddAnchor(IDOK
,BOTTOM_RIGHT
);
79 AddAnchor(IDCANCEL
,BOTTOM_RIGHT
);
80 AddAnchor(IDHELP
, BOTTOM_RIGHT
);
82 AddAnchor(IDC_AM_DUMY_TAB
, TOP_LEFT
, BOTTOM_RIGHT
);
84 this->AddOthersToAnchor();
87 void CImportPatchDlg::SetSplitterRange()
89 if ((m_cList
)&&(m_ctrlTabCtrl
))
92 m_cList
.GetWindowRect(rcTop
);
93 ScreenToClient(rcTop
);
95 m_ctrlTabCtrl
.GetWindowRect(rcMiddle
);
96 ScreenToClient(rcMiddle
);
97 if (rcMiddle
.Height() && rcMiddle
.Width())
98 m_wndSplitter
.SetRange(rcTop
.top
+160, rcMiddle
.bottom
-160);
102 BOOL
CImportPatchDlg::OnInitDialog()
104 CResizableStandAloneDialog::OnInitDialog();
105 CAppUtils::MarkWindowAsUnpinnable(m_hWnd
);
107 // Let the TaskbarButtonCreated message through the UIPI filter. If we don't
108 // do this, Explorer would be unable to send that message to our window if we
109 // were running elevated. It's OK to make the call all the time, since if we're
110 // not elevated, this is a no-op.
111 CHANGEFILTERSTRUCT cfs
= { sizeof(CHANGEFILTERSTRUCT
) };
112 typedef BOOL STDAPICALLTYPE
ChangeWindowMessageFilterExDFN(HWND hWnd
, UINT message
, DWORD action
, PCHANGEFILTERSTRUCT pChangeFilterStruct
);
113 CAutoLibrary hUser
= AtlLoadSystemLibraryUsingFullPath(_T("user32.dll"));
116 ChangeWindowMessageFilterExDFN
*pfnChangeWindowMessageFilterEx
= (ChangeWindowMessageFilterExDFN
*)GetProcAddress(hUser
, "ChangeWindowMessageFilterEx");
117 if (pfnChangeWindowMessageFilterEx
)
119 pfnChangeWindowMessageFilterEx(m_hWnd
, WM_TASKBARBTNCREATED
, MSGFLT_ALLOW
, &cfs
);
122 m_pTaskbarList
.Release();
123 if (FAILED(m_pTaskbarList
.CoCreateInstance(CLSID_TaskbarList
)))
124 m_pTaskbarList
= nullptr;
128 GetClientRect(m_DlgOrigRect
);
129 m_cList
.GetClientRect(m_PatchListOrigRect
);
131 CWnd
*pwnd
=this->GetDlgItem(IDC_AM_DUMY_TAB
);
132 pwnd
->GetWindowRect(&rectDummy
);
133 this->ScreenToClient(rectDummy
);
135 if (!m_ctrlTabCtrl
.Create(CMFCTabCtrl::STYLE_FLAT
, rectDummy
, this, IDC_AM_TAB
))
137 TRACE0("Failed to create output tab window\n");
138 return FALSE
; // fail to create
140 m_ctrlTabCtrl
.SetResizeMode(CMFCTabCtrl::RESIZE_NO
);
141 // Create output panes:
143 if( ! this->m_PatchCtrl
.Create(_T("Scintilla"),_T("source"),0,rectDummy
,&m_ctrlTabCtrl
,0,0) )
145 TRACE0("Failed to create log message control");
149 m_PatchCtrl
.Call(SCI_SETREADONLY
, TRUE
);
150 m_PatchCtrl
.SetUDiffStyle();
152 if (!m_wndOutput
.Create(_T("Scintilla"),_T("source"),0,rectDummy
, &m_ctrlTabCtrl
, 0,0) )
154 TRACE0("Failed to create output windows\n");
155 return -1; // fail to create
157 m_wndOutput
.Init(-1, FALSE
);
158 m_wndOutput
.Call(SCI_SETREADONLY
, TRUE
);
160 m_tooltips
.AddTool(IDC_CHECK_3WAY
,IDS_AM_3WAY_TT
);
161 m_tooltips
.AddTool(IDC_CHECK_IGNORE_SPACE
,IDS_AM_IGNORE_SPACE_TT
);
163 m_ctrlTabCtrl
.AddTab(&m_PatchCtrl
, CString(MAKEINTRESOURCE(IDS_PATCH
)), 0);
164 m_ctrlTabCtrl
.AddTab(&m_wndOutput
, CString(MAKEINTRESOURCE(IDS_LOG
)), 1);
167 AdjustControlSize(IDC_CHECK_3WAY
);
168 AdjustControlSize(IDC_CHECK_IGNORE_SPACE
);
169 AdjustControlSize(IDC_SIGN_OFF
);
170 AdjustControlSize(IDC_KEEP_CR
);
172 m_PathList
.SortByPathname(true);
173 m_cList
.SetExtendedStyle( m_cList
.GetExtendedStyle()| LVS_EX_CHECKBOXES
);
174 m_cList
.InsertColumn(0, L
"");
176 for (int i
= 0; i
< m_PathList
.GetCount(); ++i
)
178 m_cList
.InsertItem(0,m_PathList
[i
].GetWinPath());
179 m_cList
.SetCheck(0,true);
181 m_cList
.SetColumnWidth(0, LVSCW_AUTOSIZE
);
183 DWORD yPos
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\AMDlgSizer"));
184 RECT rcDlg
, rcLogMsg
, rcFileList
;
185 GetClientRect(&rcDlg
);
186 m_cList
.GetWindowRect(&rcLogMsg
);
187 ScreenToClient(&rcLogMsg
);
188 this->m_ctrlTabCtrl
.GetWindowRect(&rcFileList
);
189 ScreenToClient(&rcFileList
);
193 m_wndSplitter
.GetWindowRect(&rectSplitter
);
194 ScreenToClient(&rectSplitter
);
195 int delta
= yPos
- rectSplitter
.top
;
196 if ((rcLogMsg
.bottom
+ delta
> rcLogMsg
.top
)&&(rcLogMsg
.bottom
+ delta
< rcFileList
.bottom
- 30))
198 m_wndSplitter
.SetWindowPos(NULL
, 0, yPos
, 0, 0, SWP_NOSIZE
);
203 CAppUtils::SetListCtrlBackgroundImage(m_cList
.GetSafeHwnd(), IDI_IMPORTPATHCES_BKG
);
205 CString sWindowTitle
;
206 GetWindowText(sWindowTitle
);
207 CAppUtils::SetWindowTitle(m_hWnd
, g_Git
.m_CurrentDir
, sWindowTitle
);
209 EnableSaveRestore(_T("ImportDlg"));
216 BEGIN_MESSAGE_MAP(CImportPatchDlg
, CResizableStandAloneDialog
)
217 ON_LBN_SELCHANGE(IDC_LIST_PATCH
, &CImportPatchDlg::OnLbnSelchangeListPatch
)
218 ON_BN_CLICKED(IDC_BUTTON_ADD
, &CImportPatchDlg::OnBnClickedButtonAdd
)
219 ON_BN_CLICKED(IDC_BUTTON_UP
, &CImportPatchDlg::OnBnClickedButtonUp
)
220 ON_BN_CLICKED(IDC_BUTTON_DOWN
, &CImportPatchDlg::OnBnClickedButtonDown
)
221 ON_BN_CLICKED(IDC_BUTTON_REMOVE
, &CImportPatchDlg::OnBnClickedButtonRemove
)
222 ON_BN_CLICKED(IDOK
, &CImportPatchDlg::OnBnClickedOk
)
224 ON_BN_CLICKED(IDCANCEL
, &CImportPatchDlg::OnBnClickedCancel
)
225 ON_NOTIFY(LVN_ITEMCHANGED
, IDC_LIST_PATCH
, &CImportPatchDlg::OnHdnItemchangedListPatch
)
226 ON_REGISTERED_MESSAGE(WM_TASKBARBTNCREATED
, OnTaskbarBtnCreated
)
230 // CImportPatchDlg message handlers
232 void CImportPatchDlg::OnLbnSelchangeListPatch()
234 if(m_cList
.GetSelectedCount() == 0)
236 this->GetDlgItem(IDC_BUTTON_UP
)->EnableWindow(FALSE
);
237 this->GetDlgItem(IDC_BUTTON_DOWN
)->EnableWindow(FALSE
);
238 this->GetDlgItem(IDC_BUTTON_REMOVE
)->EnableWindow(FALSE
);
242 this->GetDlgItem(IDC_BUTTON_UP
)->EnableWindow(TRUE
);
243 this->GetDlgItem(IDC_BUTTON_DOWN
)->EnableWindow(TRUE
);
244 this->GetDlgItem(IDC_BUTTON_REMOVE
)->EnableWindow(TRUE
);
248 void CImportPatchDlg::OnBnClickedButtonAdd()
250 CFileDialog
dlg(TRUE
,NULL
,
252 OFN_HIDEREADONLY
| OFN_OVERWRITEPROMPT
|OFN_ALLOWMULTISELECT
,
253 CString(MAKEINTRESOURCE(IDS_PATCHFILEFILTER
)));
254 dlg
.m_ofn
.nMaxFile
= 65536;
255 std::unique_ptr
<TCHAR
[]> path(new TCHAR
[dlg
.m_ofn
.nMaxFile
]);
256 SecureZeroMemory(path
.get(), dlg
.m_ofn
.nMaxFile
);
257 dlg
.m_ofn
.lpstrFile
= path
.get();
258 INT_PTR ret
= dlg
.DoModal();
259 SetCurrentDirectory(g_Git
.m_CurrentDir
);
263 pos
= dlg
.GetStartPosition();
266 CString file
= dlg
.GetNextPathName(pos
);
270 int index
= m_cList
.InsertItem(m_cList
.GetItemCount(), file
);
272 m_cList
.SetCheck(index
, true);
275 m_cList
.SetColumnWidth(0, LVSCW_AUTOSIZE
);
279 void CImportPatchDlg::OnBnClickedButtonUp()
282 pos
= m_cList
.GetFirstSelectedItemPosition();
284 // do nothing if the first selected item is the first item in the list
285 if (m_cList
.GetNextSelectedItem(pos
) == 0)
288 pos
= m_cList
.GetFirstSelectedItemPosition();
292 int index
= m_cList
.GetNextSelectedItem(pos
);
295 CString old
= m_cList
.GetItemText(index
, 0);
296 BOOL oldState
= m_cList
.GetCheck(index
);
297 m_cList
.DeleteItem(index
);
298 m_cList
.InsertItem(index
- 1, old
);
299 m_cList
.SetCheck(index
- 1, oldState
);
300 m_cList
.SetItemState(index
- 1, LVIS_SELECTED
, LVIS_SELECTED
);
301 m_cList
.SetItemState(index
, 0, LVIS_SELECTED
);
307 void CImportPatchDlg::OnBnClickedButtonDown()
309 if (m_cList
.GetSelectedCount() == 0)
313 pos
= m_cList
.GetFirstSelectedItemPosition();
314 // use an array to store all selected item indexes; the user won't select too much items
316 indexes
= new int[m_cList
.GetSelectedCount()];
320 indexes
[i
++] = m_cList
.GetNextSelectedItem(pos
);
323 // don't move any item if the last selected item is the last item in the m_CommitList
324 // (that would change the order of the selected items)
325 if(indexes
[m_cList
.GetSelectedCount() - 1] < m_cList
.GetItemCount() - 1)
327 // iterate over the indexes backwards in order to correctly move multiselected items
328 for (i
= m_cList
.GetSelectedCount() - 1; i
>= 0; i
--)
330 int index
= indexes
[i
];
331 CString old
= m_cList
.GetItemText(index
, 0);
332 BOOL oldState
= m_cList
.GetCheck(index
);
333 m_cList
.DeleteItem(index
);
334 m_cList
.InsertItem(index
+ 1, old
);
335 m_cList
.SetCheck(index
+ 1, oldState
);
336 m_cList
.SetItemState(index
+ 1, LVIS_SELECTED
, LVIS_SELECTED
);
337 m_cList
.SetItemState(index
, 0, LVIS_SELECTED
);
344 void CImportPatchDlg::OnBnClickedButtonRemove()
347 pos
= m_cList
.GetFirstSelectedItemPosition();
350 int index
= m_cList
.GetNextSelectedItem(pos
);
351 m_cList
.DeleteItem(index
);
352 pos
= m_cList
.GetFirstSelectedItemPosition();
354 m_cList
.SetColumnWidth(0, LVSCW_AUTOSIZE
);
357 UINT
CImportPatchDlg::PatchThread()
360 path
.SetFromWin(g_Git
.m_CurrentDir
);
363 UpdateOkCancelText();
364 for (i
= m_CurrentItem
; i
< m_cList
.GetItemCount(); ++i
)
368 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NORMAL
);
369 m_pTaskbarList
->SetProgressValue(m_hWnd
, i
, m_cList
.GetItemCount());
372 m_cList
.SetItemData(i
, CPatchListCtrl::STATUS_APPLYING
|m_cList
.GetItemData(i
));
375 this->m_cList
.GetItemRect(i
,&rect
,LVIR_BOUNDS
);
376 this->m_cList
.InvalidateRect(rect
);
378 m_cList
.SetColumnWidth(0, LVSCW_AUTOSIZE
);
379 m_cList
.EnsureVisible(i
, FALSE
);
384 if(m_cList
.GetCheck(i
))
388 while(path
.HasRebaseApply())
391 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_ERROR
);
393 int ret
= CMessageBox::Show(NULL
, IDS_PROC_APPLYPATCH_REBASEDIRFOUND
,
395 1, IDI_ERROR
, IDS_ABORTBUTTON
, IDS_SKIPBUTTON
, IDS_RESOLVEDBUTTON
);
400 cmd
= _T("git.exe am --abort");
403 cmd
= _T("git.exe am --skip");
407 cmd
= _T("git.exe am --resolved");
414 m_bExitThread
= TRUE
;
418 this->AddLogString(cmd
);
420 if (g_Git
.Run(cmd
, &output
, CP_UTF8
))
422 this->AddLogString(output
);
423 this->AddLogString(CString(MAKEINTRESOURCE(IDS_FAIL
)));
427 this->AddLogString(CString(MAKEINTRESOURCE(IDS_DONE
)));
434 cmd
= _T("git.exe am ");
436 if(this->m_bAddSignedOffBy
)
437 cmd
+= _T("--signoff ");
440 cmd
+= _T("--3way ");
442 if(this->m_bIgnoreSpace
)
443 cmd
+= _T("--ignore-space-change ");
446 cmd
+= _T("--keep-cr ");
449 cmd
+= m_cList
.GetItemText(i
,0);
452 this->AddLogString(cmd
);
454 if (g_Git
.Run(cmd
, &output
, CP_UTF8
))
456 //keep STATUS_APPLYING to let user retry failed patch
457 m_cList
.SetItemData(i
, CPatchListCtrl::STATUS_APPLY_FAIL
|CPatchListCtrl::STATUS_APPLYING
);
458 this->AddLogString(output
);
459 this->AddLogString(CString(MAKEINTRESOURCE(IDS_FAIL
)));
461 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_ERROR
);
467 m_cList
.SetItemData(i
, CPatchListCtrl::STATUS_APPLY_SUCCESS
);
468 this->AddLogString(CString(MAKEINTRESOURCE(IDS_SUCCESS
)));
475 sMessage
.Format(IDS_PROC_SKIPPATCH
, m_cList
.GetItemText(i
,0));
476 AddLogString(sMessage
);
477 m_cList
.SetItemData(i
, CPatchListCtrl::STATUS_APPLY_SKIP
);
480 m_cList
.SetItemData(m_CurrentItem
, (~CPatchListCtrl::STATUS_APPLYING
)&m_cList
.GetItemData(i
));
483 this->m_cList
.GetItemRect(i
,&rect
,LVIR_BOUNDS
);
484 this->m_cList
.InvalidateRect(rect
);
486 UpdateOkCancelText();
489 //in case am fail, need refresh finial item status
491 this->m_cList
.GetItemRect(i
,&rect
,LVIR_BOUNDS
);
492 this->m_cList
.InvalidateRect(rect
);
494 this->m_cList
.GetItemRect(m_CurrentItem
,&rect
,LVIR_BOUNDS
);
495 this->m_cList
.InvalidateRect(rect
);
499 m_pTaskbarList
->SetProgressValue(m_hWnd
, m_CurrentItem
, m_cList
.GetItemCount());
500 if (m_bExitThread
&& m_CurrentItem
!= m_cList
.GetItemCount())
501 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_PAUSED
);
502 else if (!m_bExitThread
&& m_CurrentItem
== m_cList
.GetItemCount())
503 m_pTaskbarList
->SetProgressState(m_hWnd
, TBPF_NORMAL
);
506 EnableInputCtrl(true);
507 InterlockedExchange(&m_bThreadRunning
, FALSE
);
508 UpdateOkCancelText();
512 void CImportPatchDlg::OnBnClickedOk()
525 m_ctrlTabCtrl
.SetActiveTab(1);
527 EnableInputCtrl(false);
528 InterlockedExchange(&m_bThreadRunning
, TRUE
);
529 InterlockedExchange(&this->m_bExitThread
, FALSE
);
530 if ( (m_LoadingThread
=AfxBeginThread(ThreadEntry
, this)) ==NULL
)
532 InterlockedExchange(&m_bThreadRunning
, FALSE
);
533 CMessageBox::Show(NULL
, IDS_ERR_THREADSTARTFAILED
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
538 void CImportPatchDlg::DoSize(int delta
)
540 this->RemoveAllAnchors();
542 CSplitterControl::ChangeHeight(GetDlgItem(IDC_LIST_PATCH
), delta
, CW_TOPALIGN
);
543 //CSplitterControl::ChangeHeight(GetDlgItem(), delta, CW_TOPALIGN);
544 CSplitterControl::ChangeHeight(GetDlgItem(IDC_AM_TAB
), -delta
, CW_BOTTOMALIGN
);
545 //CSplitterControl::ChangeHeight(GetDlgItem(), -delta, CW_BOTTOMALIGN);
546 CSplitterControl::ChangePos(GetDlgItem(IDC_CHECK_3WAY
), 0, delta
);
547 CSplitterControl::ChangePos(GetDlgItem(IDC_CHECK_IGNORE_SPACE
), 0, delta
);
548 CSplitterControl::ChangePos(GetDlgItem(IDC_SIGN_OFF
), 0, delta
);
549 CSplitterControl::ChangePos(GetDlgItem(IDC_KEEP_CR
), 0, delta
);
552 // adjust the minimum size of the dialog to prevent the resizing from
553 // moving the list control too far down.
555 m_cList
.GetClientRect(rcLogMsg
);
556 SetMinTrackSize(CSize(m_DlgOrigRect
.Width(), m_DlgOrigRect
.Height()-m_PatchListOrigRect
.Height()+rcLogMsg
.Height()));
559 // m_CommitList.Invalidate();
561 // GetDlgItem(IDC_LOGMESSAGE)->Invalidate();
563 this->m_ctrlTabCtrl
.Invalidate();
566 void CImportPatchDlg::OnSize(UINT nType
, int cx
, int cy
)
568 CResizableStandAloneDialog::OnSize(nType
, cx
, cy
);
573 LRESULT
CImportPatchDlg::DefWindowProc(UINT message
, WPARAM wParam
, LPARAM lParam
)
577 if (wParam
== IDC_AM_SPLIT
)
579 SPC_NMHDR
* pHdr
= (SPC_NMHDR
*) lParam
;
585 return CResizableStandAloneDialog::DefWindowProc(message
, wParam
, lParam
);
588 void CImportPatchDlg::SaveSplitterPos()
592 CRegDWORD regPos
= CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\AMDlgSizer"));
594 m_wndSplitter
.GetWindowRect(&rectSplitter
);
595 ScreenToClient(&rectSplitter
);
596 regPos
= rectSplitter
.top
;
602 void CImportPatchDlg::EnableInputCtrl(BOOL b
)
604 this->GetDlgItem(IDC_BUTTON_UP
)->EnableWindow(b
);
605 this->GetDlgItem(IDC_BUTTON_DOWN
)->EnableWindow(b
);
606 this->GetDlgItem(IDC_BUTTON_REMOVE
)->EnableWindow(b
);
607 this->GetDlgItem(IDC_BUTTON_ADD
)->EnableWindow(b
);
608 this->GetDlgItem(IDOK
)->EnableWindow(b
);
611 void CImportPatchDlg::UpdateOkCancelText()
613 if (this->m_bThreadRunning
&& !IsFinish())
615 this->GetDlgItem(IDOK
)->EnableWindow(FALSE
);
616 this->GetDlgItem(IDCANCEL
)->SetWindowText(CString(MAKEINTRESOURCE(IDS_ABORTBUTTON
)));
618 else if (!IsFinish())
620 this->GetDlgItem(IDOK
)->EnableWindow(TRUE
);
624 this->GetDlgItem(IDCANCEL
)->EnableWindow(FALSE
);
625 this->GetDlgItem(IDOK
)->SetWindowText(CString(MAKEINTRESOURCE(IDS_OKBUTTON
)));
628 void CImportPatchDlg::OnBnClickedCancel()
630 if(this->m_bThreadRunning
)
632 InterlockedExchange(&m_bExitThread
,TRUE
);
637 path
.SetFromWin(g_Git
.m_CurrentDir
);
638 if(path
.HasRebaseApply())
639 if(CMessageBox::Show(NULL
, IDS_PROC_APPLYPATCH_GITAMACTIVE
, IDS_APPNAME
, MB_YESNO
| MB_ICONQUESTION
) == IDYES
)
642 if (g_Git
.Run(_T("git.exe am --abort"), &output
, CP_UTF8
))
643 MessageBox(output
, _T("TortoiseGit"), MB_OK
| MB_ICONERROR
);
649 void CImportPatchDlg::AddLogString(CString str
)
651 this->m_wndOutput
.SendMessage(SCI_SETREADONLY
, FALSE
);
652 CStringA sTextA
= m_wndOutput
.StringForControl(str
);//CUnicodeUtils::GetUTF8(str);
653 this->m_wndOutput
.SendMessage(SCI_REPLACESEL
, 0, (LPARAM
)(LPCSTR
)sTextA
);
654 this->m_wndOutput
.SendMessage(SCI_REPLACESEL
, 0, (LPARAM
)(LPCSTR
)"\n");
655 this->m_wndOutput
.SendMessage(SCI_SETREADONLY
, TRUE
);
656 //this->m_wndOutput.SendMessage(SCI_LINESCROLL,0,0x7FFFFFFF);
658 BOOL
CImportPatchDlg::PreTranslateMessage(MSG
* pMsg
)
660 if (pMsg
->message
== WM_KEYDOWN
)
662 switch (pMsg
->wParam
)
665 /* Avoid TAB control destroy but dialog exist*/
669 TCHAR buff
[128] = { 0 };
670 ::GetClassName(pMsg
->hwnd
,buff
,128);
672 /* Use MSFTEDIT_CLASS http://msdn.microsoft.com/en-us/library/bb531344.aspx */
673 if (_tcsnicmp(buff
, MSFTEDIT_CLASS
, 128) == 0 || //Unicode and MFC 2012 and later
674 _tcsnicmp(buff
, RICHEDIT_CLASS
, 128) == 0 || //ANSI or MFC 2010
675 _tcsnicmp(buff
,_T("Scintilla"),128)==0 ||
676 _tcsnicmp(buff
,_T("SysListView32"),128)==0||
677 ::GetParent(pMsg
->hwnd
) == this->m_ctrlTabCtrl
.m_hWnd
)
679 this->PostMessage(WM_KEYDOWN
,VK_ESCAPE
,0);
685 return CResizableStandAloneDialog::PreTranslateMessage(pMsg
);
688 void CImportPatchDlg::OnHdnItemchangedListPatch(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
692 if(this->m_cList
.GetSelectedCount() != 1)
694 m_PatchCtrl
.SendMessage(SCI_SETREADONLY
, FALSE
);
695 m_PatchCtrl
.SetText(CString());
696 m_PatchCtrl
.SendMessage(SCI_SETREADONLY
, TRUE
);
703 pos
= m_cList
.GetFirstSelectedItemPosition();
704 int selected
= m_cList
.GetNextSelectedItem(pos
);
706 if(selected
>=0&& selected
< m_cList
.GetItemCount())
708 CString str
= m_cList
.GetItemText(selected
,0);
709 m_PatchCtrl
.SendMessage(SCI_SETREADONLY
, FALSE
);
710 m_PatchCtrl
.SetText(text
);
711 m_PatchCtrl
.LoadFromFile(str
);
712 m_PatchCtrl
.SendMessage(SCI_SETREADONLY
, TRUE
);
717 m_PatchCtrl
.SendMessage(SCI_SETREADONLY
, FALSE
);
718 m_PatchCtrl
.SetText(text
);
719 m_PatchCtrl
.SendMessage(SCI_SETREADONLY
, TRUE
);
724 LRESULT
CImportPatchDlg::OnTaskbarBtnCreated(WPARAM
/*wParam*/, LPARAM
/*lParam*/)
726 m_pTaskbarList
.Release();
727 m_pTaskbarList
.CoCreateInstance(CLSID_TaskbarList
);
728 SetUUIDOverlayIcon(m_hWnd
);