MCPcopy Create free account
hub / github.com/GollyGang/ready / ClearMissingPatterns

Method ClearMissingPatterns

src/gui/frame.cpp:1799–1843  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1797// ---------------------------------------------------------------------
1798
1799void MyFrame::ClearMissingPatterns()
1800{
1801 int pos = 0;
1802 while (pos < numpatterns) {
1803 wxMenuItem* item = patternSubMenu->FindItemByPosition(pos);
1804 wxString path = item->GetText();
1805 #ifdef __WXGTK__
1806 // remove duplicate underscores
1807 path.Replace(wxT("__"), wxT("_"));
1808 #endif
1809 // remove duplicate ampersands
1810 path.Replace(wxT("&&"), wxT("&"));
1811
1812 // if path isn't absolute then prepend Ready directory
1813 wxFileName fname(path);
1814 if (!fname.IsAbsolute()) path = readydir + path;
1815
1816 if (wxFileExists(path)) {
1817 // keep this item
1818 pos++;
1819 } else {
1820 // remove this item by shifting up later items
1821 int nextpos = pos + 1;
1822 while (nextpos < numpatterns) {
1823 wxMenuItem* nextitem = patternSubMenu->FindItemByPosition(nextpos);
1824 #ifdef __WXGTK__
1825 // avoid wxGTK bug if item contains underscore
1826 wxString temp = nextitem->GetText();
1827 temp.Replace(wxT("__"), wxT("_"));
1828 temp.Replace(wxT("&"), wxT("&&"));
1829 item->SetText( temp );
1830 #else
1831 item->SetText( nextitem->GetText() );
1832 #endif
1833 item = nextitem;
1834 nextpos++;
1835 }
1836 // delete last item
1837 patternSubMenu->Delete(item);
1838 numpatterns--;
1839 }
1840 }
1841 wxMenuBar* mbar = GetMenuBar();
1842 if (mbar) mbar->Enable(ID::OpenRecent, numpatterns > 0);
1843}
1844
1845// ---------------------------------------------------------------------
1846

Callers

nothing calls this directly

Calls 1

EnableMethod · 0.80

Tested by

no test coverage detected