[gimp/metadata-improvements: 4/11] plug-ins: improve formatting of gps data in metadata-viewer.
- From: Jacob Boerema <jboerema src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/metadata-improvements: 4/11] plug-ins: improve formatting of gps data in metadata-viewer.
- Date: Tue, 1 Dec 2020 18:43:39 +0000 (UTC)
commit 34407a6b7e1cef63a0d3cbe21df06b1509c0ea13
Author: Jacob Boerema <jgboerema gmail com>
Date: Wed Nov 25 22:49:04 2020 -0500
plug-ins: improve formatting of gps data in metadata-viewer.
Adding metadata-tags to meson.build and Makefile.am for
the metadata-viewer since until now it was only used in
the metadata-editor.
The Exif gps metadata tags for longitude, latitude and
altitude get special handling to show them with more
precision and let the string parts be translated.
plug-ins/metadata/Makefile.am | 4 +-
plug-ins/metadata/meson.build | 5 +-
plug-ins/metadata/metadata-viewer.c | 138 ++++++++++++++++++++++++++++++++++--
3 files changed, 136 insertions(+), 11 deletions(-)
---
diff --git a/plug-ins/metadata/Makefile.am b/plug-ins/metadata/Makefile.am
index d7be32fe91..23e00f2c8d 100644
--- a/plug-ins/metadata/Makefile.am
+++ b/plug-ins/metadata/Makefile.am
@@ -40,7 +40,9 @@ metadata_editor_SOURCES = \
metadata-xml.h
metadata_viewer_SOURCES = \
- metadata-viewer.c
+ metadata-viewer.c \
+ metadata-tags.c \
+ metadata-tags.h
AM_CPPFLAGS = \
-I$(top_srcdir) \
diff --git a/plug-ins/metadata/meson.build b/plug-ins/metadata/meson.build
index 6ccdfc2e55..5f2353fcf0 100644
--- a/plug-ins/metadata/meson.build
+++ b/plug-ins/metadata/meson.build
@@ -43,6 +43,7 @@ plugin_name = 'metadata-viewer'
plugin_sources = [
'metadata-viewer.c',
+ 'metadata-tags.c',
]
if platform_windows
@@ -65,9 +66,7 @@ if platform_windows
endif
executable(plugin_name,
- [
- 'metadata-viewer.c',
- ],
+ plugin_sources,
include_directories: [ rootInclude, ],
dependencies: [
gtk3, gegl, gexiv2,
diff --git a/plug-ins/metadata/metadata-viewer.c b/plug-ins/metadata/metadata-viewer.c
index 3d7aa93e47..01ddc03625 100644
--- a/plug-ins/metadata/metadata-viewer.c
+++ b/plug-ins/metadata/metadata-viewer.c
@@ -30,6 +30,7 @@
#include "libgimp/stdplugins-intl.h"
+#include "metadata-tags.h"
#define PLUG_IN_PROC "plug-in-metadata-viewer"
#define PLUG_IN_BINARY "metadata-viewer"
@@ -107,6 +108,18 @@ static void metadata_dialog_append_tags (GExiv2Metadata *metadata,
gint tag_column,
gint value_column,
gboolean load_iptc);
+static void metadata_dialog_add_tag (GtkListStore *store,
+ GtkTreeIter iter,
+ gint tag_column,
+ gint value_column,
+ const gchar *tag,
+ const gchar *value);
+static void metadata_dialog_add_translated_tag (GExiv2Metadata *metadata,
+ GtkListStore *store,
+ GtkTreeIter iter,
+ gint tag_column,
+ gint value_column,
+ const gchar *tag);
static gchar * metadata_dialog_format_tag_value (GExiv2Metadata *metadata,
const gchar *tag,
gboolean truncate);
@@ -366,6 +379,40 @@ metadata_tag_is_string (const gchar *tag)
g_strcmp0 (tag_type, NULL) != 0);
}
+static void
+metadata_dialog_add_tag (GtkListStore *store,
+ GtkTreeIter iter,
+ gint tag_column,
+ gint value_column,
+ const gchar *tag,
+ const gchar *value)
+{
+ if (value)
+ {
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ tag_column, tag,
+ value_column, value,
+ -1);
+ }
+}
+
+static void
+metadata_dialog_add_translated_tag (GExiv2Metadata *metadata,
+ GtkListStore *store,
+ GtkTreeIter iter,
+ gint tag_column,
+ gint value_column,
+ const gchar *tag)
+{
+ gchar *value;
+
+ value = gexiv2_metadata_get_tag_interpreted_string (metadata, tag);
+ metadata_dialog_add_tag (store, iter, tag_column, value_column,
+ tag, gettext (value));
+ g_free (value);
+}
+
static void
metadata_dialog_append_tags (GExiv2Metadata *metadata,
gchar **tags,
@@ -377,6 +424,7 @@ metadata_dialog_append_tags (GExiv2Metadata *metadata,
GtkTreeIter iter;
const gchar *tag;
const gchar *last_tag = NULL;
+ gboolean gps_done = FALSE;
while ((tag = *tags++))
{
@@ -421,19 +469,95 @@ metadata_dialog_append_tags (GExiv2Metadata *metadata,
g_strfreev (values);
}
+ }
+ else if (! strcmp ("Exif.GPSInfo.GPSLongitude", tag) ||
+ ! strcmp ("Exif.GPSInfo.GPSLongitudeRef", tag) ||
+ ! strcmp ("Exif.GPSInfo.GPSLatitude", tag) ||
+ ! strcmp ("Exif.GPSInfo.GPSLatitudeRef", tag) ||
+ ! strcmp ("Exif.GPSInfo.GPSAltitude", tag) ||
+ ! strcmp ("Exif.GPSInfo.GPSAltitudeRef", tag))
+ {
+ /* We need special handling for some of the GPS tags to
+ * be able to show better values than the default. */
+ if (! gps_done)
+ {
+ gdouble lng, lat, alt;
+ gchar *str;
+ gchar *value;
+ if (gexiv2_metadata_get_gps_longitude (GEXIV2_METADATA (metadata),
+ &lng))
+ {
+ str = metadata_format_gps_longitude_latitude (lng);
+ metadata_dialog_add_tag (store, iter,
+ tag_column, value_column,
+ "Exif.GPSInfo.GPSLongitude",
+ str);
+ g_free (str);
+ }
+ metadata_dialog_add_translated_tag (metadata, store, iter,
+ tag_column, value_column,
+ "Exif.GPSInfo.GPSLongitudeRef");
+
+ if (gexiv2_metadata_get_gps_latitude (GEXIV2_METADATA (metadata),
+ &lat))
+ {
+ str = metadata_format_gps_longitude_latitude (lat);
+ metadata_dialog_add_tag (store, iter,
+ tag_column, value_column,
+ "Exif.GPSInfo.GPSLatitude",
+ str);
+ g_free (str);
+ }
+ metadata_dialog_add_translated_tag (metadata, store, iter,
+ tag_column, value_column,
+ "Exif.GPSInfo.GPSLatitudeRef");
+
+ if (gexiv2_metadata_get_gps_altitude (GEXIV2_METADATA (metadata),
+ &alt))
+ {
+ gchar *str2, *str3;
+
+ str = metadata_format_gps_altitude (alt, TRUE, _(" meter"));
+ str2 = metadata_format_gps_altitude (alt, FALSE, _(" feet"));
+ str3 = g_strdup_printf ("%s (%s)", str, str2);
+ metadata_dialog_add_tag (store, iter,
+ tag_column, value_column,
+ "Exif.GPSInfo.GPSAltitude",
+ str3);
+ g_free (str);
+ g_free (str2);
+ g_free (str3);
+ value = gexiv2_metadata_get_tag_string (metadata,
+ "Exif.GPSInfo.GPSAltitudeRef");
+
+ if (value)
+ {
+ gint index;
+
+ if (value[0] == '0')
+ index = 1;
+ else if (value[0] == '1')
+ index = 2;
+ else
+ index = 0;
+ metadata_dialog_add_tag (store, iter,
+ tag_column, value_column,
+ "Exif.GPSInfo.GPSAltitudeRef",
+ gettext (gpsaltref[index]));
+ g_free (value);
+ }
+ }
+ gps_done = TRUE;
+ }
}
else
{
value = metadata_dialog_format_tag_value (metadata, tag,
/* truncate = */ TRUE);
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- tag_column, tag,
- value_column, value,
- -1);
-
+ metadata_dialog_add_tag (store, iter,
+ tag_column, value_column,
+ tag, value);
g_free (value);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]