summaryrefslogtreecommitdiff
path: root/src/eom-exif-util.c
diff options
context:
space:
mode:
authorFelix Riemann <[email protected]>2011-12-19 18:20:30 +0100
committerraveit65 <[email protected]>2018-07-08 12:29:16 +0200
commitb1c0911213e74d91059aaa8442898e52e13368af (patch)
tree535bd586017c56856020abe18397fb579e3775b0 /src/eom-exif-util.c
parent28fbd143cb1752c3b8fd68b7206e1df679830a8b (diff)
downloadeom-b1c0911213e74d91059aaa8442898e52e13368af.tar.bz2
eom-b1c0911213e74d91059aaa8442898e52e13368af.tar.xz
Make Exif/XMP summaries available as sidebar
Makes the data from the properties dialog available as a sidebar. A button opens the details tab in the properties dialog. This is graphically still a bit roughg. Committing it in hopes to get some early feedback. https://bugzilla.gnome.org/show_bug.cgi?id=616438 origin commit: https://git.gnome.org/browse/eog/commit/?id=7ac112f
Diffstat (limited to 'src/eom-exif-util.c')
-rw-r--r--src/eom-exif-util.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/eom-exif-util.c b/src/eom-exif-util.c
index 8ff9636..8bc4afd 100644
--- a/src/eom-exif-util.c
+++ b/src/eom-exif-util.c
@@ -35,6 +35,7 @@
#include <time.h>
#include "eom-exif-util.h"
+#include "eom-util.h"
#include <string.h>
#include <glib/gi18n.h>
@@ -192,6 +193,96 @@ eom_exif_util_format_date (const gchar *date)
return new_date;
}
+void
+eom_exif_util_set_label_text (GtkLabel *label,
+ EomExifData *exif_data,
+ gint tag_id)
+{
+ gchar exif_buffer[512];
+ const gchar *buf_ptr;
+ gchar *label_text = NULL;
+
+ g_return_if_fail (GTK_IS_LABEL (label));
+
+ if (exif_data) {
+ buf_ptr = eom_exif_data_get_value (exif_data, tag_id,
+ exif_buffer, 512);
+
+ if (tag_id == EXIF_TAG_DATE_TIME_ORIGINAL && buf_ptr)
+ label_text = eom_exif_util_format_date (buf_ptr);
+ else
+ label_text = eom_util_make_valid_utf8 (buf_ptr);
+ }
+
+ gtk_label_set_text (label, label_text);
+ g_free (label_text);
+}
+
+void
+eom_exif_util_set_focal_length_label_text (GtkLabel *label,
+ EomExifData *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;
+
+ /* TRANSLATORS: This is the actual focal length used when
+ the image was taken.*/
+ fl_text = g_strdup_printf (_("%.1f (lens)"), f_val);
+
+ }
+ 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. */
+ fl35_text = g_strdup_printf(_("%.1f (35mm film)"),(float)s_val);
+ }
+
+ if (fl_text) {
+ if (fl35_text) {
+ gchar *merged_txt;
+
+ merged_txt = g_strconcat (fl35_text,", ", fl_text, NULL);
+ gtk_label_set_text (label, merged_txt);
+ g_free (merged_txt);
+ } else {
+ gtk_label_set_text (label, fl_text);
+ }
+ } else {
+ /* This will also clear the label if no ExifData was supplied */
+ gtk_label_set_text (label, fl35_text);
+ }
+
+ g_free (fl35_text);
+ g_free (fl_text);
+}
+
/**
* eom_exif_data_get_value:
* @exif_data: pointer to an <structname>ExifData</structname> struct