Commit e42ad76b authored by Paolo Bacchilega's avatar Paolo Bacchilega

copying or moving a file will copy or move its XMP sidecar as well

[bug #581641]
parent a276eff5
......@@ -726,6 +726,28 @@ exiv2_read_metadata_from_buffer (void *buffer,
}
extern "C"
GFile *
exiv2_get_sidecar (GFile *file)
{
char *uri;
char *uri_wo_ext;
char *sidecar_uri;
GFile *sidecar;
uri = g_file_get_uri (file);
uri_wo_ext = _g_uri_remove_extension (uri);
sidecar_uri = g_strconcat (uri_wo_ext, ".xmp", NULL);
sidecar = g_file_new_for_uri (sidecar_uri);
g_free (sidecar_uri);
g_free (uri_wo_ext);
g_free (uri);
return sidecar;
}
extern "C"
gboolean
exiv2_read_sidecar (GFile *file,
......
......@@ -35,6 +35,7 @@ gboolean exiv2_read_metadata_from_buffer (void *buffer,
gsize buffer_size,
GFileInfo *info,
GError **error);
GFile * exiv2_get_sidecar (GFile *file);
gboolean exiv2_read_sidecar (GFile *file,
GFileInfo *info);
gboolean exiv2_supports_writes (const char *mime_type);
......
......@@ -80,9 +80,7 @@ gth_metadata_provider_exiv2_read (GthMetadataProvider *self,
GthFileData *file_data,
const char *attributes)
{
char *uri;
char *uri_wo_ext;
char *sidecar_uri;
GFile *sidecar;
GthFileData *sidecar_file_data;
if (! g_content_type_is_a (gth_file_data_get_mime_type (file_data), "image/*"))
......@@ -95,10 +93,8 @@ gth_metadata_provider_exiv2_read (GthMetadataProvider *self,
/* sidecar data */
uri = g_file_get_uri (file_data->file);
uri_wo_ext = _g_uri_remove_extension (uri);
sidecar_uri = g_strconcat (uri_wo_ext, ".xmp", NULL);
sidecar_file_data = gth_file_data_new_for_uri (sidecar_uri, NULL);
sidecar = exiv2_get_sidecar (file_data->file);
sidecar_file_data = gth_file_data_new (sidecar, NULL);
if (g_file_query_exists (sidecar_file_data->file, NULL)) {
gth_file_data_update_info (sidecar_file_data, "time::*");
if (g_file_query_exists (sidecar_file_data->file, NULL))
......@@ -106,9 +102,7 @@ gth_metadata_provider_exiv2_read (GthMetadataProvider *self,
}
g_object_unref (sidecar_file_data);
g_free (sidecar_uri);
g_free (uri_wo_ext);
g_free (uri);
g_object_unref (sidecar);
}
......
......@@ -257,6 +257,14 @@ GthFileDataSort exiv2_sort_types[] = {
};
static void
exiv2_add_sidecars_cb (GFile *file,
GList **sidecars)
{
*sidecars = g_list_prepend (*sidecars, exiv2_get_sidecar (file));
}
G_MODULE_EXPORT void
gthumb_extension_activate (void)
{
......@@ -273,6 +281,7 @@ gthumb_extension_activate (void)
if (gth_hook_present ("jpegtran-after"))
gth_hook_add_callback ("jpegtran-after", 10, G_CALLBACK (exiv2_jpeg_tran_cb), NULL);
gth_hook_add_callback ("generate-thumbnail", 10, G_CALLBACK (exiv2_generate_thumbnail), NULL);
gth_hook_add_callback ("add-sidecars", 10, G_CALLBACK (exiv2_add_sidecars_cb), NULL);
for (i = 0; i < G_N_ELEMENTS (exiv2_sort_types); i++)
gth_main_register_sort_type (&exiv2_sort_types[i]);
......
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