diff --git a/libgimpthumb/gimp-thumbnail-list.c b/libgimpthumb/gimp-thumbnail-list.c index d846179bce..c8dad3f91c 100644 --- a/libgimpthumb/gimp-thumbnail-list.c +++ b/libgimpthumb/gimp-thumbnail-list.c @@ -58,11 +58,14 @@ main (gint argc, { GOptionContext *context; GDir *dir; - const gchar *home; gchar *thumb_folder; const gchar *folder; GError *error = NULL; + gimp_thumb_init ("gimp-thumbnail-list", NULL); + + thumb_folder = gimp_thumb_get_thumb_base_dir (); + context = g_option_context_new (NULL); g_option_context_add_main_entries (context, main_entries, NULL); @@ -72,13 +75,10 @@ main (gint argc, return -1; } - home = g_get_home_dir (); - - thumb_folder = g_build_filename (home, ".thumbnails", NULL); dir = g_dir_open (thumb_folder, 0, &error); if (! dir) - g_error ("Error opening ~/.thumbnails: %s", error->message); + g_error ("Error opening %s: %s", thumb_folder, error->message); while ((folder = g_dir_read_name (dir))) { @@ -93,7 +93,6 @@ main (gint argc, } g_dir_close (dir); - g_free (thumb_folder); return 0; } diff --git a/libgimpthumb/gimpthumb-utils.c b/libgimpthumb/gimpthumb-utils.c index bd754715a1..8359643391 100644 --- a/libgimpthumb/gimpthumb-utils.c +++ b/libgimpthumb/gimpthumb-utils.c @@ -186,6 +186,26 @@ gimp_thumb_init (const gchar *creator, return gimp_thumb_initialized; } +/** + * gimp_thumb_get_thumb_base_dir: + * + * Returns the base directory of thumbnails cache. + * It uses the Freedesktop Thumbnail Managing Standard on UNIX, + * "~/Library/Caches/org.freedesktop.thumbnails" on OSX, and a cache + * folder determined by glib on Windows (currently the common repository + * for temporary Internet files). + * The returned string belongs to GIMP and must not be changed nor freed. + * + * Returns: the thumbnails cache directory. + **/ +const gchar * +gimp_thumb_get_thumb_base_dir (void) +{ + g_return_val_if_fail (gimp_thumb_initialized, NULL); + + return thumb_dir; +} + /** * gimp_thumb_get_thumb_dir: * @size: a GimpThumbSize diff --git a/libgimpthumb/gimpthumb-utils.h b/libgimpthumb/gimpthumb-utils.h index 300ef9e020..ff89dcc036 100644 --- a/libgimpthumb/gimpthumb-utils.h +++ b/libgimpthumb/gimpthumb-utils.h @@ -35,6 +35,8 @@ G_BEGIN_DECLS gboolean gimp_thumb_init (const gchar *creator, const gchar *thumb_basedir); +const gchar * gimp_thumb_get_thumb_base_dir (void); + gchar * gimp_thumb_find_thumb (const gchar *uri, GimpThumbSize *size) G_GNUC_MALLOC; diff --git a/libgimpthumb/gimpthumb.def b/libgimpthumb/gimpthumb.def index 4ac56bfb8b..db8c44d932 100644 --- a/libgimpthumb/gimpthumb.def +++ b/libgimpthumb/gimpthumb.def @@ -5,6 +5,7 @@ EXPORTS gimp_thumb_file_test gimp_thumb_file_type_get_type gimp_thumb_find_thumb + gimp_thumb_get_thumb_base_dir gimp_thumb_get_thumb_dir gimp_thumb_get_thumb_dir_local gimp_thumb_init