Merge branch 'restructure-tree'
[TortoiseGit.git] / src / TortoiseProc / SyncDlg.h
blobb5ad82c3b6fb63416ee1e7ceafd9393be9489719
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2009 - 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.
20 #pragma once
21 #include "afxcmn.h"
22 #include "afxwin.h"
24 #include "StandAloneDlg.h"
25 #include "HistoryCombo.h"
26 #include "MenuButton.h"
27 #include "registry.h"
28 #include "Balloon.h"
29 #include "BranchCombox.h"
30 #include "GitLoglist.h"
31 #include "Win7.h"
33 // CSyncDlg dialog
34 #define IDC_SYNC_TAB 0x1000000
36 #define IDC_CMD_LOG 0x1
37 #define IDC_IN_LOGLIST 0x2
38 #define IDC_IN_CHANGELIST 0x3
39 #define IDC_IN_CONFLICT 0x4
40 #define IDC_OUT_LOGLIST 0x5
41 #define IDC_OUT_CHANGELIST 0x6
43 #define IDT_INPUT 108
45 class CSyncDlg : public CResizableStandAloneDialog,public CBranchCombox
47 DECLARE_DYNAMIC(CSyncDlg)
49 public:
50 CSyncDlg(CWnd* pParent = NULL); // standard constructor
51 virtual ~CSyncDlg();
53 // Dialog Data
54 enum { IDD = IDD_SYNC };
56 enum { GIT_COMMAND_PUSH,
57 GIT_COMMAND_PULL,
58 GIT_COMMAND_FETCH,
59 GIT_COMMAND_FETCHANDREBASE,
60 GIT_COMMAND_SUBMODULE,
61 GIT_COMMAND_REMOTE
63 protected:
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;
80 int m_CurrentCmd;
82 CRegDWORD m_regPullButton;
83 CRegDWORD m_regPushButton;
84 CRegDWORD m_regSubmoduleButton;
85 CRegDWORD m_regAutoLoadPutty;
87 CMFCTabCtrl m_ctrlTabCtrl;
89 CBalloon m_tooltips;
91 BOOL m_bInited;
93 CGitLogList m_OutLogList;
94 CGitLogList m_InLogList;
96 CGitStatusListCtrl m_OutChangeFileList;
97 CGitStatusListCtrl m_InChangeFileList;
98 CGitStatusListCtrl m_ConflictFileList;
100 CRichEditCtrl m_ctrlCmdOut;
102 CTGitPathList m_arOutChangeList;
103 CTGitPathList m_arInChangeList;
105 int m_CmdOutCurrentPos;
107 CWinThread* m_pThread;
109 volatile LONG m_bBlock;
111 void ParserCmdOutput(char ch);
113 virtual void LocalBranchChange(){FetchOutList();};
114 virtual void RemoteBranchChange(){FetchOutList();};
116 void ShowTab(int windowid)
118 this->m_ctrlTabCtrl.ShowTab(windowid-1);
119 this->m_ctrlTabCtrl.SetActiveTab(windowid-1);
122 void FetchOutList(bool force=false);
124 bool IsURL();
126 void SetRemote(CString remote)
128 if(!remote.IsEmpty())
130 int index=this->m_ctrlURL.FindStringExact(0,remote);
131 if(index>=0)
133 m_ctrlURL.SetCurSel(index);
134 return;
136 this->m_ctrlURL.AddString(remote);
140 std::vector<CString> m_GitCmdList;
142 bool m_bAbort;
144 int m_GitCmdStatus;
146 CStringA m_LogText;
147 CString m_OutLocalBranch;
148 CString m_OutRemoteBranch;
150 CGitHash m_oldHash;
152 void ShowProgressCtrl(bool bShow=true);
153 void ShowInputCtrl(bool bShow=true);
154 void SwitchToRun(){ShowProgressCtrl(true);ShowInputCtrl(false);EnableControlButton(false);}
155 void SwitchToInput(){ShowProgressCtrl(false);ShowInputCtrl(true);}
157 LRESULT OnProgressUpdateUI(WPARAM wParam,LPARAM lParam);
159 void UpdateCombox()
161 this->m_strLocalBranch = this->m_ctrlLocalBranch.GetString();
162 this->m_ctrlRemoteBranch.GetWindowText(this->m_strRemoteBranch);
163 this->m_ctrlURL.GetWindowText(this->m_strURL);
164 m_strRemoteBranch=m_strRemoteBranch.Trim();
167 void AddDiffFileList(CGitStatusListCtrl *pCtrlList, CTGitPathList *pGitList,
168 CString &rev1,CString &rev2)
170 g_Git.GetCommitDiffList(rev1,rev2,*pGitList);
171 pCtrlList->m_Rev1=rev1;
172 pCtrlList->m_Rev2=rev2;
173 pCtrlList->Show(0,*pGitList);
174 pCtrlList->SetEmptyString(CString(_T("No changed file")));
175 return;
178 void PullComplete();
179 void FetchComplete();
181 DECLARE_MESSAGE_MAP()
183 public:
184 BOOL m_bAutoLoadPuttyKey;
185 BOOL m_bForce;
186 CString m_strURL;
188 protected:
189 int m_Gitverion;
191 static UINT ProgressThreadEntry(LPVOID pVoid){ return ((CSyncDlg*)pVoid) ->ProgressThread(); };
192 UINT ProgressThread();
194 CHistoryCombo m_ctrlURL;
195 CButton m_ctrlDumyButton;
196 CMenuButton m_ctrlPull;
197 CMenuButton m_ctrlPush;
198 CStatic m_ctrlStatus;
199 CMenuButton m_ctrlSubmodule;
200 CProgressCtrl m_ctrlProgress;
201 CAnimateCtrl m_ctrlAnimate;
203 void EnableControlButton(bool bEnabled=true);
204 afx_msg void OnBnClickedButtonCommit();
206 virtual void OnOK();
207 void Refresh();
209 afx_msg void OnBnClickedButtonSubmodule();