1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2009,2012-2013 - 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.
24 #include "StandAloneDlg.h"
25 #include "HistoryCombo.h"
26 #include "MenuButton.h"
28 #include "BranchCombox.h"
29 #include "GitLoglist.h"
30 #include "GitProgressList.h"
33 #define IDC_SYNC_TAB 0x1000000
35 #define IDC_CMD_LOG 0x1
36 #define IDC_IN_LOGLIST 0x2
37 #define IDC_IN_CHANGELIST 0x3
38 #define IDC_IN_CONFLICT 0x4
39 #define IDC_OUT_LOGLIST 0x5
40 #define IDC_OUT_CHANGELIST 0x6
41 #define IDC_CMD_GIT_PROG 0x7
45 class CSyncDlg
: public CResizableStandAloneDialog
,public CBranchCombox
47 DECLARE_DYNAMIC(CSyncDlg
)
50 CSyncDlg(CWnd
* pParent
= NULL
); // standard constructor
54 enum { IDD
= IDD_SYNC
};
56 enum { GIT_COMMAND_PUSH
,
59 GIT_COMMAND_FETCHANDREBASE
,
60 GIT_COMMAND_SUBMODULE
,
64 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
65 BRANCH_COMBOX_EVENT_HANDLE();
67 virtual BOOL
OnInitDialog();
68 afx_msg
void OnBnClickedButtonManage();
69 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
70 afx_msg
void OnCbnEditchangeComboboxex();
71 afx_msg
void OnBnClickedButtonPull();
72 afx_msg
void OnBnClickedButtonPush();
73 afx_msg
void OnBnClickedButtonApply();
74 afx_msg
void OnBnClickedButtonEmail();
75 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
77 afx_msg LRESULT
OnTaskbarBtnCreated(WPARAM wParam
, LPARAM lParam
);
78 CComPtr
<ITaskbarList3
> m_pTaskbarList
;
82 CRegDWORD m_regPullButton
;
83 CRegDWORD m_regPushButton
;
84 CRegDWORD m_regSubmoduleButton
;
85 CRegDWORD m_regAutoLoadPutty
;
87 CMFCTabCtrl m_ctrlTabCtrl
;
93 CGitLogList m_OutLogList
;
94 CGitLogList m_InLogList
;
95 CGitProgressList m_GitProgressList
;
97 CGitStatusListCtrl m_OutChangeFileList
;
98 CGitStatusListCtrl m_InChangeFileList
;
99 CGitStatusListCtrl m_ConflictFileList
;
101 CRichEditCtrl m_ctrlCmdOut
;
103 CTGitPathList m_arOutChangeList
;
104 CTGitPathList m_arInChangeList
;
106 int m_CmdOutCurrentPos
;
108 CWinThread
* m_pThread
;
110 volatile LONG m_bBlock
;
111 CGitByteArray m_Databuf
;
114 void ParserCmdOutput(char ch
);
116 virtual void LocalBranchChange(){FetchOutList();};
117 virtual void RemoteBranchChange(){};
119 void ShowTab(int windowid
)
121 this->m_ctrlTabCtrl
.ShowTab(windowid
-1);
122 this->m_ctrlTabCtrl
.SetActiveTab(windowid
-1);
125 void FetchOutList(bool force
=false);
129 void SetRemote(CString remote
)
131 if(!remote
.IsEmpty())
133 int index
=this->m_ctrlURL
.FindStringExact(0,remote
);
136 m_ctrlURL
.SetCurSel(index
);
139 this->m_ctrlURL
.AddString(remote
);
143 std::vector
<CString
> m_GitCmdList
;
151 CString m_OutLocalBranch
;
152 CString m_OutRemoteBranch
;
156 void ShowProgressCtrl(bool bShow
=true);
157 void ShowInputCtrl(bool bShow
=true);
158 void SwitchToRun(){ShowProgressCtrl(true);ShowInputCtrl(false);EnableControlButton(false);}
159 void SwitchToInput(){ShowProgressCtrl(false);ShowInputCtrl(true);}
161 LRESULT
OnProgressUpdateUI(WPARAM wParam
,LPARAM lParam
);
162 LRESULT
OnProgCmdFinish(WPARAM wParam
, LPARAM lParam
);
163 void RunPostAction();
166 this->m_strLocalBranch
= this->m_ctrlLocalBranch
.GetString();
167 this->m_ctrlRemoteBranch
.GetWindowText(this->m_strRemoteBranch
);
168 this->m_ctrlURL
.GetWindowText(this->m_strURL
);
169 m_strRemoteBranch
=m_strRemoteBranch
.Trim();
172 void AddDiffFileList(CGitStatusListCtrl
*pCtrlList
, CTGitPathList
*pGitList
,
173 CString rev1
, CString rev2
)
175 g_Git
.GetCommitDiffList(rev1
,rev2
,*pGitList
);
176 pCtrlList
->m_Rev1
=rev1
;
177 pCtrlList
->m_Rev2
=rev2
;
178 pCtrlList
->Show(0,*pGitList
);
179 pCtrlList
->SetEmptyString(CString(_T("No changed file")));
184 void FetchComplete();
186 DECLARE_MESSAGE_MAP()
189 BOOL m_bAutoLoadPuttyKey
;
196 static UINT
ProgressThreadEntry(LPVOID pVoid
){ return ((CSyncDlg
*)pVoid
) ->ProgressThread(); };
197 UINT
ProgressThread();
199 CHistoryCombo m_ctrlURL
;
200 CButton m_ctrlDumyButton
;
201 CMenuButton m_ctrlPull
;
202 CMenuButton m_ctrlPush
;
203 CStatic m_ctrlStatus
;
204 CMenuButton m_ctrlSubmodule
;
205 CProgressCtrl m_ctrlProgress
;
206 CAnimateCtrl m_ctrlAnimate
;
207 CStatic m_ctrlProgLabel
;
209 void EnableControlButton(bool bEnabled
=true);
210 afx_msg
void OnBnClickedButtonCommit();
215 afx_msg
void OnBnClickedButtonSubmodule();
216 afx_msg
void OnLvnInLogListColumnClick(NMHDR
*pNMHDR
, LRESULT
*pResult
);
217 afx_msg
void OnBnClickedCheckForce();
218 afx_msg
void OnBnClickedLog();