gthumb r2247 - in trunk: . libgthumb src



Author: mjc
Date: Mon Feb  4 13:19:33 2008
New Revision: 2247
URL: http://svn.gnome.org/viewvc/gthumb?rev=2247&view=rev

Log:
2008-02-04  Michael J. Chudobiak  <mjc svn gnome org>

        * libgthumb/dlg-save-image.c: (save_image), (dlg_save_image_as),
        (dlg_save_image):
        * libgthumb/dlg-save-image.h:
        * src/gth-browser.c: (window_update_image_info), (save_jpeg_data),
        (gth_browser_save_pixbuf), (ask_whether_to_save__response_cb),
        (gth_browser_finalize):
        * src/gth-viewer.c: (gth_viewer_finalize),
        (viewer_update_image_info), (save_jpeg_data),
        (ask_whether_to_save__response_cb), (gth_viewer_save_pixbuf):
        Purged libexif from gth-browser, gth-viewer. Save and Save As now
        use exiv2-based routines to copy metadata.



Modified:
   trunk/ChangeLog
   trunk/libgthumb/dlg-save-image.c
   trunk/libgthumb/dlg-save-image.h
   trunk/src/gth-browser.c
   trunk/src/gth-viewer.c

Modified: trunk/libgthumb/dlg-save-image.c
==============================================================================
--- trunk/libgthumb/dlg-save-image.c	(original)
+++ trunk/libgthumb/dlg-save-image.c	Mon Feb  4 13:19:33 2008
@@ -53,6 +53,7 @@
 typedef struct {
 	ImageSavedFunc  done_func;
 	gpointer        done_data;
+	GList	       *metadata;
 } SaveImageData;
 
 
@@ -116,7 +117,7 @@
 			local_file = get_cache_filename_from_uri (file->path);
 			if (_gdk_pixbuf_savev (pixbuf,
 					       local_file,
-					       NULL, /* FIXME - add metadata */
+					       data->metadata,
 					       image_type,
 					       keys, values,
 					       &error))
@@ -177,7 +178,7 @@
 	else
 		mime_type = mime_types [idx - 2];
 	file->mime_type = get_static_string (mime_type);
-	
+
 	save_image (parent, file, pixbuf, data, file_sel);
 	g_free (file);
 }
@@ -226,6 +227,7 @@
 void
 dlg_save_image_as (GtkWindow       *parent,
 		   const char      *uri,
+		   GList           *metadata,
 		   GdkPixbuf       *pixbuf,
 		   ImageSavedFunc   done_func,
 		   gpointer         done_data)
@@ -282,6 +284,8 @@
 	data->done_func = done_func;
 	data->done_data = done_data;
 
+	data->metadata = metadata;
+
 	g_object_set_data (G_OBJECT (file_sel), "parent_window", parent);
 	g_object_set_data (G_OBJECT (file_sel), "pixbuf", pixbuf);
 	g_object_set_data (G_OBJECT (file_sel), "data", data);
@@ -309,6 +313,7 @@
 void
 dlg_save_image (GtkWindow       *parent,
 		FileData        *file,
+		GList		*metadata,
 		GdkPixbuf       *pixbuf,
 		ImageSavedFunc   done_func,
 		gpointer         done_data)
@@ -321,6 +326,7 @@
 	data = g_new0 (SaveImageData, 1);
 	data->done_func = done_func;
 	data->done_data = done_data;
+	data->metadata = metadata;
 
 	save_image (parent, file, pixbuf, data, NULL);
 }

Modified: trunk/libgthumb/dlg-save-image.h
==============================================================================
--- trunk/libgthumb/dlg-save-image.h	(original)
+++ trunk/libgthumb/dlg-save-image.h	Mon Feb  4 13:19:33 2008
@@ -32,11 +32,13 @@
 
 void       dlg_save_image_as (GtkWindow        *parent,
 			      const char       *uri,
+			      GList            *metadata,
 			      GdkPixbuf        *pixbuf,
 			      ImageSavedFunc    done_func,
 			      gpointer          done_data);
 void       dlg_save_image    (GtkWindow        *parent,
 			      FileData         *file,
+			      GList	       *metadata,
 			      GdkPixbuf        *pixbuf,
 			      ImageSavedFunc    done_func,
 			      gpointer          done_data);

Modified: trunk/src/gth-browser.c
==============================================================================
--- trunk/src/gth-browser.c	(original)
+++ trunk/src/gth-browser.c	Mon Feb  4 13:19:33 2008
@@ -71,7 +71,6 @@
 #include "rotation-utils.h"
 #include "dlg-scripts.h"
 
-#include <libexif/exif-data.h>
 #include "jpegutils/jpeg-data.h"
 
 #ifdef HAVE_LIBIPTCDATA
@@ -243,8 +242,6 @@
 	guint               view_image_timeout; /* timer for the
 						 * view_image_at_pos function.
 						 */
-	ExifData           *exif_data;
-
 #ifdef HAVE_LIBIPTCDATA
 	IptcData           *iptc_data;
 #endif /* HAVE_LIBIPTCDATA */
@@ -585,36 +582,9 @@
 static void
 window_update_image_info (GthBrowser *browser)
 {
-        GthBrowserPrivateData *priv = browser->priv;
-        JPEGData              *jdata = NULL;
-        char                  *cache_uri = NULL;
-
         window_update_statusbar_image_info (browser);
         window_update_statusbar_zoom_info (browser);
 
-        if (priv->exif_data != NULL) {
-                exif_data_unref (priv->exif_data);
-                priv->exif_data = NULL;
-        }
-
-        if (priv->image != NULL)
-                cache_uri = get_cache_filename_from_uri (priv->image->path);
-
-        if ((cache_uri != NULL) && (image_is_jpeg (cache_uri))) {
-                char *local_file = NULL;
-
-                local_file = get_cache_filename_from_uri (priv->image->path);
-                jdata = jpeg_data_new_from_file (local_file);
-                g_free (local_file);
-        }
-
-        g_free (cache_uri);
-
-        if (jdata != NULL) {
-                priv->exif_data = jpeg_data_get_exif_data (jdata);
-                jpeg_data_unref (jdata);
-        }
-
         gth_exif_data_viewer_update (GTH_EXIF_DATA_VIEWER (browser->priv->exif_data_viewer),
                                      IMAGE_VIEWER (browser->priv->viewer),
                                      browser->priv->image);
@@ -1759,7 +1729,6 @@
 		CopyDoneFunc  done_func,
 		gpointer      done_data)
 {
-	GthBrowserPrivateData *priv = browser->priv;
 	gboolean               data_to_save = FALSE;
 	JPEGData              *jdata;
 	char                  *local_file = NULL;
@@ -1771,9 +1740,6 @@
 	if (! image_is_jpeg (file->path))
 		return update_file_from_cache (file, done_func, done_data);
 
-	if (priv->exif_data != NULL)
-		data_to_save = TRUE;
-
 #ifdef HAVE_LIBIPTCDATA
 	if (priv->iptc_data != NULL)
 		data_to_save = TRUE;
@@ -1805,17 +1771,9 @@
 	}
 #endif /* HAVE_LIBIPTCDATA */
 
-	if (priv->exif_data != NULL)
-		jpeg_data_set_exif_data (jdata, priv->exif_data);
-
 	jpeg_data_save_file (jdata, local_file);
 	jpeg_data_unref (jdata);
 
-	/* The exif orientation tag, if present, must be reset to "top-left",
-   	   because the jpeg was saved from a gthumb-generated pixbuf, and
-   	   the pixbuf image loader always rotates the pixbuf to account for
-   	   the orientation tag. */
-	write_orientation_field (local_file, GTH_TRANSFORM_NONE);
 	g_free (local_file);
 	
 	return update_file_from_cache (file, done_func, done_data);
@@ -1847,8 +1805,10 @@
 	GthBrowserPrivateData *priv = browser->priv;
 	char                  *current_folder = NULL;
 
-	if (priv->image != NULL)
+	if (priv->image != NULL) {
 		current_folder = g_strdup (priv->image->path);
+		update_metadata (priv->image);
+	}
 	else if (priv->dir_list->path != NULL)
 		current_folder = g_strconcat (priv->dir_list->path,
 					      "/",
@@ -1857,16 +1817,19 @@
 	if (file == NULL)
 		dlg_save_image_as (GTK_WINDOW (browser),
 				   current_folder,
+				   priv->image->metadata,
 				   pixbuf,
 				   save_pixbuf__image_saved_cb,
 				   browser);
-	else
+	else {
+		update_metadata (file);
 		dlg_save_image (GTK_WINDOW (browser),
 				file,
+				priv->image->metadata,
 				pixbuf,
 				save_pixbuf__image_saved_cb,
 				browser);
-
+	}
 	g_free (current_folder);
 }
 
@@ -1881,8 +1844,10 @@
 	gtk_widget_destroy (dialog);
 
 	if (response_id == GTK_RESPONSE_YES) {
+		update_metadata (priv->image);
 		dlg_save_image_as (GTK_WINDOW (browser),
 				   priv->image->path,
+				   priv->image->metadata,
 				   image_viewer_get_current_pixbuf (IMAGE_VIEWER (priv->viewer)),
 				   save_pixbuf__image_saved_cb,
 				   browser);
@@ -5571,11 +5536,6 @@
 			priv->image_path_saved = NULL;
 		}
 
-		if (priv->exif_data != NULL) {
-			exif_data_unref (priv->exif_data);
-			priv->exif_data = NULL;
-		}
-
 #ifdef HAVE_LIBIPTCDATA
 		if (priv->iptc_data != NULL) {
 			iptc_data_unref (priv->iptc_data);

Modified: trunk/src/gth-viewer.c
==============================================================================
--- trunk/src/gth-viewer.c	(original)
+++ trunk/src/gth-viewer.c	Mon Feb  4 13:19:33 2008
@@ -30,7 +30,6 @@
 #include <libgnomevfs/gnome-vfs-utils.h>
 #include <libgnomevfs/gnome-vfs-mime.h>
 
-#include <libexif/exif-data.h>
 #include "jpegutils/jpeg-data.h"
 
 #ifdef HAVE_LIBIPTCDATA
@@ -121,7 +120,6 @@
 
 	gboolean         image_data_visible;
 	FileData        *image;
-	ExifData        *exif_data;
 	gboolean         image_error;
 
 #ifdef HAVE_LIBIPTCDATA
@@ -285,11 +283,6 @@
 			if (viewer->priv->cnxn_id[i] != -1)
 				eel_gconf_notification_remove (viewer->priv->cnxn_id[i]);
 
-		if (priv->exif_data != NULL) {
-			exif_data_unref (priv->exif_data);
-			priv->exif_data = NULL;
-		}
-
 #ifdef HAVE_LIBIPTCDATA
 		if (priv->iptc_data != NULL) {
 			iptc_data_unref (priv->iptc_data);
@@ -709,35 +702,9 @@
 static void
 viewer_update_image_info (GthViewer *viewer)
 {
-	JPEGData *jdata = NULL;
-	
 	viewer_update_statusbar_image_info (viewer);
 	viewer_update_statusbar_zoom_info (viewer);
 
-	/* Load EXIF data */
-
-	if (viewer->priv->exif_data != NULL) {
-		exif_data_unref (viewer->priv->exif_data);
-		viewer->priv->exif_data = NULL;
-	}
-
-	if ((viewer->priv->image != NULL) && (image_is_jpeg (viewer->priv->image->path))) {
-		char *local_file;
-		
-		local_file = get_cache_filename_from_uri (viewer->priv->image->path);
-		if (local_file != NULL) {
-			jdata = jpeg_data_new_from_file (local_file);
-			g_free (local_file);
-		}
-	}
-
-	if (jdata != NULL) {
-		viewer->priv->exif_data = jpeg_data_get_exif_data (jdata);
-		jpeg_data_unref (jdata);
-	}
-
-	/**/
-
 	gth_exif_data_viewer_update (GTH_EXIF_DATA_VIEWER (viewer->priv->exif_data_viewer),
 				     IMAGE_VIEWER (viewer->priv->viewer),
 				     viewer->priv->image);
@@ -879,7 +846,6 @@
 		CopyDoneFunc  done_func,
 		gpointer      done_data)
 {
-	GthViewerPrivateData  *priv = viewer->priv;
 	gboolean               data_to_save = FALSE;
 	JPEGData              *jdata;
         char                  *local_file = NULL;
@@ -891,9 +857,6 @@
 	if (! image_is_jpeg (local_file))
 		return update_file_from_cache (file, done_func, done_data);
 
-	if (priv->exif_data != NULL)
-		data_to_save = TRUE;
-
 #ifdef HAVE_LIBIPTCDATA
 	if (priv->iptc_data != NULL)
 		data_to_save = TRUE;
@@ -925,17 +888,9 @@
 	}
 #endif /* HAVE_LIBIPTCDATA */
 
-	if (priv->exif_data != NULL)
-		jpeg_data_set_exif_data (jdata, priv->exif_data);
-
 	jpeg_data_save_file (jdata, local_file);
 	jpeg_data_unref (jdata);
 
-	/* The exif orientation tag, if present, must be reset to "top-left",
-   	   because the jpeg was saved from a gthumb-generated pixbuf, and
-   	   the pixbug image loader always rotates the pixbuf to account for
-   	   the orientation tag. */
-	write_orientation_field (local_file, GTH_TRANSFORM_NONE);
         g_free (local_file);
         
         return update_file_from_cache (file, done_func, done_data);
@@ -978,6 +933,7 @@
         if (response_id == GTK_RESPONSE_YES) {
 		dlg_save_image_as (GTK_WINDOW (viewer),
 				   priv->image->path,
+				   priv->image->metadata,
 				   image_viewer_get_current_pixbuf (IMAGE_VIEWER (priv->viewer)),
 				   ask_whether_to_save__image_saved_cb,
 				   viewer);
@@ -2002,18 +1958,22 @@
 	GthViewerPrivateData *priv = viewer->priv;
 	char                 *current_folder = NULL;
 
-	if (priv->image != NULL)
+	if (priv->image != NULL) {
 		current_folder = g_strdup (priv->image->path);
+		update_metadata (priv->image);
+	}
 
 	if (file == NULL)
 		dlg_save_image_as (GTK_WINDOW (viewer),
 				   current_folder,
+				   priv->image->metadata,
 				   pixbuf,
 				   save_pixbuf__image_saved_cb,
 				   viewer);
 	else
 		dlg_save_image (GTK_WINDOW (viewer),
 				file,
+				priv->image->metadata,
 				pixbuf,
 				save_pixbuf__image_saved_cb,
 				viewer);



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