[gimp] app: add gimp_gegl_node_get_format()



commit 23c3cf72493c854bea224aa2c16fd2b5819b8821
Author: Michael Natterer <mitch gimp org>
Date:   Wed Jun 8 00:04:50 2016 +0200

    app: add gimp_gegl_node_get_format()
    
    which is a wrapper around gegl_operation_get_format().

 app/gegl/gimp-gegl-utils.c |   26 ++++++++++++++++++++++++++
 app/gegl/gimp-gegl-utils.h |   21 ++++++++++++---------
 2 files changed, 38 insertions(+), 9 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-utils.c b/app/gegl/gimp-gegl-utils.c
index f5de065..5257f76 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -23,6 +23,7 @@
 #include <string.h>
 
 #include <gegl.h>
+#include <gegl-plugin.h>
 
 #include "gimp-gegl-types.h"
 
@@ -113,6 +114,31 @@ gimp_gegl_progress_connect (GeglNode     *node,
                           (GDestroyNotify) g_free);
 }
 
+const Babl *
+gimp_gegl_node_get_format (GeglNode    *node,
+                           const gchar *pad_name)
+{
+  GeglOperation *op;
+  const Babl    *format = NULL;
+
+  g_return_val_if_fail (GEGL_IS_NODE (node), NULL);
+  g_return_val_if_fail (pad_name != NULL, NULL);
+
+  g_object_get (node, "gegl-operation", &op, NULL);
+
+  if (op)
+    {
+      format = gegl_operation_get_format (op, pad_name);
+
+      g_object_unref (op);
+    }
+
+  if (! format)
+    format = babl_format ("RGBA float");
+
+  return format;
+}
+
 gboolean
 gimp_gegl_param_spec_has_key (GParamSpec  *pspec,
                               const gchar *key,
diff --git a/app/gegl/gimp-gegl-utils.h b/app/gegl/gimp-gegl-utils.h
index 74c8981..68d434d 100644
--- a/app/gegl/gimp-gegl-utils.h
+++ b/app/gegl/gimp-gegl-utils.h
@@ -22,18 +22,21 @@
 #define __GIMP_GEGL_UTILS_H__
 
 
-GType         gimp_gegl_get_op_enum_type        (const gchar           *operation,
-                                                 const gchar           *property);
+GType        gimp_gegl_get_op_enum_type   (const gchar   *operation,
+                                           const gchar   *property);
 
-GeglColor   * gimp_gegl_color_new               (const GimpRGB         *rgb);
+GeglColor  * gimp_gegl_color_new          (const GimpRGB *rgb);
 
-void          gimp_gegl_progress_connect        (GeglNode              *node,
-                                                 GimpProgress          *progress,
-                                                 const gchar           *text);
+void         gimp_gegl_progress_connect   (GeglNode      *node,
+                                           GimpProgress  *progress,
+                                           const gchar   *text);
 
-gboolean      gimp_gegl_param_spec_has_key      (GParamSpec            *pspec,
-                                                 const gchar           *key,
-                                                 const gchar           *value);
+const Babl * gimp_gegl_node_get_format    (GeglNode      *node,
+                                           const gchar   *pad_name);
+
+gboolean     gimp_gegl_param_spec_has_key (GParamSpec    *pspec,
+                                           const gchar   *key,
+                                           const gchar   *value);
 
 
 #endif /* __GIMP_GEGL_UTILS_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]