Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-04-07 02:42:08 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-04-07 02:43:46 +0400
commitbe8b4b8b0c4d4fdeed6ebf88d8a3bd480e4c48ce (patch)
treed420ed5dd1d189f99233b93674cb467c2d1e482a /source/blender/imbuf/intern/thumbs.c
parent1194037327781edf476ebaa9313062ff8c399824 (diff)
Todo T36849: support XDG thumbnail management standard
Diffstat (limited to 'source/blender/imbuf/intern/thumbs.c')
-rw-r--r--source/blender/imbuf/intern/thumbs.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c
index 843134a4289..ff1c39997a5 100644
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@ -66,9 +66,22 @@
# include "utfconv.h"
#endif
+#if defined(WIN32) || defined(__APPLE__)
+ /* pass */
+#else
+# define USE_FREEDESKTOP
+#endif
+
+/* '$HOME/.cache/thumbnails' or '$HOME/.thumbnails' */
+#ifdef USE_FREEDESKTOP
+# define THUMBNAILS "thumbnails"
+#else
+# define THUMBNAILS ".thumbnails"
+#endif
+
#define URI_MAX (FILE_MAX * 3 + 8)
-static int get_thumb_dir(char *dir, ThumbSize size)
+static bool get_thumb_dir(char *dir, ThumbSize size)
{
char *s = dir;
const char *subdir;
@@ -78,20 +91,30 @@ static int get_thumb_dir(char *dir, ThumbSize size)
SHGetSpecialFolderPathW(0, dir_16, CSIDL_PROFILE, 0);
conv_utf_16_to_8(dir_16, dir, FILE_MAX);
s += strlen(dir);
+#elif defined(USE_FREEDESKTOP)
+ const char *home_cache = getenv("XDG_CACHE_HOME");
+ const char *home = home_cache ? home_cache : getenv("HOME");
#else
const char *home = getenv("HOME");
+#endif
if (!home) return 0;
s += BLI_strncpy_rlen(s, home, FILE_MAX);
+
+#ifdef USE_FREEDESKTOP
+ if (!home_cache) {
+ s += BLI_strncpy_rlen(s, "/.cache", FILE_MAX - (s - dir));
+ }
#endif
+
switch (size) {
case THB_NORMAL:
- subdir = "/.thumbnails/normal/";
+ subdir = "/" THUMBNAILS "/normal/";
break;
case THB_LARGE:
- subdir = "/.thumbnails/large/";
+ subdir = "/" THUMBNAILS "/large/";
break;
case THB_FAIL:
- subdir = "/.thumbnails/fail/blender/";
+ subdir = "/" THUMBNAILS "/fail/blender/";
break;
default:
return 0; /* unknown size */
@@ -103,6 +126,9 @@ static int get_thumb_dir(char *dir, ThumbSize size)
return 1;
}
+#undef THUMBNAILS
+
+
/** ----- begin of adapted code from glib ---
* The following code is adapted from function g_escape_uri_string from the gnome glib
* Source: http://svn.gnome.org/viewcvs/glib/trunk/glib/gconvert.c?view=markup