[gimp/gimp-2-10] app: apply common operation settings when reapplying a filter



commit 1a41acecf22e345954b5df47a198a41f0898956c
Author: Ell <ell_se yahoo com>
Date:   Tue Apr 7 18:39:54 2020 +0300

    app: apply common operation settings when reapplying a filter
    
    Add a new gimp_drawable_apply_operation_with_config() function,
    which takes an operation node together with a config object, and
    applies the operation using the config options, including both the
    operation-specific options, and the common GimpOperationSettings
    options.
    
    Use the function in gimp_gegl_procedure_execute(), so that
    reapplying a filter takes the common operation settings used
    originally into account.

 app/actions/gimpgeglprocedure.c   | 10 +++++-----
 app/core/gimpdrawable-operation.c | 28 +++++++++++++++++++++++++---
 app/core/gimpdrawable-operation.h | 23 ++++++++++++++---------
 3 files changed, 44 insertions(+), 17 deletions(-)
---
diff --git a/app/actions/gimpgeglprocedure.c b/app/actions/gimpgeglprocedure.c
index b3aea00bc7..b9f243fe6a 100644
--- a/app/actions/gimpgeglprocedure.c
+++ b/app/actions/gimpgeglprocedure.c
@@ -248,12 +248,12 @@ gimp_gegl_procedure_execute (GimpProcedure   *procedure,
   node = gegl_node_new_child (NULL,
                               "operation", procedure->original_name,
                               NULL);
-  if (config)
-    gimp_operation_config_sync_node (config, node);
 
-  gimp_drawable_apply_operation (drawable, progress,
-                                 gimp_procedure_get_label (procedure),
-                                 node);
+  gimp_drawable_apply_operation_with_config (
+    drawable,
+    progress, gimp_procedure_get_label (procedure),
+    node, config);
+
   g_object_unref (node);
 
   gimp_image_flush (image);
diff --git a/app/core/gimpdrawable-operation.c b/app/core/gimpdrawable-operation.c
index 2634e57862..fdda28698f 100644
--- a/app/core/gimpdrawable-operation.c
+++ b/app/core/gimpdrawable-operation.c
@@ -29,6 +29,9 @@
 
 #include "gegl/gimp-gegl-utils.h"
 
+#include "operations/gimp-operation-config.h"
+#include "operations/gimpoperationsettings.h"
+
 #include "gimpdrawable.h"
 #include "gimpdrawable-operation.h"
 #include "gimpdrawablefilter.h"
@@ -43,6 +46,18 @@ gimp_drawable_apply_operation (GimpDrawable *drawable,
                                GimpProgress *progress,
                                const gchar  *undo_desc,
                                GeglNode     *operation)
+{
+  gimp_drawable_apply_operation_with_config (drawable,
+                                             progress, undo_desc,
+                                             operation, NULL);
+}
+
+void
+gimp_drawable_apply_operation_with_config (GimpDrawable *drawable,
+                                           GimpProgress *progress,
+                                           const gchar  *undo_desc,
+                                           GeglNode     *operation,
+                                           GObject      *config)
 {
   GimpDrawableFilter *filter;
 
@@ -51,6 +66,7 @@ gimp_drawable_apply_operation (GimpDrawable *drawable,
   g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
   g_return_if_fail (undo_desc != NULL);
   g_return_if_fail (GEGL_IS_NODE (operation));
+  g_return_if_fail (config == NULL || GIMP_IS_OPERATION_SETTINGS (config));
 
   if (! gimp_item_mask_intersect (GIMP_ITEM (drawable),
                                   NULL, NULL, NULL, NULL))
@@ -60,10 +76,16 @@ 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_has_key (operation, "needs-alpha"))
+  gimp_drawable_filter_set_add_alpha (filter,
+                                      gimp_gegl_node_has_key (operation,
+                                                              "needs-alpha"));
+
+  if (config)
     {
-      gimp_drawable_filter_set_add_alpha (filter, TRUE);
+      gimp_operation_config_sync_node (config, operation);
+
+      gimp_operation_settings_sync_drawable_filter (
+        GIMP_OPERATION_SETTINGS (config), filter);
     }
 
   gimp_drawable_filter_apply  (filter, NULL);
diff --git a/app/core/gimpdrawable-operation.h b/app/core/gimpdrawable-operation.h
index 944c3877e3..6ca381f250 100644
--- a/app/core/gimpdrawable-operation.h
+++ b/app/core/gimpdrawable-operation.h
@@ -24,15 +24,20 @@
 #define __GIMP_DRAWABLE_OPERATION_H__
 
 
-void   gimp_drawable_apply_operation         (GimpDrawable *drawable,
-                                              GimpProgress *progress,
-                                              const gchar  *undo_desc,
-                                              GeglNode     *operation);
-void   gimp_drawable_apply_operation_by_name (GimpDrawable *drawable,
-                                              GimpProgress *progress,
-                                              const gchar  *undo_desc,
-                                              const gchar  *operation_type,
-                                              GObject      *config);
+void   gimp_drawable_apply_operation             (GimpDrawable *drawable,
+                                                  GimpProgress *progress,
+                                                  const gchar  *undo_desc,
+                                                  GeglNode     *operation);
+void   gimp_drawable_apply_operation_with_config (GimpDrawable *drawable,
+                                                  GimpProgress *progress,
+                                                  const gchar  *undo_desc,
+                                                  GeglNode     *operation,
+                                                  GObject      *config);
+void   gimp_drawable_apply_operation_by_name     (GimpDrawable *drawable,
+                                                  GimpProgress *progress,
+                                                  const gchar  *undo_desc,
+                                                  const gchar  *operation_type,
+                                                  GObject      *config);
 
 
 #endif /* __GIMP_DRAWABLE_OPERATION_H__ */


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