[gthumb] Add update_and_save_metadata_fd method



commit 3ff9be4bdf1b4e9bb9376207cf51a09bf07c86e0
Author: Marc Pavot <marc pavot gmail com>
Date:   Tue Jun 2 21:00:11 2009 -0400

    Add update_and_save_metadata_fd method
    
    This method is used to avoid useless instantiation of FileData.
---
 libgthumb/comments.c       |    2 +-
 libgthumb/gth-exif-utils.c |   29 ++++++++++++++++++-----------
 libgthumb/gth-exif-utils.h |    3 +++
 src/dlg-change-date.c      |    2 +-
 4 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/libgthumb/comments.c b/libgthumb/comments.c
index 566b1ad..fe78b14 100644
--- a/libgthumb/comments.c
+++ b/libgthumb/comments.c
@@ -422,7 +422,7 @@ save_comment_to_metadata (const char  *uri,
 	add_metadata = simple_add_metadata (add_metadata, TAG_NAME_SETS[KEYWORD_TAG_NAMES][0], keywords_str);
         g_free (keywords_str);
 
-	update_and_save_metadata (file->utf8_path, file->utf8_path, add_metadata);
+	update_and_save_metadata_fd (file, file, add_metadata);
 	free_metadata (add_metadata);
 	file_data_unref (file);
 }
diff --git a/libgthumb/gth-exif-utils.c b/libgthumb/gth-exif-utils.c
index 8eb3612..bedb7c6 100644
--- a/libgthumb/gth-exif-utils.c
+++ b/libgthumb/gth-exif-utils.c
@@ -408,22 +408,29 @@ update_and_save_metadata (const char *uri_src,
 	from_fd = file_data_new (uri_src);
 	to_fd = file_data_new (uri_dest);
 
-	if (!file_data_has_local_path (from_fd, NULL) || 
-	    !file_data_has_local_path (to_fd, NULL)) {
-		file_data_unref (from_fd);
-		file_data_unref (to_fd);
+        update_and_save_metadata_fd (from_fd, to_fd, metadata);
+
+	file_data_unref (from_fd);
+	file_data_unref (to_fd);
+}
+
+
+void
+update_and_save_metadata_fd (FileData   *fd_src,
+                             FileData   *fd_dest,
+                             GList      *metadata)
+{
+	if (!file_data_has_local_path (fd_src, NULL) ||
+	    !file_data_has_local_path (fd_dest, NULL)) {
 		return;
 	}
 
-	file_data_update_mime_type (to_fd, FALSE);
+	file_data_update_mime_type (fd_dest, FALSE);
 	/* TIFF metadata writing is a bit flaky, it seems.
 	   Best avoided for now. */
-	if (mime_type_is (to_fd->mime_type, "image/jpeg") ||
-	    mime_type_is (to_fd->mime_type, "image/png"))
-		write_metadata (from_fd->local_path, to_fd->local_path, metadata);
-
-	file_data_unref (from_fd);
-	file_data_unref (to_fd);
+	if (mime_type_is (fd_dest->mime_type, "image/jpeg") ||
+	    mime_type_is (fd_dest->mime_type, "image/png"))
+		write_metadata (fd_src->local_path, fd_dest->local_path, metadata);
 }
 
 
diff --git a/libgthumb/gth-exif-utils.h b/libgthumb/gth-exif-utils.h
index 16d511e..104eb3a 100644
--- a/libgthumb/gth-exif-utils.h
+++ b/libgthumb/gth-exif-utils.h
@@ -103,6 +103,9 @@ void          update_and_save_metadatum   (const char   *uri_src,
 void          update_and_save_metadata    (const char   *uri_src,
                                            const char   *uri_dest,
                                            GList        *metdata);
+void          update_and_save_metadata_fd (FileData     *fd_src,
+                                           FileData     *fd_dest,
+                                           GList        *metdata);
 void	      write_orientation_field     (const char   *filename, 
 				  	   GthTransform  transform);
 GList *       gth_read_exiv2		  (const char   *filename,
diff --git a/src/dlg-change-date.c b/src/dlg-change-date.c
index b4c938c..81a9ce6 100644
--- a/src/dlg-change-date.c
+++ b/src/dlg-change-date.c
@@ -183,7 +183,7 @@ ok_clicked (GtkWidget  *button,
 			if (is_active (data->cd_exif_dig_checkbutton))
 				add_metadata = simple_add_metadata (add_metadata, "Exif.Photo.DateTimeDigitized", buf);
 
-                        update_and_save_metadata (fdata->utf8_path, fdata->utf8_path, add_metadata);
+                        update_and_save_metadata_fd (fdata, fdata, add_metadata);
 
 			free_metadata (add_metadata);
 			g_free (buf);



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