Creating thumbnails takes too long; use only thumbnails in the cache.
Option in Preferences/General to define the maximum number of thumbnails
in the montage.
#include "image-load.h"
#include "image_load_collection.h"
+#include "cache.h"
#include "misc.h"
+#include "ui_fileops.h"
typedef struct _ImageLoaderCOLLECTION ImageLoaderCOLLECTION;
struct _ImageLoaderCOLLECTION {
ImageLoader *il = ld->data;
#define LINE_LENGTH 1000
- #define MAX_LINES 23
gboolean ret = FALSE;
gchar *randname;
gint line_count = 0;
GString *file_names = g_string_new(NULL);
gchar line[LINE_LENGTH];
+ gchar **split_line = NULL;
+ gchar *cache_found;
+ gchar *pathl;
if (runcmd("which montage >/dev/null 2>&1") == 0)
{
- fp = fopen(il->fd->path, "r");
+ pathl = path_from_utf8(il->fd->path);
+ fp = fopen(pathl, "r");
+ g_free(pathl);
if (fp)
{
- while(fgets(line, LINE_LENGTH, fp) && line_count < MAX_LINES)
+ while(fgets(line, LINE_LENGTH, fp) && line_count < options->thumbnails.collection_preview)
{
- /* get rid of ending \n from fgets */
- line[strlen(line) - 1] = '\0';
if (line[0] && line[0] != '#')
{
- file_names = g_string_append(file_names, line);
- file_names = g_string_append(file_names, " ");
+ split_line = g_strsplit(line, "\"", 4);
+ cache_found = cache_find_location(CACHE_TYPE_THUMB, split_line[1]);
+ if (cache_found)
+ {
+ file_names = g_string_append(file_names, g_strconcat("\"", cache_found,"\" ", NULL));
+ line_count++;
+ }
+ g_free(cache_found);
}
- line_count++;
+ if (split_line)
+ {
+ g_strfreev(split_line);
+ }
+ split_line = NULL;
}
fclose(fp);
if (file_names->len > 0)
{
- randname = g_strdup("geeqie_collection_XXXXXX.png");
+ randname = g_strdup("/tmp/geeqie_collection_XXXXXX.png");
g_mkstemp(randname);
cmd_line = g_strdup_printf("montage %s -geometry %dx%d+1+1 %s >/dev/null 2>&1", file_names->str, options->thumbnails.max_width, options->thumbnails.max_height, randname);
options->thumbnails.use_exif = FALSE;
options->thumbnails.use_ft_metadata = TRUE;
// options->thumbnails.use_ft_metadata_small = TRUE;
+ options->thumbnails.collection_preview = 20;
options->tree_descend_subdirs = FALSE;
options->view_dir_list_single_click_enter = TRUE;
guint quality;
gboolean use_exif;
gboolean use_ft_metadata;
+ gint collection_preview;
// gboolean use_ft_metadata_small;
} thumbnails;
options->thumbnails.enable_caching = c_options->thumbnails.enable_caching;
options->thumbnails.cache_into_dirs = c_options->thumbnails.cache_into_dirs;
options->thumbnails.use_exif = c_options->thumbnails.use_exif;
+ options->thumbnails.collection_preview = c_options->thumbnails.collection_preview;
options->thumbnails.use_ft_metadata = c_options->thumbnails.use_ft_metadata;
// options->thumbnails.use_ft_metadata_small = c_options->thumbnails.use_ft_metadata_small;
options->thumbnails.spec_standard = c_options->thumbnails.spec_standard;
pref_checkbox_new_int(group, _("Use EXIF thumbnails when available (EXIF thumbnails may be outdated)"),
options->thumbnails.use_exif, &c_options->thumbnails.use_exif);
+ spin = pref_spin_new_int(group, _("Collection preview:"), NULL,
+ 1, 999, 1,
+ options->thumbnails.collection_preview, &c_options->thumbnails.collection_preview);
+ gtk_widget_set_tooltip_text(spin, _("The maximum number of thumbnails shown in a Collection preview montage"));
+
#ifdef HAVE_FFMPEGTHUMBNAILER_METADATA
pref_checkbox_new_int(group, _("Use embedded metadata in video files as thumbnails when available"),
options->thumbnails.use_ft_metadata, &c_options->thumbnails.use_ft_metadata);
WRITE_NL(); WRITE_UINT(*options, thumbnails.quality);
WRITE_NL(); WRITE_BOOL(*options, thumbnails.use_exif);
WRITE_NL(); WRITE_BOOL(*options, thumbnails.use_ft_metadata);
+ WRITE_NL(); WRITE_INT(*options, thumbnails.collection_preview);
// WRITE_NL(); WRITE_BOOL(*options, thumbnails.use_ft_metadata_small);
/* File sorting Options */
if (READ_BOOL(*options, thumbnails.spec_standard)) continue;
if (READ_UINT_CLAMP(*options, thumbnails.quality, GDK_INTERP_NEAREST, GDK_INTERP_HYPER)) continue;
if (READ_BOOL(*options, thumbnails.use_exif)) continue;
+ if (READ_INT(*options, thumbnails.collection_preview)) continue;
if (READ_BOOL(*options, thumbnails.use_ft_metadata)) continue;
// if (READ_BOOL(*options, thumbnails.use_ft_metadata_small)) continue;