From eef54f0f2d7dcc51dd6bd4a2b8787a836b858a31 Mon Sep 17 00:00:00 2001
From: Lawrence Lee <45837045+Lawrence37@users.noreply.github.com>
Date: Sun, 11 Jun 2023 17:22:40 -0700
Subject: [PATCH] Add option to disable symlinks in recursive browse
---
rtdata/languages/default | 1 +
rtgui/filecatalog.cc | 11 ++++++++++-
rtgui/options.cc | 6 ++++++
rtgui/options.h | 1 +
rtgui/preferences.cc | 4 ++++
rtgui/preferences.h | 1 +
6 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/rtdata/languages/default b/rtdata/languages/default
index 0b581d05d..8362c1c15 100644
--- a/rtdata/languages/default
+++ b/rtdata/languages/default
@@ -1825,6 +1825,7 @@ PREFERENCES_BEHAVIOR;Behavior
PREFERENCES_BEHSETALL;All to 'Set'
PREFERENCES_BEHSETALLHINT;Set all parameters to the Set mode.\nAdjustments of parameters in the batch tool panel will be absolute, the actual values will be displayed.
PREFERENCES_BROWSERECURSIVEDEPTH;Browse sub-folders depth
+PREFERENCES_BROWSERECURSIVEFOLLOWLINKS;Follow symbolic links when browsing sub-folders
PREFERENCES_BROWSERECURSIVEMAXDIRS;Maximum sub-folders
PREFERENCES_CACHECLEAR;Clear
PREFERENCES_CACHECLEAR_ALL;Clear all cached files:
diff --git a/rtgui/filecatalog.cc b/rtgui/filecatalog.cc
index 5c20aa5fe..b01300d95 100644
--- a/rtgui/filecatalog.cc
+++ b/rtgui/filecatalog.cc
@@ -590,7 +590,16 @@ std::vector FileCatalog::getFileList(std::vectorenumerate_children("standard::name,standard::type,standard::is-hidden");
+ static const auto enumerate_attrs =
+ std::string(G_FILE_ATTRIBUTE_STANDARD_NAME) + "," +
+ G_FILE_ATTRIBUTE_STANDARD_TYPE + "," +
+ G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN + "," +
+ G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET;
+ auto enumerator = dir->enumerate_children(
+ enumerate_attrs,
+ options.browseRecursiveFollowLinks
+ ? Gio::FileQueryInfoFlags::FILE_QUERY_INFO_NONE
+ : Gio::FileQueryInfoFlags::FILE_QUERY_INFO_NOFOLLOW_SYMLINKS);
if (directories_explored) {
directories_explored->push_back(dir);
diff --git a/rtgui/options.cc b/rtgui/options.cc
index ed6f03eb7..f8143996a 100644
--- a/rtgui/options.cc
+++ b/rtgui/options.cc
@@ -438,6 +438,7 @@ void Options::setDefaults()
browseRecursive = false;
browseRecursiveDepth = 10;
browseRecursiveMaxDirs = 100;
+ browseRecursiveFollowLinks = true;
renameUseTemplates = false;
renameTemplates.clear();
thumbnailZoomRatios.clear();
@@ -1357,6 +1358,10 @@ void Options::readFromFile(Glib::ustring fname)
if (keyFile.has_key("File Browser", "BrowseRecursiveMaxDirs")) {
browseRecursiveMaxDirs = keyFile.get_integer("File Browser", "BrowseRecursiveMaxDirs");
}
+
+ if (keyFile.has_key("File Browser", "BrowseRecursiveFollowLinks")) {
+ browseRecursiveFollowLinks = keyFile.get_integer("File Browser", "BrowseRecursiveFollowLinks");
+ }
}
if (keyFile.has_group("Clipping Indication")) {
@@ -2428,6 +2433,7 @@ void Options::saveToFile(Glib::ustring fname)
keyFile.set_boolean("File Browser", "BrowseRecursive", browseRecursive);
keyFile.set_integer("File Browser", "BrowseRecursiveDepth", browseRecursiveDepth);
keyFile.set_integer("File Browser", "BrowseRecursiveMaxDirs", browseRecursiveMaxDirs);
+ keyFile.set_boolean("File Browser", "BrowseRecursiveFollowLinks", browseRecursiveFollowLinks);
keyFile.set_integer("Clipping Indication", "HighlightThreshold", highlightThreshold);
keyFile.set_integer("Clipping Indication", "ShadowThreshold", shadowThreshold);
keyFile.set_boolean("Clipping Indication", "BlinkClipped", blinkClipped);
diff --git a/rtgui/options.h b/rtgui/options.h
index 6380cdb56..2e2839723 100644
--- a/rtgui/options.h
+++ b/rtgui/options.h
@@ -318,6 +318,7 @@ public:
bool browseRecursive;
int browseRecursiveDepth;
int browseRecursiveMaxDirs;
+ bool browseRecursiveFollowLinks;
std::vector tpOpen;
bool autoSaveTpOpen;
//std::vector crvOpen;
diff --git a/rtgui/preferences.cc b/rtgui/preferences.cc
index 025fbb3ae..1838ee299 100644
--- a/rtgui/preferences.cc
+++ b/rtgui/preferences.cc
@@ -1405,7 +1405,9 @@ Gtk::Widget* Preferences::getFileBrowserPanel()
hbBrowseRecursive->pack_start(*browseRecursiveDepth, Gtk::PACK_SHRINK, 4);
hbBrowseRecursive->pack_start(*labBrowseRecursiveMaxDirs, Gtk::PACK_SHRINK, 4);
hbBrowseRecursive->pack_start(*browseRecursiveMaxDirs, Gtk::PACK_SHRINK, 4);
+ browseRecursiveFollowLinks = Gtk::manage(new Gtk::CheckButton(M("PREFERENCES_BROWSERECURSIVEFOLLOWLINKS")));
vbro->pack_start(*hbBrowseRecursive, Gtk::PACK_SHRINK, 0);
+ vbro->pack_start(*browseRecursiveFollowLinks, Gtk::PACK_SHRINK, 0);
fro->add(*vbro);
@@ -1884,6 +1886,7 @@ void Preferences::storePreferences()
moptions.internalThumbIfUntouched = ckbInternalThumbIfUntouched->get_active();
moptions.browseRecursiveDepth = static_cast(browseRecursiveDepth->get_value());
moptions.browseRecursiveMaxDirs = static_cast(browseRecursiveMaxDirs->get_value());
+ moptions.browseRecursiveFollowLinks = browseRecursiveFollowLinks->get_active();
auto save_where = saveParamsPreference->get_active_row_number();
moptions.saveParamsFile = save_where == 0 || save_where == 2;
@@ -2111,6 +2114,7 @@ void Preferences::fillPreferences()
ckbInternalThumbIfUntouched->set_active(moptions.internalThumbIfUntouched);
browseRecursiveDepth->set_value(moptions.browseRecursiveDepth);
browseRecursiveMaxDirs->set_value(moptions.browseRecursiveMaxDirs);
+ browseRecursiveFollowLinks->set_active(moptions.browseRecursiveFollowLinks);
saveParamsPreference->set_active(moptions.saveParamsFile ? (moptions.saveParamsCache ? 2 : 0) : 1);
diff --git a/rtgui/preferences.h b/rtgui/preferences.h
index 829506894..c15ea71e8 100644
--- a/rtgui/preferences.h
+++ b/rtgui/preferences.h
@@ -196,6 +196,7 @@ class Preferences final :
Gtk::CheckButton* sameThumbSize;
Gtk::SpinButton* browseRecursiveDepth;
Gtk::SpinButton* browseRecursiveMaxDirs;
+ Gtk::CheckButton* browseRecursiveFollowLinks;
Gtk::SpinButton* threadsSpinBtn;
Gtk::SpinButton* clutCacheSizeSB;