libgimpthumb/gimpthumb-utils.[ch] added an API to delete thumbnails.

2004-10-11  Sven Neumann  <sven@gimp.org>

	* 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.
This commit is contained in:
Sven Neumann 2004-10-10 23:02:34 +00:00 committed by Sven Neumann
parent f57bbe3a96
commit 9203906065
9 changed files with 127 additions and 33 deletions

View File

@ -1,3 +1,14 @@
2004-10-11 Sven Neumann <sven@gimp.org>
* 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 <sven@gimp.org>
* libgimpthumb/gimpthumb-utils.[ch]

View File

@ -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 ||

View File

@ -26,14 +26,16 @@ GIMP_THUMBNAIL_GET_CLASS
<SECTION>
<FILE>gimpthumb-utils</FILE>
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
</SECTION>
<SECTION>

View File

@ -24,16 +24,6 @@ Utility functions provided and used by libgimpthumb
@Returns:
<!-- ##### FUNCTION gimp_thumb_name_from_uri ##### -->
<para>
</para>
@uri:
@size:
@Returns:
<!-- ##### FUNCTION gimp_thumb_find_thumb ##### -->
<para>
@ -56,6 +46,16 @@ Utility functions provided and used by libgimpthumb
@Returns:
<!-- ##### FUNCTION gimp_thumb_name_from_uri ##### -->
<para>
</para>
@uri:
@size:
@Returns:
<!-- ##### FUNCTION gimp_thumb_ensure_thumb_dir ##### -->
<para>
@ -75,6 +75,14 @@ Utility functions provided and used by libgimpthumb
@Returns:
<!-- ##### FUNCTION gimp_thumbs_delete_for_uri ##### -->
<para>
</para>
@uri:
<!-- ##### FUNCTION gimp_thumb_name_from_uri_local ##### -->
<para>
@ -106,3 +114,11 @@ Utility functions provided and used by libgimpthumb
@Returns:
<!-- ##### FUNCTION gimp_thumbs_delete_for_uri_local ##### -->
<para>
</para>
@uri:

View File

@ -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)
{

View File

@ -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

View File

@ -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

View File

@ -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.
*

View File

@ -386,7 +386,6 @@ alienmap2_dialog (void)
GtkWidget *dialog;
GtkWidget *main_vbox;
GtkWidget *top_table;
GtkWidget *align;
GtkWidget *frame;
GtkWidget *toggle;
GtkWidget *hbox;