From d8cb12f74f62d765707b83969558ccd8ba9d9369 Mon Sep 17 00:00:00 2001 From: WeatherWonders Date: Mon, 9 Jun 2025 22:16:39 -0400 Subject: [PATCH 1/2] Fix long-used recent files being truncated out of the list --- src/io/recent-files.cpp | 30 ++++++++++++++------------ src/ui/dialog/inkscape-preferences.cpp | 2 -- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/io/recent-files.cpp b/src/io/recent-files.cpp index 4df63056ac..19206825fb 100644 --- a/src/io/recent-files.cpp +++ b/src/io/recent-files.cpp @@ -28,7 +28,7 @@ std::vector> getInkscapeRecentFiles(unsigned max_f std::vector> output; auto recent_manager = Gtk::RecentManager::get_default(); - // all recent files not necessarily inkscape only (std::vector) + // All recent files, not necessarily inkscape only (std::vector) auto recent_files = recent_manager->get_items(); // Remove non-inkscape files. @@ -37,15 +37,22 @@ std::vector> getInkscapeRecentFiles(unsigned max_f bool valid_file = recent_file->has_application(g_get_prgname()) || recent_file->has_application("org.inkscape.Inkscape") || - recent_file->has_application("inkscape") -#ifdef _WIN32 - || recent_file->has_application("inkscape.exe") -#endif -; + recent_file->has_application("inkscape") || + recent_file->has_application("inkscape.exe"); return !valid_file; }); - - // Truncate to user specified max_files. + + // Sort by "last modified" time, which puts the most recently opened files first. + auto sort_by_time = [&](){ + std::sort(std::begin(recent_files), std::end(recent_files), [](auto const &a, auto const &b) -> bool { + // a should precede b if a->get_modified() is later than b->get_modified() + return a->get_modified().compare(b->get_modified()) > 0; + }); + }; + + sort_by_time(); // Initial sort so the longest-unused files are removed + + // Truncate to user-specified max_files. if (max_files && recent_files.size() > max_files) { recent_files.resize(max_files); } @@ -64,11 +71,7 @@ std::vector> getInkscapeRecentFiles(unsigned max_f auto it_u = std::unique (recent_files.begin(), recent_files.end(), unique_comparator_uri); recent_files.erase(it_u, recent_files.end()); - // Sort by "last modified" time, which puts the most recently opened files first. - std::sort(std::begin(recent_files), std::end(recent_files), [](auto const &a, auto const &b) -> bool { - // a should precede b if a->get_modified() is later than b->get_modified() - return a->get_modified().compare(b->get_modified()) > 0; - }); + sort_by_time(); // Final order return recent_files; } @@ -166,7 +169,6 @@ std::map getShortenedPathMap(std::vectorhas_application(g_get_prgname()) || e->has_application("org.inkscape.Inkscape") || e->has_application("inkscape") -#ifdef _WIN32 || e->has_application("inkscape.exe") -#endif ) { manager->remove_item(e->get_uri()); } -- GitLab From f6ee41ce0cff63fcf19f00b14ecd34189b0706df Mon Sep 17 00:00:00 2001 From: WeatherWonders Date: Tue, 10 Jun 2025 10:59:36 -0400 Subject: [PATCH 2/2] Truncate after removing duplicate recent list entries --- src/io/recent-files.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/io/recent-files.cpp b/src/io/recent-files.cpp index 19206825fb..2ea50de2c9 100644 --- a/src/io/recent-files.cpp +++ b/src/io/recent-files.cpp @@ -42,21 +42,6 @@ std::vector> getInkscapeRecentFiles(unsigned max_f return !valid_file; }); - // Sort by "last modified" time, which puts the most recently opened files first. - auto sort_by_time = [&](){ - std::sort(std::begin(recent_files), std::end(recent_files), [](auto const &a, auto const &b) -> bool { - // a should precede b if a->get_modified() is later than b->get_modified() - return a->get_modified().compare(b->get_modified()) > 0; - }); - }; - - sort_by_time(); // Initial sort so the longest-unused files are removed - - // Truncate to user-specified max_files. - if (max_files && recent_files.size() > max_files) { - recent_files.resize(max_files); - } - // Ensure that display uri's are unique. It is possible that an XBEL file // has multiple entries for the same file as a path can be written in equivalent // ways: i.e. with a ';' or '%3B', or with a drive name of 'c' or 'C' on Windows. @@ -71,7 +56,16 @@ std::vector> getInkscapeRecentFiles(unsigned max_f auto it_u = std::unique (recent_files.begin(), recent_files.end(), unique_comparator_uri); recent_files.erase(it_u, recent_files.end()); - sort_by_time(); // Final order + // Sort by "last modified" time, which puts the most recently opened files first. + std::sort(std::begin(recent_files), std::end(recent_files), [](auto const &a, auto const &b) -> bool { + // a should precede b if a->get_modified() is later than b->get_modified() + return a->get_modified().compare(b->get_modified()) > 0; + }); + + // Truncate to user-specified max_files. + if (max_files && recent_files.size() > max_files) { + recent_files.resize(max_files); + } return recent_files; } -- GitLab