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.
This commit is contained in:
Ell
2020-04-07 13:13:20 +03:00
parent 2bd0b77ad0
commit 6c0326a4fa
4 changed files with 14 additions and 5 deletions

View File

@ -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);
}

View File

@ -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)

View File

@ -37,6 +37,8 @@ gboolean gimp_gegl_node_is_area_filter_operation (GeglNode *node
const gchar * gimp_gegl_node_get_key (GeglNode *node,
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);

View File

@ -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,