1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2013 - TortoiseGit
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 "SetMainPage.h"
22 #include "ProjectProperties.h"
23 #include "SetDialogs3.h"
25 CComboBox
CSetDialogs3::m_langCombo
;
27 IMPLEMENT_DYNAMIC(CSetDialogs3
, ISettingsPropPage
)
28 CSetDialogs3::CSetDialogs3()
29 : ISettingsPropPage(CSetDialogs3::IDD
)
34 CSetDialogs3::~CSetDialogs3()
38 void CSetDialogs3::DoDataExchange(CDataExchange
* pDX
)
40 ISettingsPropPage::DoDataExchange(pDX
);
41 DDX_Control(pDX
, IDC_LANGCOMBO
, m_langCombo
);
42 DDX_Text(pDX
, IDC_LOGMINSIZE
, m_LogMinSize
);
43 DDX_Text(pDX
, IDC_BORDER
, m_Border
);
44 DDX_Control(pDX
, IDC_WARN_NO_SIGNED_OFF_BY
, m_cWarnNoSignedOffBy
);
48 BEGIN_MESSAGE_MAP(CSetDialogs3
, ISettingsPropPage
)
49 GITSETTINGS_RADIO_EVENT
50 ON_CBN_SELCHANGE(IDC_LANGCOMBO
, &OnChange
)
51 ON_CBN_SELCHANGE(IDC_WARN_NO_SIGNED_OFF_BY
, &OnChange
)
52 ON_EN_CHANGE(IDC_LOGMINSIZE
, &OnChange
)
53 ON_EN_CHANGE(IDC_BORDER
, &OnChange
)
56 // CSetDialogs2 message handlers
57 BOOL
CSetDialogs3::OnInitDialog()
59 ISettingsPropPage::OnInitDialog();
61 AddTrueFalseToComboBox(m_cWarnNoSignedOffBy
);
63 m_langCombo
.AddString(_T(""));
64 m_langCombo
.SetItemData(0, 0);
65 m_langCombo
.AddString(_T("(disable)"));
66 m_langCombo
.SetItemData(1, (DWORD_PTR
)-1);
67 // fill the combo box with all available languages
68 EnumSystemLocales(EnumLocalesProc
, LCID_SUPPORTED
);
70 m_tooltips
.Create(this);
72 InitGitSettings(this, true, &m_tooltips
);
78 static void SelectLanguage(CComboBox
&combobox
, LONG langueage
)
80 for (int i
= 0; i
< combobox
.GetCount(); ++i
)
82 if (combobox
.GetItemData(i
) == langueage
)
84 combobox
.SetCurSel(i
);
90 void CSetDialogs3::LoadDataImpl(git_config
* config
)
94 GetConfigValue(config
, PROJECTPROPNAME_PROJECTLANGUAGE
, value
);
95 if (value
== _T("-1"))
96 m_langCombo
.SetCurSel(1);
97 else if (!value
.IsEmpty())
100 long longValue
= _tcstol(value
, &strEnd
, 0);
103 if (m_iConfigSource
== 0)
104 SelectLanguage(m_langCombo
, CRegDWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033));
106 m_langCombo
.SetCurSel(0);
109 SelectLanguage(m_langCombo
, longValue
);
110 } else if (m_iConfigSource
== 0)
111 SelectLanguage(m_langCombo
, CRegDWORD(_T("Software\\TortoiseGit\\LanguageID"), 1033));
113 m_langCombo
.SetCurSel(0);
117 m_LogMinSize
= _T("");
119 GetConfigValue(config
, PROJECTPROPNAME_LOGMINSIZE
, value
);
120 if (!value
.IsEmpty() || m_iConfigSource
== 0)
122 int nMinLogSize
= _ttoi(value
);
123 m_LogMinSize
.Format(L
"%d", nMinLogSize
);
130 GetConfigValue(config
, PROJECTPROPNAME_LOGWIDTHLINE
, value
);
131 if (!value
.IsEmpty() || m_iConfigSource
== 0)
133 int nLogWidthMarker
= _ttoi(value
);
134 m_Border
.Format(L
"%d", nLogWidthMarker
);
138 GetBoolConfigValueComboBox(config
, PROJECTPROPNAME_WARNNOSIGNEDOFFBY
, m_cWarnNoSignedOffBy
);
145 BOOL
CSetDialogs3::SafeDataImpl(git_config
* config
)
147 if (m_langCombo
.GetCurSel() == 1)
149 if (!Save(config
, PROJECTPROPNAME_PROJECTLANGUAGE
, L
"-1"))
156 sprintf_s(numBuf
, "%ld", m_langCombo
.GetItemData(m_langCombo
.GetCurSel()));
157 if (!Save(config
, PROJECTPROPNAME_PROJECTLANGUAGE
, (CString
)numBuf
, true))
161 if (!Save(config
, PROJECTPROPNAME_LOGMINSIZE
, m_LogMinSize
, true))
164 if (!Save(config
, PROJECTPROPNAME_LOGWIDTHLINE
, m_Border
, true))
169 m_cWarnNoSignedOffBy
.GetWindowText(value
);
170 if (!Save(config
, PROJECTPROPNAME_WARNNOSIGNEDOFFBY
, value
))
177 BOOL
CSetDialogs3::PreTranslateMessage(MSG
* pMsg
)
179 m_tooltips
.RelayEvent(pMsg
);
180 return ISettingsPropPage::PreTranslateMessage(pMsg
);
183 void CSetDialogs3::OnChange()
189 BOOL
CSetDialogs3::OnApply()
198 return ISettingsPropPage::OnApply();
201 BOOL
CSetDialogs3::EnumLocalesProc(LPTSTR lpLocaleString
)
203 DWORD langID
= _tcstol(lpLocaleString
, NULL
, 16);
205 TCHAR buf
[MAX_PATH
] = {0};
206 GetLocaleInfo(langID
, LOCALE_SNATIVELANGNAME
, buf
, _countof(buf
));
208 GetLocaleInfo(langID
, LOCALE_SNATIVECTRYNAME
, buf
, _countof(buf
));
216 int index
= m_langCombo
.AddString(sLang
);
217 m_langCombo
.SetItemData(index
, langID
);