[gimp/gimp-2-10] app: add gimp_gegl_node_{set, get}_underlying_oepration()



commit 5e212fe0dd46c01e14e30dd9a1f8e7f7fbeb7bc3
Author: Ell <ell_se yahoo com>
Date:   Wed Mar 27 14:58:30 2019 -0400

    app: add gimp_gegl_node_{set,get}_underlying_oepration()
    
    ... which allow setting/getting the "underlying operation" node of
    a graph node.  For example, GimpDrawableFilter constructs a complex
    graph around a given operation node, which would be the underlying
    operation of the graph.  This allows querying the properties of the
    underlying operation, given only the graph.
    
    In recursive cases, gimp_gegl_node_get_underlying_operation()
    returns the most-nested underlying operation; when no underlying
    operation has been set, gimp_gegl_node_get_underlying_operation()
    returns the input node.
    
    (cherry picked from commit eb5e473665679bff527e279585e6b8181e1bdf56)

 app/gegl/gimp-gegl-utils.c | 27 +++++++++++++++++++++++++++
 app/gegl/gimp-gegl-utils.h | 36 ++++++++++++++++++++----------------
 2 files changed, 47 insertions(+), 16 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-utils.c b/app/gegl/gimp-gegl-utils.c
index 91cc294645..dc9171bbae 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -174,6 +174,33 @@ gimp_gegl_node_get_format (GeglNode    *node,
   return format;
 }
 
+void
+gimp_gegl_node_set_underlying_operation (GeglNode *node,
+                                         GeglNode *operation)
+{
+  g_return_if_fail (GEGL_IS_NODE (node));
+  g_return_if_fail (operation == NULL || GEGL_IS_NODE (operation));
+
+  g_object_set_data (G_OBJECT (node),
+                     "gimp-gegl-node-underlying-operation", operation);
+}
+
+GeglNode *
+gimp_gegl_node_get_underlying_operation (GeglNode *node)
+{
+  GeglNode *operation;
+
+  g_return_val_if_fail (GEGL_IS_NODE (node), NULL);
+
+  operation = g_object_get_data (G_OBJECT (node),
+                                 "gimp-gegl-node-underlying-operation");
+
+  if (operation)
+    return gimp_gegl_node_get_underlying_operation (operation);
+  else
+    return node;
+}
+
 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 ec42a33b02..1a7d51a69e 100644
--- a/app/gegl/gimp-gegl-utils.h
+++ b/app/gegl/gimp-gegl-utils.h
@@ -22,28 +22,32 @@
 #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_node_is_source_operation     (GeglNode            *node);
-gboolean     gimp_gegl_node_is_point_operation      (GeglNode            *node);
+gboolean     gimp_gegl_node_is_source_operation      (GeglNode            *node);
+gboolean     gimp_gegl_node_is_point_operation       (GeglNode            *node);
 
-const Babl * gimp_gegl_node_get_format              (GeglNode            *node,
-                                                     const gchar         *pad_name);
+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);
+void         gimp_gegl_node_set_underlying_operation (GeglNode           *node,
+                                                      GeglNode           *operation);
+GeglNode   * gimp_gegl_node_get_underlying_operation (GeglNode           *node);
 
-void         gimp_gegl_rectangle_align_to_tile_grid (GeglRectangle       *dest,
-                                                     const GeglRectangle *src,
-                                                     GeglBuffer          *buffer);
+gboolean     gimp_gegl_param_spec_has_key            (GParamSpec          *pspec,
+                                                      const gchar         *key,
+                                                      const gchar         *value);
+
+void         gimp_gegl_rectangle_align_to_tile_grid  (GeglRectangle       *dest,
+                                                      const GeglRectangle *src,
+                                                      GeglBuffer          *buffer);
 
 
 #endif /* __GIMP_GEGL_UTILS_H__ */


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