[gimp/gimp-2-10] app: add gimp_gegl_node_has_key()



commit 6c0326a4fa8528ab850b54089d0cdb6a8a0553df
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 0d38cf0f71..efc3a1e59e 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -183,6 +183,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 4f50fdcdd5..cee725f7b7 100644
--- a/app/gegl/gimp-gegl-utils.h
+++ b/app/gegl/gimp-gegl-utils.h
@@ -36,7 +36,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 77be9943eb..e7accd44b0 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -1148,7 +1148,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"));
         }
     }
@@ -1403,7 +1403,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);
@@ -1575,7 +1575,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]