#define MAX(a,b) (((a)>(b))?(a):(b))
#endif
-#define HOME_DIR g_get_home_dir()
+static gchar* thumb_dir = NULL;
#ifdef WINDOWS
-#define THUMB_DIR "\\THUMBNAILS\\" /* viking maps default viking\maps */
-#define THUMB_SUB_DIR "normal\\"
+static void set_thumb_dir ()
+{
+ thumb_dir = g_strconcat ( g_get_home_dir(), "\\THUMBNAILS\\normal\\", NULL ) ;
+}
#else
-#define THUMB_DIR "/.thumbnails/"
-#define THUMB_SUB_DIR "normal/"
+static void set_thumb_dir ()
+{
+ const gchar *xdg_cache_home = g_getenv("XDG_CACHE_HOME");
+ if ( xdg_cache_home && g_strcmp0 (xdg_cache_home, "") != 0 )
+ thumb_dir = g_strconcat ( xdg_cache_home, "/thumbnails/normal/", NULL );
+ else
+ thumb_dir = g_strconcat ( g_get_home_dir(), "/.cache/thumbnails/normal/", NULL );
+}
#endif
#define PIXMAP_THUMB_SIZE 128
md5 = md5_hash(uri);
g_free(path);
- to = g_string_new(HOME_DIR);
- g_string_append(to, THUMB_DIR);
- g_string_append(to, THUMB_SUB_DIR);
+ to = g_string_new ( thumb_dir );
if ( g_mkdir_with_parents(to->str, 0700) != 0 )
g_warning ("%s: Failed to mkdir %s", __FUNCTION__, to->str );
g_string_append(to, md5);
md5 = md5_hash(uri);
g_free(uri);
- thumb_path = g_strdup_printf("%s%s%s%s.png", HOME_DIR, THUMB_DIR, THUMB_SUB_DIR, md5);
+ thumb_path = g_strdup_printf("%s%s.png", thumb_dir, md5);
g_free(md5);
g_free(thumb_path);
return thumb;
}
+
+/*
+ * Startup and finish routines
+ */
+
+void a_thumbnails_init ()
+{
+ set_thumb_dir ();
+}
+
+void a_thumbnails_uninit ()
+{
+ g_free ( thumb_dir );
+}