Commit f581c7fe authored by Paolo Bacchilega's avatar Paolo Bacchilega

implemeted the "delete-metadata" function for embedded metadata and comments

parent 06306a02
......@@ -68,7 +68,7 @@ get_place_for_test (GthTest *test,
}
void
static void
comments__add_sidecars_cb (GFile *file,
GList **sidecars)
{
......@@ -76,7 +76,7 @@ comments__add_sidecars_cb (GFile *file,
}
void
static void
comments__read_metadata_ready_cb (GthFileData *file_data,
const char *attributes)
{
......@@ -217,6 +217,21 @@ comments__read_metadata_ready_cb (GthFileData *file_data,
}
static void
comments__delete_metadata_cb (GFile *file,
void **buffer,
gsize *size)
{
GFile *comment_file;
comment_file = gth_comment_get_comment_file (file);
if (comment_file != NULL) {
g_file_delete (comment_file, NULL, NULL);
g_object_unref (comment_file);
}
}
G_MODULE_EXPORT void
gthumb_extension_activate (void)
{
......@@ -248,6 +263,8 @@ gthumb_extension_activate (void)
gth_hook_add_callback ("add-sidecars", 10, G_CALLBACK (comments__add_sidecars_cb), NULL);
gth_hook_add_callback ("read-metadata-ready", 10, G_CALLBACK (comments__read_metadata_ready_cb), NULL);
if (gth_main_extension_is_active ("edit_metadata"))
gth_hook_add_callback ("delete-metadata", 10, G_CALLBACK (comments__delete_metadata_cb), NULL);
}
......
......@@ -1151,7 +1151,12 @@ exiv2_clear_metadata (void **buffer,
{
try {
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open ((Exiv2::byte*) *buffer, *buffer_size);
g_assert (image.get() != 0);
if (image.get() == 0) {
if (error != NULL)
*error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, _("Invalid file format"));
return FALSE;
}
try {
image->clearMetadata();
......
......@@ -218,6 +218,15 @@ exiv2_jpeg_tran_cb (JpegTranInfo *tran_info)
}
static void
exiv2_delete_metadata_cb (GFile *file,
void **buffer,
gsize *size)
{
exiv2_clear_metadata (buffer, size, NULL);
}
static int
gth_file_data_cmp_date_time_original (GthFileData *a,
GthFileData *b)
......@@ -256,8 +265,10 @@ gthumb_extension_activate (void)
gth_main_register_metadata_category (exiv2_metadata_category);
gth_main_register_metadata_info_v (exiv2_metadata_info);
gth_main_register_metadata_provider (GTH_TYPE_METADATA_PROVIDER_EXIV2);
if (gth_main_extension_is_active ("edit_metadata"))
if (gth_main_extension_is_active ("edit_metadata")) {
gth_main_register_type ("edit-metadata-dialog-page", GTH_TYPE_EDIT_EXIV2_PAGE);
gth_hook_add_callback ("delete-metadata", 10, G_CALLBACK (exiv2_delete_metadata_cb), NULL);
}
gth_hook_add_callback ("save-pixbuf", 10, G_CALLBACK (exiv2_write_metadata), NULL);
if (gth_hook_present ("jpegtran-after"))
gth_hook_add_callback ("jpegtran-after", 10, G_CALLBACK (exiv2_jpeg_tran_cb), NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment