Add option to disable symlinks in recursive browse

This commit is contained in:
Lawrence Lee
2023-06-11 17:22:40 -07:00
parent 660c9507cc
commit eef54f0f2d
6 changed files with 23 additions and 1 deletions

View File

@@ -1825,6 +1825,7 @@ PREFERENCES_BEHAVIOR;Behavior
PREFERENCES_BEHSETALL;All to 'Set'
PREFERENCES_BEHSETALLHINT;Set all parameters to the <b>Set</b> mode.\nAdjustments of parameters in the batch tool panel will be <b>absolute</b>, 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:

View File

@@ -590,7 +590,16 @@ std::vector<Glib::ustring> FileCatalog::getFileList(std::vector<Glib::RefPtr<Gio
const auto dir = Gio::File::create_for_path(dir_path);
auto enumerator = dir->enumerate_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);

View File

@@ -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);

View File

@@ -318,6 +318,7 @@ public:
bool browseRecursive;
int browseRecursiveDepth;
int browseRecursiveMaxDirs;
bool browseRecursiveFollowLinks;
std::vector<int> tpOpen;
bool autoSaveTpOpen;
//std::vector<int> crvOpen;

View File

@@ -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<int>(browseRecursiveDepth->get_value());
moptions.browseRecursiveMaxDirs = static_cast<int>(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);

View File

@@ -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;