diff --git a/ChangeLog b/ChangeLog index 7579a999b2..8e301acf0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-10-11 Sven Neumann + + * libgimpthumb/gimpthumb-utils.[ch] + * libgimpthumb/gimpthumb.def: added an API to delete thumbnails. + + * app/widgets/gimpthumbbox.c (gimp_thumb_box_create_thumbnail): + when recreating a thumbnail on user request, delete all existing + thumbnails for it. + + * plug-ins/common/AlienMap2.c: removed unused variable. + 2004-10-10 Sven Neumann * libgimpthumb/gimpthumb-utils.[ch] diff --git a/app/widgets/gimpthumbbox.c b/app/widgets/gimpthumbbox.c index 1753a7c837..1b9ef1c7c1 100644 --- a/app/widgets/gimpthumbbox.c +++ b/app/widgets/gimpthumbbox.c @@ -666,6 +666,9 @@ gimp_thumb_box_create_thumbnail (GimpThumbBox *box, gtk_label_set_text (GTK_LABEL (box->filename), basename); g_free (basename); + if (force) + gimp_thumbs_delete_for_uri (uri); + gimp_object_set_name (GIMP_OBJECT (box->imagefile), uri); if (force || diff --git a/devel-docs/libgimpthumb/libgimpthumb-sections.txt b/devel-docs/libgimpthumb/libgimpthumb-sections.txt index 0bacf8ab03..04084ff271 100644 --- a/devel-docs/libgimpthumb/libgimpthumb-sections.txt +++ b/devel-docs/libgimpthumb/libgimpthumb-sections.txt @@ -26,14 +26,16 @@ GIMP_THUMBNAIL_GET_CLASS
gimpthumb-utils gimp_thumb_init -gimp_thumb_name_from_uri gimp_thumb_find_thumb gimp_thumb_file_test +gimp_thumb_name_from_uri gimp_thumb_ensure_thumb_dir gimp_thumb_get_thumb_dir +gimp_thumbs_delete_for_uri gimp_thumb_name_from_uri_local gimp_thumb_ensure_thumb_dir_local gimp_thumb_get_thumb_dir_local +gimp_thumbs_delete_for_uri_local
diff --git a/devel-docs/libgimpthumb/tmpl/gimpthumb-utils.sgml b/devel-docs/libgimpthumb/tmpl/gimpthumb-utils.sgml index a038aa3dd0..9634407c59 100644 --- a/devel-docs/libgimpthumb/tmpl/gimpthumb-utils.sgml +++ b/devel-docs/libgimpthumb/tmpl/gimpthumb-utils.sgml @@ -24,16 +24,6 @@ Utility functions provided and used by libgimpthumb @Returns: - - - - - -@uri: -@size: -@Returns: - - @@ -56,6 +46,16 @@ Utility functions provided and used by libgimpthumb @Returns: + + + + + +@uri: +@size: +@Returns: + + @@ -75,6 +75,14 @@ Utility functions provided and used by libgimpthumb @Returns: + + + + + +@uri: + + @@ -106,3 +114,11 @@ Utility functions provided and used by libgimpthumb @Returns: + + + + + +@uri: + + diff --git a/libgimpthumb/gimpthumb-utils.c b/libgimpthumb/gimpthumb-utils.c index 3e168918d9..74096977ac 100644 --- a/libgimpthumb/gimpthumb-utils.c +++ b/libgimpthumb/gimpthumb-utils.c @@ -301,14 +301,14 @@ gimp_thumb_ensure_thumb_dir_local (const gchar *dirname, /** * gimp_thumb_name_from_uri: - * @uri: an escaped URI in UTF-8 encoding + * @uri: an escaped URI * @size: a #GimpThumbSize * * Creates the name of the thumbnail file of the specified @size that * belongs to an image file located at the given @uri. * * Return value: a newly allocated filename in the encoding of the - * filesystem or %NULL if @uri points to the global + * filesystem or %NULL if @uri points to the user's * thumbnail repository. **/ gchar * @@ -330,7 +330,7 @@ gimp_thumb_name_from_uri (const gchar *uri, /** * gimp_thumb_name_from_uri_local: - * @uri: an escaped URI in UTF-8 encoding + * @uri: an escaped URI * @size: a #GimpThumbSize * * Creates the name of a local thumbnail file of the specified @size @@ -339,7 +339,7 @@ gimp_thumb_name_from_uri (const gchar *uri, * * Return value: a newly allocated filename in the encoding of the * filesystem or %NULL if @uri is a remote file or - * points to the global thumbnail repository. + * points to the user's thumbnail repository. * * Since: GIMP 2.2 **/ @@ -384,7 +384,7 @@ gimp_thumb_name_from_uri_local (const gchar *uri, /** * gimp_thumb_find_thumb: - * @uri: an escaped URI in UTF-8 encoding + * @uri: an escaped URI * @size: pointer to a #GimpThumbSize * * This function attempts to locate a thumbnail for the given @@ -392,7 +392,7 @@ gimp_thumb_name_from_uri_local (const gchar *uri, * thumbnail of that size is found, it will look for a larger * thumbnail, then falling back to a smaller size. * - * If the global thumbnail repository doesn't provide a thumbnail but + * If the user's thumbnail repository doesn't provide a thumbnail but * a local thumbnail repository exists for the folder the image is * located in, the same search is done among the local thumbnails. * @@ -489,6 +489,64 @@ gimp_thumb_file_test (const gchar *filename, return GIMP_THUMB_FILE_TYPE_NONE; } +/** + * gimp_thumbs_delete_for_uri: + * @uri: an escaped URI + * + * Deletes all thumbnails for the image file specified by @uri from the + * user's thumbnail repository. + * + * Since: GIMP 2.2 + **/ +void +gimp_thumbs_delete_for_uri (const gchar *uri) +{ + gint i; + + g_return_if_fail (gimp_thumb_initialized); + g_return_if_fail (uri != NULL); + + for (i = 0; i < thumb_num_sizes; i++) + { + gchar *filename = gimp_thumb_name_from_uri (uri, thumb_sizes[i]); + + if (filename) + { + unlink (filename); + g_free (filename); + } + } +} + +/** + * gimp_thumbs_delete_for_uri_local: + * @uri: an escaped URI + * + * Deletes all thumbnails for the image file specified by @uri from + * the local thumbnail repository. + * + * Since: GIMP 2.2 + **/ +void +gimp_thumbs_delete_for_uri_local (const gchar *uri) +{ + gint i; + + g_return_if_fail (gimp_thumb_initialized); + g_return_if_fail (uri != NULL); + + for (i = 0; i < thumb_num_sizes; i++) + { + gchar *filename = gimp_thumb_name_from_uri_local (uri, thumb_sizes[i]); + + if (filename) + { + unlink (filename); + g_free (filename); + } + } +} + static void gimp_thumb_exit (void) { diff --git a/libgimpthumb/gimpthumb-utils.h b/libgimpthumb/gimpthumb-utils.h index aabce366f2..867cb768df 100644 --- a/libgimpthumb/gimpthumb-utils.h +++ b/libgimpthumb/gimpthumb-utils.h @@ -32,20 +32,6 @@ G_BEGIN_DECLS gboolean gimp_thumb_init (const gchar *creator, const gchar *thumb_basedir); -const gchar * gimp_thumb_get_thumb_dir (GimpThumbSize size); -gboolean gimp_thumb_ensure_thumb_dir (GimpThumbSize size, - GError **error); -gchar * gimp_thumb_name_from_uri (const gchar *uri, - GimpThumbSize size); - -gchar * gimp_thumb_get_thumb_dir_local (const gchar *dirname, - GimpThumbSize size); -gboolean gimp_thumb_ensure_thumb_dir_local (const gchar *dirname, - GimpThumbSize size, - GError **error); -gchar * gimp_thumb_name_from_uri_local (const gchar *uri, - GimpThumbSize size); - gchar * gimp_thumb_find_thumb (const gchar *uri, GimpThumbSize *size); @@ -54,6 +40,23 @@ GimpThumbFileType gimp_thumb_file_test (const gchar *filename, gint64 *size, gint *err_no); +gchar * gimp_thumb_name_from_uri (const gchar *uri, + GimpThumbSize size); +const gchar * gimp_thumb_get_thumb_dir (GimpThumbSize size); +gboolean gimp_thumb_ensure_thumb_dir (GimpThumbSize size, + GError **error); +void gimp_thumbs_delete_for_uri (const gchar *uri); + +gchar * gimp_thumb_name_from_uri_local (const gchar *uri, + GimpThumbSize size); +gchar * gimp_thumb_get_thumb_dir_local (const gchar *dirname, + GimpThumbSize size); +gboolean gimp_thumb_ensure_thumb_dir_local (const gchar *dirname, + GimpThumbSize size, + GError **error); +void gimp_thumbs_delete_for_uri_local (const gchar *uri); + + G_END_DECLS diff --git a/libgimpthumb/gimpthumb.def b/libgimpthumb/gimpthumb.def index e5c89c674d..f6918c998e 100644 --- a/libgimpthumb/gimpthumb.def +++ b/libgimpthumb/gimpthumb.def @@ -22,3 +22,5 @@ EXPORTS gimp_thumbnail_set_filename gimp_thumbnail_set_from_thumb gimp_thumbnail_set_uri + gimp_thumbs_delete_for_uri + gimp_thumbs_delete_for_uri_local diff --git a/libgimpthumb/gimpthumbnail.c b/libgimpthumb/gimpthumbnail.c index 1744359585..6886a24e63 100644 --- a/libgimpthumb/gimpthumbnail.c +++ b/libgimpthumb/gimpthumbnail.c @@ -400,7 +400,7 @@ gimp_thumbnail_new (void) /** * gimp_thumbnail_set_uri: * @thumbnail: a #GimpThumbnail object - * @uri: an escaped URI in UTF-8 encoding + * @uri: an escaped URI * * Sets the location of the image file associated with the #thumbnail. * diff --git a/plug-ins/common/AlienMap2.c b/plug-ins/common/AlienMap2.c index 9621762333..52f2c14ba7 100644 --- a/plug-ins/common/AlienMap2.c +++ b/plug-ins/common/AlienMap2.c @@ -386,7 +386,6 @@ alienmap2_dialog (void) GtkWidget *dialog; GtkWidget *main_vbox; GtkWidget *top_table; - GtkWidget *align; GtkWidget *frame; GtkWidget *toggle; GtkWidget *hbox;