# HG changeset patch # User Colin Clark # Date 1501508189 -3600 # Node ID 034d8772d6d8d0b81fc75ce29e8ec2758909c6b0 # Parent 52fa0e775bb523b48c7f710168943dcf284a21a0 Fix #500: Geeqie doesn’t use shared thumbnail folder https://github.com/BestImageViewer/geeqie/issues/500 diff -r 52fa0e775bb5 -r 034d8772d6d8 doc/docbook/GuideOptionsGeneral.xml --- a/doc/docbook/GuideOptionsGeneral.xml Mon Jul 24 11:08:35 2017 +0100 +++ b/doc/docbook/GuideOptionsGeneral.xml Mon Jul 31 14:36:29 2017 +0100 @@ -66,51 +66,66 @@ Cache thumbnails - - Enable this to save thumbnails to disk, subsequent requests for a thumbnail will be faster. Thumbnails are cached into: - $XDG_CACHE_HOME/geeqie/thumbnails/ - ($~/.cache/geeqie/thumbnails/) - Refer to - Thumbnails Reference - for additional details. - - - - - - - - Use shared thumbnail cache - - - - This will use a thumbnail caching method that is compatible with applications that use the standard thumbnail specification. When this option is enabled thumbnails will be stored in - $HOME/.thumbnails - - - - - - - - Cache thumbnails into .thumbnails - - - - When enabled, Geeqie attempts to store cached thumbnails closer to the source image. This way multiple users can benefit from a single cache, thereby reducing wasted disk space. The resulting location is the source image's folder, in a sub folder with the name - .thumbnails - When the image source folder cannot be written, Geeqie falls back to saving the thumbnail in the user's home folder. - - - - - - - - Faster jpeg thumbnailing - - - This will speed up thumbnails generation in some cases, but may reduce the quality + Enable this to save thumbnails to disk. Subsequent requests for a thumbnail will be faster. + + + + Use Geeqie thumbnail style and cache + + + Thumbnails are stored in a folder hierachy that mirrors the location of the source images. Thumbnails have the same name as the original appended by the file extension .png. + + The root of the hierachy is: + + $XDG_CACHE_HOME/geeqie/thumbnails/ + or, if $XDG_CACHE_HOME is not defined: + $HOME/.cache/geeqie/thumbnails/ + + + + + + + + + Store thumbnails local to image folder (non-standard) + + + + When enabled, Geeqie attempts to store cached thumbnails closer to the source image. This way multiple users can benefit from a single cache, thereby reducing wasted disk space. + + Thumbnails have the same name as the original appended by the file extension .png. + + The resulting location is the source image's folder, in a sub folder with the name + .thumbnails + + When the image source folder cannot be written, Geeqie falls back to saving the thumbnail in the user's home folder. + + + + + + + + Use standard thumbnail style and cache, shared with other applications + + + + This will use a thumbnail caching method that is compatible with applications that use the standard thumbnail specification. When this option is enabled thumbnails will be stored in: + + $XDG_CACHE_HOME/thumbnails/ + or, if $XDG_CACHE_HOME is not defined: + $HOME/.cache/thumbnails/ + + + All thumbnails are stored in the same folder, with computer-generated filenames. Refer to + Thumbnails Reference + for additional details. + + + + + @@ -124,18 +139,6 @@ - - - - Use xvpics thumbnails when found - - - Refer to - - . - - -
Slide show diff -r 52fa0e775bb5 -r 034d8772d6d8 doc/docbook/GuideReference.xml --- a/doc/docbook/GuideReference.xml Mon Jul 24 11:08:35 2017 +0100 +++ b/doc/docbook/GuideReference.xml Mon Jul 31 14:36:29 2017 +0100 @@ -8,9 +8,9 @@ - + diff -r 52fa0e775bb5 -r 034d8772d6d8 doc/docbook/GuideReferenceManagement.xml --- a/doc/docbook/GuideReferenceManagement.xml Mon Jul 24 11:08:35 2017 +0100 +++ b/doc/docbook/GuideReferenceManagement.xml Mon Jul 31 14:36:29 2017 +0100 @@ -34,10 +34,7 @@ Clear cache - - Removes all thumbnails and data stored in the user's home folder: - $HOME/.cache/.geeqie/thumbnails - + Removes all thumbnails and data stored in the designated folder. @@ -59,10 +56,7 @@ Clear cache - - Removes all thumbnails stored in the user's home folder: - $HOME/.thumbnails - + Removes all thumbnails stored in the designated folder. diff -r 52fa0e775bb5 -r 034d8772d6d8 doc/docbook/GuideReferenceStandards.xml --- a/doc/docbook/GuideReferenceStandards.xml Mon Jul 24 11:08:35 2017 +0100 +++ b/doc/docbook/GuideReferenceStandards.xml Mon Jul 31 14:36:29 2017 +0100 @@ -21,4 +21,8 @@ Pango mark up: + + Thumbnails: + +
diff -r 52fa0e775bb5 -r 034d8772d6d8 doc/docbook/GuideReferenceThumbnails.xml --- a/doc/docbook/GuideReferenceThumbnails.xml Mon Jul 24 11:08:35 2017 +0100 +++ b/doc/docbook/GuideReferenceThumbnails.xml Mon Jul 31 14:36:29 2017 +0100 @@ -2,7 +2,11 @@
Thumbnails - This page only refers the Geeqie thumbnail caching mechanism, the shared thumbnail cache mechanism is not explained here. + + This page only refers the Geeqie thumbnail caching mechanism, the shared thumbnail cache mechanism is described in + Thumbnail Standards + . +
diff -r 52fa0e775bb5 -r 034d8772d6d8 src/cache.c --- a/src/cache.c Mon Jul 24 11:08:35 2017 +0100 +++ b/src/cache.c Mon Jul 31 14:36:29 2017 +0100 @@ -24,6 +24,7 @@ #include "md5-util.h" #include "secure_save.h" +#include "thumb_standard.h" #include "ui_fileops.h" #include @@ -722,7 +723,8 @@ if (USE_XDG) { - thumbnails_cache_dir = g_build_filename(xdg_cache_home_get(), GQ_APPNAME_LC, GQ_CACHE_THUMB, NULL); + thumbnails_cache_dir = g_build_filename(xdg_cache_home_get(), + GQ_APPNAME_LC, GQ_CACHE_THUMB, NULL); } else { @@ -732,6 +734,18 @@ return thumbnails_cache_dir; } +const gchar *get_thumbnails_standard_cache_dir(void) +{ + static gchar *thumbnails_standard_cache_dir = NULL; + + if (thumbnails_standard_cache_dir) return thumbnails_standard_cache_dir; + + thumbnails_standard_cache_dir = g_build_filename(xdg_cache_home_get(), + THUMB_FOLDER_GLOBAL, NULL); + + return thumbnails_standard_cache_dir; +} + const gchar *get_metadata_cache_dir(void) { static gchar *metadata_cache_dir = NULL; diff -r 52fa0e775bb5 -r 034d8772d6d8 src/cache.h --- a/src/cache.h Mon Jul 24 11:08:35 2017 +0100 +++ b/src/cache.h Mon Jul 31 14:36:29 2017 +0100 @@ -80,6 +80,7 @@ gchar *cache_find_location(CacheType type, const gchar *source); const gchar *get_thumbnails_cache_dir(void); +const gchar *get_thumbnails_standard_cache_dir(void); const gchar *get_metadata_cache_dir(void); #endif diff -r 52fa0e775bb5 -r 034d8772d6d8 src/cache_maint.c --- a/src/cache_maint.c Mon Jul 24 11:08:35 2017 +0100 +++ b/src/cache_maint.c Mon Jul 31 14:36:29 2017 +0100 @@ -992,21 +992,21 @@ gtk_progress_bar_set_text(GTK_PROGRESS_BAR(cd->progress), _("running...")); } - path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, THUMB_FOLDER_NORMAL, NULL); + path = g_build_filename(get_thumbnails_standard_cache_dir(), THUMB_FOLDER_NORMAL, NULL); dir_fd = file_data_new_dir(path); filelist_read(dir_fd, &list, NULL); cd->list = list; file_data_unref(dir_fd); g_free(path); - path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, THUMB_FOLDER_LARGE, NULL); + path = g_build_filename(get_thumbnails_standard_cache_dir(), THUMB_FOLDER_LARGE, NULL); dir_fd = file_data_new_dir(path); filelist_read(dir_fd, &list, NULL); cd->list = g_list_concat(cd->list, list); file_data_unref(dir_fd); g_free(path); - path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, THUMB_FOLDER_FAIL, NULL); + path = g_build_filename(get_thumbnails_standard_cache_dir(), THUMB_FOLDER_FAIL, NULL); dir_fd = file_data_new_dir(path); filelist_read(dir_fd, &list, NULL); cd->list = g_list_concat(cd->list, list); @@ -1218,7 +1218,7 @@ sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); - group = pref_group_new(gd->vbox, FALSE, _("Thumbnail cache"), GTK_ORIENTATION_VERTICAL); + group = pref_group_new(gd->vbox, FALSE, _("Geeqie thumbnail cache"), GTK_ORIENTATION_VERTICAL); cache_manager_location_label(group, get_thumbnails_cache_dir()); @@ -1237,7 +1237,7 @@ group = pref_group_new(gd->vbox, FALSE, _("Shared thumbnail cache"), GTK_ORIENTATION_VERTICAL); - path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, NULL); + path = g_build_filename(get_thumbnails_standard_cache_dir(), NULL); cache_manager_location_label(group, path); g_free(path); diff -r 52fa0e775bb5 -r 034d8772d6d8 src/preferences.c --- a/src/preferences.c Mon Jul 24 11:08:35 2017 +0100 +++ b/src/preferences.c Mon Jul 31 14:36:29 2017 +0100 @@ -1412,12 +1412,54 @@ return vbox; } +static void cache_standard_cb(GtkWidget *widget, gpointer data) +{ + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) + { + c_options->thumbnails.spec_standard =TRUE; + c_options->thumbnails.cache_into_dirs = FALSE; + } + else + { + c_options->thumbnails.spec_standard =FALSE; + } + DEBUG_0("standard %d",c_options->thumbnails.spec_standard); +} + +static void cache_geeqie_cb(GtkWidget *widget, gpointer data) +{ + if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) + { + c_options->thumbnails.spec_standard =TRUE; + c_options->thumbnails.cache_into_dirs = FALSE; + } + else + { + c_options->thumbnails.spec_standard =FALSE; + } + DEBUG_0("geeqie %d",c_options->thumbnails.spec_standard); +} + +static void cache_local_cb(GtkWidget *widget, gpointer data) +{ + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) + { + c_options->thumbnails.cache_into_dirs = TRUE; + c_options->thumbnails.spec_standard =FALSE; + } + else + { + c_options->thumbnails.cache_into_dirs = FALSE; + } +} + /* general options tab */ static void config_tab_general(GtkWidget *notebook) { GtkWidget *vbox; GtkWidget *hbox; GtkWidget *group; + GtkWidget *group_frame; GtkWidget *subgroup; GtkWidget *button; GtkWidget *ct_button; @@ -1438,14 +1480,25 @@ subgroup = pref_box_new(group, FALSE, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP); pref_checkbox_link_sensitivity(ct_button, subgroup); - button = pref_checkbox_new_int(subgroup, _("Use standard thumbnail cache, shared with other applications"), - options->thumbnails.spec_standard, &c_options->thumbnails.spec_standard); - - subgroup = pref_box_new(subgroup, FALSE, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP); - pref_checkbox_link_sensitivity_swap(button, subgroup); - - pref_checkbox_new_int(subgroup, _("Store thumbnails in '.thumbnails' folder, local to image folder (non-standard)"), - options->thumbnails.cache_into_dirs, &c_options->thumbnails.cache_into_dirs); + group_frame = pref_frame_new(subgroup, TRUE, _("Use Geeqie thumbnail style and cache"), + GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP); + button = pref_radiobutton_new(group_frame, NULL, get_thumbnails_cache_dir(), + !options->thumbnails.spec_standard, + G_CALLBACK(cache_geeqie_cb), NULL); + + group_frame = pref_frame_new(subgroup, TRUE, + _("Store thumbnails local to image folder (non-standard)"), + GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP); + pref_radiobutton_new(group_frame, button, "*/.thumbnails", + options->thumbnails.cache_into_dirs, + G_CALLBACK(cache_local_cb), NULL); + + group_frame = pref_frame_new(subgroup, TRUE, + _("Use standard thumbnail style and cache, shared with other applications"), + GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP); + pref_radiobutton_new(group_frame, button, get_thumbnails_standard_cache_dir(), + options->thumbnails.spec_standard, + G_CALLBACK(cache_standard_cb), NULL); pref_checkbox_new_int(group, _("Use EXIF thumbnails when available (EXIF thumbnails may be outdated)"), options->thumbnails.use_exif, &c_options->thumbnails.use_exif); diff -r 52fa0e775bb5 -r 034d8772d6d8 src/thumb_standard.c --- a/src/thumb_standard.c Mon Jul 24 11:08:35 2017 +0100 +++ b/src/thumb_standard.c Mon Jul 31 14:36:29 2017 +0100 @@ -22,6 +22,7 @@ #include "main.h" #include "thumb_standard.h" +#include "cache.h" #include "image-load.h" #include "md5-util.h" #include "pixbuf_util.h" @@ -156,7 +157,8 @@ } else { - result = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, cache_subfolder, name, NULL); + result = g_build_filename(get_thumbnails_standard_cache_dir(), + cache_subfolder, name, NULL); } g_free(name); @@ -675,7 +677,11 @@ tl->source_size = st.st_size; tl->source_mode = st.st_mode; - if (!thumb_cache) thumb_cache = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, NULL); + if (!thumb_cache) + { + thumb_cache = g_strdup(get_thumbnails_standard_cache_dir()); + } + if (strncmp(tl->fd->path, thumb_cache, strlen(thumb_cache)) != 0) { gchar *pathl; diff -r 52fa0e775bb5 -r 034d8772d6d8 src/thumb_standard.h --- a/src/thumb_standard.h Mon Jul 24 11:08:35 2017 +0100 +++ b/src/thumb_standard.h Mon Jul 31 14:36:29 2017 +0100 @@ -24,7 +24,7 @@ #if GLIB_CHECK_VERSION (2, 34, 0) -#define THUMB_FOLDER_GLOBAL ".cache/thumbnails" +#define THUMB_FOLDER_GLOBAL "thumbnails" #else #define THUMB_FOLDER_GLOBAL ".thumbnails" #endif