summaryrefslogtreecommitdiff
path: root/libcaja-private
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2026-05-18 23:04:07 -0400
committerVictor Kareh <[email protected]>2026-05-18 23:07:16 -0400
commitcc27b2b763f16983cdd38696b53256dc4e28c457 (patch)
tree00adf8c235fdd0bd4a538d6d4a94bd51c39209bc /libcaja-private
parent5382d8fcdf08ac2c833858370ac0176158e37ffe (diff)
downloadcaja-thumbnail-directory-limit.tar.bz2
caja-thumbnail-directory-limit.tar.xz
preferences: add option to disable thumbnails in large directoriesthumbnail-directory-limit
Directories with many files have significant performance issues when generating thumbnails. This adds a preference that disables thumbnails when the directory exceeds the threshold. Fixes #1304
Diffstat (limited to 'libcaja-private')
-rw-r--r--libcaja-private/caja-file.c22
-rw-r--r--libcaja-private/caja-global-preferences.h1
-rw-r--r--libcaja-private/org.mate.caja.gschema.xml5
3 files changed, 28 insertions, 0 deletions
diff --git a/libcaja-private/caja-file.c b/libcaja-private/caja-file.c
index c2a463a6..032a4d06 100644
--- a/libcaja-private/caja-file.c
+++ b/libcaja-private/caja-file.c
@@ -4338,6 +4338,7 @@ get_custom_icon (CajaFile *file)
}
static guint64 cached_thumbnail_limit;
+static guint64 cached_thumbnail_directory_limit;
int cached_thumbnail_size;
static int show_image_thumbs;
@@ -4366,6 +4367,12 @@ caja_file_should_show_thumbnail (CajaFile *file)
use_preview = caja_file_get_filesystem_use_preview (file);
+ if (file->details->directory != NULL &&
+ file->details->directory->details->confirmed_file_count > 0 &&
+ (guint64) file->details->directory->details->confirmed_file_count > cached_thumbnail_directory_limit) {
+ return FALSE;
+ }
+
mime_type = file->details->mime_type;
if (mime_type == NULL) {
mime_type = "application/octet-stream";
@@ -8535,6 +8542,16 @@ thumbnail_limit_changed_callback (gpointer user_data)
}
static void
+thumbnail_directory_limit_changed_callback (gpointer user_data)
+{
+ g_settings_get (caja_preferences,
+ CAJA_PREFERENCES_IMAGE_FILE_THUMBNAIL_DIRECTORY_LIMIT,
+ "t", &cached_thumbnail_directory_limit);
+
+ emit_change_signals_for_all_files_in_all_directories ();
+}
+
+static void
thumbnail_size_changed_callback (gpointer user_data)
{
cached_thumbnail_size = g_settings_get_int (caja_icon_view_preferences, CAJA_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE);
@@ -8655,6 +8672,11 @@ caja_file_class_init (CajaFileClass *class)
"changed::" CAJA_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT,
G_CALLBACK (thumbnail_limit_changed_callback),
NULL);
+ thumbnail_directory_limit_changed_callback (NULL);
+ g_signal_connect_swapped (caja_preferences,
+ "changed::" CAJA_PREFERENCES_IMAGE_FILE_THUMBNAIL_DIRECTORY_LIMIT,
+ G_CALLBACK (thumbnail_directory_limit_changed_callback),
+ NULL);
thumbnail_size_changed_callback (NULL);
g_signal_connect_swapped (caja_icon_view_preferences,
"changed::" CAJA_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE,
diff --git a/libcaja-private/caja-global-preferences.h b/libcaja-private/caja-global-preferences.h
index 27059ca7..9fadffd1 100644
--- a/libcaja-private/caja-global-preferences.h
+++ b/libcaja-private/caja-global-preferences.h
@@ -186,6 +186,7 @@ typedef enum
#define CAJA_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS "show-directory-item-counts"
#define CAJA_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS "show-image-thumbnails"
#define CAJA_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT "thumbnail-limit"
+#define CAJA_PREFERENCES_IMAGE_FILE_THUMBNAIL_DIRECTORY_LIMIT "thumbnail-directory-limit"
#define CAJA_PREFERENCES_PREVIEW_SOUND "preview-sound"
typedef enum
diff --git a/libcaja-private/org.mate.caja.gschema.xml b/libcaja-private/org.mate.caja.gschema.xml
index 7e9b150e..5f3792b3 100644
--- a/libcaja-private/org.mate.caja.gschema.xml
+++ b/libcaja-private/org.mate.caja.gschema.xml
@@ -165,6 +165,11 @@
<summary>Maximum image size for thumbnailing</summary>
<description>Images over this size (in bytes) won't be thumbnailed. The purpose of this setting is to avoid thumbnailing large images that may take a long time to load or use lots of memory.</description>
</key>
+ <key name="thumbnail-directory-limit" type="t">
+ <default>5000</default>
+ <summary>Maximum number of files in a directory for thumbnailing</summary>
+ <description>Directories with more than this number of files won't show thumbnails. The purpose of this setting is to avoid the performance penalty of generating thumbnails in very large directories. The file count includes hidden files regardless of whether they are displayed.</description>
+ </key>
<key name="preview-sound" enum="org.mate.caja.SpeedTradeoff">
<aliases><alias value='local_only' target='local-only'/></aliases>
<default>'local-only'</default>