[gthumb] save the Exif.Image.Software tag only if the content was modified



commit b97e5c142207c4afa0544c85859bb90bb6afd2f8
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Mon Jan 2 11:34:52 2012 +0100

    save the Exif.Image.Software tag only if the content was modified
    
    as suggested by Greg Mansfield

 extensions/exiv2_tools/exiv2-utils.cpp          |   10 ++++++----
 extensions/image_viewer/gth-image-viewer-page.c |   15 +++++++++++++++
 2 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/extensions/exiv2_tools/exiv2-utils.cpp b/extensions/exiv2_tools/exiv2-utils.cpp
index 0b1e47e..41bd305 100644
--- a/extensions/exiv2_tools/exiv2-utils.cpp
+++ b/extensions/exiv2_tools/exiv2-utils.cpp
@@ -954,11 +954,13 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr  image,
 	mandatory_string (ed, "Exif.Photo.ComponentsConfiguration", "1 2 3 0");
 	mandatory_string (ed, "Exif.Photo.FlashpixVersion", "48 49 48 48");
 
-	// Overwrite the software tag
+	// Overwrite the software tag if the image content was modified
 
-	if (software_name == NULL)
-		software_name = g_strconcat (g_get_application_name (), " ", VERSION, NULL);
-	ed["Exif.Image.Software"] = software_name;
+	if (g_file_info_get_attribute_boolean (info, "gth::file::image-changed")) {
+		if (software_name == NULL)
+			software_name = g_strconcat (g_get_application_name (), " ", VERSION, NULL);
+		ed["Exif.Image.Software"] = software_name;
+	}
 
 	// Update the dimension tags with actual image values
 
diff --git a/extensions/image_viewer/gth-image-viewer-page.c b/extensions/image_viewer/gth-image-viewer-page.c
index 613485c..fd810cc 100644
--- a/extensions/image_viewer/gth-image-viewer-page.c
+++ b/extensions/image_viewer/gth-image-viewer-page.c
@@ -1120,6 +1120,21 @@ _gth_image_viewer_page_real_save (GthViewerPage *base,
 	data->original_file = gth_file_data_dup (current_file);
 	if (file != NULL)
 		gth_file_data_set_file (current_file, file);
+
+	/* save the value of 'gth::file::is-modified' into 'gth::file::image-changed'
+	 * to allow the exiv2 metadata writer to not change some fields if the
+	 * content wasn't modified. */
+	g_file_info_set_attribute_boolean (current_file->info, "gth::file::image-changed", g_file_info_get_attribute_boolean (current_file->info, "gth::file::is-modified"));
+
+	/* the 'gth::file::is-modified' attribute must be set to false before
+	 * saving the file to avoid a scenario where the user is asked whether
+	 * he wants to save the file after saving it.
+	 * This is because when a file is modified in the current folder the
+	 * folder_changed_cb function in gth-browser.c is called automatically
+	 * and if the current file has been modified it is reloaded
+	 * (see file_attributes_ready_cb in gth-browser.c) and if it has been
+	 * modified ('gth::file::is-modified' is TRUE) the user is asked if he
+	 * wants to save (see load_file_delayed_cb in gth-browser.c). */
 	g_file_info_set_attribute_boolean (current_file->info, "gth::file::is-modified", FALSE);
 
 	pixbuf = gth_image_viewer_get_current_pixbuf (GTH_IMAGE_VIEWER (self->priv->viewer));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]