1 // TortoiseGit - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2008-2009 - TortoiseGit
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
20 // SyncDlg.cpp : implementation file
\r
24 #include "TortoiseProc.h"
\r
25 #include "SyncDlg.h"
\r
30 IMPLEMENT_DYNAMIC(CSyncDlg, CResizableStandAloneDialog)
\r
32 CSyncDlg::CSyncDlg(CWnd* pParent /*=NULL*/)
\r
33 : CResizableStandAloneDialog(CSyncDlg::IDD, pParent)
\r
34 , m_bAutoLoadPuttyKey(FALSE)
\r
36 m_pTooltip=&this->m_tooltips;
\r
39 CSyncDlg::~CSyncDlg()
\r
43 void CSyncDlg::DoDataExchange(CDataExchange* pDX)
\r
45 CDialog::DoDataExchange(pDX);
\r
46 DDX_Check(pDX, IDC_CHECK_PUTTY_KEY, m_bAutoLoadPuttyKey);
\r
47 DDX_Control(pDX, IDC_COMBOBOXEX_URL, m_ctrlURL);
\r
48 DDX_Control(pDX, IDC_BUTTON_TABCTRL, m_ctrlDumyButton);
\r
49 DDX_Control(pDX, IDC_BUTTON_PULL, m_ctrlPull);
\r
50 DDX_Control(pDX, IDC_BUTTON_PUSH, m_ctrlPush);
\r
51 DDX_Control(pDX, IDC_STATIC_STATUS, m_ctrlStatus);
\r
52 DDX_Control(pDX, IDC_PROGRESS_SYNC, m_ctrlProgress);
\r
53 DDX_Control(pDX, IDC_ANIMATE_SYNC, m_ctrlAnimate);
\r
59 BEGIN_MESSAGE_MAP(CSyncDlg, CResizableStandAloneDialog)
\r
60 ON_BN_CLICKED(IDC_BUTTON_PULL, &CSyncDlg::OnBnClickedButtonPull)
\r
61 ON_BN_CLICKED(IDC_BUTTON_PUSH, &CSyncDlg::OnBnClickedButtonPush)
\r
62 ON_BN_CLICKED(IDC_BUTTON_APPLY, &CSyncDlg::OnBnClickedButtonApply)
\r
63 ON_BN_CLICKED(IDC_BUTTON_EMAIL, &CSyncDlg::OnBnClickedButtonEmail)
\r
64 ON_BN_CLICKED(IDC_BUTTON_MANAGE, &CSyncDlg::OnBnClickedButtonManage)
\r
66 ON_NOTIFY(CBEN_ENDEDIT, IDC_COMBOBOXEX_URL, &CSyncDlg::OnCbenEndeditComboboxexUrl)
\r
67 ON_CBN_EDITCHANGE(IDC_COMBOBOXEX_URL, &CSyncDlg::OnCbnEditchangeComboboxexUrl)
\r
71 // CSyncDlg message handlers
\r
73 void CSyncDlg::OnBnClickedButtonPull()
\r
75 // TODO: Add your control notification handler code here
\r
76 this->m_regPullButton =this->m_ctrlPull.GetCurrentEntry();
\r
79 void CSyncDlg::OnBnClickedButtonPush()
\r
81 // TODO: Add your control notification handler code here
\r
82 this->m_regPushButton=this->m_ctrlPush.GetCurrentEntry();
\r
86 void CSyncDlg::OnBnClickedButtonApply()
\r
88 // TODO: Add your control notification handler code here
\r
91 void CSyncDlg::OnBnClickedButtonEmail()
\r
93 // TODO: Add your control notification handler code here
\r
96 BOOL CSyncDlg::OnInitDialog()
\r
98 CResizableStandAloneDialog::OnInitDialog();
\r
101 CWnd *pwnd=this->GetDlgItem(IDC_BUTTON_TABCTRL);
\r
103 pwnd->GetWindowRect(&rectDummy);
\r
104 this->ScreenToClient(rectDummy);
\r
106 if (!m_ctrlTabCtrl.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, IDC_SYNC_TAB))
\r
108 TRACE0("Failed to create output tab window\n");
\r
109 return FALSE; // fail to create
\r
111 m_ctrlTabCtrl.SetResizeMode(CMFCTabCtrl::RESIZE_NO);
\r
113 DWORD dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP;
\r
115 if( !m_OutLogList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_OUT_LOGLIST))
\r
117 TRACE0("Failed to create output commits window\n");
\r
118 return FALSE; // fail to create
\r
121 m_ctrlTabCtrl.InsertTab(&m_OutLogList,_T("Out Commits"),0);
\r
123 m_OutLogList.InsertGitColumn();
\r
125 dwStyle = LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL |WS_CHILD | WS_VISIBLE;
\r
127 if( !m_OutChangeFileList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_OUT_CHANGELIST))
\r
129 TRACE0("Failed to create output change files window\n");
\r
130 return FALSE; // fail to create
\r
132 m_ctrlTabCtrl.InsertTab(&m_OutChangeFileList,_T("Out ChangeList"),1);
\r
134 m_OutChangeFileList.Init(SVNSLC_COLEXT | SVNSLC_COLSTATUS |SVNSLC_COLADD|SVNSLC_COLDEL , _T("RebaseDlg"),(SVNSLC_POPALL ^ SVNSLC_POPCOMMIT),false);
\r
136 this->m_tooltips.Create(this);
\r
138 AddAnchor(IDC_SYNC_TAB,TOP_LEFT,BOTTOM_RIGHT);
\r
140 AddAnchor(IDC_GROUP_INFO,TOP_LEFT,TOP_RIGHT);
\r
141 AddAnchor(IDC_COMBOBOXEX_URL,TOP_LEFT,TOP_RIGHT);
\r
142 AddAnchor(IDC_BUTTON_MANAGE,TOP_RIGHT);
\r
143 AddAnchor(IDC_BUTTON_PULL,BOTTOM_LEFT);
\r
144 AddAnchor(IDC_BUTTON_PUSH,BOTTOM_LEFT);
\r
145 AddAnchor(IDC_BUTTON_APPLY,BOTTOM_LEFT);
\r
146 AddAnchor(IDC_BUTTON_EMAIL,BOTTOM_LEFT);
\r
147 AddAnchor(IDC_PROGRESS_SYNC,BOTTOM_LEFT,BOTTOM_RIGHT);
\r
148 AddAnchor(IDOK,BOTTOM_RIGHT);
\r
149 AddAnchor(IDHELP,BOTTOM_RIGHT);
\r
150 AddAnchor(IDC_STATIC_STATUS,BOTTOM_LEFT);
\r
151 AddAnchor(IDC_ANIMATE_SYNC,TOP_RIGHT);
\r
153 BRANCH_COMBOX_ADD_ANCHOR();
\r
155 CString WorkingDir=g_Git.m_CurrentDir;
\r
156 WorkingDir.Replace(_T(':'),_T('_'));
\r
157 m_RegKeyRemoteBranch = CString(_T("Software\\TortoiseGit\\History\\SyncBranch\\"))+WorkingDir;
\r
160 this->AddOthersToAnchor();
\r
161 // TODO: Add extra initialization here
\r
163 this->m_ctrlPush.AddEntry(CString(_T("Push")));
\r
164 this->m_ctrlPush.AddEntry(CString(_T("Push tags")));
\r
165 this->m_ctrlPush.AddEntry(CString(_T("Push All")));
\r
167 this->m_ctrlPull.AddEntry(CString(_T("&Pull")));
\r
168 this->m_ctrlPull.AddEntry(CString(_T("&Fetch")));
\r
169 this->m_ctrlPull.AddEntry(CString(_T("Fetch&&Rebase")));
\r
172 WorkingDir.Replace(_T(':'),_T('_'));
\r
175 regkey.Format(_T("Software\\TortoiseGit\\TortoiseProc\\Sync\\%s"),WorkingDir);
\r
177 this->m_regPullButton = CRegDWORD(regkey+_T("\\Pull"),0);
\r
178 this->m_regPushButton = CRegDWORD(regkey+_T("\\Push"),0);
\r
180 this->m_ctrlPull.SetCurrentEntry(this->m_regPullButton);
\r
181 this->m_ctrlPush.SetCurrentEntry(this->m_regPushButton);
\r
184 this->GetWindowText(str);
\r
185 str += _T(" - ") + g_Git.m_CurrentDir;
\r
186 this->SetWindowText(str);
\r
188 EnableSaveRestore(_T("SyncDlg"));
\r
190 this->LoadBranchInfo();
\r
193 return TRUE; // return TRUE unless you set the focus to a control
\r
194 // EXCEPTION: OCX Property Pages should return FALSE
\r
197 void CSyncDlg::OnBnClickedButtonManage()
\r
199 // TODO: Add your control notification handler code here
\r
200 CAppUtils::LaunchRemoteSetting();
\r
203 BOOL CSyncDlg::PreTranslateMessage(MSG* pMsg)
\r
205 // TODO: Add your specialized code here and/or call the base class
\r
206 m_tooltips.RelayEvent(pMsg);
\r
207 return __super::PreTranslateMessage(pMsg);
\r
209 void CSyncDlg::FetchOutList()
\r
211 m_OutChangeFileList.Clear();
\r
212 this->m_OutLogList.Clear();
\r
215 this->m_ctrlURL.GetWindowText(remote);
\r
216 CString remotebranch;
\r
217 this->m_ctrlRemoteBranch.GetWindowText(remotebranch);
\r
218 remotebranch=remote+_T("/")+remotebranch;
\r
223 str=_T("Don't know what will push befause you enter URL");
\r
224 m_OutLogList.ShowText(str);
\r
225 this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE);
\r
226 m_OutLocalBranch.Empty();
\r
227 m_OutRemoteBranch.Empty();
\r
230 }else if(g_Git.GetHash(remotebranch).GetLength()<40)
\r
233 str.Format(_T("Don't know what will push befause unkown \"%s\""),remotebranch);
\r
234 m_OutLogList.ShowText(str);
\r
235 this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE);
\r
236 m_OutLocalBranch.Empty();
\r
237 m_OutRemoteBranch.Empty();
\r
242 CString localbranch;
\r
243 localbranch=this->m_ctrlLocalBranch.GetString();
\r
245 if(localbranch != m_OutLocalBranch && m_OutRemoteBranch != remotebranch)
\r
247 m_OutLogList.ClearText();
\r
248 m_OutLogList.FillGitLog(NULL,CGit:: LOG_INFO_STAT| CGit::LOG_INFO_FILESTATE | CGit::LOG_INFO_SHOW_MERGEDFILE,
\r
249 &remotebranch,&localbranch);
\r
251 this->m_OutLocalBranch=localbranch;
\r
252 this->m_OutRemoteBranch=remotebranch;
\r
257 bool CSyncDlg::IsURL()
\r
260 this->m_ctrlURL.GetWindowText(str);
\r
261 if(str.Find(_T('\\'))>=0 || str.Find(_T('/'))>=0)
\r
266 void CSyncDlg::OnCbenEndeditComboboxexUrl(NMHDR *pNMHDR, LRESULT *pResult)
\r
268 // TODO: Add your control notification handler code here
\r
272 void CSyncDlg::OnCbnEditchangeComboboxexUrl()
\r
274 this->FetchOutList();
\r
275 // TODO: Add your control notification handler code here
\r