Merge branch 'restructure-tree'
[TortoiseGit.git] / src / TortoiseProc / BlameDlg.cpp
blobb38b70eae839d9c6fd25f059caf1620ef0bd3f18
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
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 #include "stdafx.h"
20 #include "TortoiseProc.h"
21 #include "BlameDlg.h"
22 #include "Registry.h"
23 #include "AppUtils.h"
25 //IMPLEMENT_DYNAMIC(CBlameDlg, CStandAloneDialog)
26 CBlameDlg::CBlameDlg(CWnd* pParent /*=NULL*/)
27 : CStandAloneDialog(CBlameDlg::IDD, pParent)
28 // , StartRev(1)
29 // , EndRev(0)
30 // , m_sStartRev(_T("1"))
31 , m_bTextView(FALSE)
32 , m_bIgnoreEOL(TRUE)
33 , m_bIncludeMerge(TRUE)
35 m_regTextView = CRegDWORD(_T("Software\\TortoiseGit\\TextBlame"), FALSE);
36 m_bTextView = m_regTextView;
39 CBlameDlg::~CBlameDlg()
43 void CBlameDlg::DoDataExchange(CDataExchange* pDX)
45 CStandAloneDialog::DoDataExchange(pDX);
46 DDX_Text(pDX, IDC_REVISON_START, m_sStartRev);
47 DDX_Text(pDX, IDC_REVISION_END, m_sEndRev);
48 DDX_Check(pDX, IDC_USETEXTVIEWER, m_bTextView);
49 DDX_Check(pDX, IDC_IGNOREEOL2, m_bIgnoreEOL);
50 DDX_Check(pDX, IDC_INCLUDEMERGEINFO, m_bIncludeMerge);
54 BEGIN_MESSAGE_MAP(CBlameDlg, CStandAloneDialog)
55 ON_BN_CLICKED(IDHELP, OnBnClickedHelp)
56 ON_EN_CHANGE(IDC_REVISION_END, &CBlameDlg::OnEnChangeRevisionEnd)
57 END_MESSAGE_MAP()
61 BOOL CBlameDlg::OnInitDialog()
63 CStandAloneDialog::OnInitDialog();
64 CAppUtils::MarkWindowAsUnpinnable(m_hWnd);
66 AdjustControlSize(IDC_USETEXTVIEWER);
67 AdjustControlSize(IDC_IGNOREEOL);
68 AdjustControlSize(IDC_COMPAREWHITESPACES);
69 AdjustControlSize(IDC_IGNOREWHITESPACECHANGES);
70 AdjustControlSize(IDC_IGNOREALLWHITESPACES);
71 AdjustControlSize(IDC_INCLUDEMERGEINFO);
73 m_bTextView = m_regTextView;
74 // set head revision as default revision
75 // if (EndRev.IsHead())
76 CheckRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N, IDC_REVISION_HEAD);
77 // else
78 // {
79 // m_sEndRev = EndRev.ToString();
80 // UpdateData(FALSE);
81 // CheckRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N, IDC_REVISION_N);
82 // }
84 CheckRadioButton(IDC_COMPAREWHITESPACES, IDC_IGNOREALLWHITESPACES, IDC_IGNOREALLWHITESPACES);
86 if ((m_pParentWnd==NULL)&&(hWndExplorer))
87 CenterWindow(CWnd::FromHandle(hWndExplorer));
88 return TRUE;
91 void CBlameDlg::OnOK()
93 if (!UpdateData(TRUE))
94 return; // don't dismiss dialog (error message already shown by MFC framework)
96 m_regTextView = m_bTextView;
97 // StartRev = SVNRev(m_sStartRev);
98 // EndRev = SVNRev(m_sEndRev);
99 // if (!StartRev.IsValid())
100 // {
101 /// ShowBalloon(IDC_REVISON_START, IDS_ERR_INVALIDREV);
102 // return;
103 // }
104 // EndRev = SVNRev(m_sEndRev);
105 // if (GetCheckedRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N) == IDC_REVISION_HEAD)
107 EndRev = _T("HEAD");
109 // if (!EndRev.IsValid())
110 // {
111 // ShowBalloon(IDC_REVISION_END, IDS_ERR_INVALIDREV);
112 // return;
113 // }
114 BOOL extBlame = CRegDWORD(_T("Software\\TortoiseGit\\TextBlame"), FALSE);
115 if (extBlame)
116 m_bTextView = true;
118 int rb = GetCheckedRadioButton(IDC_COMPAREWHITESPACES, IDC_IGNOREALLWHITESPACES);
119 switch (rb)
121 case IDC_IGNOREWHITESPACECHANGES:
122 // m_IgnoreSpaces = svn_diff_file_ignore_space_change;
123 break;
124 case IDC_IGNOREALLWHITESPACES:
125 // m_IgnoreSpaces = svn_diff_file_ignore_space_all;
126 break;
127 case IDC_COMPAREWHITESPACES:
128 default:
129 // m_IgnoreSpaces = svn_diff_file_ignore_space_none;
130 break;
133 UpdateData(FALSE);
135 CStandAloneDialog::OnOK();
138 void CBlameDlg::OnBnClickedHelp()
140 OnHelp();
143 void CBlameDlg::OnEnChangeRevisionEnd()
145 UpdateData();
146 if (m_sEndRev.IsEmpty())
147 CheckRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N, IDC_REVISION_HEAD);
148 else
149 CheckRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N, IDC_REVISION_N);