1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008,2011 - 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.
20 #include "TortoiseProc.h"
21 #include "SetOverlayPage.h"
22 #include "SetOverlayIcons.h"
24 #include "ShellUpdater.h"
25 #include "..\TGitCache\CacheInterface.h"
26 #include ".\setoverlaypage.h"
27 #include "MessageBox.h"
30 IMPLEMENT_DYNAMIC(CSetOverlayPage
, ISettingsPropPage
)
31 CSetOverlayPage::CSetOverlayPage()
32 : ISettingsPropPage(CSetOverlayPage::IDD
)
39 , m_bOnlyExplorer(FALSE
)
40 , m_sExcludePaths(_T(""))
41 , m_sIncludePaths(_T(""))
42 , m_bUnversionedAsModified(FALSE
)
44 , m_bShowExcludedAsNormal(TRUE
)
45 , m_bShowIgnoredOverlay(FALSE
)
46 , m_bShowUnversionedOverlay(FALSE
)
48 m_regOnlyExplorer
= CRegDWORD(_T("Software\\TortoiseGit\\LoadDllOnlyInExplorer"), FALSE
);
49 m_regDriveMaskRemovable
= CRegDWORD(_T("Software\\TortoiseGit\\DriveMaskRemovable"));
50 m_regDriveMaskFloppy
= CRegDWORD(_T("Software\\TortoiseGit\\DriveMaskFloppy"));
51 m_regDriveMaskRemote
= CRegDWORD(_T("Software\\TortoiseGit\\DriveMaskRemote"));
52 m_regDriveMaskFixed
= CRegDWORD(_T("Software\\TortoiseGit\\DriveMaskFixed"), TRUE
);
53 m_regDriveMaskCDROM
= CRegDWORD(_T("Software\\TortoiseGit\\DriveMaskCDROM"));
54 m_regDriveMaskRAM
= CRegDWORD(_T("Software\\TortoiseGit\\DriveMaskRAM"));
55 m_regDriveMaskUnknown
= CRegDWORD(_T("Software\\TortoiseGit\\DriveMaskUnknown"));
56 m_regExcludePaths
= CRegString(_T("Software\\TortoiseGit\\OverlayExcludeList"));
57 m_regIncludePaths
= CRegString(_T("Software\\TortoiseGit\\OverlayIncludeList"));
58 m_regCacheType
= CRegDWORD(_T("Software\\TortoiseGit\\CacheType"), GetSystemMetrics(SM_REMOTESESSION
) ? 2 : 1);
59 m_regUnversionedAsModified
= CRegDWORD(_T("Software\\TortoiseGit\\UnversionedAsModified"), FALSE
);
60 m_regShowExcludedAsNormal
= CRegDWORD(_T("Software\\TortoiseGit\\ShowExcludedAsNormal"), TRUE
);
61 m_regShowIgnoredOverlay
= CRegDWORD(_T("Software\\TortoiseGit\\ShowIgnoredOverlay"), TRUE
);
62 m_regShowUnversionedOverlay
= CRegDWORD(_T("Software\\TortoiseGit\\ShowUnversionedOverlay"), TRUE
);
64 m_bOnlyExplorer
= m_regOnlyExplorer
;
65 m_bRemovable
= m_regDriveMaskRemovable
;
66 m_bFloppy
= m_regDriveMaskFloppy
;
67 m_bNetwork
= m_regDriveMaskRemote
;
68 m_bFixed
= m_regDriveMaskFixed
;
69 m_bCDROM
= m_regDriveMaskCDROM
;
70 m_bRAM
= m_regDriveMaskRAM
;
71 m_bUnknown
= m_regDriveMaskUnknown
;
72 m_bUnversionedAsModified
= m_regUnversionedAsModified
;
73 m_bShowIgnoredOverlay
= m_regShowIgnoredOverlay
;
74 m_bShowUnversionedOverlay
= m_regShowUnversionedOverlay
;
75 m_bShowExcludedAsNormal
= m_regShowExcludedAsNormal
;
76 m_sExcludePaths
= m_regExcludePaths
;
77 m_sExcludePaths
.Replace(_T("\n"), _T("\r\n"));
78 m_sIncludePaths
= m_regIncludePaths
;
79 m_sIncludePaths
.Replace(_T("\n"), _T("\r\n"));
80 m_dwCacheType
= m_regCacheType
;
83 CSetOverlayPage::~CSetOverlayPage()
87 void CSetOverlayPage::DoDataExchange(CDataExchange
* pDX
)
89 ISettingsPropPage::DoDataExchange(pDX
);
90 DDX_Check(pDX
, IDC_REMOVABLE
, m_bRemovable
);
91 DDX_Check(pDX
, IDC_NETWORK
, m_bNetwork
);
92 DDX_Check(pDX
, IDC_FIXED
, m_bFixed
);
93 DDX_Check(pDX
, IDC_CDROM
, m_bCDROM
);
94 DDX_Check(pDX
, IDC_RAM
, m_bRAM
);
95 DDX_Check(pDX
, IDC_UNKNOWN
, m_bUnknown
);
96 DDX_Check(pDX
, IDC_ONLYEXPLORER
, m_bOnlyExplorer
);
97 DDX_Text(pDX
, IDC_EXCLUDEPATHS
, m_sExcludePaths
);
98 DDX_Text(pDX
, IDC_INCLUDEPATHS
, m_sIncludePaths
);
99 DDX_Check(pDX
, IDC_UNVERSIONEDASMODIFIED
, m_bUnversionedAsModified
);
100 DDX_Check(pDX
, IDC_FLOPPY
, m_bFloppy
);
101 DDX_Check(pDX
, IDC_SHOWEXCLUDEDASNORMAL
, m_bShowExcludedAsNormal
);
102 DDX_Check(pDX
, IDC_SHOWIGNOREDOVERLAY
, m_bShowIgnoredOverlay
);
103 DDX_Check(pDX
, IDC_SHOWUNVERSIONEDOVERLAY
, m_bShowUnversionedOverlay
);
106 BEGIN_MESSAGE_MAP(CSetOverlayPage
, ISettingsPropPage
)
107 ON_BN_CLICKED(IDC_REMOVABLE
, OnChange
)
108 ON_BN_CLICKED(IDC_FLOPPY
, &CSetOverlayPage::OnChange
)
109 ON_BN_CLICKED(IDC_NETWORK
, OnChange
)
110 ON_BN_CLICKED(IDC_FIXED
, OnChange
)
111 ON_BN_CLICKED(IDC_CDROM
, OnChange
)
112 ON_BN_CLICKED(IDC_UNKNOWN
, OnChange
)
113 ON_BN_CLICKED(IDC_RAM
, OnChange
)
114 ON_BN_CLICKED(IDC_ONLYEXPLORER
, OnChange
)
115 ON_EN_CHANGE(IDC_EXCLUDEPATHS
, OnChange
)
116 ON_EN_CHANGE(IDC_INCLUDEPATHS
, OnChange
)
117 ON_BN_CLICKED(IDC_CACHEDEFAULT
, &CSetOverlayPage::OnChange
)
118 ON_BN_CLICKED(IDC_CACHESHELL
, &CSetOverlayPage::OnChange
)
119 ON_BN_CLICKED(IDC_CACHESHELL2
, &CSetOverlayPage::OnChange
)
120 ON_BN_CLICKED(IDC_CACHENONE
, &CSetOverlayPage::OnChange
)
121 ON_BN_CLICKED(IDC_UNVERSIONEDASMODIFIED
, &CSetOverlayPage::OnChange
)
122 ON_BN_CLICKED(IDC_SHOWEXCLUDEDASNORMAL
, &CSetOverlayPage::OnChange
)
123 ON_BN_CLICKED(IDC_SHOWIGNOREDOVERLAY
, &CSetOverlayPage::OnChange
)
124 ON_BN_CLICKED(IDC_SHOWUNVERSIONEDOVERLAY
, &CSetOverlayPage::OnChange
)
127 BOOL
CSetOverlayPage::OnInitDialog()
129 ISettingsPropPage::OnInitDialog();
131 switch (m_dwCacheType
)
134 CheckRadioButton(IDC_CACHEDEFAULT
, IDC_CACHENONE
, IDC_CACHENONE
);
138 CheckRadioButton(IDC_CACHEDEFAULT
, IDC_CACHENONE
, IDC_CACHEDEFAULT
);
141 CheckRadioButton(IDC_CACHEDEFAULT
, IDC_CACHENONE
, IDC_CACHESHELL
);
144 CheckRadioButton(IDC_CACHEDEFAULT
, IDC_CACHENONE
, IDC_CACHESHELL2
);
147 GetDlgItem(IDC_UNVERSIONEDASMODIFIED
)->EnableWindow(m_dwCacheType
== 1);
148 GetDlgItem(IDC_FLOPPY
)->EnableWindow(m_bRemovable
);
150 m_tooltips
.Create(this);
151 m_tooltips
.AddTool(IDC_ONLYEXPLORER
, IDS_SETTINGS_ONLYEXPLORER_TT
);
152 m_tooltips
.AddTool(IDC_EXCLUDEPATHS
, IDS_SETTINGS_EXCLUDELIST_TT
);
153 m_tooltips
.AddTool(IDC_INCLUDEPATHS
, IDS_SETTINGS_INCLUDELIST_TT
);
154 m_tooltips
.AddTool(IDC_CACHEDEFAULT
, IDS_SETTINGS_CACHEDEFAULT_TT
);
155 m_tooltips
.AddTool(IDC_CACHESHELL
, IDS_SETTINGS_CACHESHELL_TT
);
156 m_tooltips
.AddTool(IDC_CACHESHELL2
, IDS_SETTINGS_CACHESHELLEXT_TT
);
157 m_tooltips
.AddTool(IDC_CACHENONE
, IDS_SETTINGS_CACHENONE_TT
);
158 m_tooltips
.AddTool(IDC_UNVERSIONEDASMODIFIED
, IDS_SETTINGS_UNVERSIONEDASMODIFIED_TT
);
159 m_tooltips
.AddTool(IDC_SHOWEXCLUDEDASNORMAL
, IDS_SETTINGS_SHOWEXCLUDEDASNORMAL_TT
);
166 BOOL
CSetOverlayPage::PreTranslateMessage(MSG
* pMsg
)
168 m_tooltips
.RelayEvent(pMsg
);
169 return ISettingsPropPage::PreTranslateMessage(pMsg
);
172 void CSetOverlayPage::OnChange()
175 int id
= GetCheckedRadioButton(IDC_CACHEDEFAULT
, IDC_CACHENONE
);
179 case IDC_CACHEDEFAULT
:
185 case IDC_CACHESHELL2
:
192 GetDlgItem(IDC_UNVERSIONEDASMODIFIED
)->EnableWindow(m_dwCacheType
== 1);
193 GetDlgItem(IDC_FLOPPY
)->EnableWindow(m_bRemovable
);
197 BOOL
CSetOverlayPage::OnApply()
200 Store (m_bOnlyExplorer
, m_regOnlyExplorer
);
201 if (DWORD(m_regDriveMaskRemovable
) != DWORD(m_bRemovable
))
202 m_restart
= Restart_Cache
;
203 Store (m_bRemovable
, m_regDriveMaskRemovable
);
205 if (DWORD(m_regDriveMaskFloppy
) != DWORD(m_bFloppy
))
206 m_restart
= Restart_Cache
;
207 Store (m_bFloppy
, m_regDriveMaskFloppy
);
209 if (DWORD(m_regDriveMaskRemote
) != DWORD(m_bNetwork
))
210 m_restart
= Restart_Cache
;
211 Store (m_bNetwork
, m_regDriveMaskRemote
);
213 if (DWORD(m_regDriveMaskFixed
) != DWORD(m_bFixed
))
214 m_restart
= Restart_Cache
;
215 Store (m_bFixed
, m_regDriveMaskFixed
);
217 if (DWORD(m_regDriveMaskCDROM
) != DWORD(m_bCDROM
))
218 m_restart
= Restart_Cache
;
219 Store (m_bCDROM
, m_regDriveMaskCDROM
);
221 if (DWORD(m_regDriveMaskRAM
) != DWORD(m_bRAM
))
222 m_restart
= Restart_Cache
;
223 Store (m_bRAM
, m_regDriveMaskRAM
);
225 if (DWORD(m_regDriveMaskUnknown
) != DWORD(m_bUnknown
))
226 m_restart
= Restart_Cache
;
227 Store (m_bUnknown
, m_regDriveMaskUnknown
);
229 if (m_sExcludePaths
.Compare(CString(m_regExcludePaths
)))
230 m_restart
= Restart_Cache
;
231 m_sExcludePaths
.Remove('\r');
232 if (m_sExcludePaths
.Right(1).Compare(_T("\n"))!=0)
233 m_sExcludePaths
+= _T("\n");
234 Store (m_sExcludePaths
, m_regExcludePaths
);
235 m_sExcludePaths
.Replace(_T("\n"), _T("\r\n"));
236 m_sIncludePaths
.Remove('\r');
237 if (m_sIncludePaths
.Right(1).Compare(_T("\n"))!=0)
238 m_sIncludePaths
+= _T("\n");
239 if (m_sIncludePaths
.Compare(CString(m_regIncludePaths
)))
240 m_restart
= Restart_Cache
;
241 Store (m_sIncludePaths
, m_regIncludePaths
);
242 m_sIncludePaths
.Replace(_T("\n"), _T("\r\n"));
244 if (DWORD(m_regUnversionedAsModified
) != DWORD(m_bUnversionedAsModified
))
245 m_restart
= Restart_Cache
;
246 Store (m_bUnversionedAsModified
, m_regUnversionedAsModified
);
247 Store (m_bShowIgnoredOverlay
, m_regShowIgnoredOverlay
);
248 Store (m_bShowUnversionedOverlay
, m_regShowUnversionedOverlay
);
249 if (DWORD(m_regShowExcludedAsNormal
) != DWORD(m_bShowExcludedAsNormal
))
250 m_restart
= Restart_Cache
;
251 Store (m_bShowExcludedAsNormal
, m_regShowExcludedAsNormal
);
253 Store (m_dwCacheType
, m_regCacheType
);
254 if (m_dwCacheType
!= 1)
256 // close the possible running cache process
257 HWND hWnd
= ::FindWindow(TSVN_CACHE_WINDOW_NAME
, TSVN_CACHE_WINDOW_NAME
);
260 ::PostMessage(hWnd
, WM_CLOSE
, NULL
, NULL
);
262 m_restart
= Restart_None
;
265 return ISettingsPropPage::OnApply();