Fixed issue #220: Enhancement, support creating bare repositories
[TortoiseGit.git] / src / TortoiseProc / SyncDlg.h
blobb6cfdede1afe366f5cf96d148cf23aea6e8198d6
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 // CSyncDlg dialog
32 #define IDC_SYNC_TAB 0x1000000
34 #define IDC_CMD_LOG 0x1
35 #define IDC_IN_LOGLIST 0x2
36 #define IDC_IN_CHANGELIST 0x3
37 #define IDC_IN_CONFLICT 0x4
38 #define IDC_OUT_LOGLIST 0x5
39 #define IDC_OUT_CHANGELIST 0x6
41 #define IDT_INPUT 108
44 class CSyncDlg : public CResizableStandAloneDialog,public CBranchCombox
46 DECLARE_DYNAMIC(CSyncDlg)
48 public:
49 CSyncDlg(CWnd* pParent = NULL); // standard constructor
50 virtual ~CSyncDlg();
52 // Dialog Data
53 enum { IDD = IDD_SYNC };
55 enum { GIT_COMMAND_PUSH,
56 GIT_COMMAND_PULL,
57 GIT_COMMAND_FETCH,
58 GIT_COMMAND_FETCHANDREBASE,
59 GIT_COMMAND_SUBMODULE,
60 GIT_COMMAND_REMOTE
62 protected:
63 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
64 BRANCH_COMBOX_EVENT_HANDLE();
66 int m_CurrentCmd;
68 CRegDWORD m_regPullButton;
69 CRegDWORD m_regPushButton;
70 CRegDWORD m_regSubmoduleButton;
71 CRegDWORD m_regAutoLoadPutty;
73 CMFCTabCtrl m_ctrlTabCtrl;
75 CBalloon m_tooltips;
77 BOOL m_bInited;
79 CGitLogList m_OutLogList;
80 CGitLogList m_InLogList;
82 CGitStatusListCtrl m_OutChangeFileList;
83 CGitStatusListCtrl m_InChangeFileList;
84 CGitStatusListCtrl m_ConflictFileList;
86 CRichEditCtrl m_ctrlCmdOut;
88 CTGitPathList m_arOutChangeList;
89 CTGitPathList m_arInChangeList;
91 int m_CmdOutCurrentPos;
93 CWinThread* m_pThread;
95 volatile LONG m_bBlock;
97 void ParserCmdOutput(char ch);
99 virtual void LocalBranchChange(){FetchOutList();};
100 virtual void RemoteBranchChange(){FetchOutList();};
101 void ShowTab(int windowid)
103 this->m_ctrlTabCtrl.ShowTab(windowid-1);
104 this->m_ctrlTabCtrl.SetActiveTab(windowid-1);
107 void FetchOutList(bool force=false);
109 bool IsURL();
111 void SetRemote(CString remote)
113 if(!remote.IsEmpty())
115 int index=this->m_ctrlURL.FindStringExact(0,remote);
116 if(index>=0)
118 m_ctrlURL.SetCurSel(index);
119 return;
121 this->m_ctrlURL.AddString(remote);
125 std::vector<CString> m_GitCmdList;
127 bool m_bAbort;
129 int m_GitCmdStatus;
131 CStringA m_LogText;
132 CString m_OutLocalBranch;
133 CString m_OutRemoteBranch;
135 CString m_oldHash;
137 void ShowProgressCtrl(bool bShow=true);
138 void ShowInputCtrl(bool bShow=true);
139 void SwitchToRun(){ShowProgressCtrl(true);ShowInputCtrl(false);EnableControlButton(false);}
140 void SwitchToInput(){ShowProgressCtrl(false);ShowInputCtrl(true);}
142 LRESULT OnProgressUpdateUI(WPARAM wParam,LPARAM lParam);
144 void UpdateCombox()
146 this->m_strLocalBranch = this->m_ctrlLocalBranch.GetString();
147 this->m_ctrlRemoteBranch.GetWindowText(this->m_strRemoteBranch);
148 this->m_ctrlURL.GetWindowText(this->m_strURL);
149 m_strRemoteBranch=m_strRemoteBranch.Trim();
152 void AddDiffFileList(CGitStatusListCtrl *pCtrlList, CTGitPathList *pGitList,
153 CString &rev1,CString &rev2)
155 g_Git.GetCommitDiffList(rev1,rev2,*pGitList);
156 pCtrlList->m_Rev1=rev1;
157 pCtrlList->m_Rev2=rev2;
158 pCtrlList->Show(0,*pGitList);
159 pCtrlList->SetEmptyString(CString(_T("No changed file")));
160 return;
163 void PullComplete();
164 void FetchComplete();
166 DECLARE_MESSAGE_MAP()
167 public:
168 BOOL m_bAutoLoadPuttyKey;
169 BOOL m_bForce;
170 CString m_strURL;
171 int m_Gitverion;
173 static UINT ProgressThreadEntry(LPVOID pVoid){ return ((CSyncDlg*)pVoid) ->ProgressThread(); };
174 UINT ProgressThread();
176 CHistoryCombo m_ctrlURL;
177 CButton m_ctrlDumyButton;
178 CMenuButton m_ctrlPull;
179 CMenuButton m_ctrlPush;
180 CMenuButton m_ctrlStatus;
181 CMenuButton m_ctrlSubmodule;
182 afx_msg void OnBnClickedButtonPull();
183 afx_msg void OnBnClickedButtonPush();
184 afx_msg void OnBnClickedButtonApply();
185 afx_msg void OnBnClickedButtonEmail();
186 afx_msg void OnTimer(UINT_PTR nIDEvent);
187 CProgressCtrl m_ctrlProgress;
188 CAnimateCtrl m_ctrlAnimate;
189 virtual BOOL OnInitDialog();
190 afx_msg void OnBnClickedButtonManage();
191 virtual BOOL PreTranslateMessage(MSG* pMsg);
192 afx_msg void OnCbenEndeditComboboxexUrl(NMHDR *pNMHDR, LRESULT *pResult);
193 afx_msg void OnCbnEditchangeComboboxex();
195 void EnableControlButton(bool bEnabled=true);
196 afx_msg void OnBnClickedButtonCommit();
197 protected:
198 virtual void OnOK();
199 void Refresh();
200 public:
201 afx_msg void OnBnClickedButtonSubmodule();