[gimp] app: add gimp_gegl_node_has_key()



commit 8c619bf0b29ea20ed8bee959f18074d789ac87ca
Author: Ell <ell_se yahoo com>
Date:   Tue Apr 7 13:13:20 2020 +0300

    app: add gimp_gegl_node_has_key()
    
    ... which determines if a node's operation-class has a specific
    key, and can be used instead of gimp_gegl_node_get_key() when only
    existence is important, to avoid compiler warnings.
    
    Update the rest of the code to use the new function.

 app/core/gimpdrawable-operation.c | 2 +-
 app/gegl/gimp-gegl-utils.c        | 7 +++++++
 app/gegl/gimp-gegl-utils.h        | 4 +++-
 app/tools/gimpfiltertool.c        | 6 +++---
 4 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/app/core/gimpdrawable-operation.c b/app/core/gimpdrawable-operation.c
index 3e64ab4d89..2634e57862 100644
--- a/app/core/gimpdrawable-operation.c
+++ b/app/core/gimpdrawable-operation.c
@@ -61,7 +61,7 @@ gimp_drawable_apply_operation (GimpDrawable *drawable,
   filter = gimp_drawable_filter_new (drawable, undo_desc, operation, NULL);
 
   if (gimp_drawable_supports_alpha (drawable) &&
-      gimp_gegl_node_get_key (operation, "needs-alpha"))
+      gimp_gegl_node_has_key (operation, "needs-alpha"))
     {
       gimp_drawable_filter_set_add_alpha (filter, TRUE);
     }
diff --git a/app/gegl/gimp-gegl-utils.c b/app/gegl/gimp-gegl-utils.c
index 6bfed25ee8..fd23496bda 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -186,6 +186,13 @@ gimp_gegl_node_get_key (GeglNode    *node,
     return NULL;
 }
 
+gboolean
+gimp_gegl_node_has_key (GeglNode    *node,
+                        const gchar *key)
+{
+  return gimp_gegl_node_get_key (node, key) != NULL;
+}
+
 const Babl *
 gimp_gegl_node_get_format (GeglNode    *node,
                            const gchar *pad_name)
diff --git a/app/gegl/gimp-gegl-utils.h b/app/gegl/gimp-gegl-utils.h
index 5d19c0184f..c057fb0576 100644
--- a/app/gegl/gimp-gegl-utils.h
+++ b/app/gegl/gimp-gegl-utils.h
@@ -37,7 +37,9 @@ gboolean      gimp_gegl_node_is_point_operation       (GeglNode            *node
 gboolean      gimp_gegl_node_is_area_filter_operation (GeglNode            *node);
 
 const gchar * gimp_gegl_node_get_key                  (GeglNode            *node,
-                                                      const gchar          *key);
+                                                       const gchar         *key);
+gboolean      gimp_gegl_node_has_key                  (GeglNode            *node,
+                                                       const gchar         *key);
 
 const Babl  * gimp_gegl_node_get_format               (GeglNode            *node,
                                                        const gchar         *pad_name);
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index 059911d0c3..bf785fc156 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -1136,7 +1136,7 @@ gimp_filter_tool_update_dialog (GimpFilterTool *filter_tool)
           gtk_widget_set_visible (
             filter_tool->region_combo,
             ! gimp_gegl_node_is_point_operation (filter_tool->operation) ||
-            gimp_gegl_node_get_key (filter_tool->operation,
+            gimp_gegl_node_has_key (filter_tool->operation,
                                     "position-dependent"));
         }
     }
@@ -1391,7 +1391,7 @@ gimp_filter_tool_update_filter (GimpFilterTool *filter_tool)
     return;
 
   add_alpha = gimp_drawable_supports_alpha (tool->drawable) &&
-              gimp_gegl_node_get_key (filter_tool->operation, "needs-alpha");
+              gimp_gegl_node_has_key (filter_tool->operation, "needs-alpha");
   clip      = options->clip == GIMP_TRANSFORM_RESIZE_CLIP ||
               ! (gimp_drawable_has_alpha (tool->drawable) ||
                  add_alpha);
@@ -1561,7 +1561,7 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
     }
 
   if (gimp_gegl_node_is_point_operation (filter_tool->operation) &&
-      ! gimp_gegl_node_get_key (filter_tool->operation, "position-dependent"))
+      ! gimp_gegl_node_has_key (filter_tool->operation, "position-dependent"))
     {
       g_object_set (GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool),
                     "region", GIMP_FILTER_REGION_SELECTION,


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