[gegl] operations: add metadata property to gegl:load and gegl:save
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] operations: add metadata property to gegl:load and gegl:save
- Date: Fri, 8 May 2020 11:46:47 +0000 (UTC)
commit 385f1ab0ec19dceb5c0e438721cd2e3ae2f8a977
Author: Øyvind Kolås <pippin gimp org>
Date: Fri May 8 13:43:51 2020 +0200
operations: add metadata property to gegl:load and gegl:save
This exposes a GeglMetaDataStore property on these wrapper ops, iff the
load handler or saver supports meta data it also gets set on the format
specific handler.
operations/common/save.c | 8 ++++++++
operations/core/load.c | 12 +++++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/operations/common/save.c b/operations/common/save.c
index 4780c8fa9..da9653a1d 100644
--- a/operations/common/save.c
+++ b/operations/common/save.c
@@ -18,12 +18,15 @@
#include "config.h"
#include <glib/gi18n-lib.h>
+#include <gegl-metadata.h>
#ifdef GEGL_PROPERTIES
property_file_path (path, _("File"), "")
description(_("Path of file to save."))
+property_object (metadata, _("Metadata"), GEGL_TYPE_METADATA)
+ description (_("Object providing image metadata"))
#else
@@ -82,6 +85,11 @@ gegl_save_set_saver (GeglOperation *operation)
"operation", handler,
"path", o->path,
NULL);
+
+ if (o->metadata &&
+ gegl_operation_find_property (handler, "metadata") != NULL)
+ gegl_node_set (self->save, "metadata", o->metadata, NULL);
+
}
else
{
diff --git a/operations/core/load.c b/operations/core/load.c
index 47d02ba7b..095e05c53 100644
--- a/operations/core/load.c
+++ b/operations/core/load.c
@@ -18,6 +18,7 @@
#include "config.h"
#include <glib/gi18n-lib.h>
+#include <gegl-metadata.h>
#ifdef G_OS_WIN32
#define realpath(a,b) _fullpath(b,a,_MAX_PATH)
@@ -29,6 +30,8 @@ property_file_path (path, _("File"), "")
description (_("Path of file to load."))
property_uri (uri, _("URI"), "")
description (_("URI of file to load."))
+property_object (metadata, _("Metadata"), GEGL_TYPE_METADATA)
+ description (_("Object to supply image metadata"))
#else
@@ -79,6 +82,7 @@ static void
do_setup (GeglOperation *operation, const gchar *path, const gchar *uri)
{
GeglOp *self = GEGL_OP (operation);
+ GeglProperties *o = GEGL_PROPERTIES (operation);
const gchar *handler = NULL;
gchar *content_type = NULL, *filename = NULL, *message;
gboolean load_from_uri, uncertain;
@@ -256,6 +260,11 @@ do_setup (GeglOperation *operation, const gchar *path, const gchar *uri)
}
gegl_node_set (self->load, "operation", handler, NULL);
+
+ if (o->metadata &&
+ gegl_operation_find_property (handler, "metadata") != NULL)
+ gegl_node_set (self->load, "metadata", o->metadata, NULL);
+
if (load_from_uri == TRUE)
gegl_node_set (self->load, "uri", uri, NULL);
else
@@ -332,6 +341,7 @@ my_set_property (GObject *gobject,
gchar *old_path = g_strdup (o->path);
gchar *old_uri = g_strdup (o->uri);
+ void *old_metadata = o->metadata;
gboolean props_changed;
@@ -339,7 +349,7 @@ my_set_property (GObject *gobject,
* storing and reffing/unreffing of the input properties
*/
set_property (gobject, property_id, value, pspec);
- props_changed = g_strcmp0 (o->path, old_path) || g_strcmp0 (o->uri, old_uri);
+ props_changed = g_strcmp0 (o->path, old_path) || g_strcmp0 (o->uri, old_uri) || (old_metadata !=
o->metadata);
if (self->load && props_changed)
do_setup (operation, o->path, o->uri);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]