Fix #500: Geeqie doesn’t use shared thumbnail folder
authorColin Clark <colin.clark@cclark.uk>
Mon, 31 Jul 2017 13:36:29 +0000 (14:36 +0100)
committerColin Clark <colin.clark@cclark.uk>
Mon, 31 Jul 2017 13:36:29 +0000 (14:36 +0100)
https://github.com/BestImageViewer/geeqie/issues/500

doc/docbook/GuideOptionsGeneral.xml
doc/docbook/GuideReference.xml
doc/docbook/GuideReferenceManagement.xml
doc/docbook/GuideReferenceStandards.xml
doc/docbook/GuideReferenceThumbnails.xml
src/cache.c
src/cache.h
src/cache_maint.c
src/preferences.c
src/thumb_standard.c
src/thumb_standard.h

index a24dc44..4d492b3 100644 (file)
           <guilabel>Cache thumbnails</guilabel>\r
         </term>\r
         <listitem>\r
-          <para>\r
-            Enable this to save thumbnails to disk, subsequent requests for a thumbnail will be faster. Thumbnails are cached into:\r
-            <programlisting>$XDG_CACHE_HOME/geeqie/thumbnails/</programlisting>\r
-            <programlisting>($~/.cache/geeqie/thumbnails/)</programlisting>\r
-            Refer to\r
-            <link linkend="GuideReferenceThumbnails">Thumbnails Reference</link>\r
-            for additional details.\r
-          </para>\r
-        </listitem>\r
-      </varlistentry>\r
-    </variablelist>\r
-    <variablelist>\r
-      <varlistentry>\r
-        <term>\r
-          <guilabel>Use shared thumbnail cache</guilabel>\r
-        </term>\r
-        <listitem>\r
-          <para>\r
-            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\r
-            <programlisting>$HOME/.thumbnails</programlisting>\r
-          </para>\r
-        </listitem>\r
-      </varlistentry>\r
-    </variablelist>\r
-    <variablelist>\r
-      <varlistentry>\r
-        <term>\r
-          <guilabel>Cache thumbnails into .thumbnails</guilabel>\r
-        </term>\r
-        <listitem>\r
-          <para>\r
-            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\r
-            <programlisting>.thumbnails</programlisting>\r
-            When the image source folder cannot be written, Geeqie falls back to saving the thumbnail in the user's home folder.\r
-          </para>\r
-        </listitem>\r
-      </varlistentry>\r
-    </variablelist>\r
-    <variablelist>\r
-      <varlistentry>\r
-        <term>\r
-          <guilabel>Faster jpeg thumbnailing</guilabel>\r
-        </term>\r
-        <listitem>\r
-          <para>This will speed up thumbnails generation in some cases, but may reduce the quality</para>\r
+          <para>Enable this to save thumbnails to disk. Subsequent requests for a thumbnail will be faster.</para>\r
+          <variablelist>\r
+            <varlistentry>\r
+              <term>\r
+                <guilabel>Use Geeqie thumbnail style and cache</guilabel>\r
+              </term>\r
+              <listitem>\r
+                <para>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.</para>\r
+                <para>\r
+                  The root of the hierachy is:\r
+                  <para>\r
+                    <programlisting>$XDG_CACHE_HOME/geeqie/thumbnails/</programlisting>\r
+                    or, if $XDG_CACHE_HOME is not defined:\r
+                    <programlisting>$HOME/.cache/geeqie/thumbnails/</programlisting>\r
+                  </para>\r
+                </para>\r
+              </listitem>\r
+            </varlistentry>\r
+          </variablelist>\r
+          <variablelist>\r
+            <varlistentry>\r
+              <term>\r
+                <guilabel>Store thumbnails local to image folder (non-standard)</guilabel>\r
+              </term>\r
+              <listitem>\r
+                <para>\r
+                  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.\r
+                  <para />\r
+                  Thumbnails have the same name as the original appended by the file extension .png.\r
+                  <para />\r
+                  The resulting location is the source image's folder, in a sub folder with the name\r
+                  <programlisting>.thumbnails</programlisting>\r
+                  <para />\r
+                  When the image source folder cannot be written, Geeqie falls back to saving the thumbnail in the user's home folder.\r
+                </para>\r
+              </listitem>\r
+            </varlistentry>\r
+          </variablelist>\r
+          <variablelist>\r
+            <varlistentry>\r
+              <term>\r
+                <guilabel>Use standard thumbnail style and cache, shared with other applications</guilabel>\r
+              </term>\r
+              <listitem>\r
+                <para>\r
+                  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:\r
+                  <para>\r
+                    <programlisting>$XDG_CACHE_HOME/thumbnails/</programlisting>\r
+                    or, if $XDG_CACHE_HOME is not defined:\r
+                    <programlisting>$HOME/.cache/thumbnails/</programlisting>\r
+                  </para>\r
+                  <para>\r
+                    All thumbnails are stored in the same folder, with computer-generated filenames. Refer to\r
+                    <link linkend="GuideReferenceThumbnails">Thumbnails Reference</link>\r
+                    for additional details.\r
+                  </para>\r
+                </para>\r
+              </listitem>\r
+            </varlistentry>\r
+          </variablelist>\r
         </listitem>\r
       </varlistentry>\r
     </variablelist>\r
         </listitem>\r
       </varlistentry>\r
     </variablelist>\r
-    <variablelist>\r
-      <varlistentry>\r
-        <term>\r
-          <guilabel>Use xvpics thumbnails when found</guilabel>\r
-        </term>\r
-        <listitem>\r
-          Refer to\r
-          <link linkend="GuideOptionsHidden" endterm="titleGuideOptionsHidden" />\r
-          .\r
-        </listitem>\r
-      </varlistentry>\r
-    </variablelist>\r
   </section>\r
   <section id="Slideshow">\r
     <title>Slide show</title>\r
index 1ef6fbf..357933c 100644 (file)
@@ -8,9 +8,9 @@
   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="GuideReferenceLua.xml" />\r
   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="GuideReferenceConfig.xml" />\r
   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="GuideReferenceLIRC.xml" />\r
-  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="GuideReferenceStandards.xml" />\r
   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="GuideReferenceTags.xml" />\r
   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="GuideReferenceSupportedFormats.xml" />\r
   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="GuideReferenceDecodeLatLong.xml" />\r
+  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="GuideReferenceStandards.xml" />\r
   <para />\r
 </chapter>\r
index 9587b3e..95b45de 100644 (file)
           <guilabel>Clear cache</guilabel>\r
         </term>\r
         <listitem>\r
-          <para>\r
-            Removes all thumbnails and data stored in the user's home folder:\r
-            <programlisting>$HOME/.cache/.geeqie/thumbnails</programlisting>\r
-          </para>\r
+          <para>Removes all thumbnails and data stored in the designated folder.</para>\r
         </listitem>\r
       </varlistentry>\r
     </variablelist>\r
           <guilabel>Clear cache</guilabel>\r
         </term>\r
         <listitem>\r
-          <para>\r
-            Removes all thumbnails stored in the user's home folder:\r
-            <programlisting>$HOME/.thumbnails</programlisting>\r
-          </para>\r
+          <para>Removes all thumbnails stored in the designated folder.</para>\r
         </listitem>\r
       </varlistentry>\r
     </variablelist>\r
index 356f74d..bb43b57 100644 (file)
@@ -21,4 +21,8 @@
     Pango mark up:\r
     <ulink url="https://developer.gnome.org/pango/stable/PangoMarkupFormat.html" />\r
   </para>\r
+  <para>\r
+    Thumbnails:\r
+    <ulink url="https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html" />\r
+  </para>\r
 </section>\r
index 7654b4e..c7cfe2e 100644 (file)
@@ -2,7 +2,11 @@
 <section id="GuideReferenceThumbnails">\r
   <title>Thumbnails</title>\r
   <note>\r
-    <para>This page only refers the Geeqie thumbnail caching mechanism, the shared thumbnail cache mechanism is not explained here.</para>\r
+    <para>\r
+      This page only refers the Geeqie thumbnail caching mechanism, the shared thumbnail cache mechanism is described in\r
+      <link linkend="GuideReferenceStandards">Thumbnail Standards</link>\r
+      .\r
+    </para>\r
   </note>\r
   <para />\r
   <section id="Format">\r
index 892f386..9dbc84b 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "md5-util.h"
 #include "secure_save.h"
+#include "thumb_standard.h"
 #include "ui_fileops.h"
 
 #include <utime.h>
@@ -722,7 +723,8 @@ const gchar *get_thumbnails_cache_dir(void)
 
        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 @@ const gchar *get_thumbnails_cache_dir(void)
        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;
index 83c094a..005733d 100644 (file)
@@ -80,6 +80,7 @@ gchar *cache_get_location(CacheType type, const gchar *source, gint include_name
 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
index ed92b54..e0df45f 100644 (file)
@@ -992,21 +992,21 @@ static void cache_manager_standard_clean_start(GenericDialog *gd, gpointer data)
                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 @@ void cache_manager_show(void)
 
        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 @@ void cache_manager_show(void)
 
        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);
 
index 8cbc01c..e7aff94 100644 (file)
@@ -1412,12 +1412,54 @@ static GtkWidget *scrolled_notebook_page(GtkWidget *notebook, const gchar *title
        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 @@ static void config_tab_general(GtkWidget *notebook)
        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);
index ce93047..35c3f0a 100644 (file)
@@ -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 @@ static gchar *thumb_std_cache_path(const gchar *path, const gchar *uri, gboolean
                }
        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 @@ gboolean thumb_loader_std_start(ThumbLoaderStd *tl, FileData *fd)
        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;
index 2b5c934..8544253 100644 (file)
@@ -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