[gimp/gimp-2-10] app: add GimpOperationSettings



commit 9e5fabf8a0a9c1942d2358f350636ffe324cfd9f
Author: Ell <ell_se yahoo com>
Date:   Tue Apr 7 01:37:19 2020 +0300

    app: add GimpOperationSettings
    
    Add a new GimpOperationSettings class, to be used as a base class
    for all operation-config types.  The class provides options common
    to all operations (namely, the clipping mode, input region, and
    color options), which were previously stored in GimpFilterOptions,
    and were therefore bound to the filter tool, instead of being
    stored as part of the operation settings; as a result, these
    options would have no effect when reapplying a filter, or when
    restoring a preset.
    
    The GimpOperationSettings options do not affect the operation
    node, but rather the associated GimpDrawableFilter object.  The
    class provides a gimp_operation_settings_sync_drawable_filter()
    function, which applies the options to the filter.
    
    Modify all custom and auto-generated operation-config types to
    derive from GimpOperationSettings, and modify the GimpConfig
    functions of the former to account for the GimpOperationSettings
    properties, using a set of protected functions provided by the
    class.

 app/actions/filters-commands.c                |   4 +-
 app/actions/gimpgeglprocedure.c               |   3 +-
 app/operations/Makefile.am                    |   2 +
 app/operations/gimp-operation-config.c        |   3 +-
 app/operations/gimpbrightnesscontrastconfig.c |   5 +-
 app/operations/gimpbrightnesscontrastconfig.h |  10 +-
 app/operations/gimpcageconfig.c               |   2 +-
 app/operations/gimpcageconfig.h               |  14 +-
 app/operations/gimpcolorbalanceconfig.c       |  12 +-
 app/operations/gimpcolorbalanceconfig.h       |  16 +-
 app/operations/gimpcurvesconfig.c             |  18 +-
 app/operations/gimpcurvesconfig.h             |  12 +-
 app/operations/gimphuesaturationconfig.c      |  12 +-
 app/operations/gimphuesaturationconfig.h      |  16 +-
 app/operations/gimplevelsconfig.c             |  18 +-
 app/operations/gimplevelsconfig.h             |  24 +--
 app/operations/gimpoperationsettings.c        | 275 ++++++++++++++++++++++++++
 app/operations/gimpoperationsettings.h        |  73 +++++++
 app/operations/operations-types.h             |   2 +
 app/tools/gimpfiltertool.c                    |   3 +-
 po/POTFILES.in                                |   1 +
 21 files changed, 455 insertions(+), 70 deletions(-)
---
diff --git a/app/actions/filters-commands.c b/app/actions/filters-commands.c
index d496bde8e8..6ca05292d5 100644
--- a/app/actions/filters-commands.c
+++ b/app/actions/filters-commands.c
@@ -29,12 +29,12 @@
 #include "actions-types.h"
 
 #include "operations/gimp-operation-config.h"
+#include "operations/gimpoperationsettings.h"
 
 #include "core/gimp.h"
 #include "core/gimp-filter-history.h"
 #include "core/gimpimage.h"
 #include "core/gimpprogress.h"
-#include "core/gimpsettings.h"
 
 #include "widgets/gimpaction.h"
 
@@ -193,7 +193,7 @@ filters_parse_operation (Gimp         *gimp,
           *settings =
             g_object_new (gimp_operation_config_get_type (gimp, operation,
                                                           icon_name,
-                                                          GIMP_TYPE_SETTINGS),
+                                                          GIMP_TYPE_OPERATION_SETTINGS),
                           NULL);
 
           if (! gimp_config_deserialize_string (GIMP_CONFIG (*settings),
diff --git a/app/actions/gimpgeglprocedure.c b/app/actions/gimpgeglprocedure.c
index 2e4c5e438c..b3aea00bc7 100644
--- a/app/actions/gimpgeglprocedure.c
+++ b/app/actions/gimpgeglprocedure.c
@@ -33,6 +33,7 @@
 #include "config/gimpguiconfig.h"
 
 #include "operations/gimp-operation-config.h"
+#include "operations/gimpoperationsettings.h"
 
 #include "core/gimp.h"
 #include "core/gimp-memsize.h"
@@ -424,7 +425,7 @@ gimp_gegl_procedure_new (Gimp        *gimp,
   g_return_val_if_fail (menu_label != NULL, NULL);
 
   config_type = gimp_operation_config_get_type (gimp, operation, icon_name,
-                                                GIMP_TYPE_SETTINGS);
+                                                GIMP_TYPE_OPERATION_SETTINGS);
 
   procedure = g_object_new (GIMP_TYPE_GEGL_PROCEDURE, NULL);
 
diff --git a/app/operations/Makefile.am b/app/operations/Makefile.am
index dad1ec9ebd..24bfe6d9eb 100644
--- a/app/operations/Makefile.am
+++ b/app/operations/Makefile.am
@@ -27,6 +27,8 @@ libappoperations_a_sources = \
        \
        gimp-operation-config.c                 \
        gimp-operation-config.h                 \
+       gimpoperationsettings.c                 \
+       gimpoperationsettings.h                 \
        gimpbrightnesscontrastconfig.c          \
        gimpbrightnesscontrastconfig.h          \
        gimpcageconfig.c                        \
diff --git a/app/operations/gimp-operation-config.c b/app/operations/gimp-operation-config.c
index 88ff32e90e..13cbcf503f 100644
--- a/app/operations/gimp-operation-config.c
+++ b/app/operations/gimp-operation-config.c
@@ -38,6 +38,7 @@
 #include "gegl/gimp-gegl-utils.h"
 
 #include "gimp-operation-config.h"
+#include "gimpoperationsettings.h"
 
 
 /*  local function prototypes  */
@@ -216,7 +217,7 @@ gimp_operation_config_equal (GimpConfig *a,
         {
           GParamSpec *pspec = list->data;
 
-          if (pspec->owner_type == G_TYPE_FROM_INSTANCE (a))
+          if (g_type_is_a (pspec->owner_type, GIMP_TYPE_OPERATION_SETTINGS))
             {
               equal = FALSE;
               break;
diff --git a/app/operations/gimpbrightnesscontrastconfig.c b/app/operations/gimpbrightnesscontrastconfig.c
index b3ba2c8ea9..1564614587 100644
--- a/app/operations/gimpbrightnesscontrastconfig.c
+++ b/app/operations/gimpbrightnesscontrastconfig.c
@@ -59,7 +59,7 @@ static gboolean gimp_brightness_contrast_config_equal        (GimpConfig   *a,
 
 G_DEFINE_TYPE_WITH_CODE (GimpBrightnessContrastConfig,
                          gimp_brightness_contrast_config,
-                         GIMP_TYPE_SETTINGS,
+                         GIMP_TYPE_OPERATION_SETTINGS,
                          G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
                                                 gimp_brightness_contrast_config_iface_init))
 
@@ -156,7 +156,8 @@ gimp_brightness_contrast_config_equal (GimpConfig *a,
   GimpBrightnessContrastConfig *config_a = GIMP_BRIGHTNESS_CONTRAST_CONFIG (a);
   GimpBrightnessContrastConfig *config_b = GIMP_BRIGHTNESS_CONTRAST_CONFIG (b);
 
-  if (config_a->brightness != config_b->brightness ||
+  if (! gimp_operation_settings_config_equal_base (a, b) ||
+      config_a->brightness != config_b->brightness       ||
       config_a->contrast   != config_b->contrast)
     {
       return FALSE;
diff --git a/app/operations/gimpbrightnesscontrastconfig.h b/app/operations/gimpbrightnesscontrastconfig.h
index d9c0881cc9..bab1a03113 100644
--- a/app/operations/gimpbrightnesscontrastconfig.h
+++ b/app/operations/gimpbrightnesscontrastconfig.h
@@ -22,7 +22,7 @@
 #define __GIMP_BRIGHTNESS_CONTRAST_CONFIG_H__
 
 
-#include "core/gimpsettings.h"
+#include "gimpoperationsettings.h"
 
 
 #define GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG            (gimp_brightness_contrast_config_get_type ())
@@ -37,15 +37,15 @@ typedef struct _GimpBrightnessContrastConfigClass GimpBrightnessContrastConfigCl
 
 struct _GimpBrightnessContrastConfig
 {
-  GimpSettings  parent_instance;
+  GimpOperationSettings  parent_instance;
 
-  gdouble       brightness;
-  gdouble       contrast;
+  gdouble                brightness;
+  gdouble                contrast;
 };
 
 struct _GimpBrightnessContrastConfigClass
 {
-  GimpSettingsClass  parent_class;
+  GimpOperationSettingsClass  parent_class;
 };
 
 
diff --git a/app/operations/gimpcageconfig.c b/app/operations/gimpcageconfig.c
index 9f5f45b53d..17548cf4f0 100644
--- a/app/operations/gimpcageconfig.c
+++ b/app/operations/gimpcageconfig.c
@@ -54,7 +54,7 @@ static void   gimp_cage_config_compute_edges_normal   (GimpCageConfig *gcc);
 
 
 G_DEFINE_TYPE_WITH_CODE (GimpCageConfig, gimp_cage_config,
-                         GIMP_TYPE_SETTINGS,
+                         GIMP_TYPE_OPERATION_SETTINGS,
                          G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
                                                 NULL))
 
diff --git a/app/operations/gimpcageconfig.h b/app/operations/gimpcageconfig.h
index 767d90b928..8106d5256a 100644
--- a/app/operations/gimpcageconfig.h
+++ b/app/operations/gimpcageconfig.h
@@ -21,7 +21,7 @@
 #define __GIMP_CAGE_CONFIG_H__
 
 
-#include "core/gimpsettings.h"
+#include "gimpoperationsettings.h"
 
 
 struct _GimpCagePoint
@@ -46,18 +46,18 @@ typedef struct _GimpCageConfigClass GimpCageConfigClass;
 
 struct _GimpCageConfig
 {
-  GimpSettings  parent_instance;
+  GimpOperationSettings  parent_instance;
 
-  GArray       *cage_points;
+  GArray                *cage_points;
 
-  gdouble       displacement_x;
-  gdouble       displacement_y;
-  GimpCageMode  cage_mode;  /* Cage mode, used to commit displacement */
+  gdouble                displacement_x;
+  gdouble                displacement_y;
+  GimpCageMode           cage_mode;  /* Cage mode, used to commit displacement */
 };
 
 struct _GimpCageConfigClass
 {
-  GimpSettingsClass  parent_class;
+  GimpOperationSettingsClass  parent_class;
 };
 
 
diff --git a/app/operations/gimpcolorbalanceconfig.c b/app/operations/gimpcolorbalanceconfig.c
index cd4d10e319..7011a86646 100644
--- a/app/operations/gimpcolorbalanceconfig.c
+++ b/app/operations/gimpcolorbalanceconfig.c
@@ -73,7 +73,7 @@ static gboolean gimp_color_balance_config_copy         (GimpConfig       *src,
 
 
 G_DEFINE_TYPE_WITH_CODE (GimpColorBalanceConfig, gimp_color_balance_config,
-                         GIMP_TYPE_SETTINGS,
+                         GIMP_TYPE_OPERATION_SETTINGS,
                          G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
                                                 gimp_color_balance_config_iface_init))
 
@@ -224,7 +224,7 @@ gimp_color_balance_config_serialize (GimpConfig       *config,
   GimpTransferMode        old_range;
   gboolean                success = TRUE;
 
-  if (! gimp_config_serialize_property_by_name (config, "time", writer))
+  if (! gimp_operation_settings_config_serialize_base (config, writer, data))
     return FALSE;
 
   old_range = bc_config->range;
@@ -289,6 +289,9 @@ gimp_color_balance_config_equal (GimpConfig *a,
   GimpColorBalanceConfig *config_b = GIMP_COLOR_BALANCE_CONFIG (b);
   GimpTransferMode        range;
 
+  if (! gimp_operation_settings_config_equal_base (a, b))
+    return FALSE;
+
   for (range = GIMP_TRANSFER_SHADOWS;
        range <= GIMP_TRANSFER_HIGHLIGHTS;
        range++)
@@ -313,6 +316,8 @@ gimp_color_balance_config_reset (GimpConfig *config)
   GimpColorBalanceConfig *cb_config = GIMP_COLOR_BALANCE_CONFIG (config);
   GimpTransferMode        range;
 
+  gimp_operation_settings_config_reset_base (config);
+
   for (range = GIMP_TRANSFER_SHADOWS;
        range <= GIMP_TRANSFER_HIGHLIGHTS;
        range++)
@@ -334,6 +339,9 @@ gimp_color_balance_config_copy (GimpConfig  *src,
   GimpColorBalanceConfig *dest_config = GIMP_COLOR_BALANCE_CONFIG (dest);
   GimpTransferMode        range;
 
+  if (! gimp_operation_settings_config_copy_base (src, dest, flags))
+    return FALSE;
+
   for (range = GIMP_TRANSFER_SHADOWS;
        range <= GIMP_TRANSFER_HIGHLIGHTS;
        range++)
diff --git a/app/operations/gimpcolorbalanceconfig.h b/app/operations/gimpcolorbalanceconfig.h
index 8da4ce7483..4c58ceab4d 100644
--- a/app/operations/gimpcolorbalanceconfig.h
+++ b/app/operations/gimpcolorbalanceconfig.h
@@ -22,7 +22,7 @@
 #define __GIMP_COLOR_BALANCE_CONFIG_H__
 
 
-#include "core/gimpsettings.h"
+#include "gimpoperationsettings.h"
 
 
 #define GIMP_TYPE_COLOR_BALANCE_CONFIG            (gimp_color_balance_config_get_type ())
@@ -37,20 +37,20 @@ typedef struct _GimpColorBalanceConfigClass GimpColorBalanceConfigClass;
 
 struct _GimpColorBalanceConfig
 {
-  GimpSettings      parent_instance;
+  GimpOperationSettings  parent_instance;
 
-  GimpTransferMode  range;
+  GimpTransferMode       range;
 
-  gdouble           cyan_red[3];
-  gdouble           magenta_green[3];
-  gdouble           yellow_blue[3];
+  gdouble                cyan_red[3];
+  gdouble                magenta_green[3];
+  gdouble                yellow_blue[3];
 
-  gboolean          preserve_luminosity;
+  gboolean               preserve_luminosity;
 };
 
 struct _GimpColorBalanceConfigClass
 {
-  GimpSettingsClass  parent_class;
+  GimpOperationSettingsClass  parent_class;
 };
 
 
diff --git a/app/operations/gimpcurvesconfig.c b/app/operations/gimpcurvesconfig.c
index 42426bcab9..b63bcf30e8 100644
--- a/app/operations/gimpcurvesconfig.c
+++ b/app/operations/gimpcurvesconfig.c
@@ -80,7 +80,7 @@ static void     gimp_curves_config_curve_dirty  (GimpCurve        *curve,
 
 
 G_DEFINE_TYPE_WITH_CODE (GimpCurvesConfig, gimp_curves_config,
-                         GIMP_TYPE_SETTINGS,
+                         GIMP_TYPE_OPERATION_SETTINGS,
                          G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
                                                 gimp_curves_config_iface_init))
 
@@ -242,7 +242,7 @@ gimp_curves_config_serialize (GimpConfig       *config,
   GimpHistogramChannel  old_channel;
   gboolean              success = TRUE;
 
-  if (! gimp_config_serialize_property_by_name (config, "time",   writer) ||
+  if (! gimp_operation_settings_config_serialize_base (config, writer, data) ||
       ! gimp_config_serialize_property_by_name (config, "linear", writer))
     return FALSE;
 
@@ -254,10 +254,10 @@ gimp_curves_config_serialize (GimpConfig       *config,
     {
       c_config->channel = channel;
 
-      /*  Serialize the channel properties manually (not using
+      /*  serialize the channel properties manually (not using
        *  gimp_config_serialize_properties()), so the parent class'
-       *  "time" property doesn't end up in the config file once per
-       *  channel. See bug #700653.
+       *  properties don't end up in the config file one per channel.
+       *  See bug #700653.
        */
       success =
         (gimp_config_serialize_property_by_name (config, "channel", writer) &&
@@ -299,7 +299,8 @@ gimp_curves_config_equal (GimpConfig *a,
   GimpCurvesConfig     *config_b = GIMP_CURVES_CONFIG (b);
   GimpHistogramChannel  channel;
 
-  if (config_a->linear != config_b->linear)
+  if (! gimp_operation_settings_config_equal_base (a, b) ||
+      config_a->linear != config_b->linear)
     return FALSE;
 
   for (channel = GIMP_HISTOGRAM_VALUE;
@@ -332,6 +333,8 @@ gimp_curves_config_reset (GimpConfig *config)
   GimpCurvesConfig     *c_config = GIMP_CURVES_CONFIG (config);
   GimpHistogramChannel  channel;
 
+  gimp_operation_settings_config_reset_base (config);
+
   for (channel = GIMP_HISTOGRAM_VALUE;
        channel <= GIMP_HISTOGRAM_ALPHA;
        channel++)
@@ -353,6 +356,9 @@ gimp_curves_config_copy (GimpConfig  *src,
   GimpCurvesConfig     *dest_config = GIMP_CURVES_CONFIG (dest);
   GimpHistogramChannel  channel;
 
+  if (! gimp_operation_settings_config_copy_base (src, dest, flags))
+    return FALSE;
+
   for (channel = GIMP_HISTOGRAM_VALUE;
        channel <= GIMP_HISTOGRAM_ALPHA;
        channel++)
diff --git a/app/operations/gimpcurvesconfig.h b/app/operations/gimpcurvesconfig.h
index 3c8b7ae5fd..c6241fe7b3 100644
--- a/app/operations/gimpcurvesconfig.h
+++ b/app/operations/gimpcurvesconfig.h
@@ -22,7 +22,7 @@
 #define __GIMP_CURVES_CONFIG_H__
 
 
-#include "core/gimpsettings.h"
+#include "gimpoperationsettings.h"
 
 
 #define GIMP_TYPE_CURVES_CONFIG            (gimp_curves_config_get_type ())
@@ -37,18 +37,18 @@ typedef struct _GimpCurvesConfigClass GimpCurvesConfigClass;
 
 struct _GimpCurvesConfig
 {
-  GimpSettings          parent_instance;
+  GimpOperationSettings  parent_instance;
 
-  gboolean              linear;
+  gboolean               linear;
 
-  GimpHistogramChannel  channel;
+  GimpHistogramChannel   channel;
 
-  GimpCurve            *curve[5];
+  GimpCurve              *curve[5];
 };
 
 struct _GimpCurvesConfigClass
 {
-  GimpSettingsClass  parent_class;
+  GimpOperationSettingsClass  parent_class;
 };
 
 
diff --git a/app/operations/gimphuesaturationconfig.c b/app/operations/gimphuesaturationconfig.c
index 7e59cbb43c..4f0a397e8b 100644
--- a/app/operations/gimphuesaturationconfig.c
+++ b/app/operations/gimphuesaturationconfig.c
@@ -71,7 +71,7 @@ static gboolean gimp_hue_saturation_config_copy         (GimpConfig       *src,
 
 
 G_DEFINE_TYPE_WITH_CODE (GimpHueSaturationConfig, gimp_hue_saturation_config,
-                         GIMP_TYPE_SETTINGS,
+                         GIMP_TYPE_OPERATION_SETTINGS,
                          G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
                                                 gimp_hue_saturation_config_iface_init))
 
@@ -222,7 +222,7 @@ gimp_hue_saturation_config_serialize (GimpConfig       *config,
   GimpHueRange             old_range;
   gboolean                 success = TRUE;
 
-  if (! gimp_config_serialize_property_by_name (config, "time", writer))
+  if (! gimp_operation_settings_config_serialize_base (config, writer, data))
     return FALSE;
 
   old_range = hs_config->range;
@@ -280,6 +280,9 @@ gimp_hue_saturation_config_equal (GimpConfig *a,
   GimpHueSaturationConfig *config_b = GIMP_HUE_SATURATION_CONFIG (b);
   GimpHueRange             range;
 
+  if (! gimp_operation_settings_config_equal_base (a, b))
+    return FALSE;
+
   for (range = GIMP_HUE_RANGE_ALL; range <= GIMP_HUE_RANGE_MAGENTA; range++)
     {
       if (config_a->hue[range]        != config_b->hue[range]        ||
@@ -302,6 +305,8 @@ gimp_hue_saturation_config_reset (GimpConfig *config)
   GimpHueSaturationConfig *hs_config = GIMP_HUE_SATURATION_CONFIG (config);
   GimpHueRange             range;
 
+  gimp_operation_settings_config_reset_base (config);
+
   for (range = GIMP_HUE_RANGE_ALL; range <= GIMP_HUE_RANGE_MAGENTA; range++)
     {
       hs_config->range = range;
@@ -321,6 +326,9 @@ gimp_hue_saturation_config_copy (GimpConfig   *src,
   GimpHueSaturationConfig *dest_config = GIMP_HUE_SATURATION_CONFIG (dest);
   GimpHueRange             range;
 
+  if (! gimp_operation_settings_config_copy_base (src, dest, flags))
+    return FALSE;
+
   for (range = GIMP_HUE_RANGE_ALL; range <= GIMP_HUE_RANGE_MAGENTA; range++)
     {
       dest_config->hue[range]        = src_config->hue[range];
diff --git a/app/operations/gimphuesaturationconfig.h b/app/operations/gimphuesaturationconfig.h
index d5241ba08e..151ac0593e 100644
--- a/app/operations/gimphuesaturationconfig.h
+++ b/app/operations/gimphuesaturationconfig.h
@@ -22,7 +22,7 @@
 #define __GIMP_HUE_SATURATION_CONFIG_H__
 
 
-#include "core/gimpsettings.h"
+#include "gimpoperationsettings.h"
 
 
 #define GIMP_TYPE_HUE_SATURATION_CONFIG            (gimp_hue_saturation_config_get_type ())
@@ -37,20 +37,20 @@ typedef struct _GimpHueSaturationConfigClass GimpHueSaturationConfigClass;
 
 struct _GimpHueSaturationConfig
 {
-  GimpSettings  parent_instance;
+  GimpOperationSettings  parent_instance;
 
-  GimpHueRange  range;
+  GimpHueRange           range;
 
-  gdouble       hue[7];
-  gdouble       saturation[7];
-  gdouble       lightness[7];
+  gdouble                hue[7];
+  gdouble                saturation[7];
+  gdouble                lightness[7];
 
-  gdouble       overlap;
+  gdouble                overlap;
 };
 
 struct _GimpHueSaturationConfigClass
 {
-  GimpSettingsClass  parent_class;
+  GimpOperationSettingsClass  parent_class;
 };
 
 
diff --git a/app/operations/gimplevelsconfig.c b/app/operations/gimplevelsconfig.c
index 758635c877..098025575f 100644
--- a/app/operations/gimplevelsconfig.c
+++ b/app/operations/gimplevelsconfig.c
@@ -86,7 +86,7 @@ static gboolean gimp_levels_config_copy         (GimpConfig       *src,
 
 
 G_DEFINE_TYPE_WITH_CODE (GimpLevelsConfig, gimp_levels_config,
-                         GIMP_TYPE_SETTINGS,
+                         GIMP_TYPE_OPERATION_SETTINGS,
                          G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
                                                 gimp_levels_config_iface_init))
 
@@ -295,7 +295,7 @@ gimp_levels_config_serialize (GimpConfig       *config,
   GimpHistogramChannel  old_channel;
   gboolean              success = TRUE;
 
-  if (! gimp_config_serialize_property_by_name (config, "time",         writer) ||
+  if (! gimp_operation_settings_config_serialize_base (config, writer, data)    ||
       ! gimp_config_serialize_property_by_name (config, "linear",       writer) ||
       ! gimp_config_serialize_property_by_name (config, "clamp-input",  writer) ||
       ! gimp_config_serialize_property_by_name (config, "clamp-output", writer))
@@ -311,8 +311,8 @@ gimp_levels_config_serialize (GimpConfig       *config,
 
       /*  serialize the channel properties manually (not using
        *  gimp_config_serialize_properties()), so the parent class'
-       *  "time" property doesn't end up in the config file one per
-       *  channel. See bug #700653.
+       *  properties don't end up in the config file one per channel.
+       *  See bug #700653.
        */
       success =
         (gimp_config_serialize_property_by_name (config, "channel",     writer) &&
@@ -358,8 +358,9 @@ gimp_levels_config_equal (GimpConfig *a,
   GimpLevelsConfig     *config_b = GIMP_LEVELS_CONFIG (b);
   GimpHistogramChannel  channel;
 
-  if (config_a->linear       != config_b->linear      ||
-      config_a->clamp_input  != config_b->clamp_input ||
+  if (! gimp_operation_settings_config_equal_base (a, b) ||
+      config_a->linear       != config_b->linear         ||
+      config_a->clamp_input  != config_b->clamp_input    ||
       config_a->clamp_output != config_b->clamp_output)
     return FALSE;
 
@@ -386,6 +387,8 @@ gimp_levels_config_reset (GimpConfig *config)
   GimpLevelsConfig     *l_config = GIMP_LEVELS_CONFIG (config);
   GimpHistogramChannel  channel;
 
+  gimp_operation_settings_config_reset_base (config);
+
   for (channel = GIMP_HISTOGRAM_VALUE;
        channel <= GIMP_HISTOGRAM_ALPHA;
        channel++)
@@ -409,6 +412,9 @@ gimp_levels_config_copy (GimpConfig  *src,
   GimpLevelsConfig     *dest_config = GIMP_LEVELS_CONFIG (dest);
   GimpHistogramChannel  channel;
 
+  if (! gimp_operation_settings_config_copy_base (src, dest, flags))
+    return FALSE;
+
   for (channel = GIMP_HISTOGRAM_VALUE;
        channel <= GIMP_HISTOGRAM_ALPHA;
        channel++)
diff --git a/app/operations/gimplevelsconfig.h b/app/operations/gimplevelsconfig.h
index fb73e81e27..2e7569ca47 100644
--- a/app/operations/gimplevelsconfig.h
+++ b/app/operations/gimplevelsconfig.h
@@ -22,7 +22,7 @@
 #define __GIMP_LEVELS_CONFIG_H__
 
 
-#include "core/gimpsettings.h"
+#include "gimpoperationsettings.h"
 
 
 #define GIMP_TYPE_LEVELS_CONFIG            (gimp_levels_config_get_type ())
@@ -37,28 +37,28 @@ typedef struct _GimpLevelsConfigClass GimpLevelsConfigClass;
 
 struct _GimpLevelsConfig
 {
-  GimpSettings          parent_instance;
+  GimpOperationSettings  parent_instance;
 
-  gboolean              linear;
+  gboolean               linear;
 
-  GimpHistogramChannel  channel;
+  GimpHistogramChannel   channel;
 
-  gdouble               low_input[5];
-  gdouble               high_input[5];
+  gdouble                low_input[5];
+  gdouble                high_input[5];
 
-  gboolean              clamp_input;
+  gboolean               clamp_input;
 
-  gdouble               gamma[5];
+  gdouble                gamma[5];
 
-  gdouble               low_output[5];
-  gdouble               high_output[5];
+  gdouble                low_output[5];
+  gdouble                high_output[5];
 
-  gboolean              clamp_output;
+  gboolean               clamp_output;
 };
 
 struct _GimpLevelsConfigClass
 {
-  GimpSettingsClass  parent_class;
+  GimpOperationSettingsClass  parent_class;
 };
 
 
diff --git a/app/operations/gimpoperationsettings.c b/app/operations/gimpoperationsettings.c
new file mode 100644
index 0000000000..194e958659
--- /dev/null
+++ b/app/operations/gimpoperationsettings.c
@@ -0,0 +1,275 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpoperationsettings.c
+ * Copyright (C) 2020 Ell
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gegl.h>
+
+#include "libgimpconfig/gimpconfig.h"
+
+#include "operations-types.h"
+
+#include "gegl/gimp-gegl-utils.h"
+
+#include "core/gimpdrawable.h"
+#include "core/gimpdrawablefilter.h"
+
+#include "gimpoperationsettings.h"
+
+#include "gimp-intl.h"
+
+
+enum
+{
+  PROP_0,
+  PROP_CLIP,
+  PROP_REGION,
+  PROP_COLOR_MANAGED,
+  PROP_GAMMA_HACK
+};
+
+
+static void   gimp_operation_settings_get_property (GObject      *object,
+                                                    guint         property_id,
+                                                    GValue       *value,
+                                                    GParamSpec   *pspec);
+static void   gimp_operation_settings_set_property (GObject      *object,
+                                                    guint         property_id,
+                                                    const GValue *value,
+                                                    GParamSpec   *pspec);
+
+
+G_DEFINE_TYPE (GimpOperationSettings, gimp_operation_settings,
+               GIMP_TYPE_SETTINGS)
+
+#define parent_class gimp_operation_settings_parent_class
+
+
+static void
+gimp_operation_settings_class_init (GimpOperationSettingsClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->set_property = gimp_operation_settings_set_property;
+  object_class->get_property = gimp_operation_settings_get_property;
+
+  GIMP_CONFIG_PROP_ENUM (object_class, PROP_CLIP,
+                         "gimp-clip",
+                         _("Clipping"),
+                         _("How to clip"),
+                         GIMP_TYPE_TRANSFORM_RESIZE,
+                         GIMP_TRANSFORM_RESIZE_ADJUST,
+                         GIMP_PARAM_STATIC_STRINGS |
+                         GIMP_CONFIG_PARAM_DEFAULTS);
+
+  GIMP_CONFIG_PROP_ENUM (object_class, PROP_REGION,
+                         "gimp-region",
+                         NULL, NULL,
+                         GIMP_TYPE_FILTER_REGION,
+                         GIMP_FILTER_REGION_SELECTION,
+                         GIMP_PARAM_STATIC_STRINGS |
+                         GIMP_CONFIG_PARAM_DEFAULTS);
+
+  GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_COLOR_MANAGED,
+                            "gimp-color-managed",
+                            _("Color _managed"),
+                            NULL,
+                            FALSE,
+                            GIMP_PARAM_STATIC_STRINGS |
+                            GIMP_CONFIG_PARAM_DEFAULTS);
+
+  GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_GAMMA_HACK,
+                            "gimp-gamma-hack",
+                            "Gamma hack (temp hack, please ignore)",
+                            NULL,
+                            FALSE,
+                            GIMP_PARAM_STATIC_STRINGS |
+                            GIMP_CONFIG_PARAM_DEFAULTS);
+}
+
+static void
+gimp_operation_settings_init (GimpOperationSettings *settings)
+{
+}
+
+static void
+gimp_operation_settings_get_property (GObject    *object,
+                                      guint       property_id,
+                                      GValue     *value,
+                                      GParamSpec *pspec)
+{
+  GimpOperationSettings *settings = GIMP_OPERATION_SETTINGS (object);
+
+  switch (property_id)
+    {
+    case PROP_CLIP:
+      g_value_set_enum (value, settings->clip);
+      break;
+
+    case PROP_REGION:
+      g_value_set_enum (value, settings->region);
+      break;
+
+    case PROP_COLOR_MANAGED:
+      g_value_set_boolean (value, settings->color_managed);
+      break;
+
+    case PROP_GAMMA_HACK:
+      g_value_set_boolean (value, settings->gamma_hack);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+    }
+}
+
+static void
+gimp_operation_settings_set_property (GObject      *object,
+                                      guint         property_id,
+                                      const GValue *value,
+                                      GParamSpec   *pspec)
+{
+  GimpOperationSettings *settings = GIMP_OPERATION_SETTINGS (object);
+
+  switch (property_id)
+    {
+    case PROP_CLIP:
+      settings->clip = g_value_get_enum (value);
+      break;
+
+    case PROP_REGION:
+      settings->region = g_value_get_enum (value);
+      break;
+
+    case PROP_COLOR_MANAGED:
+      settings->color_managed = g_value_get_boolean (value);
+      break;
+
+    case PROP_GAMMA_HACK:
+      settings->gamma_hack = g_value_get_boolean (value);
+      break;
+
+   default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+    }
+}
+
+
+/*  public functions  */
+
+void
+gimp_operation_settings_sync_drawable_filter (GimpOperationSettings *settings,
+                                              GimpDrawableFilter    *filter)
+{
+  gboolean clip;
+
+  g_return_if_fail (GIMP_IS_OPERATION_SETTINGS (settings));
+  g_return_if_fail (GIMP_IS_DRAWABLE_FILTER (filter));
+
+  clip = settings->clip == GIMP_TRANSFORM_RESIZE_CLIP ||
+         ! babl_format_has_alpha (gimp_drawable_filter_get_format (filter));
+
+  gimp_drawable_filter_set_region        (filter, settings->region);
+  gimp_drawable_filter_set_clip          (filter, clip);
+  gimp_drawable_filter_set_color_managed (filter, settings->color_managed);
+  gimp_drawable_filter_set_gamma_hack    (filter, settings->gamma_hack);
+}
+
+
+/*  protected functions  */
+
+static const gchar * const base_properties[] =
+{
+  "time",
+  "gimp-clip",
+  "gimp-region",
+  "gimp-color-managed",
+  "gimp-gamma-hack"
+};
+
+gboolean
+gimp_operation_settings_config_serialize_base (GimpConfig       *config,
+                                               GimpConfigWriter *writer,
+                                               gpointer          data)
+{
+  gint i;
+
+  for (i = 0; i < G_N_ELEMENTS (base_properties); i++)
+    {
+      if (! gimp_config_serialize_property_by_name (config,
+                                                    base_properties[i],
+                                                    writer))
+        {
+          return FALSE;
+        }
+    }
+
+  return TRUE;
+}
+
+gboolean
+gimp_operation_settings_config_equal_base (GimpConfig *a,
+                                           GimpConfig *b)
+{
+  GimpOperationSettings *settings_a = GIMP_OPERATION_SETTINGS (a);
+  GimpOperationSettings *settings_b = GIMP_OPERATION_SETTINGS (b);
+
+  return settings_a->clip          == settings_b->clip          &&
+         settings_a->region        == settings_b->region        &&
+         settings_a->color_managed == settings_b->color_managed &&
+         settings_a->gamma_hack    == settings_b->gamma_hack;
+}
+
+void
+gimp_operation_settings_config_reset_base (GimpConfig *config)
+{
+  gint i;
+
+  g_object_freeze_notify (G_OBJECT (config));
+
+  for (i = 0; i < G_N_ELEMENTS (base_properties); i++)
+    gimp_config_reset_property (G_OBJECT (config), base_properties[i]);
+
+  g_object_thaw_notify (G_OBJECT (config));
+}
+
+gboolean
+gimp_operation_settings_config_copy_base (GimpConfig  *src,
+                                          GimpConfig  *dest,
+                                          GParamFlags  flags)
+{
+  gint i;
+
+  g_object_freeze_notify (G_OBJECT (dest));
+
+  for (i = 0; i < G_N_ELEMENTS (base_properties); i++)
+    {
+      g_object_unref (g_object_bind_property (src,  base_properties[i],
+                                              dest, base_properties[i],
+                                              G_BINDING_SYNC_CREATE));
+    }
+
+  g_object_thaw_notify (G_OBJECT (dest));
+
+  return TRUE;
+}
diff --git a/app/operations/gimpoperationsettings.h b/app/operations/gimpoperationsettings.h
new file mode 100644
index 0000000000..de98afd782
--- /dev/null
+++ b/app/operations/gimpoperationsettings.h
@@ -0,0 +1,73 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpoperationsettings.h
+ * Copyright (C) 2020 Ell
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_OPERATION_SETTINGS_H__
+#define __GIMP_OPERATION_SETTINGS_H__
+
+
+#include "core/gimpsettings.h"
+
+
+#define GIMP_TYPE_OPERATION_SETTINGS            (gimp_operation_settings_get_type ())
+#define GIMP_OPERATION_SETTINGS(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GIMP_TYPE_OPERATION_SETTINGS, GimpOperationSettings))
+#define GIMP_OPERATION_SETTINGS_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  
GIMP_TYPE_OPERATION_SETTINGS, GimpOperationSettingsClass))
+#define GIMP_IS_OPERATION_SETTINGS(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
GIMP_TYPE_OPERATION_SETTINGS))
+#define GIMP_IS_OPERATION_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  
GIMP_TYPE_OPERATION_SETTINGS))
+#define GIMP_OPERATION_SETTINGS_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  
GIMP_TYPE_OPERATION_SETTINGS, GimpOperationSettingsClass))
+
+
+typedef struct _GimpOperationSettingsClass GimpOperationSettingsClass;
+
+struct _GimpOperationSettings
+{
+  GimpSettings         parent_instance;
+
+  GimpTransformResize  clip;
+  GimpFilterRegion     region;
+  gboolean             color_managed;
+  gboolean             gamma_hack;
+};
+
+struct _GimpOperationSettingsClass
+{
+  GimpSettingsClass  parent_class;
+};
+
+
+GType      gimp_operation_settings_get_type              (void) G_GNUC_CONST;
+
+void       gimp_operation_settings_sync_drawable_filter  (GimpOperationSettings *settings,
+                                                          GimpDrawableFilter    *filter);
+
+
+/*  protected  */
+
+gboolean   gimp_operation_settings_config_serialize_base (GimpConfig            *config,
+                                                          GimpConfigWriter      *writer,
+                                                          gpointer               data);
+gboolean   gimp_operation_settings_config_equal_base     (GimpConfig            *a,
+                                                          GimpConfig            *b);
+void       gimp_operation_settings_config_reset_base     (GimpConfig            *config);
+gboolean   gimp_operation_settings_config_copy_base      (GimpConfig            *src,
+                                                          GimpConfig            *dest,
+                                                          GParamFlags            flags);
+
+
+#endif /* __GIMP_OPERATION_SETTINGS_H__ */
diff --git a/app/operations/operations-types.h b/app/operations/operations-types.h
index f3b774b19b..15e97d861d 100644
--- a/app/operations/operations-types.h
+++ b/app/operations/operations-types.h
@@ -36,6 +36,8 @@ typedef struct _GimpOperationLayerMode          GimpOperationLayerMode;
 
 /*  operation config objects  */
 
+typedef struct _GimpOperationSettings           GimpOperationSettings;
+
 typedef struct _GimpBrightnessContrastConfig    GimpBrightnessContrastConfig;
 typedef struct _GimpCageConfig                  GimpCageConfig;
 typedef struct _GimpColorBalanceConfig          GimpColorBalanceConfig;
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index e7accd44b0..aeffe31333 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -39,6 +39,7 @@
 #include "config/gimpguiconfig.h"
 
 #include "operations/gimp-operation-config.h"
+#include "operations/gimpoperationsettings.h"
 
 #include "gegl/gimp-gegl-utils.h"
 
@@ -1540,7 +1541,7 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
     g_object_new (gimp_operation_config_get_type (tool->tool_info->gimp,
                                                   operation_name,
                                                   gimp_tool_get_icon_name (tool),
-                                                  GIMP_TYPE_SETTINGS),
+                                                  GIMP_TYPE_OPERATION_SETTINGS),
                   NULL);
 
   gimp_operation_config_sync_node (filter_tool->config,
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ba844e4baa..e2c4b73205 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -302,6 +302,7 @@ app/operations/gimpoperationlevels.c
 app/operations/gimpoperationoffset.c
 app/operations/gimpoperationposterize.c
 app/operations/gimpoperationsemiflatten.c
+app/operations/gimpoperationsettings.c
 app/operations/gimpoperationthreshold.c
 app/operations/gimpoperationthresholdalpha.c
 



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