[gimp] app: add gimp_gegl_node_is_point_operation()



commit 918f2e75bda4e8c93ceb76a78fdbd81a21181759
Author: Ell <ell_se yahoo com>
Date:   Fri Feb 15 12:27:55 2019 -0500

    app: add gimp_gegl_node_is_point_operation()
    
    ... which takes a GeglNode, and determines if the associated
    operation is a point operation.
    
    Use in GimpFilterTool, instead of performing the same check
    manually.

 app/gegl/gimp-gegl-utils.c | 18 ++++++++++++++++++
 app/gegl/gimp-gegl-utils.h |  2 ++
 app/tools/gimpfiltertool.c | 33 +++++++++++++++------------------
 3 files changed, 35 insertions(+), 18 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-utils.c b/app/gegl/gimp-gegl-utils.c
index dc2ecfdd9b..9c4384d345 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -119,6 +119,24 @@ gimp_gegl_progress_connect (GeglNode     *node,
                           (GDestroyNotify) g_free);
 }
 
+gboolean
+gimp_gegl_node_is_point_operation (GeglNode *node)
+{
+  GeglOperation *operation;
+
+  g_return_val_if_fail (GEGL_IS_NODE (node), FALSE);
+
+  operation = gegl_node_get_gegl_operation (node);
+
+  if (! operation)
+    return FALSE;
+
+  return GEGL_IS_OPERATION_POINT_RENDER    (operation) ||
+         GEGL_IS_OPERATION_POINT_FILTER    (operation) ||
+         GEGL_IS_OPERATION_POINT_COMPOSER  (operation) ||
+         GEGL_IS_OPERATION_POINT_COMPOSER3 (operation);
+}
+
 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 918b71bdf2..4fbe46f274 100644
--- a/app/gegl/gimp-gegl-utils.h
+++ b/app/gegl/gimp-gegl-utils.h
@@ -32,6 +32,8 @@ void         gimp_gegl_progress_connect             (GeglNode            *node,
                                                      GimpProgress        *progress,
                                                      const gchar         *text);
 
+gboolean     gimp_gegl_node_is_point_operation      (GeglNode            *node);
+
 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 5706564e76..58cf0b3b94 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -303,14 +303,13 @@ gimp_filter_tool_initialize (GimpTool     *tool,
 
   if (! filter_tool->gui)
     {
-      GtkWidget     *vbox;
-      GtkWidget     *hbox;
-      GtkWidget     *toggle;
-      GtkWidget     *expander;
-      GtkWidget     *frame;
-      GtkWidget     *vbox2;
-      GeglOperation *operation;
-      const gchar   *operation_name = NULL;
+      GtkWidget *vbox;
+      GtkWidget *hbox;
+      GtkWidget *toggle;
+      GtkWidget *expander;
+      GtkWidget *frame;
+      GtkWidget *vbox2;
+      gchar     *operation_name;
 
       /*  disabled for at least GIMP 2.8  */
       filter_tool->overlay = FALSE;
@@ -408,10 +407,9 @@ gimp_filter_tool_initialize (GimpTool     *tool,
       gtk_widget_show (toggle);
 
       /*  The area combo  */
-      operation = gegl_node_get_gegl_operation (filter_tool->operation);
-
-      if (operation)
-        operation_name = gegl_operation_get_name (operation);
+      gegl_node_get (filter_tool->operation,
+                     "operation", &operation_name,
+                     NULL);
 
       filter_tool->region_combo =
         gimp_prop_enum_combo_box_new (G_OBJECT (tool_info->tool_options),
@@ -420,16 +418,15 @@ gimp_filter_tool_initialize (GimpTool     *tool,
       gtk_box_pack_end (GTK_BOX (vbox), filter_tool->region_combo,
                         FALSE, FALSE, 0);
 
-      if (! (GEGL_IS_OPERATION_POINT_RENDER    (operation)  ||
-             GEGL_IS_OPERATION_POINT_FILTER    (operation)  ||
-             GEGL_IS_OPERATION_POINT_COMPOSER  (operation)  ||
-             GEGL_IS_OPERATION_POINT_COMPOSER3 (operation)) ||
-            (operation_name &&
-             gegl_operation_get_key (operation_name, "position-dependent")))
+      if (! gimp_gegl_node_is_point_operation (filter_tool->operation) ||
+          (operation_name                                              &&
+           gegl_operation_get_key (operation_name, "position-dependent")))
         {
           gtk_widget_show (filter_tool->region_combo);
         }
 
+      g_free (operation_name);
+
       /*  Fill in subclass widgets  */
       gimp_filter_tool_dialog (filter_tool);
     }


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