summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2007-07-24 10:08:34 +0000
committerAlexander Larsson <alexl@src.gnome.org>2007-07-24 10:08:34 +0000
commit39e570a71733027906ac972a3f146738e3fbe78e (patch)
treede1f2fa1851e03ed3b13ea7f210e2284ce2d0105
parent5e29db8a25b2f16d9181952bcb69e1fa51a1410f (diff)
downloadnautilus-39e570a71733027906ac972a3f146738e3fbe78e.tar.gz
Optionally support XMP metadata in images via exemi (#451380) Patch from
2007-07-24 Alexander Larsson <alexl@redhat.com> * configure.in: * src/Makefile.am: * src/nautilus-image-properties-page.c: * src/nautilus-main.c: Optionally support XMP metadata in images via exemi (#451380) Patch from Hubert Figuiere svn path=/trunk/; revision=13021
-rw-r--r--ChangeLog9
-rw-r--r--configure.in13
-rw-r--r--src/Makefile.am2
-rw-r--r--src/nautilus-image-properties-page.c103
-rw-r--r--src/nautilus-main.c8
5 files changed, 131 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index feb55e6c5..60888b1d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2007-07-24 Alexander Larsson <alexl@redhat.com>
+ * configure.in:
+ * src/Makefile.am:
+ * src/nautilus-image-properties-page.c:
+ * src/nautilus-main.c:
+ Optionally support XMP metadata in images via exemi (#451380)
+ Patch from Hubert Figuiere
+
+2007-07-24 Alexander Larsson <alexl@redhat.com>
+
* src/nautilus-connect-server-dialog.c:
(nautilus_connect_server_dialog_init):
React on enter key (#449591)
diff --git a/configure.in b/configure.in
index 23184d926..10cd48fe7 100644
--- a/configure.in
+++ b/configure.in
@@ -22,6 +22,7 @@ m4_define(startup_notification_minver, 0.8)
m4_define(exif_minver, 0.5.12)
m4_define(beagle_minver, 0.0.12)
m4_define(tracker_minver, 0.0.1)
+m4_define(exempi_minver, 1.99.2)
dnl 1. If the library code has changed at all since last release, then increment revision.
dnl 2. If any interfaces have been added, then increment current and set revision to 0.
@@ -260,6 +261,18 @@ AC_SUBST(EXIF_CFLAGS)
AC_SUBST(EXIF_LIBS)
dnl ==========================================================================
+
+dnl exempi checking
+
+PKG_CHECK_MODULES(EXEMPI, exempi-2.0 >= exempi_minver, [
+ AM_CONDITIONAL(HAVE_EXEMPI, true)
+ AC_DEFINE(HAVE_EXEMPI, 1, [Define to enable XMP support])
+ ], [AM_CONDITIONAL(HAVE_EXEMPI, false)])
+
+AC_SUBST(EXEMPI_CFLAGS)
+AC_SUBST(EXEMPI_LIBS)
+
+dnl ==========================================================================
dnl search implementations
dnl ****************************
diff --git a/src/Makefile.am b/src/Makefile.am
index 3f185c4b0..63a3c8b55 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,6 +14,7 @@ INCLUDES = \
-I$(top_builddir)/libnautilus-private \
$(CORE_CFLAGS) \
$(EXIF_CFLAGS) \
+ $(EXEMPI_CFLAGS) \
-DDATADIR=\""$(datadir)"\" \
-DLIBDIR=\""$(libdir)"\" \
-DNAUTILUS_DATADIR=\""$(datadir)/nautilus"\" \
@@ -30,6 +31,7 @@ LDADD =\
$(top_builddir)/libnautilus-private/libnautilus-private.la \
$(CORE_LIBS) \
$(EXIF_LIBS) \
+ $(EXEMPI_LIBS) \
$(POPT_LIBS) \
$(NULL)
diff --git a/src/nautilus-image-properties-page.c b/src/nautilus-image-properties-page.c
index d47537496..87441035b 100644
--- a/src/nautilus-image-properties-page.c
+++ b/src/nautilus-image-properties-page.c
@@ -2,6 +2,7 @@
/*
* Copyright (C) 2004 Red Hat, Inc
+ * Copyright (c) 2007 Novell, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -19,6 +20,7 @@
* Boston, MA 02111-1307, USA.
*
* Author: Alexander Larsson <alexl@redhat.com>
+ * XMP support by Hubert Figuiere <hfiguiere@novell.com>
*/
#include <config.h>
@@ -38,6 +40,18 @@
#include <libexif/exif-data.h>
#include <libexif/exif-ifd.h>
#include <libexif/exif-loader.h>
+ #define ENABLE_METADATA 1
+#endif
+#ifdef HAVE_EXEMPI
+ #include <exempi/xmp.h>
+ #include <exempi/xmpconsts.h>
+ #include <libgnomevfs/gnome-vfs-utils.h>
+ #if !defined(ENABLE_METADATA)
+ #define ENABLE_METADATA 1
+ #endif
+#endif
+
+#ifdef ENABLE_METADATA
#include <gtk/gtkliststore.h>
#include <gtk/gtktreestore.h>
#include <gtk/gtktreeview.h>
@@ -61,6 +75,9 @@ struct NautilusImagePropertiesPageDetails {
#ifdef HAVE_EXIF
ExifLoader *exifldr;
#endif /*HAVE_EXIF*/
+#ifdef HAVE_EXEMPI
+ XmpPtr xmp;
+#endif
};
#ifdef HAVE_EXIF
@@ -230,19 +247,69 @@ append_exifdata_string (ExifData *exifdata, GString *string)
}
append_tag_value_pair (string, exifdata, EXIF_TAG_EXPOSURE_TIME, _("Exposure Time"));
- append_tag_value_pair (string, exifdata, EXIF_TAG_EXPOSURE_PROGRAM, _("Exposure Program"));
append_tag_value_pair (string, exifdata, EXIF_TAG_APERTURE_VALUE, _("Aperture Value"));
- append_tag_value_pair (string, exifdata, EXIF_TAG_METERING_MODE, _("Metering Mode"));
+ append_tag_value_pair (string, exifdata, EXIF_TAG_ISO_SPEED_RATINGS, _("ISO Speed Rating"));
append_tag_value_pair (string, exifdata, EXIF_TAG_FLASH,_("Flash Fired"));
+ append_tag_value_pair (string, exifdata, EXIF_TAG_METERING_MODE, _("Metering Mode"));
+ append_tag_value_pair (string, exifdata, EXIF_TAG_EXPOSURE_PROGRAM, _("Exposure Program"));
append_tag_value_pair (string, exifdata, EXIF_TAG_FOCAL_LENGTH,_("Focal Length"));
- append_tag_value_pair (string, exifdata, EXIF_TAG_SHUTTER_SPEED_VALUE, _("Shutter Speed"));
- append_tag_value_pair (string, exifdata, EXIF_TAG_ISO_SPEED_RATINGS, _("ISO Speed Rating"));
append_tag_value_pair (string, exifdata, EXIF_TAG_SOFTWARE, _("Software"));
}
}
#endif /*HAVE_EXIF*/
+
+#ifdef HAVE_EXEMPI
+static void
+append_xmp_value_pair(GString *string, XmpPtr xmp, const char * ns, const char * propname, gchar* descr)
+{
+ uint32_t options;
+ XmpStringPtr value = xmp_string_new();
+ if(xmp_get_property_and_bits(xmp, ns, propname, value, &options)) {
+ if(XMP_IS_PROP_SIMPLE(options)) {
+ g_string_append_printf(string, "<b>%s:</b> %s\n", descr, xmp_string_cstr(value));
+ }
+ else if(XMP_IS_PROP_ARRAY(options)) {
+ XmpIteratorPtr iter = xmp_iterator_new(xmp, ns, propname, XMP_ITER_JUSTLEAFNODES);
+ if(iter) {
+ bool first = true;
+ g_string_append_printf(string, "<b>%s:</b> ", descr);
+ while (xmp_iterator_next(iter, NULL, NULL, value, &options)
+ && !XMP_IS_PROP_QUALIFIER(options)) {
+ if(!first) {
+ g_string_append_printf(string, ", ");
+ }
+ else {
+ first = false;
+ }
+ g_string_append_printf(string, "%s", xmp_string_cstr(value));
+ }
+ xmp_iterator_free(iter);
+ g_string_append_printf(string, "\n");
+ }
+ }
+ }
+ xmp_string_free(value);
+}
+
+
+static void
+append_xmpdata_string(XmpPtr xmp, GString *string)
+{
+ if(xmp != NULL) {
+ append_xmp_value_pair(string, xmp, NS_IPTC4XMP, "Location", _("Location"));
+ append_xmp_value_pair(string, xmp, NS_DC, "description", _("Description"));
+ append_xmp_value_pair(string, xmp, NS_DC, "subject", _("Keywords"));
+ append_xmp_value_pair(string, xmp, NS_DC, "creator", _("Creator"));
+ append_xmp_value_pair(string, xmp, NS_DC, "rights", _("Copyright"));
+ append_xmp_value_pair(string, xmp, NS_XAP,"Rating", _("Rating"));
+ /* TODO add CC licenses */
+ }
+}
+#endif
+
+
static void
load_finished (NautilusImagePropertiesPage *page)
{
@@ -272,6 +339,9 @@ load_finished (NautilusImagePropertiesPage *page)
#ifdef HAVE_EXIF
append_exifdata_string (exif_loader_get_data (page->details->exifldr), str);
#endif /*HAVE_EXIF*/
+#ifdef HAVE_EXEMPI
+ append_xmpdata_string(page->details->xmp, str);
+#endif /*HAVE EXEMPI*/
gtk_label_set_markup (GTK_LABEL (page->details->resolution), str->str);
gtk_label_set_selectable (GTK_LABEL (page->details->resolution), TRUE);
@@ -291,6 +361,12 @@ load_finished (NautilusImagePropertiesPage *page)
page->details->exifldr = NULL;
}
#endif /*HAVE_EXIF*/
+#ifdef HAVE_EXEMPI
+ if (page->details->xmp != NULL) {
+ xmp_free(page->details->xmp);
+ page->details->xmp = NULL;
+ }
+#endif
if (page->details->vfs_handle != NULL) {
gnome_vfs_async_close (page->details->vfs_handle, file_closed_callback, NULL);
@@ -402,6 +478,25 @@ load_location (NautilusImagePropertiesPage *page,
if (page->details->vfs_handle != NULL)
gnome_vfs_async_cancel (page->details->vfs_handle);
+#ifdef HAVE_EXEMPI
+ {
+ /* Current Exempi does not support setting custom IO to be able to use Gnome-vfs */
+ /* So it will only work with local files. Future version might remove this limitation */
+ XmpFilePtr xf;
+ gchar* localname;
+ localname = gnome_vfs_get_local_path_from_uri (location);
+ if(localname) {
+ xf = xmp_files_open_new(localname, 0);
+ page->details->xmp = xmp_files_get_new_xmp(xf); /* only load when loading */
+ xmp_files_close(xf, 0);
+ g_free(localname);
+ }
+ else {
+ page->details->xmp = NULL;
+ }
+ }
+#endif /*HAVE_EXEMPI*/
+
gnome_vfs_async_open (&page->details->vfs_handle,
location,
GNOME_VFS_OPEN_READ,
diff --git a/src/nautilus-main.c b/src/nautilus-main.c
index 61c43d9df..947c208d9 100644
--- a/src/nautilus-main.c
+++ b/src/nautilus-main.c
@@ -63,6 +63,10 @@
#include <string.h>
#include <unistd.h>
+#ifdef HAVE_EXEMPI
+#include <exempi/xmp.h>
+#endif
+
/* Keeps track of everyone who wants the main event loop kept active */
static GSList *event_loop_registrants;
@@ -433,6 +437,10 @@ main (int argc, char *argv[])
g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
+#ifdef HAVE_EXEMPI
+ xmp_init();
+#endif
+
program = gnome_program_init ("nautilus", VERSION,
LIBGNOMEUI_MODULE, argc, argv,
GNOME_PROGRAM_STANDARD_PROPERTIES,