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
)
46 m_regOnlyExplorer
= CRegDWORD(_T("Software\\TortoiseGit\\LoadDllOnlyInExplorer"), FALSE
);
47 m_regDriveMaskRemovable
= CRegDWORD(_T("Software\\TortoiseGit\\DriveMaskRemovable"));
48 m_regDriveMaskFloppy
= CRegDWORD(_T("Software\\TortoiseGit\\DriveMaskFloppy"));
49 m_regDriveMaskRemote
= CRegDWORD(_T("Software\\TortoiseGit\\DriveMaskRemote"));
50 m_regDriveMaskFixed
= CRegDWORD(_T("Software\\TortoiseGit\\DriveMaskFixed"), TRUE
);
51 m_regDriveMaskCDROM
= CRegDWORD(_T("Software\\TortoiseGit\\DriveMaskCDROM"));
52 m_regDriveMaskRAM
= CRegDWORD(_T("Software\\TortoiseGit\\DriveMaskRAM"));
53 m_regDriveMaskUnknown
= CRegDWORD(_T("Software\\TortoiseGit\\DriveMaskUnknown"));
54 m_regExcludePaths
= CRegString(_T("Software\\TortoiseGit\\OverlayExcludeList"));
55 m_regIncludePaths
= CRegString(_T("Software\\TortoiseGit\\OverlayIncludeList"));
56 m_regCacheType
= CRegDWORD(_T("Software\\TortoiseGit\\CacheType"), GetSystemMetrics(SM_REMOTESESSION
) ? 2 : 1);
57 m_regUnversionedAsModified
= CRegDWORD(_T("Software\\TortoiseGit\\UnversionedAsModified"), FALSE
);
58 m_regShowExcludedAsNormal
= CRegDWORD(_T("Software\\TortoiseGit\\ShowExcludedAsNormal"), TRUE
);
60 m_bOnlyExplorer
= m_regOnlyExplorer
;
61 m_bRemovable
= m_regDriveMaskRemovable
;
62 m_bFloppy
= m_regDriveMaskFloppy
;
63 m_bNetwork
= m_regDriveMaskRemote
;
64 m_bFixed
= m_regDriveMaskFixed
;
65 m_bCDROM
= m_regDriveMaskCDROM
;
66 m_bRAM
= m_regDriveMaskRAM
;
67 m_bUnknown
= m_regDriveMaskUnknown
;
68 m_bUnversionedAsModified
= m_regUnversionedAsModified
;
69 m_bShowExcludedAsNormal
= m_regShowExcludedAsNormal
;
70 m_sExcludePaths
= m_regExcludePaths
;
71 m_sExcludePaths
.Replace(_T("\n"), _T("\r\n"));
72 m_sIncludePaths
= m_regIncludePaths
;
73 m_sIncludePaths
.Replace(_T("\n"), _T("\r\n"));
74 m_dwCacheType
= m_regCacheType
;
77 CSetOverlayPage::~CSetOverlayPage()
81 void CSetOverlayPage::DoDataExchange(CDataExchange
* pDX
)
83 ISettingsPropPage::DoDataExchange(pDX
);
84 DDX_Check(pDX
, IDC_REMOVABLE
, m_bRemovable
);
85 DDX_Check(pDX
, IDC_NETWORK
, m_bNetwork
);
86 DDX_Check(pDX
, IDC_FIXED
, m_bFixed
);
87 DDX_Check(pDX
, IDC_CDROM
, m_bCDROM
);
88 DDX_Check(pDX
, IDC_RAM
, m_bRAM
);
89 DDX_Check(pDX
, IDC_UNKNOWN
, m_bUnknown
);
90 DDX_Check(pDX
, IDC_ONLYEXPLORER
, m_bOnlyExplorer
);
91 DDX_Text(pDX
, IDC_EXCLUDEPATHS
, m_sExcludePaths
);
92 DDX_Text(pDX
, IDC_INCLUDEPATHS
, m_sIncludePaths
);
93 DDX_Check(pDX
, IDC_UNVERSIONEDASMODIFIED
, m_bUnversionedAsModified
);
94 DDX_Check(pDX
, IDC_FLOPPY
, m_bFloppy
);
95 DDX_Check(pDX
, IDC_SHOWEXCLUDEDASNORMAL
, m_bShowExcludedAsNormal
);
98 BEGIN_MESSAGE_MAP(CSetOverlayPage
, ISettingsPropPage
)
99 ON_BN_CLICKED(IDC_REMOVABLE
, OnChange
)
100 ON_BN_CLICKED(IDC_FLOPPY
, &CSetOverlayPage::OnChange
)
101 ON_BN_CLICKED(IDC_NETWORK
, OnChange
)
102 ON_BN_CLICKED(IDC_FIXED
, OnChange
)
103 ON_BN_CLICKED(IDC_CDROM
, OnChange
)
104 ON_BN_CLICKED(IDC_UNKNOWN
, OnChange
)
105 ON_BN_CLICKED(IDC_RAM
, OnChange
)
106 ON_BN_CLICKED(IDC_ONLYEXPLORER
, OnChange
)
107 ON_EN_CHANGE(IDC_EXCLUDEPATHS
, OnChange
)
108 ON_EN_CHANGE(IDC_INCLUDEPATHS
, OnChange
)
109 ON_BN_CLICKED(IDC_CACHEDEFAULT
, &CSetOverlayPage::OnChange
)
110 ON_BN_CLICKED(IDC_CACHESHELL
, &CSetOverlayPage::OnChange
)
111 ON_BN_CLICKED(IDC_CACHESHELL2
, &CSetOverlayPage::OnChange
)
112 ON_BN_CLICKED(IDC_CACHENONE
, &CSetOverlayPage::OnChange
)
113 ON_BN_CLICKED(IDC_UNVERSIONEDASMODIFIED
, &CSetOverlayPage::OnChange
)
114 ON_BN_CLICKED(IDC_SHOWEXCLUDEDASNORMAL
, &CSetOverlayPage::OnChange
)
117 BOOL
CSetOverlayPage::OnInitDialog()
119 ISettingsPropPage::OnInitDialog();
121 switch (m_dwCacheType
)
124 CheckRadioButton(IDC_CACHEDEFAULT
, IDC_CACHENONE
, IDC_CACHENONE
);
128 CheckRadioButton(IDC_CACHEDEFAULT
, IDC_CACHENONE
, IDC_CACHEDEFAULT
);
131 CheckRadioButton(IDC_CACHEDEFAULT
, IDC_CACHENONE
, IDC_CACHESHELL
);
134 CheckRadioButton(IDC_CACHEDEFAULT
, IDC_CACHENONE
, IDC_CACHESHELL2
);
137 GetDlgItem(IDC_UNVERSIONEDASMODIFIED
)->EnableWindow(m_dwCacheType
== 1);
138 GetDlgItem(IDC_FLOPPY
)->EnableWindow(m_bRemovable
);
140 m_tooltips
.Create(this);
141 m_tooltips
.AddTool(IDC_ONLYEXPLORER
, IDS_SETTINGS_ONLYEXPLORER_TT
);
142 m_tooltips
.AddTool(IDC_EXCLUDEPATHS
, IDS_SETTINGS_EXCLUDELIST_TT
);
143 m_tooltips
.AddTool(IDC_INCLUDEPATHS
, IDS_SETTINGS_INCLUDELIST_TT
);
144 m_tooltips
.AddTool(IDC_CACHEDEFAULT
, IDS_SETTINGS_CACHEDEFAULT_TT
);
145 m_tooltips
.AddTool(IDC_CACHESHELL
, IDS_SETTINGS_CACHESHELL_TT
);
146 m_tooltips
.AddTool(IDC_CACHESHELL2
, IDS_SETTINGS_CACHESHELLEXT_TT
);
147 m_tooltips
.AddTool(IDC_CACHENONE
, IDS_SETTINGS_CACHENONE_TT
);
148 m_tooltips
.AddTool(IDC_UNVERSIONEDASMODIFIED
, IDS_SETTINGS_UNVERSIONEDASMODIFIED_TT
);
149 m_tooltips
.AddTool(IDC_SHOWEXCLUDEDASNORMAL
, IDS_SETTINGS_SHOWEXCLUDEDASNORMAL_TT
);
156 BOOL
CSetOverlayPage::PreTranslateMessage(MSG
* pMsg
)
158 m_tooltips
.RelayEvent(pMsg
);
159 return ISettingsPropPage::PreTranslateMessage(pMsg
);
162 void CSetOverlayPage::OnChange()
165 int id
= GetCheckedRadioButton(IDC_CACHEDEFAULT
, IDC_CACHENONE
);
169 case IDC_CACHEDEFAULT
:
175 case IDC_CACHESHELL2
:
182 GetDlgItem(IDC_UNVERSIONEDASMODIFIED
)->EnableWindow(m_dwCacheType
== 1);
183 GetDlgItem(IDC_FLOPPY
)->EnableWindow(m_bRemovable
);
187 BOOL
CSetOverlayPage::OnApply()
190 Store (m_bOnlyExplorer
, m_regOnlyExplorer
);
191 if (DWORD(m_regDriveMaskRemovable
) != DWORD(m_bRemovable
))
192 m_restart
= Restart_Cache
;
193 Store (m_bRemovable
, m_regDriveMaskRemovable
);
195 if (DWORD(m_regDriveMaskFloppy
) != DWORD(m_bFloppy
))
196 m_restart
= Restart_Cache
;
197 Store (m_bFloppy
, m_regDriveMaskFloppy
);
199 if (DWORD(m_regDriveMaskRemote
) != DWORD(m_bNetwork
))
200 m_restart
= Restart_Cache
;
201 Store (m_bNetwork
, m_regDriveMaskRemote
);
203 if (DWORD(m_regDriveMaskFixed
) != DWORD(m_bFixed
))
204 m_restart
= Restart_Cache
;
205 Store (m_bFixed
, m_regDriveMaskFixed
);
207 if (DWORD(m_regDriveMaskCDROM
) != DWORD(m_bCDROM
))
208 m_restart
= Restart_Cache
;
209 Store (m_bCDROM
, m_regDriveMaskCDROM
);
211 if (DWORD(m_regDriveMaskRAM
) != DWORD(m_bRAM
))
212 m_restart
= Restart_Cache
;
213 Store (m_bRAM
, m_regDriveMaskRAM
);
215 if (DWORD(m_regDriveMaskUnknown
) != DWORD(m_bUnknown
))
216 m_restart
= Restart_Cache
;
217 Store (m_bUnknown
, m_regDriveMaskUnknown
);
219 if (m_sExcludePaths
.Compare(CString(m_regExcludePaths
)))
220 m_restart
= Restart_Cache
;
221 m_sExcludePaths
.Remove('\r');
222 if (m_sExcludePaths
.Right(1).Compare(_T("\n"))!=0)
223 m_sExcludePaths
+= _T("\n");
224 Store (m_sExcludePaths
, m_regExcludePaths
);
225 m_sExcludePaths
.Replace(_T("\n"), _T("\r\n"));
226 m_sIncludePaths
.Remove('\r');
227 if (m_sIncludePaths
.Right(1).Compare(_T("\n"))!=0)
228 m_sIncludePaths
+= _T("\n");
229 if (m_sIncludePaths
.Compare(CString(m_regIncludePaths
)))
230 m_restart
= Restart_Cache
;
231 Store (m_sIncludePaths
, m_regIncludePaths
);
232 m_sIncludePaths
.Replace(_T("\n"), _T("\r\n"));
234 if (DWORD(m_regUnversionedAsModified
) != DWORD(m_bUnversionedAsModified
))
235 m_restart
= Restart_Cache
;
236 Store (m_bUnversionedAsModified
, m_regUnversionedAsModified
);
237 if (DWORD(m_regShowExcludedAsNormal
) != DWORD(m_bShowExcludedAsNormal
))
238 m_restart
= Restart_Cache
;
239 Store (m_bShowExcludedAsNormal
, m_regShowExcludedAsNormal
);
241 Store (m_dwCacheType
, m_regCacheType
);
242 if (m_dwCacheType
!= 1)
244 // close the possible running cache process
245 HWND hWnd
= ::FindWindow(TGIT_CACHE_WINDOW_NAME
, TGIT_CACHE_WINDOW_NAME
);
248 ::PostMessage(hWnd
, WM_CLOSE
, NULL
, NULL
);
250 m_restart
= Restart_None
;
253 return ISettingsPropPage::OnApply();