[eog/wip/phako/gexiv2: 1/2] all: Replace libexif with gexiv2



commit 21b4e5ffe688718b63d66c1c45b9657cfdfcee53
Author: Jens Georg <mail jensge org>
Date:   Wed Feb 7 20:18:11 2018 +0100

    all: Replace libexif with gexiv2

 meson.build                                        |    4 +-
 plugins/statusbar-date/eog-statusbar-date-plugin.c |    4 +-
 src/eog-exif-util.c                                |   79 +++++++-------------
 src/eog-exif-util.h                                |   20 +++---
 src/eog-image-jpeg.c                               |    8 ++-
 src/eog-image-private.h                            |    2 +-
 src/eog-image.c                                    |   69 ++++-------------
 src/eog-image.h                                    |    4 +-
 src/eog-list-store.c                               |    3 +
 src/eog-metadata-details.c                         |   19 +++--
 src/eog-metadata-details.h                         |    4 +-
 src/eog-metadata-reader-jpg.c                      |   27 +++----
 src/eog-metadata-reader.c                          |    2 +-
 src/eog-metadata-reader.h                          |    2 +-
 src/eog-metadata-sidebar.c                         |   21 +++---
 src/eog-properties-dialog.c                        |   22 +++---
 src/eog-thumb-view.c                               |   10 +-
 17 files changed, 124 insertions(+), 176 deletions(-)
---
diff --git a/meson.build b/meson.build
index b0e4bb8..97f8b17 100644
--- a/meson.build
+++ b/meson.build
@@ -126,8 +126,8 @@ assert(have_zlib, 'No sufficient zlib library found on your system')
 # EXIF (optional)
 have_exif = false
 if get_option('libexif')
-  libexif_dep = dependency('libexif', version: '>= 0.6.14', required: false)
-  have_exif = libexif_dep.found() and cc.has_header('libexif/exif-data.h', dependencies: libexif_dep)
+  libexif_dep = dependency('gexiv2', version: '>= 0.10.4', required: false)
+  have_exif = libexif_dep.found() and cc.has_header('gexiv2/gexiv2.h', dependencies: libexif_dep)
 
   if have_exif
     eog_deps += libexif_dep
diff --git a/plugins/statusbar-date/eog-statusbar-date-plugin.c 
b/plugins/statusbar-date/eog-statusbar-date-plugin.c
index c4da581..0a6462e 100644
--- a/plugins/statusbar-date/eog-statusbar-date-plugin.c
+++ b/plugins/statusbar-date/eog-statusbar-date-plugin.c
@@ -58,7 +58,7 @@ statusbar_set_date (GtkStatusbar *statusbar, EogThumbView *view)
        EogImage *image;
        gchar *date = NULL;
        gchar time_buffer[32];
-       ExifData *exif_data;
+       GExiv2Metadata *exif_data;
 
        if (eog_thumb_view_get_n_selected (view) == 0)
                return;
@@ -76,7 +76,7 @@ statusbar_set_date (GtkStatusbar *statusbar, EogThumbView *view)
        exif_data = eog_image_get_exif_info (image);
        if (exif_data) {
                date = eog_exif_util_format_date (
-                       eog_exif_data_get_value (exif_data, EXIF_TAG_DATE_TIME_ORIGINAL, time_buffer, 32));
+                       eog_exif_data_get_value (exif_data, "Exif.Photo.DateTimeOriginal", time_buffer, 32));
                eog_exif_data_free (exif_data);
        }
 
diff --git a/src/eog-exif-util.c b/src/eog-exif-util.c
index b77a5a2..a39108d 100644
--- a/src/eog-exif-util.c
+++ b/src/eog-exif-util.c
@@ -50,7 +50,7 @@
 #define GPOINTER_TO_BOOLEAN(i) ((gboolean) ((GPOINTER_TO_INT (i) == 2) ? TRUE : FALSE))
 #endif
 
-typedef ExifData EogExifData;
+typedef GExiv2Metadata EogExifData;
 
 /* Define EogExifData type */
 G_DEFINE_BOXED_TYPE(EogExifData, eog_exif_data, eog_exif_data_copy, eog_exif_data_free)
@@ -200,7 +200,7 @@ eog_exif_util_format_date (const gchar *date)
 void
 eog_exif_util_set_label_text (GtkLabel *label,
                              EogExifData *exif_data,
-                             gint tag_id)
+                             const char *tag_id)
 {
        gchar exif_buffer[512];
        const gchar *buf_ptr;
@@ -209,13 +209,17 @@ eog_exif_util_set_label_text (GtkLabel *label,
        g_return_if_fail (GTK_IS_LABEL (label));
 
        if (exif_data) {
-               buf_ptr = eog_exif_data_get_value (exif_data, tag_id,
-                                                  exif_buffer, 512);
+               if (g_str_has_suffix (tag_id, "FNumber")) {
+                       label_text = g_strdup_printf ("f/%.1f", gexiv2_metadata_get_fnumber (exif_data));
+               } else {
+                       buf_ptr = eog_exif_data_get_value (exif_data, tag_id,
+                                                          exif_buffer, 512);
 
-               if (tag_id == EXIF_TAG_DATE_TIME_ORIGINAL && buf_ptr)
-                       label_text = eog_exif_util_format_date (buf_ptr);
-               else
-                       label_text = eog_util_make_valid_utf8 (buf_ptr);
+                       if (g_str_has_suffix (tag_id, "DateTimeOriginal") && buf_ptr)
+                               label_text = eog_exif_util_format_date (buf_ptr);
+                       else
+                               label_text = eog_util_make_valid_utf8 (buf_ptr);
+               }
        }
 
        gtk_label_set_text (label, label_text);
@@ -224,20 +228,20 @@ eog_exif_util_set_label_text (GtkLabel *label,
 
 void
 eog_exif_util_format_datetime_label (GtkLabel *label, EogExifData *exif_data,
-                                    gint tag_id, const gchar *format)
+                                    const char *tag_id, const gchar *format)
 {
        gchar exif_buffer[512];
        const gchar *buf_ptr;
        gchar *label_text = NULL;
 
        g_return_if_fail (GTK_IS_LABEL (label));
-       g_warn_if_fail (tag_id == EXIF_TAG_DATE_TIME_ORIGINAL);
+       g_warn_if_fail (g_str_has_suffix (tag_id, "DateTimeOriginal"));
 
        if (exif_data) {
                buf_ptr = eog_exif_data_get_value (exif_data, tag_id,
                                                   exif_buffer, 512);
 
-               if (tag_id == EXIF_TAG_DATE_TIME_ORIGINAL && buf_ptr)
+               if (g_str_has_suffix (tag_id, "DateTimeOriginal") && buf_ptr)
 #ifdef HAVE_STRPTIME
                        label_text = eog_exif_util_format_date_with_strptime (buf_ptr, format);
 #else
@@ -253,45 +257,19 @@ void
 eog_exif_util_set_focal_length_label_text (GtkLabel *label,
                                           EogExifData *exif_data)
 {
-       ExifEntry *entry = NULL, *entry35mm = NULL;
-       ExifByteOrder byte_order;
-       gfloat f_val = 0.0;
        gchar *fl_text = NULL,*fl35_text = NULL;
 
        /* If no ExifData is supplied the label will be
         * cleared later as fl35_text is NULL. */
-       if (exif_data != NULL) {
-               entry = exif_data_get_entry (exif_data, EXIF_TAG_FOCAL_LENGTH);
-               entry35mm = exif_data_get_entry (exif_data,
-                                           EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM);
-               byte_order = exif_data_get_byte_order (exif_data);
-       }
-
-       if (entry && G_LIKELY (entry->format == EXIF_FORMAT_RATIONAL)) {
-               ExifRational value;
-
-               /* Decode value by hand as libexif is not necessarily returning
-                * it in the format we want it to be.
-                */
-               value = exif_get_rational (entry->data, byte_order);
-               /* Guard against div by zero */
-               if (G_LIKELY(value.denominator != 0))
-                       f_val = (gfloat)value.numerator/
-                               (gfloat)value.denominator;
 
+       if (exif_data != NULL && gexiv2_metadata_has_tag (exif_data, "Exif.Photo.FocalLength")) {
                /* TRANSLATORS: This is the actual focal length used when
                   the image was taken.*/
-               fl_text = g_strdup_printf (_("%.1f (lens)"), f_val);
+               fl_text = g_strdup_printf (_("%.1f (lens)"), gexiv2_metadata_get_focal_length (exif_data));
 
        }
-       if (entry35mm && G_LIKELY (entry35mm->format == EXIF_FORMAT_SHORT)) {
-               ExifShort s_val;
-
-               s_val = exif_get_short (entry35mm->data, byte_order);
-
-               /* Print as float to get a similar look as above. */
-               /* TRANSLATORS: This is the equivalent focal length assuming
-                  a 35mm film camera. */
+       if (exif_data != NULL && gexiv2_metadata_has_tag (exif_data, "Exif.Photo.FocalLengthIn35mmFilm")) {
+               long s_val = gexiv2_metadata_get_tag_long (exif_data, "Exif.Photo.FocalLengthIn35mmFilm");
                fl35_text = g_strdup_printf(_("%.1f (35mm film)"),(float)s_val);
        }
 
@@ -329,24 +307,19 @@ eog_exif_util_set_focal_length_label_text (GtkLabel *label,
  * Returns: a pointer to @buffer.
  */
 const gchar *
-eog_exif_data_get_value (EogExifData *exif_data, gint tag_id, gchar *buffer, guint buf_size)
+eog_exif_data_get_value (EogExifData *exif_data, const char *tag_id, gchar *buffer, guint buf_size)
 {
-       ExifEntry *exif_entry;
-       const gchar *exif_value;
-
-        exif_entry = exif_data_get_entry (exif_data, tag_id);
-
-       buffer[0] = 0;
-
-       exif_value = exif_entry_get_value (exif_entry, buffer, buf_size);
+       char *data = gexiv2_metadata_get_tag_string (exif_data, tag_id);
+       strncpy (buffer, data, buf_size - 1);
+       g_free (data);
 
-       return exif_value;
+       return buffer;
 }
 
 EogExifData *
 eog_exif_data_copy (EogExifData *data)
 {
-       exif_data_ref (data);
+       g_object_ref (data);
 
        return data;
 }
@@ -354,5 +327,5 @@ eog_exif_data_copy (EogExifData *data)
 void
 eog_exif_data_free (EogExifData *data)
 {
-       exif_data_unref (data);
+       g_object_unref (data);
 }
diff --git a/src/eog-exif-util.h b/src/eog-exif-util.h
index 5f54a8b..b89bd77 100644
--- a/src/eog-exif-util.h
+++ b/src/eog-exif-util.h
@@ -30,7 +30,7 @@
 #include <glib.h>
 #include <glib-object.h>
 #include <gtk/gtk.h>
-#include <libexif/exif-data.h>
+#include <gexiv2/gexiv2.h>
 
 G_BEGIN_DECLS
 
@@ -38,25 +38,25 @@ G_BEGIN_DECLS
 
 gchar       *eog_exif_util_format_date           (const gchar *date);
 void         eog_exif_util_format_datetime_label (GtkLabel *label,
-                                                  ExifData *exif_data,
-                                                  gint tag_id,
+                                                  GExiv2Metadata *exif_data,
+                                                  const char *tag_id,
                                                   const gchar *format);
 void         eog_exif_util_set_label_text        (GtkLabel *label,
-                                                  ExifData *exif_data,
-                                                  gint tag_id);
+                                                  GExiv2Metadata *exif_data,
+                                                  const char *tag_id);
 
 void         eog_exif_util_set_focal_length_label_text (GtkLabel *label,
-                                                        ExifData *exif_data);
+                                                        GExiv2Metadata *exif_data);
 
 
-const gchar *eog_exif_data_get_value             (ExifData *exif_data,
-                                                  gint tag_id, gchar *buffer,
+const gchar *eog_exif_data_get_value             (GExiv2Metadata *exif_data,
+                                                  const char *tag_id, gchar *buffer,
                                                   guint buf_size);
 
 GType        eog_exif_data_get_type              (void) G_GNUC_CONST;
 
-ExifData    *eog_exif_data_copy                  (ExifData *data);
-void         eog_exif_data_free                  (ExifData *data);
+GExiv2Metadata *eog_exif_data_copy                  (GExiv2Metadata *data);
+void         eog_exif_data_free                  (GExiv2Metadata *data);
 
 G_END_DECLS
 
diff --git a/src/eog-image-jpeg.c b/src/eog-image-jpeg.c
index 0eaf5f8..3f2a860 100644
--- a/src/eog-image-jpeg.c
+++ b/src/eog-image-jpeg.c
@@ -49,7 +49,7 @@
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <glib/gi18n.h>
 #if HAVE_EXIF
-#include <libexif/exif-data.h>
+#include <gexiv2/gexiv2.h>
 #endif
 
 #ifdef G_OS_WIN32
@@ -299,6 +299,8 @@ _save_jpeg_as_jpeg (EogImage *image, const char *file, EogImageSaveInfo *source,
 
        /* handle EXIF/IPTC data explicitly */
 #if HAVE_EXIF
+    // FIXME: Make this possible with GExiv2
+#if 0
        /* exif_chunk and exif are mutally exclusvie, this is what we assure here */
        g_assert (priv->exif_chunk == NULL);
        if (priv->exif != NULL)
@@ -310,6 +312,7 @@ _save_jpeg_as_jpeg (EogImage *image, const char *file, EogImageSaveInfo *source,
                jpeg_write_marker (&dstinfo, JPEG_APP0+1, exif_buf, exif_buf_len);
                g_free (exif_buf);
        }
+#endif
 #else
        if (priv->exif_chunk != NULL) {
                jpeg_write_marker (&dstinfo, JPEG_APP0+1, priv->exif_chunk, priv->exif_chunk_len);
@@ -431,6 +434,8 @@ _save_any_as_jpeg (EogImage *image, const char *file, EogImageSaveInfo *source,
        /* write EXIF/IPTC data explicitly */
 #if HAVE_EXIF
        /* exif_chunk and exif are mutally exclusvie, this is what we assure here */
+    // FIXME: Make possible with GExiv2
+#if 0
        g_assert (priv->exif_chunk == NULL);
        if (priv->exif != NULL)
        {
@@ -441,6 +446,7 @@ _save_any_as_jpeg (EogImage *image, const char *file, EogImageSaveInfo *source,
                jpeg_write_marker (&cinfo, 0xe1, exif_buf, exif_buf_len);
                g_free (exif_buf);
        }
+#endif
 #else
        if (priv->exif_chunk != NULL) {
                jpeg_write_marker (&cinfo, JPEG_APP0+1, priv->exif_chunk, priv->exif_chunk_len);
diff --git a/src/eog-image-private.h b/src/eog-image-private.h
index e0c1592..e393dbf 100644
--- a/src/eog-image-private.h
+++ b/src/eog-image-private.h
@@ -72,7 +72,7 @@ struct _EogImagePrivate {
        gboolean          autorotate;
        gint              orientation;
 #ifdef HAVE_EXIF
-       ExifData         *exif;
+       GExiv2Metadata   *exif;
 #endif
 #ifdef HAVE_EXEMPI
        XmpPtr   xmp;
diff --git a/src/eog-image.c b/src/eog-image.c
index b968863..a0d67ad 100644
--- a/src/eog-image.c
+++ b/src/eog-image.c
@@ -53,9 +53,7 @@
 
 #ifdef HAVE_EXIF
 #include "eog-exif-util.h"
-#include <libexif/exif-data.h>
-#include <libexif/exif-utils.h>
-#include <libexif/exif-loader.h>
+#include <gexiv2/gexiv2.h>
 #endif
 
 #ifdef HAVE_EXEMPI
@@ -126,10 +124,7 @@ eog_image_free_mem_private (EogImage *image)
 #endif
 
 #ifdef HAVE_EXIF
-               if (priv->exif != NULL) {
-                       exif_data_unref (priv->exif);
-                       priv->exif = NULL;
-               }
+               g_clear_object (&priv->exif);
 #endif
 
                if (priv->exif_chunk != NULL) {
@@ -361,8 +356,6 @@ eog_image_update_exif_data (EogImage *image)
 {
 #ifdef HAVE_EXIF
        EogImagePrivate *priv;
-       ExifEntry *entry;
-       ExifByteOrder bo;
 
        eog_debug (DEBUG_IMAGE_DATA);
 
@@ -372,40 +365,19 @@ eog_image_update_exif_data (EogImage *image)
 
        if (priv->exif == NULL) return;
 
-       bo = exif_data_get_byte_order (priv->exif);
-
        /* Update image width */
-       entry = exif_data_get_entry (priv->exif, EXIF_TAG_PIXEL_X_DIMENSION);
-       if (entry != NULL && (priv->width >= 0)) {
-               if (entry->format == EXIF_FORMAT_LONG)
-                       exif_set_long (entry->data, bo, priv->width);
-               else if (entry->format == EXIF_FORMAT_SHORT)
-                       exif_set_short (entry->data, bo, priv->width);
-               else
-                       g_warning ("Exif entry has unsupported size");
+       if (gexiv2_metadata_has_tag (priv->exif, "Exif.Photo.PixelXDimension")) {
+               gexiv2_metadata_set_tag_long (priv->exif, "Exif.Photo.PixelXDimension", priv->width);
        }
 
        /* Update image height */
-       entry = exif_data_get_entry (priv->exif, EXIF_TAG_PIXEL_Y_DIMENSION);
-       if (entry != NULL && (priv->height >= 0)) {
-               if (entry->format == EXIF_FORMAT_LONG)
-                       exif_set_long (entry->data, bo, priv->height);
-               else if (entry->format == EXIF_FORMAT_SHORT)
-                       exif_set_short (entry->data, bo, priv->height);
-               else
-                       g_warning ("Exif entry has unsupported size");
+       if (gexiv2_metadata_has_tag (priv->exif, "Exif.Photo.PixelYDimension")) {
+               gexiv2_metadata_set_tag_long (priv->exif, "Exif.Photo.PixelYDimension", priv->height);
        }
 
        /* Update image orientation */
-       entry = exif_data_get_entry (priv->exif, EXIF_TAG_ORIENTATION);
-       if (entry != NULL) {
-               if (entry->format == EXIF_FORMAT_LONG)
-                       exif_set_long (entry->data, bo, 1);
-               else if (entry->format == EXIF_FORMAT_SHORT)
-                       exif_set_short (entry->data, bo, 1);
-               else
-                       g_warning ("Exif entry has unsupported size");
-
+       if (gexiv2_metadata_has_tag (priv->exif, "Exif.Photo.Orientation")) {
+               gexiv2_metadata_set_tag_long (priv->exif, "Exif.Photo.Orientation", 1);
                priv->orientation = 1;
        }
 #endif
@@ -726,7 +698,7 @@ eog_image_set_orientation (EogImage *img)
 {
        EogImagePrivate *priv;
 #ifdef HAVE_EXIF
-       ExifData* exif;
+       GExiv2Metadata* exif;
 #endif
 
        g_return_if_fail (EOG_IS_IMAGE (img));
@@ -734,19 +706,14 @@ eog_image_set_orientation (EogImage *img)
        priv = img->priv;
 
 #ifdef HAVE_EXIF
-       exif = (ExifData*) eog_image_get_exif_info (img);
+       exif = (GExiv2Metadata*) eog_image_get_exif_info (img);
 
        if (exif != NULL) {
-               ExifByteOrder o = exif_data_get_byte_order (exif);
-
-               ExifEntry *entry = exif_data_get_entry (exif,
-                                                       EXIF_TAG_ORIENTATION);
-
-               if (entry && entry->data != NULL) {
-                       priv->orientation = exif_get_short (entry->data, o);
+               if (gexiv2_metadata_has_tag (exif, "Exif.Photo.Orientation")) {
+                       priv->orientation = gexiv2_metadata_get_tag_long (exif, "Exif.Photo.Orientation");
                }
 
-               exif_data_unref (exif);
+               g_object_unref (exif);
        } else
 #endif
        {
@@ -844,9 +811,7 @@ eog_image_set_exif_data (EogImage *img, EogMetadataReader *md_reader)
 
 #ifdef HAVE_EXIF
        g_mutex_lock (&priv->status_mutex);
-       if (priv->exif) {
-               exif_data_unref (priv->exif);
-       }
+       g_clear_object (&priv->exif);
        priv->exif = eog_metadata_reader_get_exif_data (md_reader);
        g_mutex_unlock (&priv->status_mutex);
 
@@ -2071,11 +2036,11 @@ eog_image_cancel_load (EogImage *img)
 }
 
 #ifdef HAVE_EXIF
-ExifData *
+GExiv2Metadata *
 eog_image_get_exif_info (EogImage *img)
 {
        EogImagePrivate *priv;
-       ExifData *data = NULL;
+       GExiv2Metadata *data = NULL;
 
        g_return_val_if_fail (EOG_IS_IMAGE (img), NULL);
 
@@ -2083,7 +2048,7 @@ eog_image_get_exif_info (EogImage *img)
 
        g_mutex_lock (&priv->status_mutex);
 
-       exif_data_ref (priv->exif);
+       g_object_ref (priv->exif);
        data = priv->exif;
 
        g_mutex_unlock (&priv->status_mutex);
diff --git a/src/eog-image.h b/src/eog-image.h
index 23f2fb3..b9b4798 100644
--- a/src/eog-image.h
+++ b/src/eog-image.h
@@ -33,7 +33,7 @@
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
 #ifdef HAVE_EXIF
-#include <libexif/exif-data.h>
+#include <gexiv2/gexiv2.h>
 #include "eog-exif-util.h"
 #endif
 
@@ -165,7 +165,7 @@ const gchar*      eog_image_get_caption              (EogImage   *img);
 const gchar      *eog_image_get_collate_key          (EogImage   *img);
 
 #if HAVE_EXIF
-ExifData*      eog_image_get_exif_info            (EogImage   *img);
+GExiv2Metadata*      eog_image_get_exif_info            (EogImage   *img);
 #endif
 
 gpointer          eog_image_get_xmp_info             (EogImage   *img);
diff --git a/src/eog-list-store.c b/src/eog-list-store.c
index a7f6563..c179fe3 100644
--- a/src/eog-list-store.c
+++ b/src/eog-list-store.c
@@ -462,6 +462,9 @@ file_monitor_changed_cb (GFileMonitor *monitor,
        case G_FILE_MONITOR_EVENT_PRE_UNMOUNT:
        case G_FILE_MONITOR_EVENT_UNMOUNTED:
        case G_FILE_MONITOR_EVENT_MOVED:
+       case G_FILE_MONITOR_EVENT_MOVED_IN:
+       case G_FILE_MONITOR_EVENT_MOVED_OUT:
+       case G_FILE_MONITOR_EVENT_RENAMED:
                break;
        }
 }
diff --git a/src/eog-metadata-details.c b/src/eog-metadata-details.c
index 6cdffda..fdb8969 100644
--- a/src/eog-metadata-details.c
+++ b/src/eog-metadata-details.c
@@ -27,8 +27,7 @@
 #include "eog-util.h"
 
 #if HAVE_EXIF
-#include <libexif/exif-entry.h>
-#include <libexif/exif-utils.h>
+#include <gexiv2/gexiv2.h>
 #endif
 #if HAVE_EXEMPI
 #include <exempi/xmp.h>
@@ -82,8 +81,9 @@ typedef struct {
        MetadataCategory category;
 } ExifTagCategory;
 
-#ifdef HAVE_EXIF
+#ifdef HAVE_EXIF_
 static ExifTagCategory exif_tag_category_map[] = {
+#if 0
        { EXIF_TAG_INTEROPERABILITY_INDEX,    EXIF_CATEGORY_CAMERA},
        { EXIF_TAG_INTEROPERABILITY_VERSION,  EXIF_CATEGORY_CAMERA},
        { EXIF_TAG_IMAGE_WIDTH,               EXIF_CATEGORY_IMAGE_DATA},
@@ -187,6 +187,7 @@ static ExifTagCategory exif_tag_category_map[] = {
        { EXIF_TAG_DEVICE_SETTING_DESCRIPTION, EXIF_CATEGORY_CAMERA},
        { EXIF_TAG_SUBJECT_DISTANCE_RANGE, EXIF_CATEGORY_IMAGE_TAKING_CONDITIONS},
        { EXIF_TAG_IMAGE_UNIQUE_ID      , EXIF_CATEGORY_IMAGE_DATA},
+#endif
        { -1, -1 }
 };
 #endif
@@ -274,11 +275,14 @@ eog_metadata_details_class_init (EogMetadataDetailsClass *klass)
        object_class->dispose = eog_metadata_details_dispose;
 }
 
-#ifdef HAVE_EXIF
+#ifdef HAVE_EXIF_
 static MetadataCategory
 get_exif_category (ExifEntry *entry)
 {
        MetadataCategory cat = EXIF_CATEGORY_OTHER;
+
+       return cat;
+#if 0
        int i;
 
        /* Some GPS tag IDs overlap with other ones, so check the IFD */
@@ -295,6 +299,7 @@ get_exif_category (ExifEntry *entry)
        }
 
        return cat;
+#endif
 }
 #endif
 
@@ -349,7 +354,7 @@ set_row_data (GtkTreeStore *store, char *path, char *parent, const char *attribu
        return path;
 }
 
-#ifdef HAVE_EXIF
+#ifdef HAVE_EXIF_
 
 static const char *
 eog_exif_entry_get_value (ExifEntry    *e,
@@ -531,7 +536,7 @@ exif_entry_cb (ExifEntry *entry, gpointer data)
 }
 #endif
 
-#ifdef HAVE_EXIF
+#ifdef HAVE_EXIF_
 static void
 exif_content_cb (ExifContent *content, gpointer data)
 {
@@ -573,7 +578,7 @@ eog_metadata_details_reset (EogMetadataDetails *details)
        }
 }
 
-#ifdef HAVE_EXIF
+#ifdef HAVE_EXIF_
 void
 eog_metadata_details_update (EogMetadataDetails *details, ExifData *data)
 {
diff --git a/src/eog-metadata-details.h b/src/eog-metadata-details.h
index 4f30299..0c66390 100644
--- a/src/eog-metadata-details.h
+++ b/src/eog-metadata-details.h
@@ -27,7 +27,7 @@
 #include <glib-object.h>
 #include <gtk/gtk.h>
 #if HAVE_EXIF
-#include <libexif/exif-data.h>
+#include <gexiv2/gexiv2.h>
 #endif
 #if HAVE_EXEMPI
 #include <exempi/xmp.h>
@@ -65,7 +65,7 @@ GtkWidget          *eog_metadata_details_new         (void);
 #if HAVE_EXIF
 G_GNUC_INTERNAL
 void                eog_metadata_details_update      (EogMetadataDetails *details,
-                                                     ExifData       *data);
+                                                     GExiv2Metadata       *data);
 #endif
 #if HAVE_EXEMPI
 G_GNUC_INTERNAL
diff --git a/src/eog-metadata-reader-jpg.c b/src/eog-metadata-reader-jpg.c
index 3b3f5a3..420a193 100644
--- a/src/eog-metadata-reader-jpg.c
+++ b/src/eog-metadata-reader-jpg.c
@@ -458,13 +458,19 @@ static gpointer
 eog_metadata_reader_jpg_get_exif_data (EogMetadataReaderJpg *emr)
 {
        EogMetadataReaderJpgPrivate *priv;
-       ExifData *data = NULL;
+       GExiv2Metadata *data = NULL;
 
        g_return_val_if_fail (EOG_IS_METADATA_READER (emr), NULL);
        priv = emr->priv;
 
        if (priv->exif_chunk != NULL) {
-               data = exif_data_new_from_data (priv->exif_chunk, priv->exif_len);
+               GError *error = NULL;
+               data = gexiv2_metadata_new ();
+               if (!gexiv2_metadata_from_app1_segment (data, priv->exif_chunk, priv->exif_len, &error)) {
+                       g_warning ("Failed to read exif data. %s", error->message);
+                       g_clear_error (&error);
+                       g_clear_object (&data);
+               }
        }
 
        return data;
@@ -526,23 +532,12 @@ eog_metadata_reader_jpg_get_icc_profile (EogMetadataReaderJpg *emr)
 
 #ifdef HAVE_EXIF
        if (!profile && priv->exif_chunk != NULL) {
-               ExifEntry *entry;
-               ExifByteOrder o;
                gint color_space;
-               ExifData *exif = eog_metadata_reader_jpg_get_exif_data (emr);
+               GExiv2Metadata *exif = eog_metadata_reader_jpg_get_exif_data (emr);
 
                if (!exif) return NULL;
 
-               o = exif_data_get_byte_order (exif);
-
-               entry = exif_data_get_entry (exif, EXIF_TAG_COLOR_SPACE);
-
-               if (entry == NULL) {
-                       exif_data_unref (exif);
-                       return NULL;
-               }
-
-               color_space = exif_get_short (entry->data, o);
+               color_space = gexiv2_metadata_get_tag_long (exif, "Exif.Photo.ColorSpace");
 
                switch (color_space) {
 #if EOG_METADATA_READER_JPG_GEN_PROFILE_FROM_EXIF_VALUES == 0
@@ -638,7 +633,7 @@ eog_metadata_reader_jpg_get_icc_profile (EogMetadataReaderJpg *emr)
 #endif
                }
 
-               exif_data_unref (exif);
+               g_object_unref (exif);
        }
 #endif
        return profile;
diff --git a/src/eog-metadata-reader.c b/src/eog-metadata-reader.c
index 959b59b..399558d 100644
--- a/src/eog-metadata-reader.c
+++ b/src/eog-metadata-reader.c
@@ -77,7 +77,7 @@ eog_metadata_reader_get_exif_chunk (EogMetadataReader *emr, guchar **data, guint
 }
 
 #ifdef HAVE_EXIF
-ExifData*
+GExiv2Metadata*
 eog_metadata_reader_get_exif_data (EogMetadataReader *emr)
 {
        return EOG_METADATA_READER_GET_INTERFACE (emr)->get_exif_data (emr);
diff --git a/src/eog-metadata-reader.h b/src/eog-metadata-reader.h
index 26788eb..83e92ce 100644
--- a/src/eog-metadata-reader.h
+++ b/src/eog-metadata-reader.h
@@ -89,7 +89,7 @@ void                 eog_metadata_reader_get_exif_chunk (EogMetadataReader *emr,
 
 #ifdef HAVE_EXIF
 G_GNUC_INTERNAL
-ExifData*         eog_metadata_reader_get_exif_data    (EogMetadataReader *emr);
+GExiv2Metadata*         eog_metadata_reader_get_exif_data      (EogMetadataReader *emr);
 #endif
 
 #ifdef HAVE_EXEMPI
diff --git a/src/eog-metadata-sidebar.c b/src/eog-metadata-sidebar.c
index b9131d1..5dc83cb 100644
--- a/src/eog-metadata-sidebar.c
+++ b/src/eog-metadata-sidebar.c
@@ -40,8 +40,7 @@
 #include "eog-window.h"
 
 #ifdef HAVE_EXIF
-#include <libexif/exif-data.h>
-#include <libexif/exif-tag.h>
+#include <gexiv2/gexiv2.h>
 #include "eog-exif-util.h"
 #endif
 
@@ -191,39 +190,39 @@ eog_metadata_sidebar_update_metadata_section (EogMetadataSidebar *sidebar)
        EogMetadataSidebarPrivate *priv = sidebar->priv;
 #if HAVE_EXIF
        EogImage *img = priv->image;
-       ExifData *exif_data = NULL;
+       GExiv2Metadata *exif_data = NULL;
 
        if (img) {
                exif_data = eog_image_get_exif_info (img);
        }
 
        eog_exif_util_set_label_text (GTK_LABEL (priv->aperture_label),
-                                     exif_data, EXIF_TAG_FNUMBER);
+                                     exif_data, "Exif.Photo.FNumber");
        eog_exif_util_set_label_text (GTK_LABEL (priv->exposure_label),
                                      exif_data,
-                                     EXIF_TAG_EXPOSURE_TIME);
+                                     "Exif.Photo.ExposureTime");
        eog_exif_util_set_focal_length_label_text (
                                       GTK_LABEL (priv->focallen_label),
                                       exif_data);
        eog_exif_util_set_label_text (GTK_LABEL (priv->iso_label),
                                      exif_data,
-                                     EXIF_TAG_ISO_SPEED_RATINGS);
+                                     "Exif.Photo.ISOSpeedRatings");
        eog_exif_util_set_label_text (GTK_LABEL (priv->metering_label),
                                      exif_data,
-                                     EXIF_TAG_METERING_MODE);
+                                     "Exif.Photo.MeteringMode");
        eog_exif_util_set_label_text (GTK_LABEL (priv->model_label),
-                                     exif_data, EXIF_TAG_MODEL);
+                                     exif_data, "Exif.Image.Model");
        eog_exif_util_format_datetime_label (GTK_LABEL (priv->date_label),
                                             exif_data,
-                                            EXIF_TAG_DATE_TIME_ORIGINAL,
+                                            "Exif.Photo.DateTimeOriginal",
                                             _("%a, %d %B %Y"));
        eog_exif_util_format_datetime_label (GTK_LABEL (priv->time_label),
                                             exif_data,
-                                            EXIF_TAG_DATE_TIME_ORIGINAL,
+                                            "Exif.Photo.DateTimeOriginal",
                                             _("%X"));
 
        /* exif_data_unref can handle NULL-values */
-       exif_data_unref(exif_data);
+       g_clear_object (&exif_data);
 #endif /* HAVE_EXIF */
 }
 #endif /* HAVE_METADATA */
diff --git a/src/eog-properties-dialog.c b/src/eog-properties-dialog.c
index 07507f0..334138a 100644
--- a/src/eog-properties-dialog.c
+++ b/src/eog-properties-dialog.c
@@ -280,7 +280,7 @@ pd_update_metadata_tab (EogPropertiesDialog *prop_dlg,
        EogPropertiesDialogPrivate *priv;
        GtkNotebook *notebook;
 #if HAVE_EXIF
-       ExifData    *exif_data;
+       GExiv2Metadata    *exif_data;
 #endif
 #if HAVE_EXEMPI
        XmpPtr      xmp_data;
@@ -325,37 +325,39 @@ pd_update_metadata_tab (EogPropertiesDialog *prop_dlg,
        }
 
 #if HAVE_EXIF
-       exif_data = (ExifData *) eog_image_get_exif_info (image);
+       exif_data = (GExiv2Metadata *) eog_image_get_exif_info (image);
 
        eog_exif_util_set_label_text (GTK_LABEL (priv->exif_aperture_label),
-                                     exif_data, EXIF_TAG_FNUMBER);
+                                     exif_data, "Exif.Photo.FNumber");
 
        eog_exif_util_set_label_text (GTK_LABEL (priv->exif_exposure_label),
-                                     exif_data, EXIF_TAG_EXPOSURE_TIME);
+                                     exif_data, "Exif.Photo.ExposureTime");
 
        eog_exif_util_set_focal_length_label_text (GTK_LABEL (priv->exif_focal_label), exif_data);
 
        eog_exif_util_set_label_text (GTK_LABEL (priv->exif_flash_label),
-                                     exif_data, EXIF_TAG_FLASH);
+                                     exif_data, "Exif.Photo.Flash");
 
        eog_exif_util_set_label_text (GTK_LABEL (priv->exif_iso_label),
-                                     exif_data, EXIF_TAG_ISO_SPEED_RATINGS);
+                                     exif_data, "Exif.Photo.ISOSpeedRatings");
 
 
        eog_exif_util_set_label_text (GTK_LABEL (priv->exif_metering_label),
-                                     exif_data, EXIF_TAG_METERING_MODE);
+                                     exif_data, "Exif.Photo.MeteringMode");
 
        eog_exif_util_set_label_text (GTK_LABEL (priv->exif_model_label),
-                                     exif_data, EXIF_TAG_MODEL);
+                                     exif_data, "Exif.Image.Model");
 
        eog_exif_util_set_label_text (GTK_LABEL (priv->exif_date_label),
-                                     exif_data, EXIF_TAG_DATE_TIME_ORIGINAL);
+                                     exif_data, "Exif.Photo.DateTimeOriginal");
 
+       /*
        eog_metadata_details_update (EOG_METADATA_DETAILS (priv->metadata_details),
                                 exif_data);
+                                */
 
        /* exif_data_unref can handle NULL-values */
-       exif_data_unref(exif_data);
+       g_clear_object (&exif_data);
 #endif
 
 #if HAVE_EXEMPI
diff --git a/src/eog-thumb-view.c b/src/eog-thumb-view.c
index 0878a76..b84493c 100644
--- a/src/eog-thumb-view.c
+++ b/src/eog-thumb-view.c
@@ -30,7 +30,7 @@
 
 #ifdef HAVE_EXIF
 #include "eog-exif-util.h"
-#include <libexif/exif-data.h>
+#include <gexiv2/gexiv2.h>
 #endif
 
 #include <gtk/gtk.h>
@@ -476,7 +476,7 @@ thumbview_get_tooltip_string (EogImage *image)
        const char *mime_str;
        gchar *tooltip_string;
 #ifdef HAVE_EXIF
-       ExifData *exif_data;
+       GExiv2Metadata *exif_data;
 #endif
 
        bytes = g_format_size (eog_image_get_bytes (image));
@@ -528,7 +528,7 @@ thumbview_get_tooltip_string (EogImage *image)
        }
 
 #ifdef HAVE_EXIF
-       exif_data = (ExifData *) eog_image_get_exif_info (image);
+       exif_data = (GExiv2Metadata *) eog_image_get_exif_info (image);
 
        if (exif_data) {
                gchar *extra_info, *tmp, *date;
@@ -537,7 +537,7 @@ thumbview_get_tooltip_string (EogImage *image)
                gchar time_buffer[32];
 
                date = eog_exif_util_format_date (
-                       eog_exif_data_get_value (exif_data, EXIF_TAG_DATE_TIME_ORIGINAL, time_buffer, 32));
+                       eog_exif_data_get_value (exif_data, "Exif.Photo.DateTimeOriginal", time_buffer, 32));
 
                if (date) {
                        extra_info = g_strdup_printf ("\n%s %s", _("Taken on"), date);
@@ -550,7 +550,7 @@ thumbview_get_tooltip_string (EogImage *image)
 
                        tooltip_string = tmp;
                }
-               exif_data_unref (exif_data);
+               g_object_unref (exif_data);
        }
 #endif
 


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