changeset 2566:034d8772d6d8

Fix #500: Geeqie doesn’t use shared thumbnail folder https://github.com/BestImageViewer/geeqie/issues/500
author Colin Clark <colin.clark@cclark.uk>
date Mon, 31 Jul 2017 14:36:29 +0100
parents 52fa0e775bb5
children 09386a249046
files 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
diffstat 11 files changed, 163 insertions(+), 84 deletions(-) [+]
line wrap: on
line diff
--- 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 @@
           <guilabel>Cache thumbnails</guilabel>
         </term>
         <listitem>
-          <para>
-            Enable this to save thumbnails to disk, subsequent requests for a thumbnail will be faster. Thumbnails are cached into:
-            <programlisting>$XDG_CACHE_HOME/geeqie/thumbnails/</programlisting>
-            <programlisting>($~/.cache/geeqie/thumbnails/)</programlisting>
-            Refer to
-            <link linkend="GuideReferenceThumbnails">Thumbnails Reference</link>
-            for additional details.
-          </para>
-        </listitem>
-      </varlistentry>
-    </variablelist>
-    <variablelist>
-      <varlistentry>
-        <term>
-          <guilabel>Use shared thumbnail cache</guilabel>
-        </term>
-        <listitem>
-          <para>
-            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
-            <programlisting>$HOME/.thumbnails</programlisting>
-          </para>
-        </listitem>
-      </varlistentry>
-    </variablelist>
-    <variablelist>
-      <varlistentry>
-        <term>
-          <guilabel>Cache thumbnails into .thumbnails</guilabel>
-        </term>
-        <listitem>
-          <para>
-            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
-            <programlisting>.thumbnails</programlisting>
-            When the image source folder cannot be written, Geeqie falls back to saving the thumbnail in the user's home folder.
-          </para>
-        </listitem>
-      </varlistentry>
-    </variablelist>
-    <variablelist>
-      <varlistentry>
-        <term>
-          <guilabel>Faster jpeg thumbnailing</guilabel>
-        </term>
-        <listitem>
-          <para>This will speed up thumbnails generation in some cases, but may reduce the quality</para>
+          <para>Enable this to save thumbnails to disk. Subsequent requests for a thumbnail will be faster.</para>
+          <variablelist>
+            <varlistentry>
+              <term>
+                <guilabel>Use Geeqie thumbnail style and cache</guilabel>
+              </term>
+              <listitem>
+                <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>
+                <para>
+                  The root of the hierachy is:
+                  <para>
+                    <programlisting>$XDG_CACHE_HOME/geeqie/thumbnails/</programlisting>
+                    or, if $XDG_CACHE_HOME is not defined:
+                    <programlisting>$HOME/.cache/geeqie/thumbnails/</programlisting>
+                  </para>
+                </para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+          <variablelist>
+            <varlistentry>
+              <term>
+                <guilabel>Store thumbnails local to image folder (non-standard)</guilabel>
+              </term>
+              <listitem>
+                <para>
+                  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.
+                  <para />
+                  Thumbnails have the same name as the original appended by the file extension .png.
+                  <para />
+                  The resulting location is the source image's folder, in a sub folder with the name
+                  <programlisting>.thumbnails</programlisting>
+                  <para />
+                  When the image source folder cannot be written, Geeqie falls back to saving the thumbnail in the user's home folder.
+                </para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
+          <variablelist>
+            <varlistentry>
+              <term>
+                <guilabel>Use standard thumbnail style and cache, shared with other applications</guilabel>
+              </term>
+              <listitem>
+                <para>
+                  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:
+                  <para>
+                    <programlisting>$XDG_CACHE_HOME/thumbnails/</programlisting>
+                    or, if $XDG_CACHE_HOME is not defined:
+                    <programlisting>$HOME/.cache/thumbnails/</programlisting>
+                  </para>
+                  <para>
+                    All thumbnails are stored in the same folder, with computer-generated filenames. Refer to
+                    <link linkend="GuideReferenceThumbnails">Thumbnails Reference</link>
+                    for additional details.
+                  </para>
+                </para>
+              </listitem>
+            </varlistentry>
+          </variablelist>
         </listitem>
       </varlistentry>
     </variablelist>
@@ -124,18 +139,6 @@
         </listitem>
       </varlistentry>
     </variablelist>
-    <variablelist>
-      <varlistentry>
-        <term>
-          <guilabel>Use xvpics thumbnails when found</guilabel>
-        </term>
-        <listitem>
-          Refer to
-          <link linkend="GuideOptionsHidden" endterm="titleGuideOptionsHidden" />
-          .
-        </listitem>
-      </varlistentry>
-    </variablelist>
   </section>
   <section id="Slideshow">
     <title>Slide show</title>
--- 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 @@
   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="GuideReferenceLua.xml" />
   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="GuideReferenceConfig.xml" />
   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="GuideReferenceLIRC.xml" />
-  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="GuideReferenceStandards.xml" />
   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="GuideReferenceTags.xml" />
   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="GuideReferenceSupportedFormats.xml" />
   <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="GuideReferenceDecodeLatLong.xml" />
+  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="GuideReferenceStandards.xml" />
   <para />
 </chapter>
--- 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 @@
           <guilabel>Clear cache</guilabel>
         </term>
         <listitem>
-          <para>
-            Removes all thumbnails and data stored in the user's home folder:
-            <programlisting>$HOME/.cache/.geeqie/thumbnails</programlisting>
-          </para>
+          <para>Removes all thumbnails and data stored in the designated folder.</para>
         </listitem>
       </varlistentry>
     </variablelist>
@@ -59,10 +56,7 @@
           <guilabel>Clear cache</guilabel>
         </term>
         <listitem>
-          <para>
-            Removes all thumbnails stored in the user's home folder:
-            <programlisting>$HOME/.thumbnails</programlisting>
-          </para>
+          <para>Removes all thumbnails stored in the designated folder.</para>
         </listitem>
       </varlistentry>
     </variablelist>
--- 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:
     <ulink url="https://developer.gnome.org/pango/stable/PangoMarkupFormat.html" />
   </para>
+  <para>
+    Thumbnails:
+    <ulink url="https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html" />
+  </para>
 </section>
--- 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 @@
 <section id="GuideReferenceThumbnails">
   <title>Thumbnails</title>
   <note>
-    <para>This page only refers the Geeqie thumbnail caching mechanism, the shared thumbnail cache mechanism is not explained here.</para>
+    <para>
+      This page only refers the Geeqie thumbnail caching mechanism, the shared thumbnail cache mechanism is described in
+      <link linkend="GuideReferenceStandards">Thumbnail Standards</link>
+      .
+    </para>
   </note>
   <para />
   <section id="Format">
--- 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 <utime.h>
@@ -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;
--- 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
--- 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);
 
--- 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);
--- 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;
--- 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