Skip to content

Commit b1c0911

Browse files
fxriraveit65
authored andcommitted
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
1 parent 28fbd14 commit b1c0911

File tree

8 files changed

+851
-121
lines changed

8 files changed

+851
-121
lines changed

src/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ NOINST_H_FILES = \
2323
eom-config-keys.h \
2424
eom-image-jpeg.h \
2525
eom-image-private.h \
26+
eom-metadata-sidebar.h \
2627
eom-uri-converter.h \
2728
eom-metadata-reader.h \
2829
eom-metadata-reader-jpg.h \
@@ -80,6 +81,7 @@ libeom_c_files = \
8081
eom-scroll-view.c \
8182
eom-thumb-view.c \
8283
eom-list-store.c \
84+
eom-metadata-sidebar.c \
8385
eom-thumbnail.c \
8486
eom-job-queue.c \
8587
eom-jobs.c \

src/eom-exif-util.c

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <time.h>
3636

3737
#include "eom-exif-util.h"
38+
#include "eom-util.h"
3839

3940
#include <string.h>
4041
#include <glib/gi18n.h>
@@ -192,6 +193,96 @@ eom_exif_util_format_date (const gchar *date)
192193
return new_date;
193194
}
194195

196+
void
197+
eom_exif_util_set_label_text (GtkLabel *label,
198+
EomExifData *exif_data,
199+
gint tag_id)
200+
{
201+
gchar exif_buffer[512];
202+
const gchar *buf_ptr;
203+
gchar *label_text = NULL;
204+
205+
g_return_if_fail (GTK_IS_LABEL (label));
206+
207+
if (exif_data) {
208+
buf_ptr = eom_exif_data_get_value (exif_data, tag_id,
209+
exif_buffer, 512);
210+
211+
if (tag_id == EXIF_TAG_DATE_TIME_ORIGINAL && buf_ptr)
212+
label_text = eom_exif_util_format_date (buf_ptr);
213+
else
214+
label_text = eom_util_make_valid_utf8 (buf_ptr);
215+
}
216+
217+
gtk_label_set_text (label, label_text);
218+
g_free (label_text);
219+
}
220+
221+
void
222+
eom_exif_util_set_focal_length_label_text (GtkLabel *label,
223+
EomExifData *exif_data)
224+
{
225+
ExifEntry *entry = NULL, *entry35mm = NULL;
226+
ExifByteOrder byte_order;
227+
gfloat f_val = 0.0;
228+
gchar *fl_text = NULL,*fl35_text = NULL;
229+
230+
/* If no ExifData is supplied the label will be
231+
* cleared later as fl35_text is NULL. */
232+
if (exif_data != NULL) {
233+
entry = exif_data_get_entry (exif_data, EXIF_TAG_FOCAL_LENGTH);
234+
entry35mm = exif_data_get_entry (exif_data,
235+
EXIF_TAG_FOCAL_LENGTH_IN_35MM_FILM);
236+
byte_order = exif_data_get_byte_order (exif_data);
237+
}
238+
239+
if (entry && G_LIKELY (entry->format == EXIF_FORMAT_RATIONAL)) {
240+
ExifRational value;
241+
242+
/* Decode value by hand as libexif is not necessarily returning
243+
* it in the format we want it to be.
244+
*/
245+
value = exif_get_rational (entry->data, byte_order);
246+
/* Guard against div by zero */
247+
if (G_LIKELY(value.denominator != 0))
248+
f_val = (gfloat)value.numerator/
249+
(gfloat)value.denominator;
250+
251+
/* TRANSLATORS: This is the actual focal length used when
252+
the image was taken.*/
253+
fl_text = g_strdup_printf (_("%.1f (lens)"), f_val);
254+
255+
}
256+
if (entry35mm && G_LIKELY (entry35mm->format == EXIF_FORMAT_SHORT)) {
257+
ExifShort s_val;
258+
259+
s_val = exif_get_short (entry35mm->data, byte_order);
260+
261+
/* Print as float to get a similar look as above. */
262+
/* TRANSLATORS: This is the equivalent focal length assuming
263+
a 35mm film camera. */
264+
fl35_text = g_strdup_printf(_("%.1f (35mm film)"),(float)s_val);
265+
}
266+
267+
if (fl_text) {
268+
if (fl35_text) {
269+
gchar *merged_txt;
270+
271+
merged_txt = g_strconcat (fl35_text,", ", fl_text, NULL);
272+
gtk_label_set_text (label, merged_txt);
273+
g_free (merged_txt);
274+
} else {
275+
gtk_label_set_text (label, fl_text);
276+
}
277+
} else {
278+
/* This will also clear the label if no ExifData was supplied */
279+
gtk_label_set_text (label, fl35_text);
280+
}
281+
282+
g_free (fl35_text);
283+
g_free (fl_text);
284+
}
285+
195286
/**
196287
* eom_exif_data_get_value:
197288
* @exif_data: pointer to an <structname>ExifData</structname> struct

src/eom-exif-util.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,29 @@
2929

3030
#include <glib.h>
3131
#include <glib-object.h>
32+
#include <gtk/gtk.h>
3233
#include <libexif/exif-data.h>
3334

3435
G_BEGIN_DECLS
3536

3637
#define EOM_TYPE_EXIF_DATA eom_exif_data_get_type()
3738

38-
gchar* eom_exif_util_format_date (const gchar *date);
39+
gchar *eom_exif_util_format_date (const gchar *date);
40+
void eom_exif_util_set_label_text (GtkLabel *label,
41+
ExifData *exif_data,
42+
gint tag_id);
3943

40-
const gchar *eom_exif_data_get_value (ExifData *exif_data, gint tag_id, gchar *buffer, guint buf_size);
44+
void eom_exif_util_set_focal_length_label_text (GtkLabel *label,
45+
ExifData *exif_data);
46+
47+
const gchar *eom_exif_data_get_value (ExifData *exif_data,
48+
gint tag_id, gchar *buffer,
49+
guint buf_size);
4150

4251
GType eom_exif_data_get_type (void) G_GNUC_CONST;
4352

44-
ExifData * eom_exif_data_copy (ExifData *data);
45-
void eom_exif_data_free (ExifData *data);
53+
ExifData *eom_exif_data_copy (ExifData *data);
54+
void eom_exif_data_free (ExifData *data);
4655

4756
G_END_DECLS
4857

0 commit comments

Comments
 (0)