mirror of https://github.com/GNOME/gimp.git
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.
This commit is contained in:
parent
7ef45be890
commit
6c4d8c45b7
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue