[gimp] libgimpthumb: new function gimp_thumb_get_thumb_base_dir()
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpthumb: new function gimp_thumb_get_thumb_base_dir()
- Date: Thu, 5 Dec 2013 08:29:45 +0000 (UTC)
commit 6c4d8c45b7f8903bdf2c30085f09625e77d45931
Author: Jehan <jehan girinstud io>
Date: Wed Dec 4 23:08:09 2013 +1300
libgimpthumb: new function gimp_thumb_get_thumb_base_dir()
Also use this new function in the gimp-thumbnail-list tool, which must
always use the same thumbnail folder as GIMP core.
libgimpthumb/gimp-thumbnail-list.c | 11 +++++------
libgimpthumb/gimpthumb-utils.c | 20 ++++++++++++++++++++
libgimpthumb/gimpthumb-utils.h | 2 ++
libgimpthumb/gimpthumb.def | 1 +
4 files changed, 28 insertions(+), 6 deletions(-)
---
diff --git a/libgimpthumb/gimp-thumbnail-list.c b/libgimpthumb/gimp-thumbnail-list.c
index d846179..c8dad3f 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 bd75471..8359643 100644
--- a/libgimpthumb/gimpthumb-utils.c
+++ b/libgimpthumb/gimpthumb-utils.c
@@ -187,6 +187,26 @@ gimp_thumb_init (const gchar *creator,
}
/**
+ * 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 300ef9e..ff89dcc 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 4ac56bf..db8c44d 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]