Fixed issue #220: Enhancement, support creating bare repositories
[TortoiseGit.git] / src / TortoiseProc / PropDlg.cpp
blobb1c6f65912dcb39d844737d5b82e855624846e2e
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - Stefan Kueng
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 "MessageBox.h"
22 #include "SVNProperties.h"
23 #include "UnicodeUtils.h"
24 #include "Propdlg.h"
25 #include "Registry.h"
28 IMPLEMENT_DYNAMIC(CPropDlg, CResizableStandAloneDialog)
29 CPropDlg::CPropDlg(CWnd* pParent /*=NULL*/)
30 : CResizableStandAloneDialog(CPropDlg::IDD, pParent)
31 , m_rev(SVNRev::REV_WC)
35 CPropDlg::~CPropDlg()
39 void CPropDlg::DoDataExchange(CDataExchange* pDX)
41 CResizableStandAloneDialog::DoDataExchange(pDX);
42 DDX_Control(pDX, IDC_PROPERTYLIST, m_proplist);
46 BEGIN_MESSAGE_MAP(CPropDlg, CResizableStandAloneDialog)
47 ON_WM_SETCURSOR()
48 END_MESSAGE_MAP()
50 BOOL CPropDlg::OnInitDialog()
52 CResizableStandAloneDialog::OnInitDialog();
54 m_proplist.SetExtendedStyle ( LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER );
56 m_proplist.DeleteAllItems();
57 int c = ((CHeaderCtrl*)(m_proplist.GetDlgItem(0)))->GetItemCount()-1;
58 while (c>=0)
59 m_proplist.DeleteColumn(c--);
60 CString temp;
61 temp.LoadString(IDS_PROPPROPERTY);
62 m_proplist.InsertColumn(0, temp);
63 temp.LoadString(IDS_PROPVALUE);
64 m_proplist.InsertColumn(1, temp);
65 m_proplist.SetRedraw(false);
66 int mincol = 0;
67 int maxcol = ((CHeaderCtrl*)(m_proplist.GetDlgItem(0)))->GetItemCount()-1;
68 int col;
69 for (col = mincol; col <= maxcol; col++)
71 m_proplist.SetColumnWidth(col,LVSCW_AUTOSIZE_USEHEADER);
73 m_proplist.SetRedraw(false);
75 DialogEnableWindow(IDOK, FALSE);
76 if (AfxBeginThread(PropThreadEntry, this)==NULL)
78 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
81 AddAnchor(IDC_PROPERTYLIST, TOP_LEFT, BOTTOM_RIGHT);
82 AddAnchor(IDOK, BOTTOM_CENTER);
83 EnableSaveRestore(_T("PropDlg"));
84 return TRUE;
87 void CPropDlg::OnCancel()
89 if (GetDlgItem(IDOK)->IsWindowEnabled())
90 CResizableStandAloneDialog::OnCancel();
93 void CPropDlg::OnOK()
95 if (GetDlgItem(IDOK)->IsWindowEnabled())
96 CResizableStandAloneDialog::OnOK();
99 UINT CPropDlg::PropThreadEntry(LPVOID pVoid)
101 return ((CPropDlg*)pVoid)->PropThread();
104 UINT CPropDlg::PropThread()
106 SVNProperties props(m_Path, m_rev, false);
108 m_proplist.SetRedraw(false);
109 int row = 0;
110 for (int i=0; i<props.GetCount(); ++i)
112 CString name = props.GetItemName(i).c_str();
113 CString val;
114 val = props.GetItemValue(i).c_str();
116 int nFound = -1;
119 nFound = val.FindOneOf(_T("\r\n"));
120 m_proplist.InsertItem(row, name);
121 if (nFound >= 0)
122 m_proplist.SetItemText(row++, 1, val.Left(nFound));
123 else
124 m_proplist.SetItemText(row++, 1, val);
125 val = val.Mid(nFound);
126 val.Trim();
127 name.Empty();
128 } while (!val.IsEmpty()&&(nFound>=0));
130 int mincol = 0;
131 int maxcol = ((CHeaderCtrl*)(m_proplist.GetDlgItem(0)))->GetItemCount()-1;
132 int col;
133 for (col = mincol; col <= maxcol; col++)
135 m_proplist.SetColumnWidth(col,LVSCW_AUTOSIZE_USEHEADER);
138 m_proplist.SetRedraw(true);
139 DialogEnableWindow(IDOK, TRUE);
140 return 0;
143 BOOL CPropDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
145 if ((GetDlgItem(IDOK)->IsWindowEnabled())||(pWnd != GetDlgItem(IDC_PROPERTYLIST)))
147 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
148 SetCursor(hCur);
149 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
151 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT));
152 SetCursor(hCur);
153 return TRUE;