CString GitPatch::CheckPatchPath(const CString& path) { // first check if the path already matches if (CountMatches(path) > (GetNumberOfFiles() / 3)) return path; CSysProgressDlg progress; CString tmp; progress.SetTitle(IDS_PATCH_SEARCHPATHTITLE); progress.SetShowProgressBar(false); tmp.LoadString(IDS_PATCH_SEARCHPATHLINE1); progress.SetLine(1, tmp); progress.ShowModeless(AfxGetMainWnd()); // now go up the tree and try again CString upperpath = path; while (upperpath.ReverseFind('\\')>0) { upperpath = upperpath.Left(upperpath.ReverseFind('\\')); progress.SetLine(2, upperpath, true); if (progress.HasUserCancelled()) return path; if (CountMatches(upperpath) > (GetNumberOfFiles()/3)) return upperpath; } // still no match found. So try sub folders bool isDir = false; CString subpath; CDirFileEnum filefinder(path); while (filefinder.NextFile(subpath, &isDir)) { if (progress.HasUserCancelled()) return path; if (!isDir) continue; if (GitAdminDir::IsAdminDirPath(subpath)) continue; progress.SetLine(2, subpath, true); if (CountMatches(subpath) > (GetNumberOfFiles()/3)) return subpath; } // if a patch file only contains newly added files // we can't really find the correct path. // But: we can compare paths strings without the filenames // and check if at least those match upperpath = path; while (upperpath.ReverseFind('\\')>0) { upperpath = upperpath.Left(upperpath.ReverseFind('\\')); progress.SetLine(2, upperpath, true); if (progress.HasUserCancelled()) return path; if (CountDirMatches(upperpath) > (GetNumberOfFiles()/3)) return upperpath; } return path; }
CString CPatch::CheckPatchPath(const CString& path) { //first check if the path already matches if (CountMatches(path) > (GetNumberOfFiles()/3)) return path; //now go up the tree and try again CString upperpath = path; while (upperpath.ReverseFind('\\')>0) { upperpath = upperpath.Left(upperpath.ReverseFind('\\')); if (CountMatches(upperpath) > (GetNumberOfFiles()/3)) return upperpath; } //still no match found. So try sub folders bool isDir = false; CString subpath; CDirFileEnum filefinder(path); while (filefinder.NextFile(subpath, &isDir)) { if (!isDir) continue; if (g_GitAdminDir.IsAdminDirPath(subpath)) continue; if (CountMatches(subpath) > (GetNumberOfFiles()/3)) return subpath; } // if a patch file only contains newly added files // we can't really find the correct path. // But: we can compare paths strings without the filenames // and check if at least those match upperpath = path; while (upperpath.ReverseFind('\\')>0) { upperpath = upperpath.Left(upperpath.ReverseFind('\\')); if (CountDirMatches(upperpath) > (GetNumberOfFiles()/3)) return upperpath; } return path; }
BOOL CSetOverlayIcons::OnInitDialog() { ISettingsPropPage::OnInitDialog(); m_cIconList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP | LVS_EX_SUBITEMIMAGES); // get the path to our icon sets TCHAR buf[MAX_PATH] = {0}; SHGetSpecialFolderPath(m_hWnd, buf, CSIDL_PROGRAM_FILES_COMMON, true); m_sIconPath = buf; m_sIconPath += _T("\\TortoiseOverlays\\Icons"); // list all the icon sets CDirFileEnum filefinder(m_sIconPath); bool isDir = false; CString item; while (filefinder.NextFile(item, &isDir)) { if (!isDir) continue; m_cIconSet.AddString(CPathUtils::GetFileNameFromPath(item)); } CheckRadioButton(IDC_LISTRADIO, IDC_SYMBOLRADIO, IDC_LISTRADIO); CString sModifiedIcon = m_regModified; if (sModifiedIcon.IsEmpty()) { // no custom icon set, use the default sModifiedIcon = m_sIconPath + _T("\\XPStyle\\ModifiedIcon.ico"); } if (sModifiedIcon.Left(m_sIconPath.GetLength()).CompareNoCase(m_sIconPath)!=0) { // an icon set outside our own installation? We don't support that, // so fall back to the default! sModifiedIcon = m_sIconPath + _T("\\XPStyle\\ModifiedIcon.ico"); } // the name of the icon set is the folder of the icon location m_sOriginalIconSet = sModifiedIcon.Mid(m_sIconPath.GetLength()+1); m_sOriginalIconSet = m_sOriginalIconSet.Left(m_sOriginalIconSet.ReverseFind('\\')); // now we have the name of the icon set. Set the combobox to show // that as selected CString ComboItem; for (int i=0; i<m_cIconSet.GetCount(); ++i) { m_cIconSet.GetLBText(i, ComboItem); if (ComboItem.CompareNoCase(m_sOriginalIconSet)==0) m_cIconSet.SetCurSel(i); } m_sNormal = CString(MAKEINTRESOURCE(IDS_STATUSNORMAL)); m_sModified = CString(MAKEINTRESOURCE(IDS_STATUSMODIFIED)); m_sConflicted = CString(MAKEINTRESOURCE(IDS_STATUSCONFLICTED)); m_sDeleted = CString(MAKEINTRESOURCE(IDS_STATUSDELETED)); m_sAdded = CString(MAKEINTRESOURCE(IDS_STATUSADDED)); m_sIgnored = CString(MAKEINTRESOURCE(IDS_STATUSIGNORED)); m_sUnversioned = CString(MAKEINTRESOURCE(IDS_STATUSUNVERSIONED)); m_sReadOnly.LoadString(IDS_SETTINGS_READONLYNAME); m_sLocked.LoadString(IDS_SETTINGS_LOCKEDNAME); SetWindowTheme(m_hWnd, L"Explorer", NULL); ShowIconSet(true); return TRUE; }
BOOL CSetOverlayIcons::OnInitDialog() { ISettingsPropPage::OnInitDialog(); m_cIconList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP | LVS_EX_SUBITEMIMAGES); // get the path to our icon sets TCHAR buf[MAX_PATH] = {0}; SHGetSpecialFolderPath(m_hWnd, buf, CSIDL_PROGRAM_FILES_COMMON, true); m_sIconPath = buf; m_sIconPath += _T("\\TortoiseOverlays\\Icons"); // list all the icon sets CDirFileEnum filefinder(m_sIconPath); bool isDir = false; CString item; while (filefinder.NextFile(item, &isDir)) { if (!isDir) continue; m_cIconSet.AddString(CPathUtils::GetFileNameFromPath(item)); } CheckRadioButton(IDC_LISTRADIO, IDC_SYMBOLRADIO, IDC_LISTRADIO); CString sModifiedIcon = m_regModified; if (sModifiedIcon.IsEmpty()) { // no custom icon set, use the default sModifiedIcon = m_sIconPath + _T("\\XPStyle\\ModifiedIcon.ico"); } if (sModifiedIcon.Left(m_sIconPath.GetLength()).CompareNoCase(m_sIconPath)!=0) { // an icon set outside our own installation? We don't support that, // so fall back to the default! sModifiedIcon = m_sIconPath + _T("\\XPStyle\\ModifiedIcon.ico"); } // the name of the icon set is the folder of the icon location m_sOriginalIconSet = sModifiedIcon.Mid(m_sIconPath.GetLength()+1); m_sOriginalIconSet = m_sOriginalIconSet.Left(m_sOriginalIconSet.ReverseFind('\\')); // now we have the name of the icon set. Set the combobox to show // that as selected CString ComboItem; for (int i=0; i<m_cIconSet.GetCount(); ++i) { m_cIconSet.GetLBText(i, ComboItem); if (ComboItem.CompareNoCase(m_sOriginalIconSet)==0) m_cIconSet.SetCurSel(i); } WORD langID = (WORD)(DWORD)CRegStdDWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID()); TCHAR statustext[MAX_STATUS_STRING_LENGTH] = { 0 }; GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_normal, statustext, _countof(statustext), langID); m_sNormal = statustext; GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_modified, statustext, _countof(statustext), langID); m_sModified = statustext; GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_conflicted, statustext, _countof(statustext), langID); m_sConflicted = statustext; GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_deleted, statustext, _countof(statustext), langID); m_sDeleted = statustext; GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_added, statustext, _countof(statustext), langID); m_sAdded = statustext; GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_ignored, statustext, _countof(statustext), langID); m_sIgnored = statustext; GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_unversioned, statustext, _countof(statustext), langID); m_sUnversioned = statustext; m_sReadOnly.LoadString(IDS_SETTINGS_READONLYNAME); m_sLocked.LoadString(IDS_SETTINGS_LOCKEDNAME); SetWindowTheme(m_hWnd, L"Explorer", NULL); ShowIconSet(true); return TRUE; }