diff options
Diffstat (limited to '')
-rw-r--r-- | plug-ins/metadata/Makefile.am | 80 | ||||
-rw-r--r-- | plug-ins/metadata/Makefile.in | 1110 | ||||
-rw-r--r-- | plug-ins/metadata/metadata-editor.c | 5779 | ||||
-rw-r--r-- | plug-ins/metadata/metadata-editor.h | 27 | ||||
-rw-r--r-- | plug-ins/metadata/metadata-impexp.c | 244 | ||||
-rw-r--r-- | plug-ins/metadata/metadata-impexp.h | 30 | ||||
-rw-r--r-- | plug-ins/metadata/metadata-misc.h | 70 | ||||
-rw-r--r-- | plug-ins/metadata/metadata-tags.c | 408 | ||||
-rw-r--r-- | plug-ins/metadata/metadata-tags.h | 236 | ||||
-rw-r--r-- | plug-ins/metadata/metadata-viewer.c | 402 | ||||
-rw-r--r-- | plug-ins/metadata/metadata-xml.c | 1179 | ||||
-rw-r--r-- | plug-ins/metadata/metadata-xml.h | 98 |
12 files changed, 9663 insertions, 0 deletions
diff --git a/plug-ins/metadata/Makefile.am b/plug-ins/metadata/Makefile.am new file mode 100644 index 0000000..d7be32f --- /dev/null +++ b/plug-ins/metadata/Makefile.am @@ -0,0 +1,80 @@ +## Process this file with automake to produce Makefile.in + +if OS_WIN32 +mwindows = -mwindows +else +libm = -lm +endif + +libgimpui = $(top_builddir)/libgimp/libgimpui-$(GIMP_API_VERSION).la +libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la +libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la +libgimp = $(top_builddir)/libgimp/libgimp-$(GIMP_API_VERSION).la +libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la +libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la +libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la + +if HAVE_WINDRES +include $(top_srcdir)/build/windows/gimprc-plug-ins.rule +metadata_editor_RC = metadata-editor.rc.o +metadata_viewer_RC = metadata-viewer.rc.o +endif + +AM_LDFLAGS = $(mwindows) + +me_libexecdir = $(gimpplugindir)/plug-ins/metadata-editor +mv_libexecdir = $(gimpplugindir)/plug-ins/metadata-viewer + +me_libexec_PROGRAMS = metadata-editor +mv_libexec_PROGRAMS = metadata-viewer + +metadata_editor_SOURCES = \ + metadata-editor.c \ + metadata-editor.h \ + metadata-impexp.c \ + metadata-impexp.h \ + metadata-misc.h \ + metadata-tags.c \ + metadata-tags.h \ + metadata-xml.c \ + metadata-xml.h + +metadata_viewer_SOURCES = \ + metadata-viewer.c + +AM_CPPFLAGS = \ + -I$(top_srcdir) \ + $(GTK_CFLAGS) \ + $(GEGL_CFLAGS) \ + -I$(includedir) + +metadata_viewer_LDADD = \ + $(libm) \ + $(libgimpui) \ + $(libgimpwidgets) \ + $(libgimpconfig) \ + $(libgimp) \ + $(libgimpcolor) \ + $(libgimpmath) \ + $(libgimpbase) \ + $(GTK_LIBS) \ + $(GEXIV2_LIBS) \ + $(RT_LIBS) \ + $(INTLLIBS) \ + $(metadata_viewer_RC) + +metadata_editor_LDADD = \ + $(libm) \ + $(libgimpui) \ + $(libgimpwidgets) \ + $(libgimpconfig) \ + $(libgimp) \ + $(libgimpcolor) \ + $(libgimpmath) \ + $(libgimpbase) \ + $(GTK_LIBS) \ + $(GEXIV2_LIBS) \ + $(RT_LIBS) \ + $(INTLLIBS) \ + $(metadata_editor_RC) + diff --git a/plug-ins/metadata/Makefile.in b/plug-ins/metadata/Makefile.in new file mode 100644 index 0000000..6a4fff1 --- /dev/null +++ b/plug-ins/metadata/Makefile.in @@ -0,0 +1,1110 @@ +# Makefile.in generated by automake 1.16.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2020 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Version resources for Microsoft Windows + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +me_libexec_PROGRAMS = metadata-editor$(EXEEXT) +mv_libexec_PROGRAMS = metadata-viewer$(EXEEXT) +subdir = plug-ins/metadata +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4macros/gtk-doc.m4 \ + $(top_srcdir)/m4macros/intltool.m4 \ + $(top_srcdir)/m4macros/libtool.m4 \ + $(top_srcdir)/m4macros/ltoptions.m4 \ + $(top_srcdir)/m4macros/ltsugar.m4 \ + $(top_srcdir)/m4macros/ltversion.m4 \ + $(top_srcdir)/m4macros/lt~obsolete.m4 \ + $(top_srcdir)/acinclude.m4 $(top_srcdir)/m4macros/alsa.m4 \ + $(top_srcdir)/m4macros/ax_compare_version.m4 \ + $(top_srcdir)/m4macros/ax_cxx_compile_stdcxx.m4 \ + $(top_srcdir)/m4macros/ax_gcc_func_attribute.m4 \ + $(top_srcdir)/m4macros/ax_prog_cc_for_build.m4 \ + $(top_srcdir)/m4macros/ax_prog_perl_version.m4 \ + $(top_srcdir)/m4macros/detectcflags.m4 \ + $(top_srcdir)/m4macros/pythondev.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(me_libexecdir)" \ + "$(DESTDIR)$(mv_libexecdir)" +PROGRAMS = $(me_libexec_PROGRAMS) $(mv_libexec_PROGRAMS) +am_metadata_editor_OBJECTS = metadata-editor.$(OBJEXT) \ + metadata-impexp.$(OBJEXT) metadata-tags.$(OBJEXT) \ + metadata-xml.$(OBJEXT) +metadata_editor_OBJECTS = $(am_metadata_editor_OBJECTS) +am__DEPENDENCIES_1 = +metadata_editor_DEPENDENCIES = $(am__DEPENDENCIES_1) $(libgimpui) \ + $(libgimpwidgets) $(libgimpconfig) $(libgimp) $(libgimpcolor) \ + $(libgimpmath) $(libgimpbase) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(metadata_editor_RC) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +am_metadata_viewer_OBJECTS = metadata-viewer.$(OBJEXT) +metadata_viewer_OBJECTS = $(am_metadata_viewer_OBJECTS) +metadata_viewer_DEPENDENCIES = $(am__DEPENDENCIES_1) $(libgimpui) \ + $(libgimpwidgets) $(libgimpconfig) $(libgimp) $(libgimpcolor) \ + $(libgimpmath) $(libgimpbase) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(metadata_viewer_RC) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/metadata-editor.Po \ + ./$(DEPDIR)/metadata-impexp.Po ./$(DEPDIR)/metadata-tags.Po \ + ./$(DEPDIR)/metadata-viewer.Po ./$(DEPDIR)/metadata-xml.Po +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(metadata_editor_SOURCES) $(metadata_viewer_SOURCES) +DIST_SOURCES = $(metadata_editor_SOURCES) $(metadata_viewer_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(top_srcdir)/build/windows/gimprc-plug-ins.rule \ + $(top_srcdir)/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +AA_LIBS = @AA_LIBS@ +ACLOCAL = @ACLOCAL@ +ALLOCA = @ALLOCA@ +ALL_LINGUAS = @ALL_LINGUAS@ +ALSA_CFLAGS = @ALSA_CFLAGS@ +ALSA_LIBS = @ALSA_LIBS@ +ALTIVEC_EXTRA_CFLAGS = @ALTIVEC_EXTRA_CFLAGS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +APPSTREAM_UTIL = @APPSTREAM_UTIL@ +AR = @AR@ +AS = @AS@ +ATK_CFLAGS = @ATK_CFLAGS@ +ATK_LIBS = @ATK_LIBS@ +ATK_REQUIRED_VERSION = @ATK_REQUIRED_VERSION@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BABL_CFLAGS = @BABL_CFLAGS@ +BABL_LIBS = @BABL_LIBS@ +BABL_REQUIRED_VERSION = @BABL_REQUIRED_VERSION@ +BUG_REPORT_URL = @BUG_REPORT_URL@ +BUILD_EXEEXT = @BUILD_EXEEXT@ +BUILD_OBJEXT = @BUILD_OBJEXT@ +BZIP2_LIBS = @BZIP2_LIBS@ +CAIRO_CFLAGS = @CAIRO_CFLAGS@ +CAIRO_LIBS = @CAIRO_LIBS@ +CAIRO_PDF_CFLAGS = @CAIRO_PDF_CFLAGS@ +CAIRO_PDF_LIBS = @CAIRO_PDF_LIBS@ +CAIRO_PDF_REQUIRED_VERSION = @CAIRO_PDF_REQUIRED_VERSION@ +CAIRO_REQUIRED_VERSION = @CAIRO_REQUIRED_VERSION@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CC_FOR_BUILD = @CC_FOR_BUILD@ +CC_VERSION = @CC_VERSION@ +CFLAGS = @CFLAGS@ +CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@ +CPP_FOR_BUILD = @CPP_FOR_BUILD@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DESKTOP_DATADIR = @DESKTOP_DATADIR@ +DESKTOP_FILE_VALIDATE = @DESKTOP_FILE_VALIDATE@ +DLLTOOL = @DLLTOOL@ +DOC_SHOOTER = @DOC_SHOOTER@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FILE_AA = @FILE_AA@ +FILE_EXR = @FILE_EXR@ +FILE_HEIF = @FILE_HEIF@ +FILE_JP2_LOAD = @FILE_JP2_LOAD@ +FILE_MNG = @FILE_MNG@ +FILE_PDF_SAVE = @FILE_PDF_SAVE@ +FILE_PS = @FILE_PS@ +FILE_WMF = @FILE_WMF@ +FILE_XMC = @FILE_XMC@ +FILE_XPM = @FILE_XPM@ +FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@ +FONTCONFIG_LIBS = @FONTCONFIG_LIBS@ +FONTCONFIG_REQUIRED_VERSION = @FONTCONFIG_REQUIRED_VERSION@ +FREETYPE2_REQUIRED_VERSION = @FREETYPE2_REQUIRED_VERSION@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GDBUS_CODEGEN = @GDBUS_CODEGEN@ +GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@ +GDK_PIXBUF_CSOURCE = @GDK_PIXBUF_CSOURCE@ +GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@ +GDK_PIXBUF_REQUIRED_VERSION = @GDK_PIXBUF_REQUIRED_VERSION@ +GEGL = @GEGL@ +GEGL_CFLAGS = @GEGL_CFLAGS@ +GEGL_LIBS = @GEGL_LIBS@ +GEGL_MAJOR_MINOR_VERSION = @GEGL_MAJOR_MINOR_VERSION@ +GEGL_REQUIRED_VERSION = @GEGL_REQUIRED_VERSION@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GEXIV2_CFLAGS = @GEXIV2_CFLAGS@ +GEXIV2_LIBS = @GEXIV2_LIBS@ +GEXIV2_REQUIRED_VERSION = @GEXIV2_REQUIRED_VERSION@ +GIMP_API_VERSION = @GIMP_API_VERSION@ +GIMP_APP_VERSION = @GIMP_APP_VERSION@ +GIMP_BINARY_AGE = @GIMP_BINARY_AGE@ +GIMP_COMMAND = @GIMP_COMMAND@ +GIMP_DATA_VERSION = @GIMP_DATA_VERSION@ +GIMP_FULL_NAME = @GIMP_FULL_NAME@ +GIMP_INTERFACE_AGE = @GIMP_INTERFACE_AGE@ +GIMP_MAJOR_VERSION = @GIMP_MAJOR_VERSION@ +GIMP_MICRO_VERSION = @GIMP_MICRO_VERSION@ +GIMP_MINOR_VERSION = @GIMP_MINOR_VERSION@ +GIMP_MKENUMS = @GIMP_MKENUMS@ +GIMP_MODULES = @GIMP_MODULES@ +GIMP_PACKAGE_REVISION = @GIMP_PACKAGE_REVISION@ +GIMP_PKGCONFIG_VERSION = @GIMP_PKGCONFIG_VERSION@ +GIMP_PLUGINS = @GIMP_PLUGINS@ +GIMP_PLUGIN_VERSION = @GIMP_PLUGIN_VERSION@ +GIMP_REAL_VERSION = @GIMP_REAL_VERSION@ +GIMP_SYSCONF_VERSION = @GIMP_SYSCONF_VERSION@ +GIMP_TOOL_VERSION = @GIMP_TOOL_VERSION@ +GIMP_UNSTABLE = @GIMP_UNSTABLE@ +GIMP_USER_VERSION = @GIMP_USER_VERSION@ +GIMP_VERSION = @GIMP_VERSION@ +GIO_CFLAGS = @GIO_CFLAGS@ +GIO_LIBS = @GIO_LIBS@ +GIO_UNIX_CFLAGS = @GIO_UNIX_CFLAGS@ +GIO_UNIX_LIBS = @GIO_UNIX_LIBS@ +GIO_WINDOWS_CFLAGS = @GIO_WINDOWS_CFLAGS@ +GIO_WINDOWS_LIBS = @GIO_WINDOWS_LIBS@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_COMPILE_RESOURCES = @GLIB_COMPILE_RESOURCES@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_LIBS = @GLIB_LIBS@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GLIB_REQUIRED_VERSION = @GLIB_REQUIRED_VERSION@ +GMODULE_NO_EXPORT_CFLAGS = @GMODULE_NO_EXPORT_CFLAGS@ +GMODULE_NO_EXPORT_LIBS = @GMODULE_NO_EXPORT_LIBS@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GOBJECT_QUERY = @GOBJECT_QUERY@ +GREP = @GREP@ +GS_LIBS = @GS_LIBS@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +GTK_CFLAGS = @GTK_CFLAGS@ +GTK_LIBS = @GTK_LIBS@ +GTK_MAC_INTEGRATION_CFLAGS = @GTK_MAC_INTEGRATION_CFLAGS@ +GTK_MAC_INTEGRATION_LIBS = @GTK_MAC_INTEGRATION_LIBS@ +GTK_REQUIRED_VERSION = @GTK_REQUIRED_VERSION@ +GTK_UPDATE_ICON_CACHE = @GTK_UPDATE_ICON_CACHE@ +GUDEV_CFLAGS = @GUDEV_CFLAGS@ +GUDEV_LIBS = @GUDEV_LIBS@ +HARFBUZZ_CFLAGS = @HARFBUZZ_CFLAGS@ +HARFBUZZ_LIBS = @HARFBUZZ_LIBS@ +HARFBUZZ_REQUIRED_VERSION = @HARFBUZZ_REQUIRED_VERSION@ +HAVE_CXX14 = @HAVE_CXX14@ +HAVE_FINITE = @HAVE_FINITE@ +HAVE_ISFINITE = @HAVE_ISFINITE@ +HAVE_VFORK = @HAVE_VFORK@ +HOST_GLIB_COMPILE_RESOURCES = @HOST_GLIB_COMPILE_RESOURCES@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_REQUIRED_VERSION = @INTLTOOL_REQUIRED_VERSION@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ +INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ +INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ +INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +ISO_CODES_LOCALEDIR = @ISO_CODES_LOCALEDIR@ +ISO_CODES_LOCATION = @ISO_CODES_LOCATION@ +JPEG_LIBS = @JPEG_LIBS@ +JSON_GLIB_CFLAGS = @JSON_GLIB_CFLAGS@ +JSON_GLIB_LIBS = @JSON_GLIB_LIBS@ +LCMS_CFLAGS = @LCMS_CFLAGS@ +LCMS_LIBS = @LCMS_LIBS@ +LCMS_REQUIRED_VERSION = @LCMS_REQUIRED_VERSION@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@ +LIBBACKTRACE_LIBS = @LIBBACKTRACE_LIBS@ +LIBHEIF_CFLAGS = @LIBHEIF_CFLAGS@ +LIBHEIF_LIBS = @LIBHEIF_LIBS@ +LIBHEIF_REQUIRED_VERSION = @LIBHEIF_REQUIRED_VERSION@ +LIBLZMA_REQUIRED_VERSION = @LIBLZMA_REQUIRED_VERSION@ +LIBMYPAINT_CFLAGS = @LIBMYPAINT_CFLAGS@ +LIBMYPAINT_LIBS = @LIBMYPAINT_LIBS@ +LIBMYPAINT_REQUIRED_VERSION = @LIBMYPAINT_REQUIRED_VERSION@ +LIBOBJS = @LIBOBJS@ +LIBPNG_REQUIRED_VERSION = @LIBPNG_REQUIRED_VERSION@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUNWIND_CFLAGS = @LIBUNWIND_CFLAGS@ +LIBUNWIND_LIBS = @LIBUNWIND_LIBS@ +LIBUNWIND_REQUIRED_VERSION = @LIBUNWIND_REQUIRED_VERSION@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_CURRENT_MINUS_AGE = @LT_CURRENT_MINUS_AGE@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +LT_VERSION_INFO = @LT_VERSION_INFO@ +LZMA_CFLAGS = @LZMA_CFLAGS@ +LZMA_LIBS = @LZMA_LIBS@ +MAIL = @MAIL@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MIME_INFO_CFLAGS = @MIME_INFO_CFLAGS@ +MIME_INFO_LIBS = @MIME_INFO_LIBS@ +MIME_TYPES = @MIME_TYPES@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MMX_EXTRA_CFLAGS = @MMX_EXTRA_CFLAGS@ +MNG_CFLAGS = @MNG_CFLAGS@ +MNG_LIBS = @MNG_LIBS@ +MSGFMT = @MSGFMT@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGMERGE = @MSGMERGE@ +MYPAINT_BRUSHES_CFLAGS = @MYPAINT_BRUSHES_CFLAGS@ +MYPAINT_BRUSHES_LIBS = @MYPAINT_BRUSHES_LIBS@ +NATIVE_GLIB_CFLAGS = @NATIVE_GLIB_CFLAGS@ +NATIVE_GLIB_LIBS = @NATIVE_GLIB_LIBS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENEXR_CFLAGS = @OPENEXR_CFLAGS@ +OPENEXR_LIBS = @OPENEXR_LIBS@ +OPENEXR_REQUIRED_VERSION = @OPENEXR_REQUIRED_VERSION@ +OPENJPEG_CFLAGS = @OPENJPEG_CFLAGS@ +OPENJPEG_LIBS = @OPENJPEG_LIBS@ +OPENJPEG_REQUIRED_VERSION = @OPENJPEG_REQUIRED_VERSION@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PANGOCAIRO_CFLAGS = @PANGOCAIRO_CFLAGS@ +PANGOCAIRO_LIBS = @PANGOCAIRO_LIBS@ +PANGOCAIRO_REQUIRED_VERSION = @PANGOCAIRO_REQUIRED_VERSION@ +PATHSEP = @PATHSEP@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PERL_REQUIRED_VERSION = @PERL_REQUIRED_VERSION@ +PERL_VERSION = @PERL_VERSION@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PNG_CFLAGS = @PNG_CFLAGS@ +PNG_LIBS = @PNG_LIBS@ +POFILES = @POFILES@ +POPPLER_CFLAGS = @POPPLER_CFLAGS@ +POPPLER_DATA_CFLAGS = @POPPLER_DATA_CFLAGS@ +POPPLER_DATA_LIBS = @POPPLER_DATA_LIBS@ +POPPLER_DATA_REQUIRED_VERSION = @POPPLER_DATA_REQUIRED_VERSION@ +POPPLER_LIBS = @POPPLER_LIBS@ +POPPLER_REQUIRED_VERSION = @POPPLER_REQUIRED_VERSION@ +POSUB = @POSUB@ +PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ +PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ +PYBIN_PATH = @PYBIN_PATH@ +PYCAIRO_CFLAGS = @PYCAIRO_CFLAGS@ +PYCAIRO_LIBS = @PYCAIRO_LIBS@ +PYGIMP_EXTRA_CFLAGS = @PYGIMP_EXTRA_CFLAGS@ +PYGTK_CFLAGS = @PYGTK_CFLAGS@ +PYGTK_CODEGEN = @PYGTK_CODEGEN@ +PYGTK_DEFSDIR = @PYGTK_DEFSDIR@ +PYGTK_LIBS = @PYGTK_LIBS@ +PYLINK_LIBS = @PYLINK_LIBS@ +PYTHON = @PYTHON@ +PYTHON2_REQUIRED_VERSION = @PYTHON2_REQUIRED_VERSION@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_INCLUDES = @PYTHON_INCLUDES@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +RSVG_REQUIRED_VERSION = @RSVG_REQUIRED_VERSION@ +RT_LIBS = @RT_LIBS@ +SCREENSHOT_LIBS = @SCREENSHOT_LIBS@ +SED = @SED@ +SENDMAIL = @SENDMAIL@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOCKET_LIBS = @SOCKET_LIBS@ +SSE2_EXTRA_CFLAGS = @SSE2_EXTRA_CFLAGS@ +SSE4_1_EXTRA_CFLAGS = @SSE4_1_EXTRA_CFLAGS@ +SSE_EXTRA_CFLAGS = @SSE_EXTRA_CFLAGS@ +STRIP = @STRIP@ +SVG_CFLAGS = @SVG_CFLAGS@ +SVG_LIBS = @SVG_LIBS@ +SYMPREFIX = @SYMPREFIX@ +TIFF_LIBS = @TIFF_LIBS@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WEBKIT_CFLAGS = @WEBKIT_CFLAGS@ +WEBKIT_LIBS = @WEBKIT_LIBS@ +WEBKIT_REQUIRED_VERSION = @WEBKIT_REQUIRED_VERSION@ +WEBPDEMUX_CFLAGS = @WEBPDEMUX_CFLAGS@ +WEBPDEMUX_LIBS = @WEBPDEMUX_LIBS@ +WEBPMUX_CFLAGS = @WEBPMUX_CFLAGS@ +WEBPMUX_LIBS = @WEBPMUX_LIBS@ +WEBP_CFLAGS = @WEBP_CFLAGS@ +WEBP_LIBS = @WEBP_LIBS@ +WEBP_REQUIRED_VERSION = @WEBP_REQUIRED_VERSION@ +WEB_PAGE = @WEB_PAGE@ +WIN32_LARGE_ADDRESS_AWARE = @WIN32_LARGE_ADDRESS_AWARE@ +WINDRES = @WINDRES@ +WMF_CFLAGS = @WMF_CFLAGS@ +WMF_CONFIG = @WMF_CONFIG@ +WMF_LIBS = @WMF_LIBS@ +WMF_REQUIRED_VERSION = @WMF_REQUIRED_VERSION@ +XDG_EMAIL = @XDG_EMAIL@ +XFIXES_CFLAGS = @XFIXES_CFLAGS@ +XFIXES_LIBS = @XFIXES_LIBS@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_REQUIRED_VERSION = @XGETTEXT_REQUIRED_VERSION@ +XMC_CFLAGS = @XMC_CFLAGS@ +XMC_LIBS = @XMC_LIBS@ +XMKMF = @XMKMF@ +XMLLINT = @XMLLINT@ +XMU_LIBS = @XMU_LIBS@ +XPM_LIBS = @XPM_LIBS@ +XSLTPROC = @XSLTPROC@ +XVFB_RUN = @XVFB_RUN@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +Z_LIBS = @Z_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CC_FOR_BUILD = @ac_ct_CC_FOR_BUILD@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +gimpdatadir = @gimpdatadir@ +gimpdir = @gimpdir@ +gimplocaledir = @gimplocaledir@ +gimpplugindir = @gimpplugindir@ +gimpsysconfdir = @gimpsysconfdir@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +intltool__v_merge_options_ = @intltool__v_merge_options_@ +intltool__v_merge_options_0 = @intltool__v_merge_options_0@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +manpage_gimpdir = @manpage_gimpdir@ +mkdir_p = @mkdir_p@ +ms_librarian = @ms_librarian@ +mypaint_brushes_dir = @mypaint_brushes_dir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +@OS_WIN32_TRUE@mwindows = -mwindows +@OS_WIN32_FALSE@libm = -lm +libgimpui = $(top_builddir)/libgimp/libgimpui-$(GIMP_API_VERSION).la +libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la +libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la +libgimp = $(top_builddir)/libgimp/libgimp-$(GIMP_API_VERSION).la +libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la +libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la +libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la +@HAVE_WINDRES_TRUE@GIMPPLUGINRC = $(top_builddir)/build/windows/gimp-plug-ins.rc +@HAVE_WINDRES_TRUE@metadata_editor_RC = metadata-editor.rc.o +@HAVE_WINDRES_TRUE@metadata_viewer_RC = metadata-viewer.rc.o +AM_LDFLAGS = $(mwindows) +me_libexecdir = $(gimpplugindir)/plug-ins/metadata-editor +mv_libexecdir = $(gimpplugindir)/plug-ins/metadata-viewer +metadata_editor_SOURCES = \ + metadata-editor.c \ + metadata-editor.h \ + metadata-impexp.c \ + metadata-impexp.h \ + metadata-misc.h \ + metadata-tags.c \ + metadata-tags.h \ + metadata-xml.c \ + metadata-xml.h + +metadata_viewer_SOURCES = \ + metadata-viewer.c + +AM_CPPFLAGS = \ + -I$(top_srcdir) \ + $(GTK_CFLAGS) \ + $(GEGL_CFLAGS) \ + -I$(includedir) + +metadata_viewer_LDADD = \ + $(libm) \ + $(libgimpui) \ + $(libgimpwidgets) \ + $(libgimpconfig) \ + $(libgimp) \ + $(libgimpcolor) \ + $(libgimpmath) \ + $(libgimpbase) \ + $(GTK_LIBS) \ + $(GEXIV2_LIBS) \ + $(RT_LIBS) \ + $(INTLLIBS) \ + $(metadata_viewer_RC) + +metadata_editor_LDADD = \ + $(libm) \ + $(libgimpui) \ + $(libgimpwidgets) \ + $(libgimpconfig) \ + $(libgimp) \ + $(libgimpcolor) \ + $(libgimpmath) \ + $(libgimpbase) \ + $(GTK_LIBS) \ + $(GEXIV2_LIBS) \ + $(RT_LIBS) \ + $(INTLLIBS) \ + $(metadata_editor_RC) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/build/windows/gimprc-plug-ins.rule $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu plug-ins/metadata/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu plug-ins/metadata/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; +$(top_srcdir)/build/windows/gimprc-plug-ins.rule $(am__empty): + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-me_libexecPROGRAMS: $(me_libexec_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(me_libexec_PROGRAMS)'; test -n "$(me_libexecdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(me_libexecdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(me_libexecdir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p \ + || test -f $$p1 \ + ; then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' \ + -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(me_libexecdir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(me_libexecdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-me_libexecPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(me_libexec_PROGRAMS)'; test -n "$(me_libexecdir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' \ + `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(me_libexecdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(me_libexecdir)" && rm -f $$files + +clean-me_libexecPROGRAMS: + @list='$(me_libexec_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +install-mv_libexecPROGRAMS: $(mv_libexec_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(mv_libexec_PROGRAMS)'; test -n "$(mv_libexecdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(mv_libexecdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(mv_libexecdir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p \ + || test -f $$p1 \ + ; then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' \ + -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(mv_libexecdir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(mv_libexecdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-mv_libexecPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(mv_libexec_PROGRAMS)'; test -n "$(mv_libexecdir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' \ + `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(mv_libexecdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(mv_libexecdir)" && rm -f $$files + +clean-mv_libexecPROGRAMS: + @list='$(mv_libexec_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +metadata-editor$(EXEEXT): $(metadata_editor_OBJECTS) $(metadata_editor_DEPENDENCIES) $(EXTRA_metadata_editor_DEPENDENCIES) + @rm -f metadata-editor$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(metadata_editor_OBJECTS) $(metadata_editor_LDADD) $(LIBS) + +metadata-viewer$(EXEEXT): $(metadata_viewer_OBJECTS) $(metadata_viewer_DEPENDENCIES) $(EXTRA_metadata_viewer_DEPENDENCIES) + @rm -f metadata-viewer$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(metadata_viewer_OBJECTS) $(metadata_viewer_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/metadata-editor.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/metadata-impexp.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/metadata-tags.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/metadata-viewer.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/metadata-xml.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(me_libexecdir)" "$(DESTDIR)$(mv_libexecdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-me_libexecPROGRAMS \ + clean-mv_libexecPROGRAMS mostlyclean-am + +distclean: distclean-am + -rm -f ./$(DEPDIR)/metadata-editor.Po + -rm -f ./$(DEPDIR)/metadata-impexp.Po + -rm -f ./$(DEPDIR)/metadata-tags.Po + -rm -f ./$(DEPDIR)/metadata-viewer.Po + -rm -f ./$(DEPDIR)/metadata-xml.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-me_libexecPROGRAMS install-mv_libexecPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f ./$(DEPDIR)/metadata-editor.Po + -rm -f ./$(DEPDIR)/metadata-impexp.Po + -rm -f ./$(DEPDIR)/metadata-tags.Po + -rm -f ./$(DEPDIR)/metadata-viewer.Po + -rm -f ./$(DEPDIR)/metadata-xml.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-me_libexecPROGRAMS \ + uninstall-mv_libexecPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ + clean-generic clean-libtool clean-me_libexecPROGRAMS \ + clean-mv_libexecPROGRAMS cscopelist-am ctags ctags-am \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-me_libexecPROGRAMS \ + install-mv_libexecPROGRAMS install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am \ + uninstall-me_libexecPROGRAMS uninstall-mv_libexecPROGRAMS + +.PRECIOUS: Makefile + + +# `windres` seems a very stupid tool and it breaks with double shlashes +# in parameter paths. Strengthen the rule a little. +@HAVE_WINDRES_TRUE@%.rc.o: +@HAVE_WINDRES_TRUE@ $(WINDRES) --define ORIGINALFILENAME_STR="$*$(EXEEXT)" \ +@HAVE_WINDRES_TRUE@ --define INTERNALNAME_STR="$*" \ +@HAVE_WINDRES_TRUE@ --define TOP_SRCDIR="`echo $(top_srcdir) | sed 's*//*/*'`" \ +@HAVE_WINDRES_TRUE@ -I"`echo $(top_srcdir)/app | sed 's%/\+%/%'`" \ +@HAVE_WINDRES_TRUE@ -I"`echo $(top_builddir)/app | sed 's%/\+%/%'`"\ +@HAVE_WINDRES_TRUE@ -I"`echo $(top_builddir) | sed 's%/\+%/%'`"\ +@HAVE_WINDRES_TRUE@ $(GIMPPLUGINRC) $@ + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/plug-ins/metadata/metadata-editor.c b/plug-ins/metadata/metadata-editor.c new file mode 100644 index 0000000..fc958b7 --- /dev/null +++ b/plug-ins/metadata/metadata-editor.c @@ -0,0 +1,5779 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * metadata-editor.c + * Copyright (C) 2016, 2017 Ben Touchette + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#include "config.h" + +#include <stdlib.h> +#include <ctype.h> + +#include <gegl.h> +#include <gtk/gtk.h> +#include <gexiv2/gexiv2.h> + +#include <glib.h> +#include <glib/gstdio.h> + +#include <libgimp/gimp.h> +#include <libgimp/gimpui.h> + +#include "libgimp/stdplugins-intl.h" + +#include "metadata-tags.h" +#include "metadata-xml.h" +#include "metadata-impexp.h" +#include "metadata-misc.h" + +#define PLUG_IN_PROC "plug-in-metadata-editor" +#define PLUG_IN_BINARY "metadata-editor" +#define PLUG_IN_ROLE "gimp-metadata" + +#define DEFAULT_TEMPLATE_FILE "gimp_metadata_template.xml" + +/* local function prototypes */ + +static void query (void); +static void run (const gchar *name, + gint nparams, + const GimpParam *param, + gint *nreturn_vals, + GimpParam **return_vals); + +static gboolean metadata_editor_dialog (gint32 image_id, + GimpMetadata *metadata); + +static void metadata_dialog_editor_set_metadata (GExiv2Metadata *metadata, + GtkBuilder *builder); + +void metadata_editor_write_callback (GtkWidget *dialog, + GtkBuilder *builder, + gint32 image_id); + +static void impex_combo_callback (GtkComboBoxText *combo, + gpointer data); + +static void gpsaltsys_combo_callback (GtkComboBoxText *combo, + gpointer data); + +static void remove_substring (const gchar *string, + const gchar *substring); + +gboolean hasCreatorTagData (GtkBuilder *builder); +gboolean hasLocationCreationTagData (GtkBuilder *builder); +gboolean hasImageSupplierTagData (GtkBuilder *builder); + +void on_date_button_clicked (GtkButton *widget, + GtkWidget *entry_widget, + gchar *tag); + +void on_create_date_button_clicked (GtkButton *widget, + gpointer data); + +void on_patient_dob_date_button_clicked (GtkButton *widget, + gpointer data); + +void on_study_date_button_clicked (GtkButton *widget, + gpointer data); + +void on_series_date_button_clicked (GtkButton *widget, + gpointer data); + + +static void +property_release_id_remove_callback (GtkWidget *widget, + gpointer data); +static void +property_release_id_add_callback (GtkWidget *widget, + gpointer data); +static void +model_release_id_remove_callback (GtkWidget *widget, + gpointer data); +static void +model_release_id_add_callback (GtkWidget *widget, + gpointer data); +static void +shown_location_remove_callback (GtkWidget *widget, + gpointer data); +static void +shown_location_add_callback (GtkWidget *widget, + gpointer data); +static void +feat_org_name_add_callback (GtkWidget *widget, + gpointer data); +static void +feat_org_name_remove_callback (GtkWidget *widget, + gpointer data); +static void +feat_org_code_add_callback (GtkWidget *widget, + gpointer data); +static void +feat_org_code_remove_callback (GtkWidget *widget, + gpointer data); +static void +artwork_object_add_callback (GtkWidget *widget, + gpointer data); +static void +artwork_object_remove_callback (GtkWidget *widget, + gpointer data); +static void +reg_entry_add_callback (GtkWidget *widget, + gpointer data); +static void +reg_entry_remove_callback (GtkWidget *widget, + gpointer data); +static void +image_creator_add_callback (GtkWidget *widget, + gpointer data); +static void +image_creator_remove_callback (GtkWidget *widget, + gpointer data); + +static void +copyright_own_add_callback (GtkWidget *widget, + gpointer data); +static void +copyright_own_remove_callback (GtkWidget *widget, + gpointer data); +static void +licensor_add_callback (GtkWidget *widget, + gpointer data); +static void +licensor_remove_callback (GtkWidget *widget, + gpointer data); + +static void +list_row_remove_callback (GtkWidget *widget, + gpointer data, + gchar *tag); + +static void +list_row_add_callback (GtkWidget *widget, + gpointer data, + gchar *tag); + +static gint +count_tags (GExiv2Metadata *metadata, + const gchar *header, + const gchar **tags, + int items); + +static void +get_tags (GExiv2Metadata *metadata, + const gchar *header, + const gchar **tags, + const int items, + const int count); + +gboolean +hasModelReleaseTagData (GtkBuilder *builder); + +gboolean +hasPropertyReleaseTagData (GtkBuilder *builder); + +static void +organisation_image_code_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +organisation_image_name_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +prop_rel_id_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +loc_sho_sub_loc_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +loc_sho_city_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +loc_sho_state_prov_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +loc_sho_cntry_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +loc_sho_cntry_iso_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +reg_org_id_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +reg_item_id_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +aoo_title_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +aoo_copyright_notice_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +aoo_source_inv_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +aoo_source_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +aoo_creator_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +aoo_date_creat_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +cr_owner_name_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +cr_owner_id_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +licensor_name_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +licensor_id_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +licensor_phone1_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +licensor_phone_type1_cell_edited_callback (GtkCellRendererCombo *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +licensor_phone2_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +licensor_phone_type2_cell_edited_callback (GtkCellRendererCombo *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +licensor_email_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +static void +licensor_web_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data); + +void +cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data, + int index); + +void +cell_edited_callback_combo (GtkCellRendererCombo *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data, + int index); + + +/* local variables */ + +gchar *tagdata[256][256]; + +static int last_gpsaltsys_sel; + +gboolean gimpmetadata; +gboolean force_write; + +static const gchar *lang_default = "lang=\"x-default\""; +static const gchar *seq_default = "type=\"Seq\""; +static const gchar *bag_default = "type=\"Bag\""; + +metadata_editor meta_args; + +const GimpPlugInInfo PLUG_IN_INFO = +{ + NULL, /* init_proc */ + NULL, /* quit_proc */ + query, /* query_proc */ + run, /* run_proc */ +}; + +/* ============================================================================ + * ==[ ]============================================================= + * ==[ FUNCTIONS ]============================================================= + * ==[ ]============================================================= + * ============================================================================ + */ + + +MAIN () + +/* ============================================================================ + * ==[ QUERY ]================================================================= + * ============================================================================ + */ + +static void +query (void) +{ + static const GimpParamDef metadata_args[] = + { + { GIMP_PDB_INT32, "run-mode", "Run mode { RUN-INTERACTIVE (0) }" }, + { GIMP_PDB_IMAGE, "image", "Input image" } + }; + + gimp_install_procedure (PLUG_IN_PROC, + N_("Edit metadata (IPTC, EXIF, XMP)"), + "Edit metadata information attached to the " + "current image. Some or all of this metadata " + "will be saved in the file, depending on the output " + "file format.", + "Ben Touchette", + "Ben Touchette", + "2017", + N_("_Edit Metadata"), + "*", + GIMP_PLUGIN, + G_N_ELEMENTS (metadata_args), 0, + metadata_args, NULL); + + gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Image/Metadata"); +} + +/* ============================================================================ + * ==[ RUN ]=================================================================== + * ============================================================================ + */ + +static void +run (const gchar *name, + gint nparams, + const GimpParam *param, + gint *nreturn_vals, + GimpParam **return_vals) +{ + static GimpParam values[1]; + GimpPDBStatusType status = GIMP_PDB_SUCCESS; + + *nreturn_vals = 1; + *return_vals = values; + + values[0].type = GIMP_PDB_STATUS; + values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR; + + force_write = FALSE; + + INIT_I18N (); + gimp_ui_init (PLUG_IN_BINARY, TRUE); + + if (! strcmp (name, PLUG_IN_PROC)) + { + GimpMetadata *metadata; + gint32 image_ID = param[1].data.d_image; + + metadata = gimp_image_get_metadata (image_ID); + + /* Always show metadata dialog so we can add + appropriate iptc data as needed. Sometimes + license data needs to be added after the + fact and the image may not contain metadata + but should have it added as needed. */ + + if (!metadata) + { + metadata = gimp_metadata_new (); + gimp_image_set_metadata (image_ID, metadata); + } + + metadata_editor_dialog (image_ID, metadata); + + status = GIMP_PDB_SUCCESS; + } + else + { + status = GIMP_PDB_CALLING_ERROR; + } + + values[0].data.d_status = status; +} + +/* ============================================================================ + * ==[ EDITOR DIALOG UI ]====================================================== + * ============================================================================ + */ + +static GtkWidget * +builder_get_widget (GtkBuilder *builder, + const gchar *name) +{ + GObject *object = gtk_builder_get_object (builder, name); + + return GTK_WIDGET (object); +} + +static gboolean +metadata_editor_dialog (gint32 image_id, + GimpMetadata *g_metadata) +{ + GtkBuilder *builder; + GtkWidget *dialog; + GtkWidget *metadata_vbox; + GtkWidget *impex_combo; + GtkWidget *content_area; + GExiv2Metadata *metadata; + gchar *ui_file; + gchar *title; + gchar *name; + GError *error = NULL; + gboolean run; + + metadata = GEXIV2_METADATA (g_metadata); + + builder = gtk_builder_new (); + + meta_args.image_id = image_id; + meta_args.builder = builder; + meta_args.metadata = metadata; + meta_args.filename = g_strconcat (g_get_home_dir (), "/", DEFAULT_TEMPLATE_FILE, + NULL); + + ui_file = g_build_filename (gimp_data_directory (), + "ui", "plug-ins", "plug-in-metadata-editor.ui", NULL); + + if (! gtk_builder_add_from_file (builder, ui_file, &error)) + { + g_printerr ("Error occurred while loading UI file!\n"); + g_printerr ("Message: %s\n", error->message); + g_clear_error (&error); + if (ui_file) + g_free (ui_file); + g_object_unref (builder); + return FALSE; + } + + g_free (ui_file); + + name = gimp_image_get_name (image_id); + title = g_strdup_printf (_("Metadata Editor: %s"), name); + if (name) + g_free (name); + + dialog = gimp_dialog_new (title, + "gimp-metadata-editor-dialog", + NULL, 0, + gimp_standard_help_func, PLUG_IN_PROC, + _("_Cancel"), GTK_RESPONSE_NO, + _("_Write Metadata"), GTK_RESPONSE_YES, + NULL); + + meta_args.dialog = dialog; + + gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES); + gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), + GTK_RESPONSE_YES, + GTK_RESPONSE_NO, + -1); + + gimp_window_set_transient (GTK_WINDOW (dialog)); + + if (title) + g_free (title); + + content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); + + metadata_vbox = builder_get_widget (builder, "metadata-vbox"); + impex_combo = builder_get_widget (builder, "impex_combo"); + + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (impex_combo), + _("Select:")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (impex_combo), + _("Import metadata")); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (impex_combo), + _("Export metadata")); + gtk_combo_box_set_active (GTK_COMBO_BOX (impex_combo), 0); + + g_signal_connect (G_OBJECT (impex_combo), + "changed", G_CALLBACK (impex_combo_callback), &meta_args); + + gtk_container_set_border_width (GTK_CONTAINER (metadata_vbox), 12); + gtk_box_pack_start (GTK_BOX (content_area), metadata_vbox, TRUE, TRUE, 0); + + metadata_dialog_editor_set_metadata (metadata, builder); + + run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_YES); + if (run) + { + metadata_editor_write_callback (dialog, builder, image_id); + } + + if (meta_args.filename) + { + g_free (meta_args.filename); + } + + return TRUE; +} + +/* ============================================================================ + * ==[ ]===================================================== + * ==[ PRIVATE FUNCTIONS ]===================================================== + * ==[ ]===================================================== + * ============================================================================ + */ +static void +remove_substring (const gchar *string, + const gchar *substring) +{ + if (string != NULL && substring != NULL && substring[0] != '\0') + { + gchar *p = strstr (string, substring); + if (p) + { + memmove (p, p + strlen (substring), strlen (p + strlen (substring)) + 1); + } + } +} + +static gint +count_tags (GExiv2Metadata *metadata, + const gchar *header, + const gchar **tags, + gint items) +{ + int tagcount; + gchar tag[256]; + int oo; + int ii; + + tagcount = 0; + for (oo = 1; oo < 256; oo++) + { + for (ii = 0; ii < items; ii++) + { + g_sprintf ((gchar*) &tag, "%s[%d]", header, oo); + g_sprintf ((gchar*) &tag, "%s%s", + (gchar*) &tag, (gchar*) tags[ii]); + if (gexiv2_metadata_has_tag (metadata, (gchar*) &tag)) + { + tagcount++; + break; + } + } + } + return tagcount; +} + +static void +get_tags (GExiv2Metadata *metadata, + const gchar *header, + const gchar **tags, + const gint items, + const gint count) +{ + gchar tag[256]; + int ooo; + int iii; + + for (ooo = 1; ooo < count + 1; ooo++) + { + for (iii = 0; iii < items; iii++) + { + gchar *value; + g_sprintf ((gchar*) &tag, "%s[%d]", header, ooo); + g_sprintf ((gchar*) &tag, "%s%s", (gchar*) &tag, (gchar*) tags[iii]); + value = gexiv2_metadata_get_tag_string (metadata, (gchar*) &tag); + tagdata[ooo-1][iii] = strdup (value); + } + } +} + +/* ============================================================================ + * ==[ DATE CALLBACKS ]======================================================== + * ============================================================================ + */ +void +on_create_date_button_clicked (GtkButton *widget, + gpointer data) +{ + on_date_button_clicked (widget, (GtkWidget*)data, + "Xmp.photoshop.DateCreated"); +} + +void +on_patient_dob_date_button_clicked (GtkButton *widget, + gpointer data) +{ + on_date_button_clicked (widget, (GtkWidget*)data, + "Xmp.DICOM.PatientDOB"); +} + +void +on_study_date_button_clicked (GtkButton *widget, + gpointer data) +{ + on_date_button_clicked (widget, (GtkWidget*)data, + "Xmp.DICOM.StudyDateTime"); +} + +void +on_series_date_button_clicked (GtkButton *widget, + gpointer data) +{ + on_date_button_clicked (widget, (GtkWidget*)data, + "Xmp.DICOM.SeriesDateTime"); +} + +void +on_date_button_clicked (GtkButton *widget, + GtkWidget *entry_widget, + gchar *tag) +{ + GtkBuilder *builder; + GtkWidget *calendar_dialog; + GtkWidget *calendar_content_area; + GtkWidget *calendar_vbox; + GtkWidget *calendar; + const gchar *date_text; + gchar *ui_file; + GError *error = NULL; + GDateTime *current_datetime; + guint year, month, day; + + builder = gtk_builder_new (); + + ui_file = g_build_filename (gimp_data_directory (), + "ui", "plug-ins", + "plug-in-metadata-editor-calendar.ui", NULL); + + if (! gtk_builder_add_from_file (builder, ui_file, &error)) + { + g_printerr ("Error occurred while loading UI file!\n"); + if (error != NULL) + { + g_printerr ("Message: %s\n", error->message); + g_clear_error (&error); + } + if (ui_file) + g_free (ui_file); + g_object_unref (builder); + return; + } + + if (ui_file) + g_free (ui_file); + + date_text = gtk_entry_get_text (GTK_ENTRY (entry_widget)); + if (date_text && date_text[0] != '\0') + { + sscanf (date_text, "%d-%d-%d;", &year, &month, &day); + month--; + } + else + { + current_datetime = g_date_time_new_now_local (); + year = g_date_time_get_year (current_datetime); + month = g_date_time_get_month (current_datetime) - 1; + day = g_date_time_get_day_of_month (current_datetime); + } + + calendar_dialog = + gtk_dialog_new_with_buttons (_("Calendar Date:"), + NULL, + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + _("_Cancel"), GTK_RESPONSE_NO, + _("Set Date"), GTK_RESPONSE_YES, + NULL); + + gtk_dialog_set_default_response (GTK_DIALOG (calendar_dialog), + GTK_RESPONSE_YES); + gtk_dialog_set_alternative_button_order (GTK_DIALOG (calendar_dialog), + GTK_RESPONSE_YES, + GTK_RESPONSE_NO, + -1); + + gimp_window_set_transient (GTK_WINDOW (calendar_dialog)); + + calendar_content_area = gtk_dialog_get_content_area (GTK_DIALOG ( + calendar_dialog)); + + calendar_vbox = builder_get_widget (builder, "calendar-vbox"); + + gtk_container_set_border_width (GTK_CONTAINER (calendar_vbox), 12); + gtk_box_pack_start (GTK_BOX (calendar_content_area), calendar_vbox, TRUE, TRUE, + 0); + + calendar = builder_get_widget (builder, "calendar"); + + gtk_calendar_select_month (GTK_CALENDAR (calendar), month, year); + gtk_calendar_select_day (GTK_CALENDAR (calendar), day); + gtk_calendar_mark_day (GTK_CALENDAR (calendar), day); + + if (gtk_dialog_run (GTK_DIALOG (calendar_dialog)) == GTK_RESPONSE_YES) + { + gchar date[25]; + gtk_calendar_get_date (GTK_CALENDAR (calendar), &year, &month, &day); + g_sprintf ((gchar*) &date, "%d-%02d-%02d", year, month+1, day); + gtk_entry_set_text (GTK_ENTRY (entry_widget), date); + } + + gtk_widget_destroy (calendar_dialog); +} + +/* ============================================================================ + * ==[ SPECIAL TAGS HANDLERS ]================================================= + * ============================================================================ + */ + +gboolean +hasImageSupplierTagData (GtkBuilder *builder) +{ + gint loop; + + for (loop = 0; loop < imageSupplierInfoHeader.size; loop++) + { + GObject *object; + const gchar *text; + + object = gtk_builder_get_object (builder, default_metadata_tags[loop].tag); + + if (! strcmp (imageSupplierInfoTags[loop].mode, "single")) + { + text = gtk_entry_get_text (GTK_ENTRY (object)); + + if (text && *text) + return TRUE; + } + else if (! strcmp (imageSupplierInfoTags[loop].mode, "multi")) + { + text = gtk_entry_get_text (GTK_ENTRY (object)); + + if (text && *text) + return TRUE; + } + } + + return FALSE; +} + +gboolean +hasLocationCreationTagData (GtkBuilder *builder) +{ + gint loop; + + for (loop = 0; loop < creatorContactInfoHeader.size; loop++) + { + GObject *object; + const gchar *text; + + object = gtk_builder_get_object (builder, default_metadata_tags[loop].tag); + + if (! strcmp (locationCreationInfoTags[loop].mode, "single")) + { + text = gtk_entry_get_text (GTK_ENTRY (object)); + + if (text && *text) + return TRUE; + } + } + + return FALSE; +} + +gboolean +hasModelReleaseTagData (GtkBuilder *builder) +{ + return FALSE; +} + +gboolean +hasPropertyReleaseTagData (GtkBuilder *builder) +{ + return FALSE; +} + + +gboolean +hasCreatorTagData (GtkBuilder *builder) +{ + gboolean has_data = FALSE; + gint loop; + + for (loop = 0; loop < creatorContactInfoHeader.size; loop++) + { + GObject *object; + + object = gtk_builder_get_object (builder, default_metadata_tags[loop].tag); + + if (GTK_IS_ENTRY (object)) + { + const gchar *text = gtk_entry_get_text (GTK_ENTRY (object)); + + if (text && *text) + has_data = TRUE; + } + else if (GTK_IS_TEXT_VIEW (object)) + { + GtkTextView *text_view = GTK_TEXT_VIEW (object); + GtkTextBuffer *buffer = gtk_text_view_get_buffer (text_view); + GtkTextIter start; + GtkTextIter end; + gchar *text; + + gtk_text_buffer_get_start_iter (buffer, &start); + gtk_text_buffer_get_end_iter (buffer, &end); + + text = gtk_text_buffer_get_text (buffer, &start, &end, TRUE); + + if (text && *text) + has_data = TRUE; + + if (text) + g_free (text); + } + } + + return has_data; +} + +/* ============================================================================ + * ==[ SET DIALOG METADATA ]=================================================== + * ============================================================================ + */ + +/* CELL EDITED */ + +void +cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data, + int index) +{ + GtkTreeModel *model; + GtkTreePath *path; + GtkTreeIter iter; + + model = (GtkTreeModel *)data; + path = gtk_tree_path_new_from_string (path_string); + + gtk_tree_model_get_iter (model, &iter, path); + + gtk_list_store_set (GTK_LIST_STORE (model), &iter, index, + new_text, -1); +} + +void +cell_edited_callback_combo (GtkCellRendererCombo *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data, + int column) +{ + GtkWidget *widget; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + GtkTreePath *path; + GtkTreeSelection *selection; + + widget = GTK_WIDGET (data); + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)); + + if (gtk_tree_selection_get_selected (GTK_TREE_SELECTION (selection), + NULL, &iter)) + { + path = gtk_tree_model_get_path (treemodel, &iter); + gtk_tree_path_free (path); + gtk_list_store_set (liststore, &iter, column, new_text, -1); + } +} + +static void +licensor_name_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 0); +} + +static void +licensor_id_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 1); +} + +static void +licensor_phone1_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 2); +} + +static void +licensor_phone_type1_cell_edited_callback (GtkCellRendererCombo *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback_combo (cell, path_string, new_text, data, 3); +} + +static void +licensor_phone2_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 4); +} + +static void +licensor_phone_type2_cell_edited_callback (GtkCellRendererCombo *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback_combo (cell, path_string, new_text, data, 5); +} + +static void +licensor_email_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 6); +} + +static void +licensor_web_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 7); +} + +static void +cr_owner_name_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 0); +} + +static void +cr_owner_id_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 1); +} + +static void +img_cr8_name_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 0); +} + +static void +img_cr8_id_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 1); +} + +static void +aoo_copyright_notice_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 5); +} + +static void +aoo_source_inv_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 4); +} + +static void +aoo_source_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 3); +} + +static void +aoo_creator_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 2); +} + +static void +aoo_date_creat_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 1); +} + +static void +aoo_title_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 0); +} + +static void +reg_org_id_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 0); +} + +static void +reg_item_id_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 1); +} + +static void +loc_sho_sub_loc_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 0); +} + +static void +loc_sho_city_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 1); +} + +static void +loc_sho_state_prov_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 2); +} + +static void +loc_sho_cntry_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 3); +} + +static void +loc_sho_cntry_iso_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 4); +} + +static void +loc_sho_wrld_reg_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + cell_edited_callback (cell, path_string, new_text, data, 5); +} + +static void +prop_rel_id_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + GtkTreeModel *model; + GtkTreePath *path; + GtkTreeIter iter; + gint column; + model = (GtkTreeModel *)data; + path = gtk_tree_path_new_from_string (path_string); + + column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column")); + + gtk_tree_model_get_iter (model, &iter, path); + + gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, + new_text, -1); +} + +static void +mod_rel_id_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + GtkTreeModel *model; + GtkTreePath *path; + GtkTreeIter iter; + gint column; + + model = (GtkTreeModel *)data; + path = gtk_tree_path_new_from_string (path_string); + + column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column")); + + gtk_tree_model_get_iter (model, &iter, path); + + gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, + new_text, -1); +} + +static void +organisation_image_name_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + GtkTreeModel *model; + GtkTreePath *path; + GtkTreeIter iter; + gint column; + + model = (GtkTreeModel *)data; + path = gtk_tree_path_new_from_string (path_string); + + column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column")); + + gtk_tree_model_get_iter (model, &iter, path); + + gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, + new_text, -1); +} + +static void +organisation_image_code_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) +{ + GtkTreeModel *model; + GtkTreePath *path; + GtkTreeIter iter; + gint column; + + model = (GtkTreeModel *)data; + path = gtk_tree_path_new_from_string (path_string); + + column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column")); + + gtk_tree_model_get_iter (model, &iter, path); + + gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, + new_text, -1); +} + + +/* CELL / ROW REMOVE */ + +static void +list_row_remove_callback (GtkWidget *widget, + gpointer data, + gchar *tag) +{ + GtkBuilder *builder = data; + GtkWidget *list_widget; + GtkListStore *liststore; + GtkTreeIter iter; + GtkTreeModel *treemodel; + GtkTreeSelection *selection; + GtkTreePath *path; + + list_widget = builder_get_widget (builder, tag); + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (list_widget)); + liststore = GTK_LIST_STORE (treemodel); + + selection = gtk_tree_view_get_selection ((GtkTreeView *)list_widget); + + if (gtk_tree_selection_get_selected (selection, NULL, &iter)) + { + gint number_of_rows; + + path = gtk_tree_model_get_path (treemodel, &iter); + gtk_list_store_remove (liststore, &iter); + gtk_tree_path_free (path); + + number_of_rows = gtk_tree_model_iter_n_children (treemodel, NULL); + /* Make sur that two rows are always showing, else it looks ugly. */ + if (number_of_rows < 2) + { + gtk_list_store_append (liststore, &iter); + } + } +} + +static void +property_release_id_remove_callback (GtkWidget *widget, + gpointer data) +{ + list_row_remove_callback (widget, data, "Xmp.plus.PropertyReleaseID"); +} + +static void +model_release_id_remove_callback (GtkWidget *widget, + gpointer data) +{ + list_row_remove_callback (widget, data, "Xmp.plus.ModelReleaseID"); +} + +static void +shown_location_remove_callback (GtkWidget *widget, + gpointer data) +{ + list_row_remove_callback (widget, data, "Xmp.iptcExt.LocationShown"); +} + +static void +feat_org_name_remove_callback (GtkWidget *widget, + gpointer data) +{ + list_row_remove_callback (widget, data, "Xmp.iptcExt.OrganisationInImageName"); +} + +static void +feat_org_code_remove_callback (GtkWidget *widget, + gpointer data) +{ + list_row_remove_callback (widget, data, "Xmp.iptcExt.OrganisationInImageCode"); +} + +static void +artwork_object_remove_callback (GtkWidget *widget, + gpointer data) +{ + list_row_remove_callback (widget, data, "Xmp.iptcExt.ArtworkOrObject"); +} + +static void +reg_entry_remove_callback (GtkWidget *widget, + gpointer data) +{ + list_row_remove_callback (widget, data, "Xmp.iptcExt.RegistryId"); +} + +static void +image_creator_remove_callback (GtkWidget *widget, + gpointer data) +{ + list_row_remove_callback (widget, data, "Xmp.plus.ImageCreator"); +} + +static void +copyright_own_remove_callback (GtkWidget *widget, + gpointer data) +{ + list_row_remove_callback (widget, data, "Xmp.plus.CopyrightOwner"); +} + +static void +licensor_remove_callback (GtkWidget *widget, + gpointer data) +{ + list_row_remove_callback (widget, data, "Xmp.plus.Licensor"); +} + + +/* CELL / ROW ADD */ + +static void +list_row_add_callback (GtkWidget *widget, + gpointer data, + gchar *tag) +{ + GtkBuilder *builder = data; + GtkWidget *list_widget; + GtkListStore *liststore; + GtkTreeIter iter; + + list_widget = builder_get_widget (builder, tag); + + liststore = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (list_widget))); + + gtk_list_store_append (liststore, &iter); +} + +static void +property_release_id_add_callback (GtkWidget *widget, + gpointer data) +{ + list_row_add_callback (widget, data, "Xmp.plus.PropertyReleaseID"); +} + +static void +model_release_id_add_callback (GtkWidget *widget, + gpointer data) +{ + list_row_add_callback (widget, data, "Xmp.plus.ModelReleaseID"); +} + +static void +shown_location_add_callback (GtkWidget *widget, + gpointer data) +{ + list_row_add_callback (widget, data, "Xmp.iptcExt.LocationShown"); +} + +static void +feat_org_name_add_callback (GtkWidget *widget, + gpointer data) +{ + list_row_add_callback (widget, data, "Xmp.iptcExt.OrganisationInImageName"); +} + +static void +feat_org_code_add_callback (GtkWidget *widget, + gpointer data) +{ + list_row_add_callback (widget, data, "Xmp.iptcExt.OrganisationInImageCode"); +} + +static void +artwork_object_add_callback (GtkWidget *widget, + gpointer data) +{ + list_row_add_callback (widget, data, "Xmp.iptcExt.ArtworkOrObject"); +} + +static void +reg_entry_add_callback (GtkWidget *widget, + gpointer data) +{ + list_row_add_callback (widget, data, "Xmp.iptcExt.RegistryId"); +} + +static void +image_creator_add_callback (GtkWidget *widget, + gpointer data) +{ + list_row_add_callback (widget, data, "Xmp.plus.ImageCreator"); +} + +static void +copyright_own_add_callback (GtkWidget *widget, + gpointer data) +{ + list_row_add_callback (widget, data, "Xmp.plus.CopyrightOwner"); +} + +static void +licensor_add_callback (GtkWidget *widget, + gpointer data) +{ + list_row_add_callback (widget, data, "Xmp.plus.Licensor"); +} + + +/* Set dialog display settings and data */ + +static void +metadata_dialog_editor_set_metadata (GExiv2Metadata *metadata, + GtkBuilder *builder) +{ + GtkWidget *combo_widget; + GtkWidget *entry_widget; + GtkWidget *text_widget; + GtkWidget *button_widget; + gint width, height; + gchar *value; + gint i; + + gint32 numele = n_default_metadata_tags; + + /* Setup Buttons */ + button_widget = builder_get_widget (builder, "add_licensor_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (licensor_add_callback), + builder); + + button_widget = builder_get_widget (builder, "rem_licensor_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (licensor_remove_callback), + builder); + + button_widget = builder_get_widget (builder, "add_copyright_own_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (copyright_own_add_callback), + builder); + + button_widget = builder_get_widget (builder, "rem_copyright_own_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (copyright_own_remove_callback), + builder); + + button_widget = builder_get_widget (builder, "add_image_creator_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (image_creator_add_callback), + builder); + + button_widget = builder_get_widget (builder, "rem_image_creator_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (image_creator_remove_callback), + builder); + + button_widget = builder_get_widget (builder, "add_reg_entry_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (reg_entry_add_callback), + builder); + + button_widget = builder_get_widget (builder, "rem_reg_entry_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (reg_entry_remove_callback), + builder); + + button_widget = builder_get_widget (builder, "add_artwork_object_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (artwork_object_add_callback), + builder); + + button_widget = builder_get_widget (builder, "rem_artwork_object_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (artwork_object_remove_callback), + builder); + + button_widget = builder_get_widget (builder, "add_feat_org_code_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (feat_org_code_add_callback), + builder); + + button_widget = builder_get_widget (builder, "rem_feat_org_code_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (feat_org_code_remove_callback), + builder); + + button_widget = builder_get_widget (builder, "add_feat_org_name_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (feat_org_name_add_callback), + builder); + + button_widget = builder_get_widget (builder, "rem_feat_org_name_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (feat_org_name_remove_callback), + builder); + + button_widget = builder_get_widget (builder, "add_shown_location_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (shown_location_add_callback), + builder); + + button_widget = builder_get_widget (builder, "rem_shown_location_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (shown_location_remove_callback), + builder); + + button_widget = builder_get_widget (builder, "add_model_rel_id_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (model_release_id_add_callback), + builder); + + button_widget = builder_get_widget (builder, "rem_model_rel_id_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (model_release_id_remove_callback), + builder); + + button_widget = builder_get_widget (builder, "add_prop_rel_id_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (property_release_id_add_callback), + builder); + + button_widget = builder_get_widget (builder, "rem_prop_rel_id_button"); + g_signal_connect (G_OBJECT (button_widget), "clicked", + G_CALLBACK (property_release_id_remove_callback), + builder); + + + /* Setup Comboboxes */ + combo_widget = builder_get_widget (builder, "Xmp.xmp.Rating"); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_widget), + _("Unrated")); + for (i = 1; i < 6; i++) + { + gchar *display = g_strdup_printf ("%d", i); + + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_widget), + display); + g_free (display); + } + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_widget), 0); + + combo_widget = builder_get_widget (builder, "Xmp.xmpRights.Marked"); + for (i = 0; i < 3; i++) + { + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_widget), + gettext (marked[i].display)); + } + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_widget), 0); + + combo_widget = builder_get_widget (builder, "Xmp.photoshop.Urgency"); + for (i = 0; i < 9; i++) + { + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_widget), + gettext (urgency[i])); + } + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_widget), 0); + + combo_widget = builder_get_widget (builder, "Xmp.plus.MinorModelAgeDisclosure"); + for (i = 0; i < 13; i++) + { + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_widget), + gettext (minormodelagedisclosure[i].display)); + } + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_widget), 0); + + combo_widget = builder_get_widget (builder, "Xmp.plus.ModelReleaseStatus"); + for (i = 0; i < 4; i++) + { + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_widget), + gettext (modelreleasestatus[i].display)); + } + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_widget), 0); + gtk_widget_get_size_request (combo_widget, &width, &height); + gtk_widget_set_size_request (combo_widget, 180, height); + + combo_widget = builder_get_widget (builder, "Xmp.iptcExt.DigitalSourceType"); + for (i = 0; i < 5; i++) + { + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_widget), + gettext (digitalsourcetype[i].display)); + } + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_widget), 0); + + combo_widget = builder_get_widget (builder, "Xmp.plus.PropertyReleaseStatus"); + for (i = 0; i < 4; i++) + { + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_widget), + gettext (propertyreleasestatus[i].display)); + } + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_widget), 0); + gtk_widget_get_size_request (combo_widget, &width, &height); + gtk_widget_set_size_request (combo_widget, 180, height); + + combo_widget = builder_get_widget (builder, "Xmp.DICOM.PatientSex"); + for (i = 0; i < 4; i++) + { + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_widget), + gettext (dicom[i].display)); + } + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_widget), 0); + + combo_widget = builder_get_widget (builder, "Exif.GPSInfo.GPSLatitudeRef"); + for (i = 0; i < 3; i++) + { + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_widget), + gettext (gpslatref[i])); + } + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_widget), 0); + + combo_widget = builder_get_widget (builder, "Exif.GPSInfo.GPSLongitudeRef"); + for (i = 0; i < 3; i++) + { + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_widget), + gettext (gpslngref[i])); + } + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_widget), 0); + + combo_widget = builder_get_widget (builder, "Exif.GPSInfo.GPSAltitudeRef"); + for (i = 0; i < 3; i++) + { + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_widget), + gettext (gpsaltref[i])); + } + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_widget), 0); + + combo_widget = builder_get_widget (builder, "GPSAltitudeSystem"); + for (i = 0; i < 2; i++) + { + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_widget), + gettext (gpsaltsys[i])); + } + + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_widget), 0); + + g_signal_connect (G_OBJECT (combo_widget), "changed", + G_CALLBACK (gpsaltsys_combo_callback), + builder); + + /* Set up text view heights */ + for (i = 0; i < numele; i++) + { + if (! strcmp ("multi", default_metadata_tags[i].mode)) + { + text_widget = builder_get_widget (builder, + default_metadata_tags[i].tag); + gtk_widget_get_size_request (text_widget, &width, &height); + gtk_widget_set_size_request (text_widget, width, height + 60); + } + } + + for (i = 0; i < creatorContactInfoHeader.size; i++) + { + if (! strcmp ("multi", creatorContactInfoTags[i].mode)) + { + text_widget = builder_get_widget (builder, + creatorContactInfoTags[i].id); + gtk_widget_get_size_request (text_widget, &width, &height); + gtk_widget_set_size_request (text_widget, width, height + 60); + } + } + + /* Set up lists */ + for (i = 0; i < imageSupplierInfoHeader.size; i++) + { + GtkWidget *widget; + + widget = builder_get_widget (builder, + imageSupplierInfoTags[i].id); + + value = gexiv2_metadata_get_tag_interpreted_string (metadata, + imageSupplierInfoTags[i].tag); + + if (value) + { + gchar *value_clean; + gchar *value_utf; + + value_clean = g_strdup (value); + + if (strstr (value_clean, lang_default) != NULL) + { + remove_substring (value_clean, lang_default); + if (strstr (value_clean, " ") != NULL) + { + remove_substring (value_clean, " "); + } + } + + if (strstr (value_clean, bag_default) != NULL) + { + remove_substring (value_clean, bag_default); + if (strstr (value_clean, " ") != NULL) + { + remove_substring (value_clean, " "); + } + } + + if (strstr (value_clean, seq_default) != NULL) + { + remove_substring (value_clean, seq_default); + if (strstr (value_clean, " ") != NULL) + { + remove_substring (value_clean, " "); + } + } + + value_utf = g_locale_to_utf8 (value_clean, -1, NULL, NULL, NULL); + + if (! strcmp ("single", imageSupplierInfoTags[i].mode)) + { + gtk_entry_set_text (GTK_ENTRY (widget), value_utf); + } + else if (! strcmp ("multi", imageSupplierInfoTags[i].mode)) + { + GtkTextBuffer *buffer; + + buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)); + gtk_text_buffer_set_text (buffer, value_utf, -1); + } + } + } + + for (i = 0; i < locationCreationInfoHeader.size; i++) + { + GtkWidget *widget; + + widget = builder_get_widget (builder, + locationCreationInfoTags[i].id); + + value = gexiv2_metadata_get_tag_interpreted_string (metadata, + locationCreationInfoTags[i].tag); + + if (value) + { + gchar *value_clean; + gchar *value_utf; + + value_clean = g_strdup (value); + + if (strstr (value_clean, lang_default) != NULL) + { + remove_substring (value_clean, lang_default); + if (strstr (value_clean, " ") != NULL) + { + remove_substring (value_clean, " "); + } + } + + if (strstr (value_clean, bag_default) != NULL) + { + remove_substring (value_clean, bag_default); + if (strstr (value_clean, " ") != NULL) + { + remove_substring (value_clean, " "); + } + } + + if (strstr (value_clean, seq_default) != NULL) + { + remove_substring (value_clean, seq_default); + if (strstr (value_clean, " ") != NULL) + { + remove_substring (value_clean, " "); + } + } + + value_utf = g_locale_to_utf8 (value_clean, -1, NULL, NULL, NULL); + + if (! strcmp ("single", locationCreationInfoTags[i].mode)) + { + gtk_entry_set_text (GTK_ENTRY (widget), value_utf); + } + } + } + + /* Set up tag data */ + + for (i = 0; i < creatorContactInfoHeader.size; i++) + { + GtkWidget *widget; + + widget = builder_get_widget (builder, creatorContactInfoTags[i].id); + + value = gexiv2_metadata_get_tag_interpreted_string (metadata, + creatorContactInfoTags[i].tag); + + if (value) + { + gchar *value_clean; + gchar *value_utf; + + value_clean = g_strdup (value); + + if (strstr (value_clean, lang_default) != NULL) + { + remove_substring (value_clean, lang_default); + if (strstr (value_clean, " ") != NULL) + { + remove_substring (value_clean, " "); + } + } + + if (strstr (value_clean, bag_default) != NULL) + { + remove_substring (value_clean, bag_default); + if (strstr (value_clean, " ") != NULL) + { + remove_substring (value_clean, " "); + } + } + + if (strstr (value_clean, seq_default) != NULL) + { + remove_substring (value_clean, seq_default); + if (strstr (value_clean, " ") != NULL) + { + remove_substring (value_clean, " "); + } + } + + value_utf = g_locale_to_utf8 (value_clean, -1, NULL, NULL, NULL); + + if (! strcmp ("single", creatorContactInfoTags[i].mode)) + { + gtk_entry_set_text (GTK_ENTRY (widget), value_utf); + } + else if (! strcmp ("multi", creatorContactInfoTags[i].mode)) + { + GtkTextBuffer *buffer; + buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)); + gtk_text_buffer_set_text (buffer, value_utf, -1); + } + } + } + + for (i = 0; i < numele; i++) + { + GtkWidget *widget; + + widget = builder_get_widget (builder, default_metadata_tags[i].tag); + + value = gexiv2_metadata_get_tag_interpreted_string (metadata, + default_metadata_tags[i].tag); + + if (! value || value[0] == '\0') + { + gint index; + + if (value) + g_free (value); + + index = default_metadata_tags[i].other_tag_index; + if (index > -1) + { + value = gexiv2_metadata_get_tag_interpreted_string (metadata, + equivalent_metadata_tags[index].tag); + } + } + + if (value) + { + gchar *value_clean; + gchar *value_utf; + + value_clean = g_strdup (value); + + if (strstr (value_clean, lang_default) != NULL) + { + remove_substring (value_clean, lang_default); + if (strstr (value_clean, " ") != NULL) + { + remove_substring (value_clean, " "); + } + } + + if (strstr (value_clean, bag_default) != NULL) + { + remove_substring (value_clean, bag_default); + if (strstr (value_clean, " ") != NULL) + { + remove_substring (value_clean, " "); + } + } + + if (strstr (value_clean, seq_default) != NULL) + { + remove_substring (value_clean, seq_default); + if (strstr (value_clean, " ") != NULL) + { + remove_substring (value_clean, " "); + } + } + + if (! strcmp ("Exif.GPSInfo.GPSAltitude", + default_metadata_tags[i].tag) && + value_clean) + { + gchar *new_value_clean[2]; + + new_value_clean[0] = strtok (value_clean, " "); + strcpy (value_clean, new_value_clean[0]); + } + + value_utf = g_locale_to_utf8 (value_clean, -1, NULL, NULL, NULL); + + if (! strcmp ("single", default_metadata_tags[i].mode)) + { + gtk_entry_set_text (GTK_ENTRY (widget), value_utf); + } + else if (! strcmp ("multi", default_metadata_tags[i].mode)) + { + GtkTextBuffer *buffer; + + buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)); + gtk_text_buffer_set_text (buffer, value_utf, -1); + } + else if (!strcmp ("list", default_metadata_tags[i].mode)) + { + if (! strcmp ("Xmp.plus.CopyrightOwner", + default_metadata_tags[i].tag)) + { + GList *rlist; + GList *r; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gint store_index; + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + /* COPYRIGHT OWNER - NAME */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_CR_OWNER_NAME); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (cr_owner_name_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", GINT_TO_POINTER (COL_CR_OWNER_NAME)); + } + + /* COPYRIGHT OWNER - ID */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_CR_OWNER_ID); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (cr_owner_id_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", GINT_TO_POINTER (COL_CR_OWNER_ID)); + } + + store_index = 0; + + if (store_index > 0) + { + gint item; + + for (item = 0; item < store_index; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_CR_OWNER_NAME, NULL, + COL_CR_OWNER_ID, NULL, + -1); + } + } + else + { + gint item; + + for (item = 0; item < 2; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_CR_OWNER_NAME, NULL, + COL_CR_OWNER_ID, NULL, + -1); + } + } + } + else if (! strcmp ("Xmp.plus.ImageCreator", + default_metadata_tags[i].tag)) + { + GList *rlist; + GList *r; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gint store_index; + gchar arr1[256][256]; + gchar arr2[256][256]; + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + /* IMAGE CREATOR - NAME */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_IMG_CR8_NAME); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (img_cr8_name_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", GINT_TO_POINTER (COL_IMG_CR8_NAME)); + } + + /* IMAGE CREATOR - ID */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_IMG_CR8_ID); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (img_cr8_id_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", GINT_TO_POINTER (COL_IMG_CR8_ID)); + } + + store_index = 0; + + if (store_index > 0) + { + gint item; + + for (item = 0; item < store_index; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_IMG_CR8_NAME, &arr1[item], + COL_IMG_CR8_ID, &arr2[item], + -1); + } + } + else + { + gint item; + + for (item = 0; item < 2; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_IMG_CR8_NAME, NULL, + COL_IMG_CR8_ID, NULL, + -1); + } + } + } + else if (! strcmp ("Xmp.iptcExt.ArtworkOrObject", + default_metadata_tags[i].tag)) + { + GList *rlist; + GList *r; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gint store_index; + gchar arr1[256][256]; + gchar arr2[256][256]; + gchar arr3[256][256]; + gchar arr4[256][256]; + gchar arr5[256][256]; + gchar arr6[256][256]; + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + /* ARTWORK OR OBJECT - TITLE */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_AOO_TITLE); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (aoo_title_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", GINT_TO_POINTER (COL_AOO_TITLE)); + } + + /* ARTWORK OR OBJECT - DATE CREATED */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_AOO_DATE_CREAT); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r != NULL; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (aoo_date_creat_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", GINT_TO_POINTER (COL_AOO_DATE_CREAT)); + } + + /* ARTWORK OR OBJECT - CREATOR */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_AOO_CREATOR); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r != NULL; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (aoo_creator_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", GINT_TO_POINTER (COL_AOO_CREATOR)); + } + + /* ARTWORK OR OBJECT - SOURCE */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_AOO_SOURCE); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (aoo_source_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", GINT_TO_POINTER (COL_AOO_SOURCE)); + } + + /* ARTWORK OR OBJECT - SOURCE INVENTORY ID */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_AOO_SRC_INV_ID); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (aoo_source_inv_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", GINT_TO_POINTER (COL_AOO_SRC_INV_ID)); + } + + /* ARTWORK OR OBJECT - COPYRIGHT NOTICE */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_AOO_CR_NOT); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (aoo_copyright_notice_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", GINT_TO_POINTER (COL_AOO_CR_NOT)); + } + + store_index = 0; + + if (store_index > 0) + { + gint item; + + for (item = 0; item < store_index; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_AOO_TITLE, &arr1[item], + COL_AOO_DATE_CREAT, &arr2[item], + COL_AOO_CREATOR, &arr3[item], + COL_AOO_SOURCE, &arr4[item], + COL_AOO_SRC_INV_ID, &arr5[item], + COL_AOO_CR_NOT, &arr6[item], + -1); + } + } + else + { + gint item; + + for (item = 0; item < 2; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_AOO_TITLE, NULL, + COL_AOO_DATE_CREAT, NULL, + COL_AOO_CREATOR, NULL, + COL_AOO_SOURCE, NULL, + COL_AOO_SRC_INV_ID, NULL, + COL_AOO_CR_NOT, NULL, + -1); + } + } + } + else if (! strcmp ("Xmp.iptcExt.RegistryId", + default_metadata_tags[i].tag)) + { + GList *rlist; + GList *r; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gint store_index; + gchar arr1[256][256]; + gchar arr2[256][256]; + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + /* LOCATION SHOWN - SUB LOCATION */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_REGSITRY_ORG_ID); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r != NULL; r = r->next) + { + renderer = (GtkCellRenderer*) r->data; + g_object_set (renderer, + "editable", TRUE, + NULL); + g_signal_connect (renderer, "edited", + G_CALLBACK (reg_org_id_cell_edited_callback), treemodel); + g_object_set_data (G_OBJECT (renderer), + "column", GINT_TO_POINTER (COL_REGSITRY_ORG_ID)); + } + + /* LOCATION SHOWN - CITY */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_REGSITRY_ITEM_ID); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (reg_item_id_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", GINT_TO_POINTER (COL_REGSITRY_ITEM_ID)); + } + + store_index = 0; + + if (store_index > 0) + { + gint item; + + for (item = 0; item < store_index; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_REGSITRY_ORG_ID, &arr1[item], + COL_REGSITRY_ITEM_ID, &arr2[item], + -1); + } + } + else + { + gint item; + + for (item = 0; item < 2; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_REGSITRY_ORG_ID, NULL, + COL_REGSITRY_ITEM_ID, NULL, + -1); + } + } + } + else if (! strcmp ("Xmp.iptcExt.OrganisationInImageName", + default_metadata_tags[i].tag)) + { + GList *rlist; + GList *r; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gchar *str; + gint i_ctr; + gint store_index; + gchar arr[256][256]; + + /* separate list on commas */ + store_index = 0; + if (value) + { + for (i_ctr = 0, str = strtok (value, ",;"); + str; + i_ctr++, str = strtok (NULL, ",;")) + { + /* remove leading whitespace */ + gint l = strlen (str); + + while (isspace (str[l - 1])) --l; + while (* str && isspace (*str)) ++str, --l; + + /* stuff into array */ + strcpy (arr[i_ctr], str); + store_index++; + } + } + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)), + GTK_SELECTION_SINGLE); + + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), 0); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (organisation_image_name_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", GINT_TO_POINTER (COL_ORG_IMG_NAME)); + } + + if (store_index > 0) + { + gint item; + + for (item = 0; item < store_index; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_ORG_IMG_NAME, &arr[item], + -1); + } + } + else + { + gint item; + + for (item = 0; item < 2; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_ORG_IMG_NAME, NULL, + -1); + } + } + } + else if (! strcmp ("Xmp.iptcExt.OrganisationInImageCode", + default_metadata_tags[i].tag)) + { + GList *rlist; + GList *r; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gchar *str; + int i_ctr; + int store_index; + gchar arr[256][256]; + + /* separate list on commas */ + store_index = 0; + if (value) + { + for (i_ctr = 0, str = strtok (value, ",;"); + str; + i_ctr++, str = strtok (NULL, ",;")) + { + /* remove leading whitespace */ + gint l = strlen (str); + + while (isspace (str[l - 1])) --l; + while (* str && isspace (*str)) ++str, --l; + + /* stuff into array */ + strcpy (arr[i_ctr], str); + store_index++; + } + } + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)), + GTK_SELECTION_SINGLE); + + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), 0); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (organisation_image_code_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", GINT_TO_POINTER (COL_ORG_IMG_CODE)); + } + + if (store_index > 0) + { + gint item; + + for (item = 0; item < store_index; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_ORG_IMG_CODE, &arr[item], + -1); + } + } + else + { + gint item; + + for (item = 0; item < 2; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_ORG_IMG_CODE, NULL, + -1); + } + } + } + else if (! strcmp ("Xmp.plus.PropertyReleaseID", + default_metadata_tags[i].tag)) + { + GList *rlist; + GList *r; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gchar *str; + int i_ctr; + int store_index; + gchar arr[256][256]; + + /* separate list on commas */ + store_index = 0; + if (value) + { + for (i_ctr = 0, str = strtok (value, ",;"); + str; + i_ctr++, str = strtok (NULL, ",;")) + { + /* remove leading whitespace */ + gint l = strlen (str); + + while (isspace (str[l - 1])) --l; + while (* str && isspace (*str)) ++str, --l; + + /* stuff into array */ + strcpy (arr[i_ctr], str); + store_index++; + } + } + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)), + GTK_SELECTION_SINGLE); + + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), 0); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (prop_rel_id_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_PROP_REL_ID)); + } + + if (store_index > 0) + { + gint item; + + for (item = 0; item < store_index; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_PROP_REL_ID, &arr[item], + -1); + } + + if (store_index == 1) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_PROP_REL_ID, NULL, + -1); + } + } + else + { + gint item; + + for (item = 0; item < 2; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_PROP_REL_ID, NULL, + -1); + } + } + } + else if (! strcmp ("Xmp.plus.ModelReleaseID", + default_metadata_tags[i].tag)) + { + GList *rlist; + GList *r; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gchar *str; + int i_ctr; + int store_index; + gchar arr[256][256]; + + /* separate list on commas */ + store_index = 0; + if (value) + { + for (i_ctr = 0, str = strtok (value, ",;"); + str; + i_ctr++, str = strtok (NULL, ",;")) + { + /* remove leading whitespace */ + gint l = strlen (str); + + while (isspace (str[l - 1])) --l; + while (*str && isspace (*str)) ++str, --l; + + /* stuff into array */ + strcpy (arr[i_ctr], str); + store_index++; + } + } + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)), + GTK_SELECTION_SINGLE); + + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), 0); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (mod_rel_id_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_PROP_REL_ID)); + } + + if (store_index > 0) + { + gint item; + + for (item = 0; item < store_index; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_MOD_REL_ID, &arr[item], + -1); + } + + if (store_index == 1) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_MOD_REL_ID, NULL, + -1); + } + } + else + { + gint item; + + for (item = 0; item < 2; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_MOD_REL_ID, NULL, + -1); + } + } + } + } + else if (! strcmp ("combo", default_metadata_tags[i].mode)) + { + gint32 data = 0; + + if (! strcmp ("Exif.GPSInfo.GPSLatitudeRef", + default_metadata_tags[i].tag)) + { + if (! strncmp ("N", value, 1)) + { + data = 1; + } + else if (! strncmp ("S", value, 1)) + { + data = 2; + } + + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), data); + } + else if (! strcmp ("Exif.GPSInfo.GPSLongitudeRef", + default_metadata_tags[i].tag)) + { + if (! strncmp ("E", value, 1)) + { + data = 1; + } + else if (! strncmp ("W", value, 1)) + { + data = 2; + } + + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), data); + } + else if (! strcmp ("Exif.GPSInfo.GPSAltitudeRef", + default_metadata_tags[i].tag)) + { + if (! strncmp ("A", value, 1)) + { + data = 1; + } + else if (! strncmp ("B", value, 1)) + { + data = 2; + } + + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), data); + } + else if (! strcmp ("Xmp.xmp.Rating", default_metadata_tags[i].tag)) + { + if (! strcmp ("1", value)) + { + data = 1; + } + else if (! strcmp ("2", value)) + { + data = 2; + } + else if (! strcmp ("3", value)) + { + data = 3; + } + else if (! strcmp ("4", value)) + { + data = 4; + } + else if (! strcmp ("5", value)) + { + data = 5; + } + + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), data); + } + else if (! strcmp ("Xmp.xmpRights.Marked", + default_metadata_tags[i].tag)) + { + if (! strcmp ("True", value)) + { + data = 1; + } + else if (! strcmp ("False", value)) + { + data = 2; + } + + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), data); + } + else if (! strcmp ("Xmp.photoshop.Urgency", + default_metadata_tags[i].tag)) + { + if (! strcmp ("1", value)) + { + data = 1; + } + else if (! strcmp ("2", value)) + { + data = 2; + } + else if (! strcmp ("3", value)) + { + data = 3; + } + else if (! strcmp ("4", value)) + { + data = 4; + } + else if (! strcmp ("5", value)) + { + data = 5; + } + else if (! strcmp ("6", value)) + { + data = 6; + } + else if (! strcmp ("7", value)) + { + data = 7; + } + else if (! strcmp ("8", value)) + { + data = 8; + } + + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), data); + } + else if (! strcmp ("Xmp.plus.MinorModelAgeDisclosure", + default_metadata_tags[i].tag)) + { + if (! strcmp ("Age Unknown", value)) + { + data = 0; + } + else if (! strcmp ("Age 25 or Over", value)) + { + data = 1; + } + else if (! strcmp ("Age 24", value)) + { + data = 2; + } + else if (! strcmp ("Age 23", value)) + { + data = 3; + } + else if (! strcmp ("Age 22", value)) + { + data = 4; + } + else if (! strcmp ("Age 21", value)) + { + data = 5; + } + else if (! strcmp ("Age 20", value)) + { + data = 6; + } + else if (! strcmp ("Age 19", value)) + { + data = 7; + } + else if (! strcmp ("Age 18", value)) + { + data = 8; + } + else if (! strcmp ("Age 17", value)) + { + data = 9; + } + else if (! strcmp ("Age 16", value)) + { + data = 10; + } + else if (! strcmp ("Age 15", value)) + { + data = 11; + } + else if (! strcmp ("Age 14 or Under", value)) + { + data = 12; + } + + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), data); + } + else if (! strcmp ("Xmp.plus.ModelReleaseStatus", + default_metadata_tags[i].tag)) + { + gint loop; + + for (loop = 0; loop < 4; loop++) + { + if (! strcmp (modelreleasestatus[loop].data, value)) + { + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), loop); + break; + } + + if (! strcmp (gettext (modelreleasestatus[loop].display), + value)) + { + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), loop); + break; + } + } + } + else if (! strcmp ("Xmp.iptcExt.DigitalSourceType", + default_metadata_tags[i].tag)) + { + gint loop; + + for (loop = 0; loop < 5; loop++) + { + if (! strcmp (digitalsourcetype[loop].data, value)) + { + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), loop); + break; + } + + if (! strcmp (gettext (digitalsourcetype[loop].display), + value)) + { + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), loop); + break; + } + } + } + else if (! strcmp ("Xmp.plus.PropertyReleaseStatus", + default_metadata_tags[i].tag)) + { + gint loop; + + for (loop = 0; loop < 4; loop++) + { + if (! strcmp (propertyreleasestatus[loop].data, value)) + { + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), loop); + break; + } + + if (! strcmp (gettext (propertyreleasestatus[loop].display), + value)) + { + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), loop); + break; + } + } + } + else if (! strcmp ("Xmp.DICOM.PatientSex", + default_metadata_tags[i].tag)) + { + if (! strcmp ("male", value)) + { + data = 1; + } + else if (! strcmp ("female", value)) + { + data = 2; + } + else if (! strcmp ("other", value)) + { + data = 3; + } + + gtk_combo_box_set_active (GTK_COMBO_BOX (widget), data); + } + } + } + else + { + if (! strcmp ("list", default_metadata_tags[i].mode)) + { + if (! strcmp ("Xmp.plus.Licensor", default_metadata_tags[i].tag)) + { + GList *rlist; + GList *r; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreeModel *treemodel; + GtkTreeModel *phonemodel; + GtkListStore *liststore; + GtkListStore *phonestore; + GtkTreeIter iter; + GtkTreeIter phoneiter; + gint counter; + gint j; + + counter = count_tags (metadata, LICENSOR_HEADER, + licensor, + n_licensor); + + get_tags (metadata, LICENSOR_HEADER, + licensor, + n_licensor, counter); + + phonestore = gtk_list_store_new (1, G_TYPE_STRING); + gtk_list_store_append (phonestore, &phoneiter); + gtk_list_store_set (phonestore, &phoneiter, 0, "Unknown", -1); + for (j=1; j < 6; j++) + { + gtk_list_store_append (phonestore, &phoneiter); + gtk_list_store_set (phonestore, &phoneiter, + 0, gettext (phone_types[j].display), + -1); + } + phonemodel = GTK_TREE_MODEL (phonestore); + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + /* LICENSOR - NAME */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_LICENSOR_NAME); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (licensor_name_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_LICENSOR_NAME)); + } + + /* LICENSOR - ID */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_LICENSOR_ID); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (licensor_id_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_LICENSOR_ID)); + } + + /* LICENSOR - PHONE NUMBER 1 */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_LICENSOR_PHONE1); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (licensor_phone1_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_LICENSOR_PHONE1)); + } + + /* LICENSOR - PHONE TYPE 1 */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_LICENSOR_PHONE_TYPE1); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + "text-column", 0, + "has-entry", FALSE, + "model", phonemodel, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (licensor_phone_type1_cell_edited_callback), + widget); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_LICENSOR_PHONE_TYPE1)); + } + + /* LICENSOR - PHONE NUMBER 2 */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_LICENSOR_PHONE2); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (licensor_phone2_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_LICENSOR_PHONE2)); + } + + /* LICENSOR - PHONE TYPE 2 */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_LICENSOR_PHONE_TYPE2); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + "text-column", 0, + "has-entry", FALSE, + "model", phonemodel, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (licensor_phone_type2_cell_edited_callback), + widget); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_LICENSOR_PHONE_TYPE2)); + } + + /* LICENSOR - EMAIL */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_LICENSOR_EMAIL); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (licensor_email_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_LICENSOR_EMAIL)); + } + + /* LICENSOR - WEB ADDRESS */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_LICENSOR_WEB); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (licensor_web_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_LICENSOR_WEB)); + } + + if (counter > 0) + { + gint item; + + for (item = 0; item < counter; item++) + { + gchar type1[256]; + gchar type2[256]; + gint types; + + strcpy (type1, gettext (phone_types[0].display)); + strcpy (type2, gettext (phone_types[0].display)); + + for (types = 0; types < 6; types++) + { + if (! strcmp (tagdata[item][3], + phone_types[types].data)) + { + strcpy (type1, + gettext (phone_types[types].display)); + } + + if (! strcmp (tagdata[item][5], + phone_types[types].data)) + { + strcpy (type2, + gettext (phone_types[types].display)); + } + } + + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_LICENSOR_NAME, tagdata[item][0], + COL_LICENSOR_ID, tagdata[item][1], + COL_LICENSOR_PHONE1, tagdata[item][2], + COL_LICENSOR_PHONE_TYPE1, (gchar*)&type1, + COL_LICENSOR_PHONE2, tagdata[item][4], + COL_LICENSOR_PHONE_TYPE2, (gchar*)&type2, + COL_LICENSOR_EMAIL, tagdata[item][6], + COL_LICENSOR_WEB, tagdata[item][7], + -1); + } + } + else + { + gint item; + + for (item = 0; item < 2; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_LICENSOR_NAME, NULL, + COL_LICENSOR_ID, NULL, + COL_LICENSOR_PHONE1, NULL, + COL_LICENSOR_PHONE_TYPE1, gettext (phone_types[0].display), + COL_LICENSOR_PHONE2, NULL, + COL_LICENSOR_PHONE_TYPE1, gettext (phone_types[0].display), + COL_LICENSOR_EMAIL, NULL, + COL_LICENSOR_WEB, NULL, + -1); + } + } + } + else if (! strcmp ("Xmp.plus.CopyrightOwner", + default_metadata_tags[i].tag)) + { + GList *rlist; + GList *r; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gint counter; + + counter = count_tags (metadata, COPYRIGHTOWNER_HEADER, + copyrightowner, + n_copyrightowner); + + get_tags (metadata, COPYRIGHTOWNER_HEADER, + copyrightowner, + n_copyrightowner, counter); + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + /* COPYRIGHT OWNER - NAME */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_CR_OWNER_NAME); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (cr_owner_name_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_CR_OWNER_NAME)); + } + + /* COPYRIGHT OWNER - ID */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_CR_OWNER_ID); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (cr_owner_id_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_CR_OWNER_ID)); + } + + if (counter > 0) + { + gint item; + + for (item = 0; item < counter; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_CR_OWNER_NAME, tagdata[item][0], + COL_CR_OWNER_ID, tagdata[item][1], + -1); + } + } + else + { + gint item; + + for (item = 0; item < 2; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_CR_OWNER_NAME, NULL, + COL_CR_OWNER_ID, NULL, + -1); + } + } + } + else if (! strcmp ("Xmp.plus.ImageCreator", + default_metadata_tags[i].tag)) + { + GList *rlist; + GList *r; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gint counter; + + counter = count_tags (metadata, IMAGECREATOR_HEADER, + imagecreator, + n_imagecreator); + + get_tags (metadata, IMAGECREATOR_HEADER, + imagecreator, + n_imagecreator, counter); + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + /* IMAGE CREATOR - NAME */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_IMG_CR8_NAME); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (img_cr8_name_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_IMG_CR8_NAME)); + } + + /* IMAGE CREATOR - ID */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_IMG_CR8_ID); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (img_cr8_id_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_IMG_CR8_ID)); + } + + if (counter > 0) + { + gint item; + + for (item = 0; item < counter; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_IMG_CR8_NAME, tagdata[item][0], + COL_IMG_CR8_ID, tagdata[item][1], + -1); + } + } + else + { + gint item; + + for (item = 0; item < 2; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_IMG_CR8_NAME, NULL, + COL_IMG_CR8_ID, NULL, + -1); + } + } + } + else if (! strcmp ("Xmp.iptcExt.ArtworkOrObject", + default_metadata_tags[i].tag)) + { + GList *rlist; + GList *r; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gint counter; + + counter = count_tags (metadata, ARTWORKOROBJECT_HEADER, + artworkorobject, + n_artworkorobject); + + get_tags (metadata, ARTWORKOROBJECT_HEADER, + artworkorobject, + n_artworkorobject, counter); + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + /* ARTWORK OR OBJECT - TITLE */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_AOO_TITLE); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (aoo_title_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_AOO_TITLE)); + } + + /* ARTWORK OR OBJECT - DATED CREATED */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_AOO_DATE_CREAT); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (aoo_date_creat_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_AOO_DATE_CREAT)); + } + + /* ARTWORK OR OBJECT - CREATOR */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_AOO_CREATOR); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (aoo_creator_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_AOO_CREATOR)); + } + + /* ARTWORK OR OBJECT - SOURCE */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_AOO_SOURCE); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (aoo_source_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_AOO_SOURCE)); + } + + /* ARTWORK OR OBJECT - SOURCE INVENTORY ID */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_AOO_SRC_INV_ID); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (aoo_source_inv_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_AOO_SRC_INV_ID)); + } + + /* ARTWORK OR OBJECT - COPYRIGHT NOTICE */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_AOO_CR_NOT); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (aoo_copyright_notice_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_AOO_CR_NOT)); + } + + if (counter > 0) + { + gint item; + + for (item = 0; item < counter; item++) + { + /* remove substring for language id in title field */ + remove_substring (tagdata[item][4], lang_default); + if (strstr (tagdata[item][4], " ")) + { + remove_substring (tagdata[item][4], " "); + } + + remove_substring (tagdata[item][4], bag_default); + if (strstr (tagdata[item][4], " ")) + { + remove_substring (tagdata[item][4], " "); + } + + remove_substring (tagdata[item][4], seq_default); + if (strstr (tagdata[item][4], " ")) + { + remove_substring (tagdata[item][4], " "); + } + + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_AOO_TITLE, tagdata[item][4], + COL_AOO_DATE_CREAT, tagdata[item][0], + COL_AOO_CREATOR, tagdata[item][5], + COL_AOO_SOURCE, tagdata[item][1], + COL_AOO_SRC_INV_ID, tagdata[item][2], + COL_AOO_CR_NOT, tagdata[item][3], + -1); + } + } + else + { + gint item; + + for (item = 0; item < 2; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_AOO_TITLE, NULL, + COL_AOO_DATE_CREAT, NULL, + COL_AOO_CREATOR, NULL, + COL_AOO_SOURCE, NULL, + COL_AOO_SRC_INV_ID, NULL, + COL_AOO_CR_NOT, NULL, + -1); + } + } + } + else if (! strcmp ("Xmp.iptcExt.RegistryId", + default_metadata_tags[i].tag)) + { + GList *rlist; + GList *r; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gint counter; + + counter = count_tags (metadata, REGISTRYID_HEADER, + registryid, + n_registryid); + + get_tags (metadata, REGISTRYID_HEADER, + registryid, + n_registryid, counter); + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + /* REGISTRY - ORGANIZATION ID */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_REGSITRY_ORG_ID); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (reg_org_id_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_REGSITRY_ORG_ID)); + } + + /* REGISTRY - ITEM ID */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_REGSITRY_ITEM_ID); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (reg_item_id_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_REGSITRY_ITEM_ID)); + } + + if (counter > 0) + { + gint item; + + for (item = 0; item < counter; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_REGSITRY_ORG_ID, tagdata[item][0], + COL_REGSITRY_ITEM_ID, tagdata[item][1], + -1); + } + } + else + { + gint item; + + for (item = 0; item < 2; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_REGSITRY_ORG_ID, NULL, + COL_REGSITRY_ITEM_ID, NULL, + -1); + } + } + } + else if (! strcmp ("Xmp.iptcExt.LocationShown", + default_metadata_tags[i].tag)) + { + GList *rlist; + GList *r; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gint counter; + + counter = count_tags (metadata, LOCATIONSHOWN_HEADER, + locationshown, + n_locationshown); + + get_tags (metadata, LOCATIONSHOWN_HEADER, + locationshown, + n_locationshown, counter); + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + /* LOCATION SHOWN - SUB LOCATION */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_LOC_SHO_SUB_LOC); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (loc_sho_sub_loc_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_LOC_SHO_SUB_LOC)); + } + + /* LOCATION SHOWN - CITY */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_LOC_SHO_CITY); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (loc_sho_city_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_LOC_SHO_CITY)); + } + + /* LOCATION SHOWN - STATE PROVINCE */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_LOC_SHO_STATE_PROV); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (loc_sho_state_prov_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_LOC_SHO_STATE_PROV)); + } + + /* LOCATION SHOWN - COUNTRY */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_LOC_SHO_CNTRY); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (loc_sho_cntry_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_LOC_SHO_CNTRY)); + } + + /* LOCATION SHOWN - COUNTRY ISO */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_LOC_SHO_CNTRY_ISO); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (loc_sho_cntry_iso_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_LOC_SHO_CNTRY_ISO)); + } + + /* LOCATION SHOWN - WORLD REGION */ + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), + COL_LOC_SHO_CNTRY_WRLD_REG); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (loc_sho_wrld_reg_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_LOC_SHO_CNTRY_WRLD_REG)); + } + + if (counter > 0) + { + gint item; + + for (item = 0; item < counter; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_LOC_SHO_SUB_LOC, tagdata[item][0], + COL_LOC_SHO_CITY, tagdata[item][1], + COL_LOC_SHO_STATE_PROV, tagdata[item][2], + COL_LOC_SHO_CNTRY, tagdata[item][3], + COL_LOC_SHO_CNTRY_ISO, tagdata[item][4], + COL_LOC_SHO_CNTRY_WRLD_REG, tagdata[item][5], + -1); + } + + if (counter == 1) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_LOC_SHO_SUB_LOC, NULL, + COL_LOC_SHO_CITY, NULL, + COL_LOC_SHO_STATE_PROV, NULL, + COL_LOC_SHO_CNTRY, NULL, + COL_LOC_SHO_CNTRY_ISO, NULL, + COL_LOC_SHO_CNTRY_WRLD_REG, NULL, + -1); + } + } + else + { + gint item; + + for (item = 0; item < 2; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_LOC_SHO_SUB_LOC, NULL, + COL_LOC_SHO_CITY, NULL, + COL_LOC_SHO_STATE_PROV, NULL, + COL_LOC_SHO_CNTRY, NULL, + COL_LOC_SHO_CNTRY_ISO, NULL, + COL_LOC_SHO_CNTRY_WRLD_REG, NULL, + -1); + } + } + } + else if (! strcmp ("Xmp.iptcExt.OrganisationInImageName", + default_metadata_tags[i].tag)) + { + GList *rlist; + GList *r; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gchar *str; + gint i_ctr; + gint store_index; + gchar arr[256][256]; + gint item; + + /* separate list on commas */ + store_index = 0; + if (value) + { + for (i_ctr = 0, str = strtok (value, ",;"); + str; + i_ctr++, str = strtok (NULL, ",;")) + { + /* remove leading whitespace */ + gint l = strlen (str); + + while (isspace (str[l - 1])) --l; + while (*str && isspace (*str)) ++str, --l; + + /* stuff into array */ + strcpy (arr[i_ctr], str); + store_index++; + } + } + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)), + GTK_SELECTION_SINGLE); + + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), 0); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (organisation_image_name_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_ORG_IMG_NAME)); + } + + for (item = 0; item < 2; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_ORG_IMG_NAME, NULL, + -1); + } + } + else if (! strcmp ("Xmp.iptcExt.OrganisationInImageCode", + default_metadata_tags[i].tag)) + { + GList *rlist; + GList *r; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gchar *str; + int i_ctr; + int store_index; + gchar arr[256][256]; + gint item; + + /* separate list on commas */ + store_index = 0; + if (value) + { + for (i_ctr = 0, str = strtok (value, ",;"); + str; + i_ctr++, str = strtok (NULL, ",;")) + { + /* remove leading whitespace */ + gint l = strlen (str); + + while (isspace (str[l - 1])) --l; + while (*str && isspace (*str)) ++str, --l; + + /* stuff into array */ + strcpy (arr[i_ctr], str); + store_index++; + } + } + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)), + GTK_SELECTION_SINGLE); + + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), 0); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (organisation_image_code_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_ORG_IMG_CODE)); + } + + for (item = 0; item < 2; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_ORG_IMG_CODE, NULL, + -1); + } + } + else if (! strcmp ("Xmp.plus.PropertyReleaseID", + default_metadata_tags[i].tag)) + { + GList *rlist; + GList *r; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gchar *str; + int i_ctr; + int store_index; + gchar arr[256][256]; + gint item; + + /* separate list on commas */ + store_index = 0; + if (value) + { + for (i_ctr = 0, str = strtok (value, ",;"); + str; + i_ctr++, str = strtok (NULL, ",;")) + { + /* remove leading whitespace */ + gint l = strlen (str); + + while (isspace (str[l - 1])) --l; + while (*str && isspace (*str)) ++str, --l; + + /* stuff into array */ + strcpy (arr[i_ctr], str); + store_index++; + } + } + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)), + GTK_SELECTION_SINGLE); + + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), 0); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (prop_rel_id_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_PROP_REL_ID)); + } + + for (item = 0; item < 2; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_PROP_REL_ID, NULL, + -1); + } + } + else if (! strcmp ("Xmp.plus.ModelReleaseID", + default_metadata_tags[i].tag)) + { + GList *rlist; + GList *r; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gchar *str; + int i_ctr; + int store_index; + gchar arr[256][256]; + gint item; + + /* separate list on commas */ + store_index = 0; + if (value) + { + for (i_ctr = 0, str = strtok (value, ",;"); + str; + i_ctr++, str = strtok (NULL, ",;")) + { + /* remove leading whitespace */ + gint l = strlen (str); + + while (isspace (str[l - 1])) --l; + while (*str && isspace (*str)) ++str, --l; + + /* stuff into array */ + strcpy (arr[i_ctr], str); + store_index++; + } + } + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); + liststore = GTK_LIST_STORE (treemodel); + + gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)), + GTK_SELECTION_SINGLE); + + column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), 0); + rlist = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + for (r = rlist; r; r = r->next) + { + renderer = r->data; + + g_object_set (renderer, + "editable", TRUE, + NULL); + + g_signal_connect (renderer, "edited", + G_CALLBACK (mod_rel_id_cell_edited_callback), + treemodel); + + g_object_set_data (G_OBJECT (renderer), + "column", + GINT_TO_POINTER (COL_PROP_REL_ID)); + } + + for (item = 0; item < 2; item++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_PROP_REL_ID, NULL, + -1); + } + } + } + } + } + + /* Set creation date */ + entry_widget = builder_get_widget (builder, "create_date_button"); + g_signal_connect (entry_widget, "clicked", + G_CALLBACK (on_create_date_button_clicked), + builder_get_widget (builder, + "Xmp.photoshop.DateCreated")); + + /* Set patient dob date */ + entry_widget = builder_get_widget (builder, "dob_date_button"); + g_signal_connect (entry_widget, "clicked", + G_CALLBACK (on_patient_dob_date_button_clicked), + builder_get_widget (builder, + "Xmp.DICOM.PatientDOB")); + + /* Set study date */ + entry_widget = builder_get_widget (builder, "study_date_button"); + g_signal_connect (entry_widget, "clicked", + G_CALLBACK (on_study_date_button_clicked), + builder_get_widget (builder, + "Xmp.DICOM.StudyDateTime")); + + /* Set series date */ + entry_widget = builder_get_widget (builder, "series_date_button"); + g_signal_connect (entry_widget, "clicked", + G_CALLBACK (on_series_date_button_clicked), + builder_get_widget (builder, + "Xmp.DICOM.SeriesDateTime")); +} + + +/* ============================================================================ + * ==[ WRITE METADATA ]======================================================== + * ============================================================================ + */ + +static void +set_tag_string (GimpMetadata *metadata, + const gchar *name, + const gchar *value) +{ + gexiv2_metadata_clear_tag (GEXIV2_METADATA (metadata), name); + + if (metadata == NULL) return; + if (name == NULL) return; + if (value == NULL) return; + + if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (metadata), + name, value)) + { + g_printerr ("metadata-editor: failed to set tag [%s]\n", name); + } +} + +void +metadata_editor_write_callback (GtkWidget *dialog, + GtkBuilder *builder, + gint32 image_id) +{ + GimpMetadata *g_metadata; + gint max_elements; + gint i; + GtkWidget *list_widget; + GtkTreeIter iter; + GtkTreeModel *treemodel; + gchar *rc_data; + gint number_of_rows; + gchar output_data[256 * 1024]; + gchar tag[1024]; + gint counter; + gint row; + + i = 0; + + g_metadata = gimp_image_get_metadata (image_id); + + gimp_metadata_add_xmp_history (g_metadata, "metadata"); + + /* DO ORG IMG NAME (LISTSTORE) */ + + list_widget = builder_get_widget (builder, + "Xmp.iptcExt.OrganisationInImageName"); + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (list_widget)); + + number_of_rows = gtk_tree_model_iter_n_children (treemodel, NULL); + + output_data[0] = 0; + for (row = 0; row < number_of_rows; row++) + { + if (gtk_tree_model_iter_nth_child (treemodel, &iter, NULL, row)) + { + gtk_tree_model_get (treemodel, &iter, + COL_ORG_IMG_NAME, &rc_data, + -1); + if (rc_data && *rc_data) + { + strcat (output_data, rc_data); + if (row + 1 < number_of_rows) + strcat (output_data, ", "); + } + } + } + + set_tag_string (g_metadata, + "Xmp.iptcExt.OrganisationInImageName", + output_data); + + /* DO ORG IMG CODE (LISTSTORE) */ + + list_widget = builder_get_widget (builder, + "Xmp.iptcExt.OrganisationInImageCode"); + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (list_widget)); + + number_of_rows = gtk_tree_model_iter_n_children (treemodel, NULL); + + output_data[0] = 0; + for (row = 0; row < number_of_rows; row++) + { + if (gtk_tree_model_iter_nth_child (treemodel, &iter, NULL, row)) + { + gtk_tree_model_get (treemodel, &iter, + COL_ORG_IMG_CODE, &rc_data, + -1); + if (rc_data && *rc_data) + { + strcat (output_data, rc_data); + if (row + 1 < number_of_rows) + strcat (output_data, ", "); + } + } + } + + set_tag_string (g_metadata, + "Xmp.iptcExt.OrganisationInImageCode", + output_data); + + /* DO MODEL RELEASE (LISTSTORE) */ + + list_widget = builder_get_widget (builder, "Xmp.plus.ModelReleaseID"); + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (list_widget)); + + number_of_rows = gtk_tree_model_iter_n_children (treemodel, NULL); + + output_data[0] = 0; + for (row = 0; row < number_of_rows; row++) + { + if (gtk_tree_model_iter_nth_child (treemodel, &iter, NULL, row)) + { + gtk_tree_model_get (treemodel, &iter, + COL_MOD_REL_ID, &rc_data, + -1); + if (rc_data && *rc_data) + { + strcat (output_data, rc_data); + if (row + 1 < number_of_rows) + strcat (output_data, ", "); + } + } + } + + set_tag_string (g_metadata, + "Xmp.plus.ModelReleaseID", + output_data); + + /* DO PROPERTY RELEASE (LISTSTORE) */ + + list_widget = builder_get_widget (builder, "Xmp.plus.PropertyReleaseID"); + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (list_widget)); + + number_of_rows = gtk_tree_model_iter_n_children (treemodel, NULL); + + output_data[0] = 0; + for (row = 0; row < number_of_rows; row++) + { + if (gtk_tree_model_iter_nth_child (treemodel, &iter, NULL, row)) + { + gtk_tree_model_get (treemodel, &iter, + COL_PROP_REL_ID, &rc_data, + -1); + if (rc_data && *rc_data) + { + strcat (output_data, rc_data); + if (row + 1 < number_of_rows) + strcat (output_data, ", "); + } + } + } + + set_tag_string (g_metadata, + "Xmp.plus.PropertyReleaseID", + output_data); + + /* DO LOCATION SHOWN (LISTSTORE) */ + + list_widget = builder_get_widget (builder, "Xmp.iptcExt.LocationShown"); + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (list_widget)); + + number_of_rows = gtk_tree_model_iter_n_children (treemodel, NULL); + + /* CLEAR LOCATION SHOW DATA */ + + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + LOCATIONSHOWN_HEADER); + + output_data[0] = 0; + for (row = 0; row < 256; row++) + { + gint item; + + for (item = 0; item < n_locationshown; item++) + { + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + LOCATIONSHOWN_HEADER, row, locationshown[item]); + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), tag); + } + } + + /* SET LOCATION SHOW DATA */ + gexiv2_metadata_set_xmp_tag_struct (GEXIV2_METADATA (g_metadata), + "Xmp.iptcExt.LocationShown", + GEXIV2_STRUCTURE_XA_BAG); + + counter = 1; + for (row = 0; row < number_of_rows; row++) + { + if (gtk_tree_model_iter_nth_child (treemodel, &iter, NULL, row)) + { + gchar *tag_data; + + gtk_tree_model_get (treemodel, &iter, + COL_LOC_SHO_SUB_LOC, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + LOCATIONSHOWN_HEADER, counter, locationshown[0]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + gtk_tree_model_get (treemodel, &iter, + COL_LOC_SHO_CITY, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + LOCATIONSHOWN_HEADER, counter, locationshown[1]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + gtk_tree_model_get (treemodel, &iter, + COL_LOC_SHO_STATE_PROV, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + LOCATIONSHOWN_HEADER, counter, locationshown[2]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + gtk_tree_model_get (treemodel, &iter, + COL_LOC_SHO_CNTRY, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + LOCATIONSHOWN_HEADER, counter, locationshown[3]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + gtk_tree_model_get (treemodel, &iter, + COL_LOC_SHO_CNTRY_ISO, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + LOCATIONSHOWN_HEADER, counter, locationshown[4]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + gtk_tree_model_get (treemodel, &iter, + COL_LOC_SHO_CNTRY_WRLD_REG, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + LOCATIONSHOWN_HEADER, counter, locationshown[5]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + counter++; + } + } + + /* DO ARTWORK OR OBJECT (LISTSTORE) */ + + list_widget = builder_get_widget (builder, "Xmp.iptcExt.ArtworkOrObject"); + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (list_widget)); + + number_of_rows = gtk_tree_model_iter_n_children (treemodel, NULL); + + /* CLEAR ARTWORK OR OBJECT DATA */ + + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + ARTWORKOROBJECT_HEADER); + + output_data[0] = 0; + for (row = 0; row < 256; row++) + { + gint item; + + for (item = 0; item < n_artworkorobject; item++) + { + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + ARTWORKOROBJECT_HEADER, row, artworkorobject[item]); + + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), tag); + } + } + + /* SET ARTWORK OR OBJECT DATA */ + + gexiv2_metadata_set_xmp_tag_struct (GEXIV2_METADATA (g_metadata), + "Xmp.iptcExt.ArtworkOrObject", + GEXIV2_STRUCTURE_XA_BAG); + + counter = 1; + for (row = 0; row < number_of_rows; row++) + { + if (gtk_tree_model_iter_nth_child (treemodel, &iter, NULL, row)) + { + gchar *tag_data; + + gtk_tree_model_get (treemodel, &iter, + COL_AOO_TITLE, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + ARTWORKOROBJECT_HEADER, counter, artworkorobject[0]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + gtk_tree_model_get (treemodel, &iter, + COL_AOO_DATE_CREAT, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + ARTWORKOROBJECT_HEADER, counter, artworkorobject[1]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + gtk_tree_model_get (treemodel, &iter, + COL_AOO_CREATOR, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + ARTWORKOROBJECT_HEADER, counter, artworkorobject[2]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + gtk_tree_model_get (treemodel, &iter, + COL_AOO_SOURCE, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + ARTWORKOROBJECT_HEADER, counter, artworkorobject[3]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + gtk_tree_model_get (treemodel, &iter, + COL_AOO_SRC_INV_ID, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + ARTWORKOROBJECT_HEADER, counter, artworkorobject[4]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + gtk_tree_model_get (treemodel, &iter, + COL_AOO_CR_NOT, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + ARTWORKOROBJECT_HEADER, counter, artworkorobject[5]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + counter++; + } + } + + /* DO REGISTRY ID (LISTSTORE) */ + + list_widget = builder_get_widget (builder, "Xmp.iptcExt.RegistryId"); + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (list_widget)); + + number_of_rows = gtk_tree_model_iter_n_children (treemodel, NULL); + + /* CLEAR REGISTRY ID DATA */ + + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + REGISTRYID_HEADER); + + output_data[0] = 0; + for (row = 0; row < 256; row++) + { + gint item; + + for (item = 0; item < n_registryid; item++) + { + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + REGISTRYID_HEADER, row, registryid[item]); + + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), tag); + } + } + + /* SET REGISTRY ID DATA */ + + gexiv2_metadata_set_xmp_tag_struct (GEXIV2_METADATA (g_metadata), + "Xmp.iptcExt.RegistryId", + GEXIV2_STRUCTURE_XA_BAG); + + counter = 1; + for (row = 0; row < number_of_rows; row++) + { + if (gtk_tree_model_iter_nth_child (treemodel, &iter, NULL, row)) + { + gchar *tag_data; + + gtk_tree_model_get (treemodel, &iter, + COL_REGSITRY_ORG_ID, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + REGISTRYID_HEADER, counter, registryid[0]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + gtk_tree_model_get (treemodel, &iter, + COL_REGSITRY_ITEM_ID, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + REGISTRYID_HEADER, counter, registryid[1]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + counter++; + } + } + + /* DO IMAGE CREATOR (LISTSTORE) */ + + list_widget = builder_get_widget (builder, "Xmp.plus.ImageCreator"); + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (list_widget)); + + number_of_rows = gtk_tree_model_iter_n_children (treemodel, NULL); + + /* CLEAR IMAGE CREATOR DATA */ + + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + IMAGECREATOR_HEADER); + + output_data[0] = 0; + for (row = 0; row < 256; row++) + { + gint item; + + for (item = 0; item < n_imagecreator; item++) + { + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + IMAGECREATOR_HEADER, row, imagecreator[item]); + + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), tag); + } + } + + /* SET IMAGE CREATOR DATA */ + + gexiv2_metadata_set_xmp_tag_struct (GEXIV2_METADATA (g_metadata), + "Xmp.plus.ImageCreator", + GEXIV2_STRUCTURE_XA_SEQ); + + counter = 1; + for (row = 0; row < number_of_rows; row++) + { + if (gtk_tree_model_iter_nth_child (treemodel, &iter, NULL, row)) + { + gchar *tag_data; + + gtk_tree_model_get (treemodel, &iter, + COL_IMG_CR8_NAME, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + IMAGECREATOR_HEADER, counter, imagecreator[0]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + gtk_tree_model_get (treemodel, &iter, + COL_IMG_CR8_ID, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + IMAGECREATOR_HEADER, counter, imagecreator[1]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + counter++; + } + } + + /* DO COPYRIGHT OWNER (LISTSTORE) */ + + list_widget = builder_get_widget (builder, "Xmp.plus.CopyrightOwner"); + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (list_widget)); + + number_of_rows = gtk_tree_model_iter_n_children (treemodel, NULL); + + /* CLEAR COPYRIGHT OWNER DATA */ + + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + COPYRIGHTOWNER_HEADER); + + output_data[0] = 0; + for (row = 0; row < 256; row++) + { + gint item; + + for (item = 0; item < n_copyrightowner; item++) + { + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + COPYRIGHTOWNER_HEADER, row, copyrightowner[item]); + + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), tag); + } + } + + /* SET COPYRIGHT OWNER DATA */ + + gexiv2_metadata_set_xmp_tag_struct (GEXIV2_METADATA (g_metadata), + "Xmp.plus.CopyrightOwner", + GEXIV2_STRUCTURE_XA_SEQ); + + counter = 1; + for (row = 0; row < number_of_rows; row++) + { + if (gtk_tree_model_iter_nth_child (treemodel, &iter, NULL, row)) + { + gchar *tag_data; + + gtk_tree_model_get (treemodel, &iter, + COL_CR_OWNER_NAME, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + COPYRIGHTOWNER_HEADER, counter, copyrightowner[0]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + gtk_tree_model_get (treemodel, &iter, + COL_CR_OWNER_ID, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + COPYRIGHTOWNER_HEADER, counter, copyrightowner[1]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + counter++; + } + } + + /* DO LICENSOR (LISTSTORE) */ + + list_widget = builder_get_widget (builder, "Xmp.plus.Licensor"); + + treemodel = gtk_tree_view_get_model (GTK_TREE_VIEW (list_widget)); + + number_of_rows = gtk_tree_model_iter_n_children (treemodel, NULL); + + /* CLEAR LICENSOR DATA */ + + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + LICENSOR_HEADER); + + output_data[0] = 0; + for (row = 0; row < 256; row++) + { + gint item; + + for (item = 0; item < n_licensor; item++) + { + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + LICENSOR_HEADER, row, licensor[item]); + + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), tag); + } + } + + /* SET LICENSOR DATA */ + + gexiv2_metadata_set_xmp_tag_struct (GEXIV2_METADATA (g_metadata), + "Xmp.plus.Licensor", + GEXIV2_STRUCTURE_XA_SEQ); + + counter = 1; + for (row = 0; row < number_of_rows; row++) + { + if (gtk_tree_model_iter_nth_child (treemodel, &iter, NULL, row)) + { + gchar *tag_data; + gchar type1[256]; + gchar type2[256]; + gint types; + + gtk_tree_model_get (treemodel, &iter, + COL_LICENSOR_NAME, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + LICENSOR_HEADER, counter, licensor[0]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + gtk_tree_model_get (treemodel, &iter, + COL_LICENSOR_ID, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + LICENSOR_HEADER, counter, licensor[1]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + gtk_tree_model_get (treemodel, &iter, + COL_LICENSOR_PHONE1, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + LICENSOR_HEADER, counter, licensor[2]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + gtk_tree_model_get (treemodel, &iter, + COL_LICENSOR_PHONE_TYPE1, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + LICENSOR_HEADER, counter, licensor[3]); + + strcpy (type1, phone_types[0].data); + + if (tag_data != NULL) + { + for (types = 0; types < 6; types++) + { + if (! strcmp (tag_data, gettext (phone_types[types].display))) + { + strcpy (type1, phone_types[types].data); + break; + } + } + } + + set_tag_string (g_metadata, tag, type1); + + gtk_tree_model_get (treemodel, &iter, + COL_LICENSOR_PHONE2, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + LICENSOR_HEADER, counter, licensor[4]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + gtk_tree_model_get (treemodel, &iter, + COL_LICENSOR_PHONE_TYPE2, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + LICENSOR_HEADER, counter, licensor[5]); + + strcpy (type2, phone_types[0].data); + + if (tag_data != NULL) + { + for (types = 0; types < 6; types++) + { + g_print ("%d %s %s\n", types, tag_data, + gettext (phone_types[types].display)); + if (! strcmp (tag_data, gettext (phone_types[types].display))) + { + g_print ("%d %s \n", types, phone_types[types].data); + strcpy (type2, phone_types[types].data); + break; + } + } + } + set_tag_string (g_metadata, tag, type2); + + gtk_tree_model_get (treemodel, &iter, + COL_LICENSOR_EMAIL, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + LICENSOR_HEADER, counter, licensor[6]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + gtk_tree_model_get (treemodel, &iter, + COL_LICENSOR_WEB, &tag_data, + -1); + + g_snprintf (tag, sizeof (tag), "%s[%d]%s", + LICENSOR_HEADER, counter, licensor[7]); + + set_tag_string (g_metadata, tag, tag_data); + g_free (tag_data); + + counter++; + } + } + + /* DO CREATOR TAGS */ + + if (hasCreatorTagData (builder)) + { + if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + creatorContactInfoHeader.header, + "type=\"Struct\"")) + { + g_printerr ("failed to set tag [%s]\n", + creatorContactInfoTags[i].tag); + } + + for (i = 0; i < creatorContactInfoHeader.size; i++) + { + GObject *object = gtk_builder_get_object (builder, + creatorContactInfoTags[i].id); + + if (! strcmp ("single", creatorContactInfoTags[i].mode)) + { + GtkEntry *entry = GTK_ENTRY (object); + + if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + creatorContactInfoTags[i].tag, + gtk_entry_get_text (entry))) + { + g_printerr ("failed to set tag [%s]\n", + creatorContactInfoTags[i].tag); + } + } + else if (! strcmp ("multi", default_metadata_tags[i].mode)) + { + GtkTextView *text_view = GTK_TEXT_VIEW (object); + GtkTextBuffer *buffer; + GtkTextIter start; + GtkTextIter end; + gchar *text; + + buffer = gtk_text_view_get_buffer (text_view); + gtk_text_buffer_get_start_iter (buffer, &start); + gtk_text_buffer_get_end_iter (buffer, &end); + + text = gtk_text_buffer_get_text (buffer, &start, &end, TRUE); + + if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + creatorContactInfoTags[i].tag, + text)) + { + g_printerr ("failed to set tag [%s]\n", + creatorContactInfoTags[i].tag); + } + + g_free (text); + } + } + } + + /* DO SINGLE, MULTI AND COMBO TAGS */ + + else + { + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + creatorContactInfoHeader.header); + + for (i = 0; i < creatorContactInfoHeader.size; i++) + { + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + creatorContactInfoTags[i].tag); + } + } + + max_elements = n_default_metadata_tags; + + for (i = 0; i < max_elements; i++) + { + GObject *object = gtk_builder_get_object (builder, + default_metadata_tags[i].tag); + + /* SINGLE TAGS */ + + if (! strcmp ("single", default_metadata_tags[i].mode)) + { + GtkEntry *entry = GTK_ENTRY (object); + gchar *value_entry = g_strdup (gtk_entry_get_text (entry)); + + if (! strcmp ("Exif.GPSInfo.GPSLongitude", + default_metadata_tags[i].tag)) + { + const gchar delimiters_dms[] = " deg'\""; + gchar lng[256]; + gchar *s = g_strdup (value_entry); + gchar *str1 = NULL; + gchar *str2 = NULL; + gchar *str3 = NULL; + + if (s && strstr (s, ".")) + { + gdouble degs; + gint deg; + gint min; + gint sec; + + degs = atof (s); + if (degs < 0) + degs *= -1; + deg = (gint) degs; + min = (gint) ((degs - deg) * 60.f); + sec = (gint) ((degs - (float) deg - (float) (min / 60.f)) * 60.f * 60.f); + str1 = malloc (256); + str2 = malloc (256); + str3 = malloc (256); + g_sprintf (str1, "%d", deg); + g_sprintf (str2, "%d", min); + g_sprintf (str3, "%d", sec); + } + else if (s) + { + str1 = strtok (s, delimiters_dms); + str2 = strtok (NULL, delimiters_dms); + str3 = strtok (NULL, delimiters_dms); + } + + if (str1) + { + strcpy (lng, str1); + strcat (lng, "/1"); + } + else + { + strcpy (lng, "0/1"); + } + + if (str2) + { + strcat (lng, " "); + strcat (lng, str2); + strcat (lng, "/1"); + } + else + { + strcat (lng, " "); + strcat (lng, "0/1"); + } + + if (str3) + { + strcat (lng, " "); + strcat (lng, str3); + strcat (lng, "/1"); + } + else + { + strcat (lng, " "); + strcat (lng, "0/1"); + } + + if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + lng)) + { + g_printerr ("failed to set tag [%s]\n", + default_metadata_tags[i].tag); + } + + if (s && strstr (s, ".")) + { + free (str1); + free (str2); + free (str3); + } + + free (s); + } + else if (! strcmp ("Exif.GPSInfo.GPSLatitude", + default_metadata_tags[i].tag)) + { + const gchar delimiters_dms[] = " deg'\""; + gchar lat[256]; + gchar *s = g_strdup (value_entry); + gchar *str1 = NULL; + gchar *str2 = NULL; + gchar *str3 = NULL; + + if (s && strstr (s, ".")) + { + gdouble degs; + gint deg; + gint min; + gint sec; + + degs = atof (s); + if (degs < 0) + degs *= -1; + deg = (gint) (degs); + min = (gint) ((degs - deg) * 60.f); + sec = (gint) ((degs - (float) deg - (float) (min / 60.f)) * 60.f * 60.f); + str1 = malloc (256); + str2 = malloc (256); + str3 = malloc (256); + g_sprintf (str1, "%d", deg); + g_sprintf (str2, "%d", min); + g_sprintf (str3, "%d", sec); + } + else if (s) + { + str1 = strtok (s, delimiters_dms); + str2 = strtok (NULL, delimiters_dms); + str3 = strtok (NULL, delimiters_dms); + } + + if (str1) + { + strcpy (lat, str1); + strcat (lat, "/1"); + } + else + { + strcpy (lat, "0/1"); + } + + if (str2) + { + strcat (lat, " "); + strcat (lat, str2); + strcat (lat, "/1"); + } + else + { + strcat (lat, " "); + strcat (lat, "0/1"); + } + + if (str3) + { + strcat (lat, " "); + strcat (lat, str3); + strcat (lat, "/1"); + } + else + { + strcat (lat, " "); + strcat (lat, "0/1"); + } + + if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + lat)) + { + g_printerr ("failed to set tag [%s]\n", + default_metadata_tags[i].tag); + } + + if (s) + free (s); + } + else if (! strcmp ("Exif.GPSInfo.GPSAltitude", + default_metadata_tags[i].tag)) + { + GtkWidget *combo_widget; + gchar alt_str[256]; + gdouble alt_d; + gint msr; + + combo_widget = builder_get_widget (builder, + "GPSAltitudeSystem"); + msr = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_widget)); + + alt_d = atof (gtk_entry_get_text (entry)); + if (msr == 1) + alt_d = (alt_d * 12 * 2.54) / 100; + alt_d *= 10.f; + + g_snprintf (alt_str, sizeof (alt_str), "%d/10", (gint) alt_d); + + if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + alt_str)) + { + g_printerr ("failed to set tag [%s]\n", + default_metadata_tags[i].tag); + } + } + else + { + const gchar *text_value = gtk_entry_get_text (entry); + + if (default_metadata_tags[i].xmp_type == GIMP_XMP_TEXT || + default_metadata_tags[i].xmp_type == GIMP_XMP_NONE) + { + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag); + gexiv2_metadata_set_xmp_tag_struct (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + GEXIV2_STRUCTURE_XA_NONE); + if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + text_value)) + { + g_printerr ("failed to set tag [%s]\n", + default_metadata_tags[i].tag); + } + } + else if (default_metadata_tags[i].xmp_type == GIMP_XMP_BAG) + { + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag); + gexiv2_metadata_set_xmp_tag_struct (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + GEXIV2_STRUCTURE_XA_BAG); + if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + text_value)) + { + g_printerr ("failed to set tag [%s]\n", + default_metadata_tags[i].tag); + } + } + else if (default_metadata_tags[i].xmp_type == GIMP_XMP_SEQ) + { + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag); + gexiv2_metadata_set_xmp_tag_struct (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + GEXIV2_STRUCTURE_XA_SEQ); + if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + text_value)) + { + g_printerr ("failed to set tag [%s]\n", + default_metadata_tags[i].tag); + } + } + } + } + + /* MULTI TAGS */ + + else if (! strcmp ("multi", default_metadata_tags[i].mode)) + { + GtkTextView *text_view = GTK_TEXT_VIEW (object); + GtkTextBuffer *buffer; + GtkTextIter start; + GtkTextIter end; + gchar *text; + + buffer = gtk_text_view_get_buffer (text_view); + gtk_text_buffer_get_start_iter (buffer, &start); + gtk_text_buffer_get_end_iter (buffer, &end); + + text = gtk_text_buffer_get_text (buffer, &start, &end, TRUE); + + if (default_metadata_tags[i].xmp_type == GIMP_XMP_TEXT || + default_metadata_tags[i].xmp_type == GIMP_XMP_NONE) + { + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag); + gexiv2_metadata_set_xmp_tag_struct (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + GEXIV2_STRUCTURE_XA_NONE); + if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + text)) + { + g_printerr ("failed to set tag [%s]\n", + default_metadata_tags[i].tag); + } + } + else if (default_metadata_tags[i].xmp_type == GIMP_XMP_BAG) + { + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag); + gexiv2_metadata_set_xmp_tag_struct (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + GEXIV2_STRUCTURE_XA_BAG); + if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + text)) + { + g_printerr ("failed to set tag [%s]\n", + default_metadata_tags[i].tag); + } + } + else if (default_metadata_tags[i].xmp_type == GIMP_XMP_SEQ) + { + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag); + gexiv2_metadata_set_xmp_tag_struct (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + GEXIV2_STRUCTURE_XA_SEQ); + if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + text)) + { + g_printerr ("failed to set tag [%s]\n", + default_metadata_tags[i].tag); + } + } + + if (text) + g_free (text); + } + else if (! strcmp ("list", default_metadata_tags[i].mode)) + { + /* MIGHT DO SOMETHING HERE */ + } + + /* COMBO TAGS */ + + else if (! strcmp ("combo", default_metadata_tags[i].mode)) + { + GtkComboBoxText *combo; + gint32 value; + + combo = GTK_COMBO_BOX_TEXT (object); + value = gtk_combo_box_get_active (GTK_COMBO_BOX (combo)); + + if (! strcmp ("Xmp.xmp.Rating", default_metadata_tags[i].tag)) + { + if (value == 0) + { + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag); + } + else + { + gchar *save; + + save = g_strdup_printf ("%d", value); + + gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + save); + g_free (save); + } + } + else if (! strcmp ("Xmp.DICOM.PatientSex", + default_metadata_tags[i].tag)) + { + switch (value) + { + case 0: + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag); + break; + + case 1: + if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + "male")) + { + g_printerr ("failed to set tag [%s]\n", + default_metadata_tags[i].tag); + } + break; + + case 2: + if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + "female")) + { + g_printerr ("failed to set tag [%s]\n", + default_metadata_tags[i].tag); + } + break; + + case 3: + if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + "other")) + { + g_printerr ("failed to set tag [%s]\n", + default_metadata_tags[i].tag); + } + break; + } + } + else if (! strcmp ("Exif.GPSInfo.GPSLongitudeRef", + default_metadata_tags[i].tag)) + { + switch (value) + { + case 0: + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag); + break; + + case 1: + gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + "E"); + break; + + case 2: + gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + "W"); + break; + } + } + else if (! strcmp ("Exif.GPSInfo.GPSLatitudeRef", + default_metadata_tags[i].tag)) + { + switch (value) + { + case 0: + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag); + break; + + case 1: + gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + "N"); + break; + + case 2: + gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + "S"); + break; + } + } + else if (! strcmp ("Exif.GPSInfo.GPSAltitudeRef", + default_metadata_tags[i].tag)) + { + switch (value) + { + case 0: + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag); + break; + + case 1: + gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + "0"); + break; + + case 2: + gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + "1"); + break; + } + } + else if (! strcmp ("Xmp.plus.ModelReleaseStatus", + default_metadata_tags[i].tag)) + { + gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + modelreleasestatus[value].data); + } + else if (! strcmp ("Xmp.plus.PropertyReleaseStatus", + default_metadata_tags[i].tag)) + { + if (value == 0) + { + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag); + } + else + { + gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + propertyreleasestatus[value].data); + } + } + else if (! strcmp ("Xmp.plus.MinorModelAgeDisclosure", + default_metadata_tags[i].tag)) + { + if (value == 0) + { + gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag); + } + else + { + gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + minormodelagedisclosure[value].data); + } + } + else if (! strcmp ("Xmp.iptcExt.DigitalSourceType", + default_metadata_tags[i].tag)) + { + gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata), + default_metadata_tags[i].tag, + digitalsourcetype[value].data); + } + } + } + + gimp_image_set_metadata (image_id, g_metadata); +} + +/* ============================================================================ + * ==[ METADATA IMPORT / EXPORT FILE DIALOG UI ]=============================== + * ============================================================================ + */ + +static void +import_dialog_metadata (metadata_editor *args) +{ + GtkWidget *file_dialog; + gchar *filename; + + file_dialog = gtk_file_chooser_dialog_new (_("Import Metadata File"), + NULL, + GTK_FILE_CHOOSER_ACTION_OPEN, + _("_Cancel"), GTK_RESPONSE_CANCEL, + _("_Import"), GTK_RESPONSE_ACCEPT, + NULL); + + gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (file_dialog), + args->filename); + + if (gtk_dialog_run (GTK_DIALOG (file_dialog)) == GTK_RESPONSE_ACCEPT) + { + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_dialog)); + + if (filename) + { + if (args->filename) + { + g_free (args->filename); + } + + args->filename = g_strdup (filename); + import_file_metadata (args); + } + } + + gtk_widget_destroy (file_dialog); +} + +static void +export_dialog_metadata (metadata_editor *args) +{ + GtkWidget *file_dialog; + gchar *filename; + + file_dialog = gtk_file_chooser_dialog_new (_("Export Metadata File"), + NULL, + GTK_FILE_CHOOSER_ACTION_SAVE, + _("_Cancel"), GTK_RESPONSE_CANCEL, + _("_Export"), GTK_RESPONSE_ACCEPT, + NULL); + + gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (file_dialog), + TRUE); + gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (file_dialog), + args->filename); + + if (gtk_dialog_run (GTK_DIALOG (file_dialog)) == GTK_RESPONSE_ACCEPT) + { + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_dialog)); + + if (filename) + { + if (args->filename) + { + g_free (args->filename); + } + + args->filename = g_strdup (filename); + export_file_metadata (args); + } + } + + gtk_widget_destroy (file_dialog); +} + +static void +impex_combo_callback (GtkComboBoxText *combo, + gpointer data) +{ + metadata_editor *args; + gint32 selection; + + args = data; + selection = gtk_combo_box_get_active (GTK_COMBO_BOX (combo)); + + switch (selection) + { + case 1: /* Import */ + import_dialog_metadata (args); + gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0); + break; + + case 2: /* Export */ + export_dialog_metadata (args); + gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0); + break; + } +} + + +static void +gpsaltsys_combo_callback (GtkComboBoxText *combo, + gpointer data) +{ + GtkWidget *entry; + GtkBuilder *builder; + gint32 selection; + gchar alt_str[256]; + double alt_d; + + builder = data; + selection = gtk_combo_box_get_active (GTK_COMBO_BOX (combo)); + + entry = builder_get_widget (builder, "Exif.GPSInfo.GPSAltitude"); + + switch (selection) + { + case 0: /* Meters */ + if (last_gpsaltsys_sel != 0) + { + alt_d = atof (gtk_entry_get_text (GTK_ENTRY (entry))); + alt_d = (alt_d * (12 * 2.54)) / 100; + + g_snprintf (alt_str, sizeof (alt_str), "%2f", (float)alt_d); + + gtk_entry_set_text (GTK_ENTRY (entry), alt_str); + } + break; + + case 1: /* Feet */ + if (last_gpsaltsys_sel != 1) + { + alt_d = atof (gtk_entry_get_text (GTK_ENTRY (entry))); + alt_d = alt_d * 3.28; + + g_snprintf (alt_str, sizeof (alt_str), "%2f", (float)alt_d); + + gtk_entry_set_text (GTK_ENTRY (entry), alt_str); + } + break; + } + + last_gpsaltsys_sel = selection; +} diff --git a/plug-ins/metadata/metadata-editor.h b/plug-ins/metadata/metadata-editor.h new file mode 100644 index 0000000..c3fe93c --- /dev/null +++ b/plug-ins/metadata/metadata-editor.h @@ -0,0 +1,27 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * Copyright (C) 2016, 2017 Ben Touchette + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#ifndef __METADATA_EDITOR_H__ +#define __METADATA_EDITOR_H__ + +extern void metadata_editor_write_callback (GtkWidget *dialog, + GtkBuilder *builder, + gint32 image_id); + +#endif /* __METADATA_EDITOR_H__ */ diff --git a/plug-ins/metadata/metadata-impexp.c b/plug-ins/metadata/metadata-impexp.c new file mode 100644 index 0000000..8cf6fc7 --- /dev/null +++ b/plug-ins/metadata/metadata-impexp.c @@ -0,0 +1,244 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * metadata-editor.c + * Copyright (C) 2016, 2017 Ben Touchette + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#include "config.h" + +#include <stdlib.h> +#include <ctype.h> + +#include <gegl.h> +#include <gtk/gtk.h> +#include <gexiv2/gexiv2.h> + +#include <glib.h> +#include <glib/gstdio.h> + +#include <libgimp/gimp.h> +#include <libgimp/gimpui.h> + +#include "libgimp/stdplugins-intl.h" + +#include "metadata-xml.h" +#include "metadata-misc.h" +#include "metadata-tags.h" +#include "metadata-impexp.h" +#include "metadata-editor.h" + +extern gboolean gimpmetadata; +extern gboolean xmptag; +extern gboolean iptctag; +extern gboolean tagvalue; +extern gboolean tagname; +extern gboolean force_write; +extern gchar *str_tag_value; +extern gchar *str_tag_name; + +const GMarkupParser xml_markup_parser = +{ + xml_parser_start_element, + xml_parser_end_element, + xml_parser_data, + NULL, /* passthrough */ + NULL /* error */ +}; + + +/* ============================================================================ + * ==[ METADATA IMPORT TEMPLATE ]============================================== + * ============================================================================ + */ +void +import_file_metadata(metadata_editor *args) +{ + GimpXmlParser *xml_parser; + GError *error = NULL; + FILE *file; + gchar *xmldata; + + gimpmetadata = FALSE; + xmptag = FALSE; + iptctag = FALSE; + tagvalue = FALSE; + tagname = FALSE; + + file = g_fopen (args->filename, "r"); + if (file != NULL) + { + /* get xml data from file */ + g_file_get_contents (args->filename, &xmldata, NULL, &error); + + /* parse xml data fetched from file */ + xml_parser = xml_parser_new (&xml_markup_parser, args); + xml_parser_parse_file (xml_parser, args->filename, &error); + xml_parser_free (xml_parser); + + fclose (file); + } +} + +/* ============================================================================ + * ==[ METADATA EXPORT TEMPLATE ]============================================== + * ============================================================================ + */ +void +export_file_metadata (metadata_editor *args) +{ + GError *error = NULL; + FILE *file; + gchar *value; + gchar *value_utf; + gchar *xmldata; + gint i, size; + + if (force_write == TRUE) + { + /* Save fields in case of updates */ + metadata_editor_write_callback (args->dialog, args->builder, args->image_id); + /* Fetch a fresh copy of the metadata */ + args->metadata = GEXIV2_METADATA (gimp_image_get_metadata (args->image_id)); + } + + xmldata = g_strconcat ("<?xml version=“1.0” encoding=“utf-8”?>\n", + "<gimp-metadata>\n", NULL); + + /* HANDLE IPTC */ + for (i = 0; i < n_equivalent_metadata_tags; i++) + { + int index = equivalent_metadata_tags[i].other_tag_index; + xmldata = g_strconcat (xmldata, "\t<iptc-tag>\n", NULL); + xmldata = g_strconcat (xmldata, "\t\t<tag-name>", NULL); + xmldata = g_strconcat (xmldata, equivalent_metadata_tags[i].tag, NULL); + xmldata = g_strconcat (xmldata, "</tag-name>\n", NULL); + xmldata = g_strconcat (xmldata, "\t\t<tag-mode>", NULL); + xmldata = g_strconcat (xmldata, equivalent_metadata_tags[i].mode, NULL); + xmldata = g_strconcat (xmldata, "</tag-mode>\n", NULL); + + xmldata = g_strconcat (xmldata, "\t\t<tag-value>", NULL); + + if (!strcmp("single", default_metadata_tags[index].mode) || + !strcmp("multi", default_metadata_tags[index].mode)) + { + const gchar *value; + + value = get_tag_ui_text (args, default_metadata_tags[index].tag, + default_metadata_tags[index].mode); + + if (value) + { + value_utf = g_locale_to_utf8 (value, -1, NULL, NULL, NULL); + xmldata = g_strconcat (xmldata, value_utf, NULL); + } + } + else if (!strcmp("combo", default_metadata_tags[index].mode)) + { + gint data = get_tag_ui_combo (args, default_metadata_tags[index].tag, + default_metadata_tags[index].mode); + value = g_malloc(1024); + g_sprintf(value, "%d", data); + xmldata = g_strconcat (xmldata, value, NULL); + g_free(value); + } + else if (!strcmp("list", default_metadata_tags[i].mode)) + { + /* No IPTC lists elements at this point */ + } + + xmldata = g_strconcat (xmldata, "</tag-value>\n", NULL); + xmldata = g_strconcat (xmldata, "\t</iptc-tag>\n", NULL); + } + + /* HANDLE XMP */ + for (i = 0; i < n_default_metadata_tags; i++) + { + xmldata = g_strconcat (xmldata, "\t<xmp-tag>\n", NULL); + xmldata = g_strconcat (xmldata, "\t\t<tag-name>", NULL); + xmldata = g_strconcat (xmldata, default_metadata_tags[i].tag, NULL); + xmldata = g_strconcat (xmldata, "</tag-name>\n", NULL); + xmldata = g_strconcat (xmldata, "\t\t<tag-mode>", NULL); + xmldata = g_strconcat (xmldata, default_metadata_tags[i].mode, NULL); + xmldata = g_strconcat (xmldata, "</tag-mode>\n", NULL); + + if (!strcmp("single", default_metadata_tags[i].mode) || + !strcmp("multi", default_metadata_tags[i].mode)) + { + const gchar *value; + + xmldata = g_strconcat (xmldata, "\t\t<tag-value>", NULL); + value = get_tag_ui_text (args, default_metadata_tags[i].tag, + default_metadata_tags[i].mode); + + if (value) + { + value_utf = g_locale_to_utf8 (value, -1, NULL, NULL, NULL); + xmldata = g_strconcat (xmldata, value_utf, NULL); + } + + xmldata = g_strconcat (xmldata, "</tag-value>\n", NULL); + } + else if (!strcmp("combo", default_metadata_tags[i].mode)) + { + gint data; + + xmldata = g_strconcat (xmldata, "\t\t<tag-value>", NULL); + + data = get_tag_ui_combo (args, default_metadata_tags[i].tag, + default_metadata_tags[i].mode); + value = g_malloc(1024); + g_sprintf(value, "%d", data); + xmldata = g_strconcat (xmldata, value, NULL); + g_free(value); + + xmldata = g_strconcat (xmldata, "</tag-value>\n", NULL); + } + else if (!strcmp("list", default_metadata_tags[i].mode)) + { + gchar *data; + + xmldata = g_strconcat (xmldata, "\t\t<tag-list-value>\n", NULL); + + data = get_tag_ui_list (args, default_metadata_tags[i].tag, + default_metadata_tags[i].mode); + xmldata = g_strconcat (xmldata, data, NULL); + + if (data) + g_free(data); + + xmldata = g_strconcat (xmldata, "\t\t</tag-list-value>\n", NULL); + } + + xmldata = g_strconcat (xmldata, "\t</xmp-tag>\n", NULL); + } + + xmldata = g_strconcat(xmldata, "</gimp-metadata>\n", NULL); + + size = strlen (xmldata); + file = g_fopen (args->filename, "w"); + if (file != NULL) + { + g_file_set_contents (args->filename, xmldata, size, &error); + fclose (file); + } + + if (xmldata) + { + g_free (xmldata); + } +} + diff --git a/plug-ins/metadata/metadata-impexp.h b/plug-ins/metadata/metadata-impexp.h new file mode 100644 index 0000000..0229751 --- /dev/null +++ b/plug-ins/metadata/metadata-impexp.h @@ -0,0 +1,30 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * Copyright (C) 2016, 2017 Ben Touchette + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#ifndef __METADATA_IMPEXP_H__ +#define __METADATA_IMPEXP_H__ + +void +import_file_metadata (metadata_editor *args); + +void +export_file_metadata (metadata_editor *args); + +#endif /* __METADATA_IMPEXP_H__ */ + diff --git a/plug-ins/metadata/metadata-misc.h b/plug-ins/metadata/metadata-misc.h new file mode 100644 index 0000000..4ba27d5 --- /dev/null +++ b/plug-ins/metadata/metadata-misc.h @@ -0,0 +1,70 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * Copyright (C) 2016, 2017 Ben Touchette + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#ifndef __METADATA_MISC_H__ +#define __METADATA_MISC_H__ + +typedef struct +{ + GtkWidget *dialog; + GtkBuilder *builder; + GExiv2Metadata *metadata; + gint32 image_id; + gchar *filename; +} metadata_editor; + +typedef struct +{ + gchar *tag; + gchar *mode; + gint32 other_tag_index; + gint32 tag_type; + gint32 xmp_type; +} metadata_tag; + +typedef struct +{ + gchar *data; + gchar *display; +} combobox_str_tag; + +typedef struct +{ + gint32 data; + gchar *display; +} combobox_int_tag; + +typedef struct +{ + gchar *header; + gchar *type; + gint32 size; +} TranslateHeaderTag; + +typedef struct +{ + gchar *id; + gchar *tag; + gchar *mode; + gint32 other_tag_index; + gint32 tag_type; +} TranslateTag; + +#endif /* __METADATA_MISC_H__ */ + diff --git a/plug-ins/metadata/metadata-tags.c b/plug-ins/metadata/metadata-tags.c new file mode 100644 index 0000000..89f83b2 --- /dev/null +++ b/plug-ins/metadata/metadata-tags.c @@ -0,0 +1,408 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#include "config.h" + +#include <gexiv2/gexiv2.h> +#include <glib.h> +#include <gtk/gtk.h> + +#include <libgimp/gimp.h> +#include "libgimp/stdplugins-intl.h" + +#include "metadata-tags.h" + + +const metadata_tag default_metadata_tags[] = +{ + /* Description */ + { "Xmp.dc.title", "single", 16, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 0 + { "Xmp.dc.creator", "single", 13, TAG_TYPE_XMP, GIMP_XMP_SEQ }, // 1 + { "Xmp.dc.description", "multi", 14, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 2 + { "Xmp.dc.subject", "multi", 15, TAG_TYPE_XMP, GIMP_XMP_BAG }, // 3 + { "Xmp.dc.rights", "single", 17, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 4 + { "Xmp.photoshop.AuthorsPosition", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 5 + { "Xmp.photoshop.CaptionWriter", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 6 + { "Xmp.xmp.Rating", "combo", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 7 + { "Xmp.xmpRights.Marked", "combo", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 8 + { "Xmp.xmpRights.WebStatement", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 9 + + /* IPTC */ + { "Xmp.photoshop.DateCreated", "single", 0, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 10 + { "Xmp.photoshop.Headline", "multi", 3, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 11 + { "Xmp.photoshop.TransmissionReference", "single", 1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 12 + { "Xmp.photoshop.Instructions", "multi", 2, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 13 + { "Xmp.iptc.IntellectualGenre", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 14 + { "Xmp.iptc.Scene", "multi", -1, TAG_TYPE_XMP, GIMP_XMP_BAG }, // 15 + { "Xmp.iptc.Location", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 16 + { "Xmp.iptc.CountryCode", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 17 + { "Xmp.iptc.SubjectCode", "multi", -1, TAG_TYPE_XMP, GIMP_XMP_BAG }, // 18 + { "Xmp.xmpRights.UsageTerms", "multi", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 19 + { "Xmp.photoshop.City", "single", 5, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 20 + { "Xmp.photoshop.State", "single", 6, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 21 + { "Xmp.photoshop.Country", "single", 7, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 22 + { "Xmp.photoshop.CaptionWriter", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 23 + { "Xmp.photoshop.Credit", "single", 8, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 24 + { "Xmp.photoshop.Source", "single", 9, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 25 + { "Xmp.photoshop.Urgency", "combo", 11, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 26 + + /* IPTC Extension */ + { "Xmp.iptcExt.PersonInImage", "multi", -1, TAG_TYPE_XMP, GIMP_XMP_BAG }, // 27 + { "Xmp.iptcExt.Sublocation", "single", 12, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 28 + { "Xmp.iptcExt.City", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 29 + { "Xmp.iptcExt.ProvinceState", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 30 + { "Xmp.iptcExt.CountryName", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 31 + { "Xmp.iptcExt.CountryCode", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 32 + { "Xmp.iptcExt.WorldRegion", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 33 + { "Xmp.iptcExt.LocationShown", "list", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 34 + { "Xmp.iptcExt.OrganisationInImageName", "list", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 35 + { "Xmp.iptcExt.OrganisationInImageCode", "list", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 36 + { "Xmp.iptcExt.Event", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 37 + { "Xmp.iptcExt.RegistryId", "list", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 38 + { "Xmp.iptcExt.ArtworkOrObject", "list", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 39 + { "Xmp.iptcExt.AddlModelInfo", "multi", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 40 + { "Xmp.iptcExt.ModelAge", "single", -1, TAG_TYPE_XMP, GIMP_XMP_BAG }, // 41 + { "Xmp.iptcExt.MaxAvailWidth", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 42 + { "Xmp.iptcExt.MaxAvailHeight", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 43 + { "Xmp.iptcExt.DigitalSourceType", "combo", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 44 + { "Xmp.plus.MinorModelAgeDisclosure", "combo", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 45 + { "Xmp.plus.ModelReleaseStatus", "combo", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 46 + { "Xmp.plus.ModelReleaseID", "list", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 47 + { "Xmp.plus.ImageSupplierName", "multi", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 48 + { "Xmp.plus.ImageSupplierID", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 49 + { "Xmp.plus.ImageSupplierImageID", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 50 + { "Xmp.plus.ImageCreator", "list", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 51 + { "Xmp.plus.CopyrightOwner", "list", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 52 + { "Xmp.plus.Licensor", "list", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 53 + { "Xmp.plus.PropertyReleaseStatus", "combo", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 54 + { "Xmp.plus.PropertyReleaseID", "list", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 55 + + /* Categories */ + { "Xmp.photoshop.Category", "single", 4, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 56 + { "Xmp.photoshop.SupplementalCategories", "multi", 10, TAG_TYPE_XMP, GIMP_XMP_BAG }, // 57 + + /* GPS */ + { "Exif.GPSInfo.GPSLongitude", "single", -1, TAG_TYPE_EXIF, GIMP_XMP_NONE }, // 58 + { "Exif.GPSInfo.GPSLongitudeRef", "combo", -1, TAG_TYPE_EXIF, GIMP_XMP_NONE }, // 59 + { "Exif.GPSInfo.GPSLatitude", "single", -1, TAG_TYPE_EXIF, GIMP_XMP_NONE }, // 60 + { "Exif.GPSInfo.GPSLatitudeRef", "combo", -1, TAG_TYPE_EXIF, GIMP_XMP_NONE }, // 61 + { "Exif.GPSInfo.GPSAltitude", "single", -1, TAG_TYPE_EXIF, GIMP_XMP_NONE }, // 62 + { "Exif.GPSInfo.GPSAltitudeRef", "combo", -1, TAG_TYPE_EXIF, GIMP_XMP_NONE }, // 63 + + /* DICOM */ + { "Xmp.DICOM.PatientName", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 64 + { "Xmp.DICOM.PatientID", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 65 + { "Xmp.DICOM.PatientDOB", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 66 + { "Xmp.DICOM.PatientSex", "combo", -1, TAG_TYPE_XMP, GIMP_XMP_NONE }, // 67 + { "Xmp.DICOM.StudyID", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 68 + { "Xmp.DICOM.StudyPhysician", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 69 + { "Xmp.DICOM.StudyDateTime", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 70 + { "Xmp.DICOM.StudyDescription", "multi", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 71 + { "Xmp.DICOM.SeriesNumber", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 72 + { "Xmp.DICOM.SeriesModality", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 73 + { "Xmp.DICOM.SeriesDateTime", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 74 + { "Xmp.DICOM.SeriesDescription", "multi", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 75 + { "Xmp.DICOM.EquipmentInstitution", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 76 + { "Xmp.DICOM.EquipmentManufacturer", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 77 + + /* IPTC */ + { "Xmp.iptc.CiAdrExtadr", "multi", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 78 + { "Xmp.iptc.CiAdrCity", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 79 + { "Xmp.iptc.CiAdrRegion", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 80 + { "Xmp.iptc.CiAdrPcode", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 81 + { "Xmp.iptc.CiAdrCtry", "single", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 82 + { "Xmp.iptc.CiTelWork", "multi", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 83 + { "Xmp.iptc.CiEmailWork", "multi", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT }, // 84 + { "Xmp.iptc.CiUrlWork", "multi", -1, TAG_TYPE_XMP, GIMP_XMP_TEXT } // 85 + +}; +const gint n_default_metadata_tags = G_N_ELEMENTS (default_metadata_tags); + +const metadata_tag equivalent_metadata_tags[] = +{ + { "Iptc.Application2.DateCreated", "single", 10, TAG_TYPE_IPTC, GIMP_XMP_NONE }, // 0 + { "Iptc.Application2.TransmissionReference", "single", 12, TAG_TYPE_IPTC, GIMP_XMP_NONE }, // 1 + { "Iptc.Application2.SpecialInstructions", "single", 13, TAG_TYPE_IPTC, GIMP_XMP_NONE }, // 2 + { "Iptc.Application2.Headline", "multi", 11, TAG_TYPE_IPTC, GIMP_XMP_NONE }, // 3 + { "Iptc.Application2.Category", "single", 56, TAG_TYPE_IPTC, GIMP_XMP_NONE }, // 4 + { "Iptc.Application2.City", "single", 20, TAG_TYPE_IPTC, GIMP_XMP_NONE }, // 5 + { "Iptc.Application2.ProvinceState", "single", 21, TAG_TYPE_IPTC, GIMP_XMP_NONE }, // 6 + { "Iptc.Application2.CountryName", "single", 22, TAG_TYPE_IPTC, GIMP_XMP_NONE }, // 7 + { "Iptc.Application2.Credit", "single", 24, TAG_TYPE_IPTC, GIMP_XMP_NONE }, // 8 + { "Iptc.Application2.Source", "single", 25, TAG_TYPE_IPTC, GIMP_XMP_NONE }, // 9 + { "Iptc.Application2.SuppCategory", "single", 57, TAG_TYPE_IPTC, GIMP_XMP_NONE }, // 10 + { "Iptc.Application2.Urgency", "combo", 26, TAG_TYPE_IPTC, GIMP_XMP_NONE }, // 11 + { "Iptc.Application2.SubLocation", "single", 28, TAG_TYPE_IPTC, GIMP_XMP_NONE }, // 12 + { "Iptc.Application2.Byline", "single", 1, TAG_TYPE_IPTC, GIMP_XMP_NONE }, // 13 + { "Iptc.Application2.Caption", "multi", 2, TAG_TYPE_IPTC, GIMP_XMP_NONE }, // 14 + { "Iptc.Application2.Keywords", "single", 3, TAG_TYPE_IPTC, GIMP_XMP_NONE }, // 15 + { "Iptc.Application2.ObjectName", "multi", 0, TAG_TYPE_IPTC, GIMP_XMP_NONE }, // 16 + { "Iptc.Application2.Copyright", "single", 4, TAG_TYPE_IPTC, GIMP_XMP_NONE } // 17 +}; +const gint n_equivalent_metadata_tags = G_N_ELEMENTS (equivalent_metadata_tags); + +/* Digital Source Type Combobox Items + * http://cv.iptc.org/newscodes/digitalsourcetype/ + */ +const combobox_str_tag digitalsourcetype[] = +{ + { "http://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture", N_("Original digital capture of a real life scene") }, + { "http://cv.iptc.org/newscodes/digitalsourcetype/negativeFilm", N_("Digitized from a negative on film") }, + { "http://cv.iptc.org/newscodes/digitalsourcetype/positiveFilm", N_("Digitized from a positive on film") }, + { "http://cv.iptc.org/newscodes/digitalsourcetype/print", N_("Digitized from a print on non-transparent medium") }, + { "http://cv.iptc.org/newscodes/digitalsourcetype/softwareImage", N_("Created by software") } +}; +const gint n_digitalsourcetype = G_N_ELEMENTS (digitalsourcetype); + +/* Model Release Status Combobox Items + * http://ns.useplus.org/LDF/ldf-XMPSpecification#ModelReleaseStatus + */ +const combobox_str_tag modelreleasestatus[] = +{ + { "http://ns.useplus.org/ldf/vocab/MR-NON", N_("None") }, + { "http://ns.useplus.org/ldf/vocab/MR-NAP", N_("Not Applicable") }, + { "http://ns.useplus.org/ldf/vocab/MR-NAP", N_("Unlimited Model Releases") }, + { "http://ns.useplus.org/ldf/vocab/MR-LPR", N_("Limited or Incomplete Model Releases") } +}; +const gint n_modelreleasestatus = G_N_ELEMENTS (modelreleasestatus); + +/* Property Release Status Combobox Items + * http://ns.useplus.org/LDF/ldf-XMPSpecification#PropertyReleaseStatus + */ +const combobox_str_tag propertyreleasestatus[] = +{ + { "http://ns.useplus.org/ldf/vocab/PR-NON", N_("None") }, + { "http://ns.useplus.org/ldf/vocab/PR-NAP", N_("Not Applicable") }, + { "http://ns.useplus.org/ldf/vocab/PR-NAP", N_("Unlimited Property Releases") }, + { "http://ns.useplus.org/ldf/vocab/PR-LPR", N_("Limited or Incomplete Property Releases") } +}; +const gint n_propertyreleasestatus = G_N_ELEMENTS (propertyreleasestatus); + +/* Minor Model Age Disclosure Combobox Items + * http://ns.useplus.org/LDF/ldf-XMPSpecification#MinorModelAgeDisclosure + */ +const combobox_str_tag minormodelagedisclosure[] = +{ + { "http://ns.useplus.org/ldf/vocab/AG-UNK", N_("Age Unknown") }, + { "http://ns.useplus.org/ldf/vocab/AG-A25", N_("Age 25 or Over") }, + { "http://ns.useplus.org/ldf/vocab/AG-A24", N_("Age 24") }, + { "http://ns.useplus.org/ldf/vocab/AG-A23", N_("Age 23") }, + { "http://ns.useplus.org/ldf/vocab/AG-A22", N_("Age 22") }, + { "http://ns.useplus.org/ldf/vocab/AG-A21", N_("Age 21") }, + { "http://ns.useplus.org/ldf/vocab/AG-A20", N_("Age 20") }, + { "http://ns.useplus.org/ldf/vocab/AG-A19", N_("Age 19") }, + { "http://ns.useplus.org/ldf/vocab/AG-A18", N_("Age 18") }, + { "http://ns.useplus.org/ldf/vocab/AG-A17", N_("Age 17") }, + { "http://ns.useplus.org/ldf/vocab/AG-A16", N_("Age 16") }, + { "http://ns.useplus.org/ldf/vocab/AG-A15", N_("Age 15") }, + { "http://ns.useplus.org/ldf/vocab/AG-U14", N_("Age 14 or Under") } +}; +const gint n_minormodelagedisclosure = G_N_ELEMENTS (minormodelagedisclosure); + +/* Urgency */ +const gchar *urgency[] = +{ + N_("None"), N_("High"), N_("2"), N_("3"), N_("4"), N_("Normal"), N_("6"), N_("7"), N_("Low") +}; +const gint n_urgency = G_N_ELEMENTS (urgency); + +/* Marked */ +const combobox_int_tag marked[] = +{ + { -1, N_("Unknown") }, // DO NOT SAVE + { TRUE, N_("Copyrighted") }, // TRUE + { FALSE, N_("Public Domain") }, // FALSE +}; +const gint n_marked = G_N_ELEMENTS (marked); + +/* Phone Types */ +const combobox_str_tag phone_types[] = +{ + { "", N_("Select a value") }, + { "http://ns.useplus.org/ldf/vocab/work", N_("Work") }, + { "http://ns.useplus.org/ldf/vocab/cell", N_("Cell") }, + { "http://ns.useplus.org/ldf/vocab/fax", N_("Fax") }, + { "http://ns.useplus.org/ldf/vocab/home", N_("Home") }, + { "http://ns.useplus.org/ldf/vocab/pager", N_("Pager") } +}; +const gint n_phone_types = G_N_ELEMENTS (phone_types); + +/* DICOM Patient Sex + * http://dicomlookup.com/lookup.asp?sw=Ttable&q=C.7-1 + * http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/XMP.html#DICOM + * https://dicomiseasy.blogspot.ca/2011/11/introduction-to-dicom-chapter-iii-dicom.html + * http://dicom.nema.org/standard.html + */ +const combobox_str_tag dicom[] = +{ + { "", N_("Select a value") }, + { "male", N_("Male") }, + { "female", N_("Female") }, + { "other", N_("Other") }, +}; +const gint n_dicom = G_N_ELEMENTS (dicom); + +/* GPS Altitude Ref */ +const gchar *gpsaltref[] = +{ + N_("Unknown"), N_("Above Sea Level"), N_("Below Sea Level") +}; +const gint n_gpsaltref = G_N_ELEMENTS (gpsaltref); + +/* GPS Latitude Ref */ +const gchar *gpslatref[] = +{ + N_("Unknown"), N_("North"), N_("South") +}; +const gint n_gpslatref = G_N_ELEMENTS (gpslatref); + +/* GPS Longitude Ref */ +const gchar *gpslngref[] = +{ + N_("Unknown"), N_("East"), N_("West") +}; +const gint n_gpslngref = G_N_ELEMENTS (gpslngref); + +/* GPS Measurement System */ +const gchar *gpsaltsys[] = +{ + "M", "FT" +}; +const gint n_gpsaltsys = G_N_ELEMENTS (gpsaltsys); + +const TranslateHeaderTag creatorContactInfoHeader = +{ + "Xmp.iptc.CreatorContactInfo", "type=\"Struct\"", 8 +}; + +const TranslateTag creatorContactInfoTags[] = +{ + { "Xmp.iptc.CiAdrExtadr", "Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrExtadr", "multi", -1, TAG_TYPE_XMP }, + { "Xmp.iptc.CiAdrCity", "Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrCity", "single", -1, TAG_TYPE_XMP }, + { "Xmp.iptc.CiAdrRegion", "Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrRegion", "single", -1, TAG_TYPE_XMP }, + { "Xmp.iptc.CiAdrPcode", "Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrPcode", "single", -1, TAG_TYPE_XMP }, + { "Xmp.iptc.CiAdrCtry", "Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrCtry", "single", -1, TAG_TYPE_XMP }, + { "Xmp.iptc.CiTelWork", "Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiTelWork", "multi", -1, TAG_TYPE_XMP }, + { "Xmp.iptc.CiEmailWork", "Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiEmailWork", "multi", -1, TAG_TYPE_XMP }, + { "Xmp.iptc.CiUrlWork", "Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiUrlWork", "multi", -1, TAG_TYPE_XMP } +}; + +const TranslateHeaderTag locationCreationInfoHeader = +{ + "Xmp.iptcExt.LocationCreated", "type=\"Bag\"", 6 +}; + +const TranslateTag locationCreationInfoTags[] = +{ + { "Xmp.iptcExt.Sublocation", "Xmp.iptcExt.LocationCreated[1]/Iptc4xmpExt:Sublocation", "single", -1, TAG_TYPE_XMP }, + { "Xmp.iptcExt.City", "Xmp.iptcExt.LocationCreated[1]/Iptc4xmpExt:City", "single", -1, TAG_TYPE_XMP }, + { "Xmp.iptcExt.ProvinceState", "Xmp.iptcExt.LocationCreated[1]/Iptc4xmpExt:ProvinceState", "single", -1, TAG_TYPE_XMP }, + { "Xmp.iptcExt.CountryName", "Xmp.iptcExt.LocationCreated[1]/Iptc4xmpExt:CountryName", "single", -1, TAG_TYPE_XMP }, + { "Xmp.iptcExt.CountryCode", "Xmp.iptcExt.LocationCreated[1]/Iptc4xmpExt:CountryCode", "single", -1, TAG_TYPE_XMP }, + { "Xmp.iptcExt.WorldRegion", "Xmp.iptcExt.LocationCreated[1]/Iptc4xmpExt:WorldRegion", "single", -1, TAG_TYPE_XMP } +}; + +const TranslateHeaderTag imageSupplierInfoHeader = +{ + "Xmp.plus.ImageSupplier", "type=\"Seq\"", 2 +}; + +const TranslateTag imageSupplierInfoTags[] = +{ + { "Xmp.plus.ImageSupplierName", "Xmp.plus.ImageSupplier[1]/plus:ImageSupplierName", "multi", -1, TAG_TYPE_XMP }, + { "Xmp.plus.ImageSupplierID", "Xmp.plus.ImageSupplier[1]/plus:ImageSupplierID", "single", -1, TAG_TYPE_XMP } +}; + +/* Plus and IPTC extension tags */ + +const gchar *licensor[] = +{ + "/plus:LicensorName", + "/plus:LicensorID", + "/plus:LicensorTelephone1", + "/plus:LicensorTelephoneType1", + "/plus:LicensorTelephone2", + "/plus:LicensorTelephoneType2", + "/plus:LicensorEmail", + "/plus:LicensorURL" +}; +const gint n_licensor = G_N_ELEMENTS (licensor); + +#ifdef USE_TAGS +const gchar *imagesupplier[] = +{ + "/plus:ImageSupplierName", + "/plus:ImageSupplierID" +}; +const gint n_imagesupplier = G_N_ELEMENTS (imagesupplier); +#endif + +const gchar *imagecreator[] = +{ + "/plus:ImageCreatorName", + "/plus:ImageCreatorID" +}; +const gint n_imagecreator = G_N_ELEMENTS (imagecreator); + +const gchar *copyrightowner[] = +{ + "/plus:CopyrightOwnerName", + "/plus:CopyrightOwnerID" +}; +const gint n_copyrightowner = G_N_ELEMENTS (copyrightowner); + +const gchar *registryid[] = +{ + "/Iptc4xmpExt:RegOrgId", + "/Iptc4xmpExt:RegItemId" +}; +const gint n_registryid = G_N_ELEMENTS (registryid); + +const gchar *artworkorobject[] = +{ + "/Iptc4xmpExt:AODateCreated", + "/Iptc4xmpExt:AOSource", + "/Iptc4xmpExt:AOSourceInvNo", + "/Iptc4xmpExt:AOTitle", + "/Iptc4xmpExt:AOCopyrightNotice", + "/Iptc4xmpExt:AOCreator" +}; +const gint n_artworkorobject = G_N_ELEMENTS (artworkorobject); + +const gchar *locationshown[] = +{ + "/Iptc4xmpExt:Sublocation", + "/Iptc4xmpExt:City", + "/Iptc4xmpExt:ProvinceState", + "/Iptc4xmpExt:CountryName", + "/Iptc4xmpExt:CountryCode", + "/Iptc4xmpExt:WorldRegion" +}; +const gint n_locationshown = G_N_ELEMENTS (locationshown); + +#ifdef USE_TAGS +const gchar *locationcreated[] = +{ + "/Iptc4xmpExt:Sublocation", + "/Iptc4xmpExt:City", + "/Iptc4xmpExt:ProvinceState", + "/Iptc4xmpExt:CountryName", + "/Iptc4xmpExt:CountryCode", + "/Iptc4xmpExt:WorldRegion" +}; +const gint n_locationcreated = G_N_ELEMENTS (locationcreated); +#endif diff --git a/plug-ins/metadata/metadata-tags.h b/plug-ins/metadata/metadata-tags.h new file mode 100644 index 0000000..38e3280 --- /dev/null +++ b/plug-ins/metadata/metadata-tags.h @@ -0,0 +1,236 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * Copyright (C) 2016, 2017 Ben Touchette + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#ifndef __METADATA_TAGS_H__ +#define __METADATA_TAGS_H__ + +#include "metadata-misc.h" + +#define TAG_TYPE_XMP 1 +#define TAG_TYPE_EXIF 2 +#define TAG_TYPE_IPTC 3 + +enum +{ + GIMP_XMP_NONE = 0, + GIMP_XMP_TEXT, + GIMP_XMP_BAG, + GIMP_XMP_SEQ, + GIMP_XMP_LANG, + GIMP_XMP_ALT +}; + +enum +{ + COL_LICENSOR_NAME = 0, + COL_LICENSOR_ID, + COL_LICENSOR_PHONE1, + COL_LICENSOR_PHONE_TYPE1, + COL_LICENSOR_PHONE2, + COL_LICENSOR_PHONE_TYPE2, + COL_LICENSOR_EMAIL, + COL_LICENSOR_WEB, + COL_LICENSOR_NUM_COLS +}; + +enum +{ + COL_CR_OWNER_NAME = 0, + COL_CR_OWNER_ID, + COL_CR_OWNER_NUM_COLS +}; + +enum +{ + COL_IMG_CR8_NAME = 0, + COL_IMG_CR8_ID, + COL_IMG_CR8_NUM_COLS +}; + +enum +{ + COL_AOO_TITLE = 0, + COL_AOO_DATE_CREAT, + COL_AOO_CREATOR, + COL_AOO_SOURCE, + COL_AOO_SRC_INV_ID, + COL_AOO_CR_NOT, + COL_AOO_NUM_COLS +}; + +enum +{ + COL_REGSITRY_ORG_ID = 0, + COL_REGSITRY_ITEM_ID, + COL_REGSITRY_NUM_COLS +}; + +enum +{ + COL_LOC_SHO_SUB_LOC = 0, + COL_LOC_SHO_CITY, + COL_LOC_SHO_STATE_PROV, + COL_LOC_SHO_CNTRY, + COL_LOC_SHO_CNTRY_ISO, + COL_LOC_SHO_CNTRY_WRLD_REG, + COL_LOC_SHO_NUM_COLS +}; + +enum +{ + COL_ORG_IMG_CODE = 0, + ORG_IMG_CODE_REL_NUM_COLS +}; + +enum +{ + COL_ORG_IMG_NAME = 0, + ORG_IMG_NAME_REL_NUM_COLS +}; + +enum +{ + COL_MOD_REL_ID = 0, + MOD_REL_NUM_COLS +}; + +enum +{ + COL_PROP_REL_ID = 0, + PROP_REL_NUM_COLS +}; + +extern const metadata_tag default_metadata_tags[]; +extern const gint n_default_metadata_tags; + +extern const metadata_tag equivalent_metadata_tags[]; +extern const gint n_equivalent_metadata_tags; + +/* Digital Source Type Combobox Items + * http://cv.iptc.org/newscodes/digitalsourcetype/ + */ +extern const combobox_str_tag digitalsourcetype[]; +extern const gint n_digitalsourcetype; + +/* Model Release Status Combobox Items + * http://ns.useplus.org/LDF/ldf-XMPSpecification#ModelReleaseStatus + */ +extern const combobox_str_tag modelreleasestatus[]; +extern const gint n_modelreleasestatus; + +/* Property Release Status Combobox Items + * http://ns.useplus.org/LDF/ldf-XMPSpecification#PropertyReleaseStatus + */ +extern const combobox_str_tag propertyreleasestatus[]; +extern const gint n_propertyreleasestatus; + +/* Minor Model Age Disclosure Combobox Items + * http://ns.useplus.org/LDF/ldf-XMPSpecification#MinorModelAgeDisclosure + */ +extern const combobox_str_tag minormodelagedisclosure[]; +extern const gint n_minormodelagedisclosure; + +/* Urgency */ +extern const gchar *urgency[]; +extern const gint n_urgency; + +/* Marked */ +extern const combobox_int_tag marked[]; +extern const gint n_marked; + +/* Phone Types */ +extern const combobox_str_tag phone_types[]; +extern const gint n_phone_types; + +/* DICOM Patient Sex + * http://dicomlookup.com/lookup.asp?sw=Ttable&q=C.7-1 + * http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/XMP.html#DICOM + * https://dicomiseasy.blogspot.ca/2011/11/introduction-to-dicom-chapter-iii-dicom.html + * http://dicom.nema.org/standard.html + */ +extern const combobox_str_tag dicom[]; +extern const gint n_dicom; + +/* GPS Altitude Ref */ +extern const gchar *gpsaltref[]; +extern const gint n_gpsaltref; + +/* GPS Latitude Ref */ +extern const gchar *gpslatref[]; +extern const gint n_gpslatref; + +/* GPS Longitude Ref */ +extern const gchar *gpslngref[]; +extern const gint n_gpslngref; + +/* GPS Measurement System */ +extern const gchar *gpsaltsys[]; +extern const gint n_gpsaltsys; + +extern const TranslateHeaderTag creatorContactInfoHeader; + +extern const TranslateTag creatorContactInfoTags[]; + +extern const TranslateHeaderTag locationCreationInfoHeader; + +extern const TranslateTag locationCreationInfoTags[]; + +extern const TranslateHeaderTag imageSupplierInfoHeader; + +extern const TranslateTag imageSupplierInfoTags[]; + +/* Plus and IPTC extension tags */ + +#define LICENSOR_HEADER "Xmp.plus.Licensor" +extern const gchar *licensor[]; +extern const gint n_licensor; + +#ifdef USE_TAGS +#define IMAGESUPPLIER_HEADER "Xmp.plus.ImageSupplier" +extern const gchar *imagesupplier[]; +extern const gint n_imagesupplier; +#endif + +#define IMAGECREATOR_HEADER "Xmp.plus.ImageCreator" +extern const gchar *imagecreator[]; +extern const gint n_imagecreator; + +#define COPYRIGHTOWNER_HEADER "Xmp.plus.CopyrightOwner" +extern const gchar *copyrightowner[]; +extern const gint n_copyrightowner; + +#define REGISTRYID_HEADER "Xmp.iptcExt.RegistryId" +extern const gchar *registryid[]; +extern const gint n_registryid; + +#define ARTWORKOROBJECT_HEADER "Xmp.iptcExt.ArtworkOrObject" +extern const gchar *artworkorobject[]; +extern const gint n_artworkorobject; + +#define LOCATIONSHOWN_HEADER "Xmp.iptcExt.LocationShown" +extern const gchar *locationshown[]; +extern const gint n_locationshown; + +#ifdef USE_TAGS +#define LOCATIONCREATED_HEADER "Xmp.iptcExt.LocationCreated" +extern const gchar *locationcreated[]; +extern const gint n_locationcreated; +#endif + +#endif /* __METADATA_TAGS_H__ */ diff --git a/plug-ins/metadata/metadata-viewer.c b/plug-ins/metadata/metadata-viewer.c new file mode 100644 index 0000000..30a1ece --- /dev/null +++ b/plug-ins/metadata/metadata-viewer.c @@ -0,0 +1,402 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * metadata.c + * Copyright (C) 2013 Hartmut Kuhse + * Copyright (C) 2016 Ben Touchette + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#include "config.h" + +#include <gegl.h> +#include <gtk/gtk.h> +#include <gexiv2/gexiv2.h> + +#include <libgimp/gimp.h> +#include <libgimp/gimpui.h> + +#include "libgimp/stdplugins-intl.h" + + +#define PLUG_IN_PROC "plug-in-metadata-viewer" +#define PLUG_IN_BINARY "metadata-viewer" +#define PLUG_IN_ROLE "gimp-metadata" + +#define EXIF_PREFIX "Exif." +#define IPTC_PREFIX "Iptc." +#define XMP_PREFIX "Xmp." + +/* The length at which to truncate tag values, in characters. */ +#define TAG_VALUE_MAX_SIZE 1024 + +/* The length at which to truncate raw data (i.e., tag values + * of type "Byte" or "Undefined"), in bytes. + */ +#define RAW_DATA_MAX_SIZE 16 + + +enum +{ + C_XMP_TAG = 0, + C_XMP_VALUE, + NUM_XMP_COLS +}; + +enum +{ + C_EXIF_TAG = 0, + C_EXIF_VALUE, + NUM_EXIF_COLS +}; + +enum +{ + C_IPTC_TAG = 0, + C_IPTC_VALUE, + NUM_IPTC_COLS +}; + + +/* local function prototypes */ + +static void query (void); +static void run (const gchar *name, + gint nparams, + const GimpParam *param, + gint *nreturn_vals, + GimpParam **return_vals); + +static gboolean metadata_viewer_dialog (gint32 image_id, + GimpMetadata *g_metadata); +static void metadata_dialog_set_metadata (GExiv2Metadata *metadata, + GtkBuilder *builder); +static void metadata_dialog_append_tags (GExiv2Metadata *metadata, + gchar **tags, + GtkListStore *store, + gint tag_column, + gint value_column); +static gchar * metadata_dialog_format_tag_value (GExiv2Metadata *metadata, + const gchar *tag, + gboolean truncate); + + +/* local variables */ + +const GimpPlugInInfo PLUG_IN_INFO = +{ + NULL, /* init_proc */ + NULL, /* quit_proc */ + query, /* query_proc */ + run, /* run_proc */ +}; + +/* functions */ + +MAIN () + +static void +query (void) +{ + static const GimpParamDef metadata_args[] = + { + { GIMP_PDB_INT32, "run-mode", "Run mode { RUN-INTERACTIVE (0) }" }, + { GIMP_PDB_IMAGE, "image", "Input image" } + }; + + gimp_install_procedure (PLUG_IN_PROC, + N_("View metadata (Exif, IPTC, XMP)"), + "View metadata information attached to the " + "current image. This can include Exif, IPTC and/or " + "XMP information.", + "Hartmut Kuhse, Michael Natterer, Ben Touchette", + "Hartmut Kuhse, Michael Natterer, Ben Touchette", + "2013, 2017", + N_("_View Metadata"), + "*", + GIMP_PLUGIN, + G_N_ELEMENTS (metadata_args), 0, + metadata_args, NULL); + + gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Image/Metadata"); +} + +static void +run (const gchar *name, + gint nparams, + const GimpParam *param, + gint *nreturn_vals, + GimpParam **return_vals) +{ + static GimpParam values[1]; + GimpPDBStatusType status = GIMP_PDB_SUCCESS; + + *nreturn_vals = 1; + *return_vals = values; + + values[0].type = GIMP_PDB_STATUS; + values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR; + + INIT_I18N(); + gimp_ui_init (PLUG_IN_BINARY, TRUE); + + if (! strcmp (name, PLUG_IN_PROC)) + { + GimpMetadata *metadata; + gint32 image_ID = param[1].data.d_image; + + metadata = gimp_image_get_metadata (image_ID); + + /* Always show metadata dialog so we can add + appropriate iptc data as needed. Sometimes + license data needs to be added after the + fact and the image may not contain metadata + but should have it added as needed. */ + + if (!metadata) + { + metadata = gimp_metadata_new(); + gimp_image_set_metadata (image_ID, metadata); + } + + metadata_viewer_dialog (image_ID, metadata); + + status = GIMP_PDB_SUCCESS; + } + else + { + status = GIMP_PDB_CALLING_ERROR; + } + + values[0].data.d_status = status; +} + +static gboolean +metadata_viewer_dialog (gint32 image_id, + GimpMetadata *g_metadata) +{ + GtkBuilder *builder; + GtkWidget *dialog; + GtkWidget *metadata_vbox; + GtkWidget *content_area; + gchar *ui_file; + gchar *title; + gchar *name; + GError *error = NULL; + GExiv2Metadata *metadata; + + metadata = GEXIV2_METADATA(g_metadata); + + builder = gtk_builder_new (); + + ui_file = g_build_filename (gimp_data_directory (), + "ui", "plug-ins", "plug-in-metadata-viewer.ui", NULL); + + if (! gtk_builder_add_from_file (builder, ui_file, &error)) + { + g_printerr ("Error occurred while loading UI file!\n"); + g_printerr ("Message: %s\n", error->message); + g_clear_error (&error); + g_free (ui_file); + g_object_unref (builder); + return FALSE; + } + + g_free (ui_file); + + name = gimp_image_get_name (image_id); + title = g_strdup_printf (_("Metadata Viewer: %s"), name); + g_free (name); + + dialog = gimp_dialog_new (title, + "gimp-metadata-viewer-dialog", + NULL, 0, + gimp_standard_help_func, PLUG_IN_PROC, + _("_Close"), GTK_RESPONSE_CLOSE, + NULL); + + gtk_widget_set_size_request(dialog, 460, 340); + + g_free (title); + + gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), + GTK_RESPONSE_CLOSE, + -1); + + content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); + + metadata_vbox = GTK_WIDGET (gtk_builder_get_object (builder, + "metadata-vbox")); + gtk_container_set_border_width (GTK_CONTAINER (metadata_vbox), 12); + gtk_box_pack_start (GTK_BOX (content_area), metadata_vbox, TRUE, TRUE, 0); + + metadata_dialog_set_metadata (metadata, builder); + + gtk_dialog_run (GTK_DIALOG (dialog)); + + return TRUE; +} + + +/* private functions */ + +static void +metadata_dialog_set_metadata (GExiv2Metadata *metadata, + GtkBuilder *builder) +{ + gchar **tags; + GtkListStore *store; + + /* load exif tags */ + tags = gexiv2_metadata_get_exif_tags (metadata); + store = GTK_LIST_STORE (gtk_builder_get_object (builder, "exif-liststore")); + + metadata_dialog_append_tags (metadata, tags, store, C_EXIF_TAG, C_EXIF_VALUE); + + g_strfreev (tags); + + /* load xmp tags */ + tags = gexiv2_metadata_get_xmp_tags (metadata); + store = GTK_LIST_STORE (gtk_builder_get_object (builder, "xmp-liststore")); + + metadata_dialog_append_tags (metadata, tags, store, C_XMP_TAG, C_XMP_VALUE); + + g_strfreev (tags); + + /* load iptc tags */ + tags = gexiv2_metadata_get_iptc_tags (metadata); + store = GTK_LIST_STORE (gtk_builder_get_object (builder, "iptc-liststore")); + + metadata_dialog_append_tags (metadata, tags, store, C_IPTC_TAG, C_IPTC_VALUE); + + g_strfreev (tags); +} + +static void +metadata_dialog_append_tags (GExiv2Metadata *metadata, + gchar **tags, + GtkListStore *store, + gint tag_column, + gint value_column) +{ + GtkTreeIter iter; + const gchar *tag; + + while ((tag = *tags++)) + { + gchar *value; + + gtk_list_store_append (store, &iter); + + value = metadata_dialog_format_tag_value (metadata, tag, + /* truncate = */ TRUE); + + gtk_list_store_set (store, &iter, + tag_column, tag, + value_column, value, + -1); + + g_free (value); + } +} + +static gchar * +metadata_dialog_format_tag_value (GExiv2Metadata *metadata, + const gchar *tag, + gboolean truncate) +{ + const gchar *tag_type; + gchar *result; + + tag_type = gexiv2_metadata_get_tag_type (tag); + + if (g_strcmp0 (tag_type, "Byte") != 0 && + g_strcmp0 (tag_type, "Undefined") != 0 && + g_strcmp0 (tag_type, NULL) != 0) + { + gchar *value; + gchar *value_utf8; + glong size; + + value = gexiv2_metadata_get_tag_interpreted_string (metadata, tag); + value_utf8 = g_locale_to_utf8 (value, -1, NULL, NULL, NULL); + + g_free (value); + + size = g_utf8_strlen (value_utf8, -1); + + if (! truncate || size <= TAG_VALUE_MAX_SIZE) + { + result = value_utf8; + } + else + { + gchar *value_utf8_trunc; + GString *str; + + value_utf8_trunc = g_utf8_substring (value_utf8, + 0, TAG_VALUE_MAX_SIZE); + + g_free (value_utf8); + + str = g_string_new (value_utf8_trunc); + + g_free (value_utf8_trunc); + + g_string_append (str, "... "); + g_string_append_printf (str, + _("(%lu more character(s))"), + size - TAG_VALUE_MAX_SIZE); + + result = g_string_free (str, FALSE); + } + } + else + { + GBytes *bytes; + const guchar *data; + gsize size; + gsize display_size; + GString *str; + gint i; + + bytes = gexiv2_metadata_get_tag_raw (metadata, tag); + data = g_bytes_get_data (bytes, &size); + + if (! truncate) + display_size = size; + else + display_size = MIN (size, RAW_DATA_MAX_SIZE); + + str = g_string_sized_new (3 * display_size); + + for (i = 0; i < display_size; i++) + g_string_append_printf (str, i == 0 ? "%02x" : " %02x", data[i]); + + if (display_size < size) + { + g_string_append (str, " ... "); + g_string_append_printf (str, + _("(%llu more byte(s))"), + (unsigned long long) (size - display_size)); + } + + result = g_string_free (str, FALSE); + + g_bytes_unref (bytes); + } + + return result; +} diff --git a/plug-ins/metadata/metadata-xml.c b/plug-ins/metadata/metadata-xml.c new file mode 100644 index 0000000..660cc14 --- /dev/null +++ b/plug-ins/metadata/metadata-xml.c @@ -0,0 +1,1179 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * metadata-editor.c + * Copyright (C) 2016, 2017 Ben Touchette + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#include "config.h" + +#include <stdlib.h> +#include <ctype.h> + +#include <gegl.h> +#include <gtk/gtk.h> +#include <gexiv2/gexiv2.h> + +#include <glib.h> +#include <glib/gstdio.h> + +#include <libgimp/gimp.h> +#include <libgimp/gimpui.h> + +#include "libgimp/stdplugins-intl.h" + +#include "metadata-misc.h" +#include "metadata-xml.h" +#include "metadata-tags.h" + +extern gboolean gimpmetadata; +extern gboolean force_write; + +gboolean xmptag; +gboolean iptctag; +gboolean tagvalue; +gboolean taglistvalue; +gboolean tagname; +gboolean tagmode; +gboolean listelement; +gboolean element; +gchar *str_tag_value; +gchar *str_tag_name; +gchar *str_tag_mode; +gchar *str_element; +gchar *list_tag_data[256][256]; +gint row_count = 0; +gint item_count = 0; + + +void +xml_parser_start_element (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + gpointer user_data, + GError **error) +{ + if (strcmp (element_name, "gimp-metadata") == 0) + { + gimpmetadata = TRUE; + } + else if (strcmp (element_name, "iptc-tag") == 0) + { + item_count = 0; + row_count = 0; + iptctag = TRUE; + } + else if (strcmp (element_name, "xmp-tag") == 0) + { + item_count = 0; + row_count = 0; + xmptag = TRUE; + } + else if (strcmp (element_name, "tag-value") == 0) + { + tagvalue = TRUE; + } + else if (strcmp (element_name, "tag-list-value") == 0) + { + taglistvalue = TRUE; + } + else if (strcmp (element_name, "tag-name") == 0) + { + tagname = TRUE; + } + else if (strcmp (element_name, "tag-mode") == 0) + { + tagmode = TRUE; + } + else if (strcmp (element_name, "list-element") == 0) + { + listelement = TRUE; + row_count += 1; + } + else if (strcmp (element_name, "element") == 0) + { + element = TRUE; + item_count += 1; + } +} + +void +xml_parser_data (GMarkupParseContext *context, + const gchar *text, + gsize text_len, + gpointer user_data, + GError **error) +{ + if (tagvalue) + { + if (str_tag_value) + g_free(str_tag_value); + + if (text) + str_tag_value = g_strdup(text); + else + str_tag_value = g_strconcat("", NULL); + } + else if (tagname) + { + if (str_tag_name) + g_free(str_tag_name); + + if (text) + str_tag_name = g_strdup(text); + else + str_tag_name = g_strconcat("", NULL); + } + else if (tagmode) + { + if (str_tag_mode) + g_free(str_tag_mode); + + if (text) + str_tag_mode = g_strdup(text); + else + str_tag_mode = g_strconcat("", NULL); + } + else if (element) + { + if (str_element) + g_free(str_element); + + if (text) + str_element = g_strdup(text); + else + str_element = g_strconcat("", NULL); + } +} + +void +set_tag_ui (metadata_editor *args, + gint index, + gchar *name, + gchar *value, + gchar* mode) +{ + GtkWidget *widget; + gchar *value_utf; + + widget = GTK_WIDGET (gtk_builder_get_object (args->builder, str_tag_name)); + + if (!strcmp ("single", mode)) + { + GtkEntry *entry_widget; + + value_utf = g_locale_to_utf8 (str_tag_value, -1, NULL, NULL, NULL); + entry_widget = GTK_ENTRY (widget); + gtk_entry_set_text (entry_widget, value_utf); + } + else if (!strcmp ("multi", mode)) + { + GtkTextView *text_view; + GtkTextBuffer *buffer; + + value_utf = g_locale_to_utf8 (str_tag_value, -1, NULL, NULL, NULL); + text_view = GTK_TEXT_VIEW (widget); + buffer = gtk_text_view_get_buffer (text_view); + gtk_text_buffer_set_text (buffer, value_utf, -1); + } + else if (!strcmp ("combo", mode)) + { + gint32 value; + + value_utf = g_locale_to_utf8 (str_tag_value, -1, NULL, NULL, NULL); + value = atoi(value_utf); + gtk_combo_box_set_active (GTK_COMBO_BOX(widget), value); + } + else if (!strcmp ("list", mode)) + { + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gint number_of_rows; + gint row; + gint item; + + liststore = GTK_LIST_STORE(gtk_tree_view_get_model((GtkTreeView *)widget)); + treemodel = GTK_TREE_MODEL (liststore); + number_of_rows = + gtk_tree_model_iter_n_children(GTK_TREE_MODEL(liststore), NULL); + + /* Clear all current values */ + for (row = number_of_rows; row > -1; row--) + { + if (gtk_tree_model_iter_nth_child(treemodel, &iter, NULL, row)) + { + gtk_list_store_remove(liststore, &iter); + } + } + /* Add new values values */ + if (!strcmp (LICENSOR_HEADER, name)) + { + for (row = 1; row < row_count+1; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_LICENSOR_NAME, list_tag_data[row][1], + COL_LICENSOR_ID, list_tag_data[row][2], + COL_LICENSOR_PHONE1, list_tag_data[row][3], + COL_LICENSOR_PHONE_TYPE1, list_tag_data[row][4], + COL_LICENSOR_PHONE2, list_tag_data[row][5], + COL_LICENSOR_PHONE_TYPE2, list_tag_data[row][6], + COL_LICENSOR_EMAIL, list_tag_data[row][7], + COL_LICENSOR_WEB, list_tag_data[row][8], + -1); + for (item = 1; item < n_licensor + 1; item++) + { + if (list_tag_data[row][item]) + { + if (list_tag_data[row][item]) + g_free(list_tag_data[row][item]); + } + } + } + + if (row_count < 2) + { + for (row = 0; row < 2 - row_count; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_LICENSOR_NAME, NULL, + COL_LICENSOR_ID, NULL, + COL_LICENSOR_PHONE1, NULL, + COL_LICENSOR_PHONE_TYPE1, NULL, + COL_LICENSOR_PHONE2, NULL, + COL_LICENSOR_PHONE_TYPE2, NULL, + COL_LICENSOR_EMAIL, NULL, + COL_LICENSOR_WEB, NULL, + -1); + } + } + } + else if (!strcmp (IMAGECREATOR_HEADER, name)) + { + for (row = 1; row < row_count+1; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_IMG_CR8_NAME, list_tag_data[row][1], + COL_IMG_CR8_ID, list_tag_data[row][2], + -1); + for (item = 1; item < n_imagecreator + 1; item++) + { + if (list_tag_data[row][item]) + { + if (list_tag_data[row][item]) + g_free(list_tag_data[row][item]); + } + } + } + + if (row_count < 2) + { + for (row = 0; row < 2 - row_count; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_IMG_CR8_NAME, NULL, + COL_IMG_CR8_ID, NULL, + -1); + } + } + } + else if (!strcmp (ARTWORKOROBJECT_HEADER, name)) + { + for (row = 1; row < row_count+1; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_AOO_TITLE, list_tag_data[row][1], + COL_AOO_DATE_CREAT, list_tag_data[row][2], + COL_AOO_CREATOR, list_tag_data[row][3], + COL_AOO_SOURCE, list_tag_data[row][4], + COL_AOO_SRC_INV_ID, list_tag_data[row][5], + COL_AOO_CR_NOT, list_tag_data[row][6], + -1); + for (item = 1; item < n_artworkorobject + 1; item++) + { + if (list_tag_data[row][item]) + { + if (list_tag_data[row][item]) + g_free(list_tag_data[row][item]); + } + } + } + + if (row_count < 2) + { + for (row = 0; row < 2 - row_count; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_AOO_TITLE, NULL, + COL_AOO_DATE_CREAT, NULL, + COL_AOO_CREATOR, NULL, + COL_AOO_SOURCE, NULL, + COL_AOO_SRC_INV_ID, NULL, + COL_AOO_CR_NOT, NULL, + -1); + } + } + } + else if (!strcmp (REGISTRYID_HEADER, name)) + { + for (row = 1; row < row_count+1; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_REGSITRY_ORG_ID, list_tag_data[row][1], + COL_REGSITRY_ITEM_ID, list_tag_data[row][2], + -1); + for (item = 1; item < n_registryid + 1; item++) + { + if (list_tag_data[row][item]) + { + if (list_tag_data[row][item]) + g_free(list_tag_data[row][item]); + } + } + } + + if (row_count < 2) + { + for (row = 0; row < 2 - row_count; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_REGSITRY_ORG_ID, NULL, + COL_REGSITRY_ITEM_ID, NULL, + -1); + } + } + } + else if (!strcmp (COPYRIGHTOWNER_HEADER, name)) + { + if (row_count > 0) + { + for (row = 1; row < row_count+1; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_CR_OWNER_NAME, list_tag_data[row][1], + COL_CR_OWNER_ID, list_tag_data[row][2], + -1); + for (item = 1; item < n_copyrightowner + 1; item++) + { + if (list_tag_data[row][item]) + { + if (list_tag_data[row][item]) + g_free(list_tag_data[row][item]); + } + } + } + } + + if (row_count < 2) + { + for (row = 0; row < 2 - row_count; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_CR_OWNER_NAME, NULL, + COL_CR_OWNER_ID, NULL, + -1); + } + } + } + else if (!strcmp (LOCATIONSHOWN_HEADER, name)) + { + for (row = 1; row < row_count+1; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_LOC_SHO_SUB_LOC, list_tag_data[row][1], + COL_LOC_SHO_CITY, list_tag_data[row][2], + COL_LOC_SHO_STATE_PROV, list_tag_data[row][3], + COL_LOC_SHO_CNTRY, list_tag_data[row][4], + COL_LOC_SHO_CNTRY_ISO, list_tag_data[row][5], + COL_LOC_SHO_CNTRY_WRLD_REG, list_tag_data[row][6], + -1); + for (item = 1; item < n_locationshown + 1; item++) + { + if (list_tag_data[row][item]) + { + if (list_tag_data[row][item]) + g_free(list_tag_data[row][item]); + } + } + } + + if (row_count < 2) + { + for (row = 0; row < 2 - row_count; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_LOC_SHO_SUB_LOC, NULL, + COL_LOC_SHO_CITY, NULL, + COL_LOC_SHO_STATE_PROV, NULL, + COL_LOC_SHO_CNTRY, NULL, + COL_LOC_SHO_CNTRY_ISO, NULL, + COL_LOC_SHO_CNTRY_WRLD_REG, NULL, + -1); + } + } + } + else if (!strcmp ("Xmp.iptcExt.OrganisationInImageName", name)) + { + for (row = 1; row < row_count+1; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_ORG_IMG_NAME, list_tag_data[row][1], + -1); + if (list_tag_data[row][1]) + { + if (list_tag_data[row][1]) + g_free(list_tag_data[row][1]); + } + } + + if (row_count < 2) + { + for (row = 0; row < 2 - row_count; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_ORG_IMG_NAME, NULL, + -1); + } + } + } + else if (!strcmp ("Xmp.iptcExt.OrganisationInImageCode", name)) + { + for (row = 1; row < row_count+1; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_ORG_IMG_CODE, list_tag_data[row][1], + -1); + if (list_tag_data[row][1]) + { + if (list_tag_data[row][1]) + g_free(list_tag_data[row][1]); + } + } + + if (row_count < 2) + { + for (row = 0; row < 2 - row_count; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_ORG_IMG_CODE, NULL, + -1); + } + } + } + else if (!strcmp ("Xmp.plus.PropertyReleaseID", name)) + { + for (row = 1; row < row_count+1; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_PROP_REL_ID, list_tag_data[row][1], + -1); + if (list_tag_data[row][1]) + { + if (list_tag_data[row][1]) + g_free(list_tag_data[row][1]); + } + } + + if (row_count < 2) + { + for (row = 0; row < 2 - row_count; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_PROP_REL_ID, NULL, + -1); + } + } + } + else if (!strcmp ("Xmp.plus.ModelReleaseID", name)) + { + for (row = 1; row < row_count+1; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_MOD_REL_ID, list_tag_data[row][1], + -1); + if (list_tag_data[row][1]) + { + if (list_tag_data[row][1]) + g_free(list_tag_data[row][1]); + } + } + + if (row_count < 2) + { + for (row = 0; row < 2 - row_count; row++) + { + gtk_list_store_append (liststore, &iter); + gtk_list_store_set (liststore, &iter, + COL_MOD_REL_ID, NULL, + -1); + } + } + } + } +} + +const gchar * +get_tag_ui_text (metadata_editor *args, + gchar *name, + gchar *mode) +{ + GObject *object; + + object = gtk_builder_get_object (args->builder, name); + + if (! strcmp ("single", mode)) + { + GtkEntry *entry = GTK_ENTRY (object); + return gtk_entry_get_text (entry); + } + else if (!strcmp ("multi", mode)) + { + GtkTextView *text_view = GTK_TEXT_VIEW (object); + GtkTextBuffer *buffer; + GtkTextIter start; + GtkTextIter end; + + buffer = gtk_text_view_get_buffer (text_view); + gtk_text_buffer_get_start_iter (buffer, &start); + gtk_text_buffer_get_end_iter (buffer, &end); + + return gtk_text_buffer_get_text (buffer, &start, &end, TRUE); + } + + return NULL; +} + +gchar * +get_tag_ui_list (metadata_editor *args, gchar *name, gchar *mode) +{ + GObject *object; + GtkWidget *widget; + GtkTreeModel *treemodel; + GtkListStore *liststore; + GtkTreeIter iter; + gchar *xmldata; + gint number_of_rows; + gint row; + gint has_data; + gchar *tagdata[256][256]; + + has_data = FALSE; + xmldata = (gchar*)g_malloc(262144); + object = gtk_builder_get_object (args->builder, name); + widget = GTK_WIDGET(object); + + liststore = GTK_LIST_STORE(gtk_tree_view_get_model((GtkTreeView *)widget)); + treemodel = GTK_TREE_MODEL (liststore); + number_of_rows = + gtk_tree_model_iter_n_children(GTK_TREE_MODEL(liststore), NULL); + + for (row = 0; row < number_of_rows; row++) + { + if (gtk_tree_model_iter_nth_child(treemodel, &iter, NULL, row)) + { + if (!strcmp (LICENSOR_HEADER, name)) + { + gtk_tree_model_get (treemodel, &iter, + COL_LICENSOR_NAME, &tagdata[row][0], + COL_LICENSOR_ID, &tagdata[row][1], + COL_LICENSOR_PHONE1, &tagdata[row][2], + COL_LICENSOR_PHONE_TYPE1, &tagdata[row][3], + COL_LICENSOR_PHONE2, &tagdata[row][4], + COL_LICENSOR_PHONE_TYPE2, &tagdata[row][5], + COL_LICENSOR_EMAIL, &tagdata[row][6], + COL_LICENSOR_WEB, &tagdata[row][7], + -1); + + if ((tagdata[row][0] != NULL && strlen(tagdata[row][0]) > 0) || + (tagdata[row][1] != NULL && strlen(tagdata[row][1]) > 0) || + (tagdata[row][2] != NULL && strlen(tagdata[row][2]) > 0) || + (tagdata[row][3] != NULL && strlen(tagdata[row][3]) > 0) || + (tagdata[row][4] != NULL && strlen(tagdata[row][4]) > 0) || + (tagdata[row][5] != NULL && strlen(tagdata[row][5]) > 0) || + (tagdata[row][6] != NULL && strlen(tagdata[row][6]) > 0) || + (tagdata[row][7] != NULL && strlen(tagdata[row][7]) > 0)) + { + gint types; + + has_data = TRUE; + + xmldata = g_strconcat (xmldata, "\t\t\t<list-element>\n", NULL); + for (types = 0; types < 8; types++) + { + xmldata = g_strconcat (xmldata, "\t\t\t\t<element>", NULL); + xmldata = g_strconcat (xmldata, tagdata[row][types], NULL); + xmldata = g_strconcat (xmldata, "</element>\n", NULL); + } + xmldata = g_strconcat (xmldata, "\t\t\t</list-element>\n", NULL); + } + } + else if (!strcmp (COPYRIGHTOWNER_HEADER, name)) + { + gtk_tree_model_get (treemodel, &iter, + COL_CR_OWNER_NAME, &tagdata[row][0], + COL_CR_OWNER_ID, &tagdata[row][1], + -1); + + if ((tagdata[row][0] != NULL && strlen(tagdata[row][0]) > 0) || + (tagdata[row][1] != NULL && strlen(tagdata[row][1]) > 0)) + { + has_data = TRUE; + + xmldata = g_strconcat (xmldata, "\t\t\t<list-element>\n", NULL); + xmldata = g_strconcat (xmldata, "\t\t\t\t<element>", NULL); + xmldata = g_strconcat (xmldata, tagdata[row][0], NULL); + xmldata = g_strconcat (xmldata, "</element>\n", NULL); + xmldata = g_strconcat (xmldata, "\t\t\t\t<element>", NULL); + xmldata = g_strconcat (xmldata, tagdata[row][1], NULL); + xmldata = g_strconcat (xmldata, "</element>\n", NULL); + xmldata = g_strconcat (xmldata, "\t\t\t</list-element>\n", NULL); + } + } + else if (!strcmp (IMAGECREATOR_HEADER, name)) + { + gtk_tree_model_get (treemodel, &iter, + COL_IMG_CR8_NAME, &tagdata[row][0], + COL_IMG_CR8_ID, &tagdata[row][1], + -1); + + if ((tagdata[row][0] != NULL && strlen(tagdata[row][0]) > 0) || + (tagdata[row][1] != NULL && strlen(tagdata[row][1]) > 0)) + { + gint types; + + has_data = TRUE; + + xmldata = g_strconcat (xmldata, "\t\t\t<list-element>\n", NULL); + for (types = 0; types < 2; types++) + { + xmldata = g_strconcat (xmldata, "\t\t\t\t<element>", NULL); + xmldata = g_strconcat (xmldata, tagdata[row][types], NULL); + xmldata = g_strconcat (xmldata, "</element>\n", NULL); + } + xmldata = g_strconcat (xmldata, "\t\t\t</list-element>\n", NULL); + } + } + else if (!strcmp (ARTWORKOROBJECT_HEADER, name)) + { + gtk_tree_model_get (treemodel, &iter, + COL_AOO_TITLE, &tagdata[row][0], + COL_AOO_DATE_CREAT, &tagdata[row][1], + COL_AOO_CREATOR, &tagdata[row][2], + COL_AOO_SOURCE, &tagdata[row][3], + COL_AOO_SRC_INV_ID, &tagdata[row][4], + COL_AOO_CR_NOT, &tagdata[row][5], + -1); + + if ((tagdata[row][0] != NULL && strlen(tagdata[row][0]) > 0) || + (tagdata[row][1] != NULL && strlen(tagdata[row][1]) > 0) || + (tagdata[row][2] != NULL && strlen(tagdata[row][2]) > 0) || + (tagdata[row][3] != NULL && strlen(tagdata[row][3]) > 0) || + (tagdata[row][4] != NULL && strlen(tagdata[row][4]) > 0) || + (tagdata[row][5] != NULL && strlen(tagdata[row][5]) > 0)) + { + gint types; + + has_data = TRUE; + + xmldata = g_strconcat (xmldata, "\t\t\t<list-element>\n", NULL); + for (types = 0; types < 6; types++) + { + xmldata = g_strconcat (xmldata, "\t\t\t\t<element>", NULL); + xmldata = g_strconcat (xmldata, tagdata[row][types], NULL); + xmldata = g_strconcat (xmldata, "</element>\n", NULL); + } + xmldata = g_strconcat (xmldata, "\t\t\t</list-element>\n", NULL); + } + } + else if (!strcmp (REGISTRYID_HEADER, name)) + { + gtk_tree_model_get (treemodel, &iter, + COL_REGSITRY_ORG_ID, &tagdata[row][0], + COL_REGSITRY_ITEM_ID, &tagdata[row][1], + -1); + + if ((tagdata[row][0] != NULL && strlen(tagdata[row][0]) > 0) || + (tagdata[row][1] != NULL && strlen(tagdata[row][1]) > 0)) + { + gint types; + + has_data = TRUE; + + xmldata = g_strconcat (xmldata, "\t\t\t<list-element>\n", NULL); + for (types = 0; types < 2; types++) + { + xmldata = g_strconcat (xmldata, "\t\t\t\t<element>", NULL); + xmldata = g_strconcat (xmldata, tagdata[row][types], NULL); + xmldata = g_strconcat (xmldata, "</element>\n", NULL); + } + xmldata = g_strconcat (xmldata, "\t\t\t</list-element>\n", NULL); + } + } + else if (!strcmp (LOCATIONSHOWN_HEADER, name)) + { + gtk_tree_model_get (treemodel, &iter, + COL_LOC_SHO_SUB_LOC, &tagdata[row][0], + COL_LOC_SHO_CITY, &tagdata[row][1], + COL_LOC_SHO_STATE_PROV, &tagdata[row][2], + COL_LOC_SHO_CNTRY, &tagdata[row][3], + COL_LOC_SHO_CNTRY_ISO, &tagdata[row][4], + COL_LOC_SHO_CNTRY_WRLD_REG, &tagdata[row][5], + -1); + + if ((tagdata[row][0] != NULL && strlen(tagdata[row][0]) > 0) || + (tagdata[row][1] != NULL && strlen(tagdata[row][1]) > 0) || + (tagdata[row][2] != NULL && strlen(tagdata[row][2]) > 0) || + (tagdata[row][3] != NULL && strlen(tagdata[row][3]) > 0) || + (tagdata[row][4] != NULL && strlen(tagdata[row][4]) > 0) || + (tagdata[row][5] != NULL && strlen(tagdata[row][5]) > 0)) + { + gint types; + + has_data = TRUE; + + xmldata = g_strconcat (xmldata, "\t\t\t<list-element>\n", NULL); + for (types = 0; types < 6; types++) + { + xmldata = g_strconcat (xmldata, "\t\t\t\t<element>", NULL); + xmldata = g_strconcat (xmldata, tagdata[row][types], NULL); + xmldata = g_strconcat (xmldata, "</element>\n", NULL); + } + xmldata = g_strconcat (xmldata, "\t\t\t</list-element>\n", NULL); + } + } + else if (!strcmp ("Xmp.iptcExt.OrganisationInImageName", name)) + { + gtk_tree_model_get (treemodel, &iter, + COL_ORG_IMG_NAME, &tagdata[row][0], + -1); + + if ((tagdata[row][0] != NULL && strlen(tagdata[row][0]) > 0)) + { + has_data = TRUE; + + xmldata = g_strconcat (xmldata, "\t\t\t<list-element>\n", NULL); + xmldata = g_strconcat (xmldata, "\t\t\t\t<element>", NULL); + xmldata = g_strconcat (xmldata, tagdata[row][0], NULL); + xmldata = g_strconcat (xmldata, "</element>\n", NULL); + xmldata = g_strconcat (xmldata, "\t\t\t</list-element>\n", NULL); + } + } + else if (!strcmp ("Xmp.iptcExt.OrganisationInImageCode", name)) + { + gtk_tree_model_get (treemodel, &iter, + COL_ORG_IMG_CODE, &tagdata[row][0], + -1); + + if ((tagdata[row][0] != NULL && strlen(tagdata[row][0]) > 0)) + { + has_data = TRUE; + + xmldata = g_strconcat (xmldata, "\t\t\t<list-element>\n", NULL); + xmldata = g_strconcat (xmldata, "\t\t\t\t<element>", NULL); + xmldata = g_strconcat (xmldata, tagdata[row][0], NULL); + xmldata = g_strconcat (xmldata, "</element>\n", NULL); + xmldata = g_strconcat (xmldata, "\t\t\t</list-element>\n", NULL); + } + } + else if (!strcmp ("Xmp.plus.PropertyReleaseID", name)) + { + gtk_tree_model_get (treemodel, &iter, + COL_PROP_REL_ID, &tagdata[row][0], + -1); + + if ((tagdata[row][0] != NULL && strlen(tagdata[row][0]) > 0)) + { + has_data = TRUE; + + xmldata = g_strconcat (xmldata, "\t\t\t<list-element>\n", NULL); + xmldata = g_strconcat (xmldata, "\t\t\t\t<element>", NULL); + xmldata = g_strconcat (xmldata, tagdata[row][0], NULL); + xmldata = g_strconcat (xmldata, "</element>\n", NULL); + xmldata = g_strconcat (xmldata, "\t\t\t</list-element>\n", NULL); + } + } + else if (!strcmp ("Xmp.plus.ModelReleaseID", name)) + { + gtk_tree_model_get (treemodel, &iter, + COL_MOD_REL_ID, &tagdata[row][0], + -1); + + if ((tagdata[row][0] != NULL && strlen(tagdata[row][0]) > 0)) + { + has_data = TRUE; + + xmldata = g_strconcat (xmldata, "\t\t\t<list-element>\n", NULL); + xmldata = g_strconcat (xmldata, "\t\t\t\t<element>", NULL); + xmldata = g_strconcat (xmldata, tagdata[row][0], NULL); + xmldata = g_strconcat (xmldata, "</element>\n", NULL); + xmldata = g_strconcat (xmldata, "\t\t\t</list-element>\n", NULL); + } + } + } + } + + if (has_data == TRUE) + { + return xmldata; + } + + g_free(xmldata); + + return NULL; +} + +gint +get_tag_ui_combo (metadata_editor *args, gchar *name, gchar *mode) +{ + GObject *object; + GtkComboBoxText *combo; + gint value; + + object = gtk_builder_get_object (args->builder, name); + + combo = GTK_COMBO_BOX_TEXT (object); + value = gtk_combo_box_get_active (GTK_COMBO_BOX(combo)); + + return value; +} + +void +xml_parser_end_element (GMarkupParseContext *context, + const gchar *element_name, + gpointer user_data, + GError **error) +{ + metadata_editor *args; + int i; + + args = user_data; + + if (strcmp (element_name, "gimp-metadata") == 0) + { + gimpmetadata = FALSE; + } + else if (strcmp (element_name, "iptc-tag") == 0) + { + iptctag = FALSE; +#ifdef _ENABLE_IPTC_TAG_ + if (str_tag_name && str_tag_value) + { + /* make sure to only allow supported tags */ + for (i = 0; i < n_equivalent_metadata_tags; i++) + { + if (strcmp(equivalent_metadata_tags[i].tag, str_tag_name) == 0) + { +#ifdef _SET_IPTC_TAG_ + set_tag_ui (args, i, str_tag_name, str_tag_value, + equivalent_metadata_tags[i].mode); +#endif + if (force_write == TRUE) + gexiv2_metadata_set_tag_string (args->metadata, + str_tag_name, + str_tag_value); + break; + } + } + } +#endif + } + else if (strcmp (element_name, "xmp-tag") == 0) + { + xmptag = FALSE; + if (strcmp (str_tag_mode, "list") != 0) + { + if (str_tag_name && str_tag_value) + { + /* make sure to only allow supported tags */ + for (i = 0; i < n_default_metadata_tags; i++) + { + if (strcmp(default_metadata_tags[i].tag, str_tag_name) == 0) + { + set_tag_ui (args, i, str_tag_name, str_tag_value, + default_metadata_tags[i].mode); +#ifdef _ENABLE_FORCE_WRITE_ + if (force_write == TRUE) + gexiv2_metadata_set_tag_string (args->metadata, + str_tag_name, + str_tag_value); +#endif + break; + } + } + } + + } + else if (strcmp (str_tag_mode, "list") == 0) + { + if (row_count > 0) + { + /* make sure to only allow supported tags */ + for (i = 0; i < n_default_metadata_tags; i++) + { + if (strcmp(default_metadata_tags[i].tag, str_tag_name) == 0) + { + set_tag_ui (args, i, str_tag_name, str_tag_value, + default_metadata_tags[i].mode); +#ifdef _ENABLE_FORCE_WRITE_ + if (force_write == TRUE) + gexiv2_metadata_set_tag_string (args->metadata, + str_tag_name, + str_tag_value); +#endif + break; + } + } + } + row_count = 0; + item_count = 0; + } + } + else if (strcmp (element_name, "tag-value") == 0) + { + tagvalue = FALSE; + } + else if (strcmp (element_name, "tag-list-value") == 0) + { + taglistvalue = FALSE; + } + else if (strcmp (element_name, "tag-name") == 0) + { + tagname = FALSE; + } + else if (strcmp (element_name, "tag-mode") == 0) + { + tagmode = FALSE; + } + else if (strcmp (element_name, "list-element") == 0) + { + listelement = FALSE; + item_count = 0; + } + else if (strcmp (element_name, "element") == 0) + { + element = FALSE; + list_tag_data[row_count][item_count] = g_strdup(str_element); + } +} + +gboolean +xml_parser_parse_file (GimpXmlParser *parser, + const gchar *filename, + GError **error) +{ + GIOChannel *io; + gboolean success; + + g_return_val_if_fail (parser != NULL, FALSE); + g_return_val_if_fail (filename != NULL, FALSE); + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + io = g_io_channel_new_file (filename, "r", error); + if (!io) + return FALSE; + + success = xml_parser_parse_io_channel (parser, io, error); + + g_io_channel_unref (io); + + return success; +} + +GimpXmlParser * +xml_parser_new (const GMarkupParser *markup_parser, + gpointer user_data) +{ + GimpXmlParser *parser; + + g_return_val_if_fail (markup_parser != NULL, NULL); + + parser = g_slice_new (GimpXmlParser); + + parser->context = g_markup_parse_context_new (markup_parser, + 0, user_data, NULL); + + return parser; +} + +void +xml_parser_free (GimpXmlParser *parser) +{ + g_return_if_fail (parser != NULL); + + g_markup_parse_context_free (parser->context); + g_slice_free (GimpXmlParser, parser); +} + +gboolean +parse_encoding (const gchar *text, + gint text_len, + gchar **encoding) +{ + const gchar *start; + const gchar *end; + gint i; + + g_return_val_if_fail (text, FALSE); + + if (text_len < 20) + return FALSE; + + start = g_strstr_len (text, text_len, "<?xml"); + if (!start) + return FALSE; + + end = g_strstr_len (start, text_len - (start - text), "?>"); + if (!end) + return FALSE; + + *encoding = NULL; + + text_len = end - start; + if (text_len < 12) + return TRUE; + + start = g_strstr_len (start + 1, text_len - 1, "encoding"); + if (!start) + return TRUE; + + start += 8; + + while (start < end && *start == ' ') + start++; + + if (*start != '=') + return TRUE; + + start++; + + while (start < end && *start == ' ') + start++; + + if (*start != '\"' && *start != '\'') + return TRUE; + + text_len = end - start; + if (text_len < 1) + return TRUE; + + for (i = 1; i < text_len; i++) + if (start[i] == start[0]) + break; + + if (i == text_len || i < 3) + return TRUE; + + *encoding = g_strndup (start + 1, i - 1); + + return TRUE; +} + +gboolean +xml_parser_parse_io_channel (GimpXmlParser *parser, + GIOChannel *io, + GError **error) +{ + GIOStatus status; + gchar buffer[4096]; + gsize len = 0; + gsize bytes; + const gchar *io_encoding; + gchar *encoding = NULL; + + g_return_val_if_fail (parser != NULL, FALSE); + g_return_val_if_fail (io != NULL, FALSE); + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + io_encoding = g_io_channel_get_encoding (io); + if (g_strcmp0 (io_encoding, "UTF-8")) + { + g_warning ("xml_parser_parse_io_channel():\n" + "The encoding has already been set on this GIOChannel!"); + return FALSE; + } + + /* try to determine the encoding */ + + g_io_channel_set_encoding (io, NULL, NULL); + + while (len < sizeof (buffer)) + { + status = g_io_channel_read_chars (io, buffer + len, 1, &bytes, error); + len += bytes; + + if (status == G_IO_STATUS_ERROR) + return FALSE; + if (status == G_IO_STATUS_EOF) + break; + + if (parse_encoding (buffer, len, &encoding)) + break; + } + + if (encoding) + { + if (! g_io_channel_set_encoding (io, encoding, error)) + return FALSE; + + if (encoding) + g_free (encoding); + } + else + { + g_io_channel_set_encoding (io, "UTF-8", NULL); + } + + while (TRUE) + { + if (!g_markup_parse_context_parse (parser->context, buffer, len, error)) + return FALSE; + + status = g_io_channel_read_chars (io, + buffer, sizeof (buffer), &len, error); + + switch (status) + { + case G_IO_STATUS_ERROR: + return FALSE; + case G_IO_STATUS_EOF: + return g_markup_parse_context_end_parse (parser->context, error); + case G_IO_STATUS_NORMAL: + case G_IO_STATUS_AGAIN: + break; + } + } +} + diff --git a/plug-ins/metadata/metadata-xml.h b/plug-ins/metadata/metadata-xml.h new file mode 100644 index 0000000..12ac77b --- /dev/null +++ b/plug-ins/metadata/metadata-xml.h @@ -0,0 +1,98 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * Copyright (C) 2016, 2017 Ben Touchette + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +#ifndef __METADATA_XML_H__ +#define __METADATA_XML_H__ + +#include "metadata-misc.h" + +struct _GimpXmlParser +{ + GMarkupParseContext *context; +}; + +typedef struct _GimpXmlParser GimpXmlParser; + +void +xml_parser_start_element (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + gpointer user_data, + GError **error); + +void +xml_parser_data (GMarkupParseContext *context, + const gchar *text, + gsize text_len, + gpointer user_data, + GError **error); + +void +set_tag_ui (metadata_editor *args, + int index, + gchar *name, + gchar *value, + gchar *mode); + +const gchar * +get_tag_ui_text (metadata_editor *args, + gchar *name, + gchar *mode); + +gchar * +get_tag_ui_list (metadata_editor *args, + gchar *name, + gchar *mode); + +gint +get_tag_ui_combo (metadata_editor *args, + gchar *name, + gchar *mode); + +void +xml_parser_end_element (GMarkupParseContext *context, + const gchar *element_name, + gpointer user_data, + GError **error); + +gboolean +xml_parser_parse_file (GimpXmlParser *parser, + const gchar *filename, + GError **error); + +void +xml_parser_free (GimpXmlParser *parser); + +gboolean +parse_encoding (const gchar *text, + gint text_len, + gchar **encoding); + +gboolean +xml_parser_parse_io_channel (GimpXmlParser *parser, + GIOChannel *io, + GError **error); + +GimpXmlParser * +xml_parser_new (const GMarkupParser *markup_parser, + gpointer user_data); + +#endif /* __METADATA_XML_H__ */ + |