From cd47aac4351c3ebbefdc01eaef354568c7fffa28 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Fri, 22 Jan 2016 22:37:23 +0100 Subject: [PATCH] app: remove GimpThresholdConfig The new more general GimpImageMapTool code handles this case completely automatically now. --- app/operations/Makefile.am | 2 - app/operations/gimp-operations.c | 3 - app/operations/gimpoperationthreshold.c | 111 ++++++++++++---- app/operations/gimpoperationthreshold.h | 3 + app/operations/gimpthresholdconfig.c | 161 ------------------------ app/operations/gimpthresholdconfig.h | 55 -------- app/pdb/color-cmds.c | 20 +-- app/pdb/drawable-color-cmds.c | 20 +-- po/POTFILES.in | 2 +- tools/pdbgen/pdb/color.pdb | 20 +-- tools/pdbgen/pdb/drawable_color.pdb | 20 +-- 11 files changed, 134 insertions(+), 283 deletions(-) delete mode 100644 app/operations/gimpthresholdconfig.c delete mode 100644 app/operations/gimpthresholdconfig.h diff --git a/app/operations/Makefile.am b/app/operations/Makefile.am index a6f8b100e3..4d169f8413 100644 --- a/app/operations/Makefile.am +++ b/app/operations/Makefile.am @@ -37,8 +37,6 @@ libappoperations_generic_a_sources = \ gimphuesaturationconfig.h \ gimplevelsconfig.c \ gimplevelsconfig.h \ - gimpthresholdconfig.c \ - gimpthresholdconfig.h \ \ gimpoperationblend.c \ gimpoperationblend.h \ diff --git a/app/operations/gimp-operations.c b/app/operations/gimp-operations.c index 41a89ed791..e3f322ece9 100644 --- a/app/operations/gimp-operations.c +++ b/app/operations/gimp-operations.c @@ -61,7 +61,6 @@ #include "gimpcurvesconfig.h" #include "gimphuesaturationconfig.h" #include "gimplevelsconfig.h" -#include "gimpthresholdconfig.h" #include "gimpoperationpointlayermode.h" #include "gimpoperationnormalmode.h" @@ -168,6 +167,4 @@ gimp_operations_init (void) GIMP_TYPE_HUE_SATURATION_CONFIG); gimp_gegl_config_register ("gimp:levels", GIMP_TYPE_LEVELS_CONFIG); - gimp_gegl_config_register ("gimp:threshold", - GIMP_TYPE_THRESHOLD_CONFIG); } diff --git a/app/operations/gimpoperationthreshold.c b/app/operations/gimpoperationthreshold.c index 8fee2773de..c71d196d58 100644 --- a/app/operations/gimpoperationthreshold.c +++ b/app/operations/gimpoperationthreshold.c @@ -24,11 +24,31 @@ #include #include +#include "libgimpconfig/gimpconfig.h" + #include "operations-types.h" #include "gimpoperationthreshold.h" -#include "gimpthresholdconfig.h" +#include "gimp-intl.h" + + +enum +{ + PROP_0, + PROP_LOW, + PROP_HIGH +}; + + +static void gimp_operation_threshold_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); +static void gimp_operation_threshold_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); static gboolean gimp_operation_threshold_process (GeglOperation *operation, void *in_buf, @@ -51,8 +71,10 @@ gimp_operation_threshold_class_init (GimpOperationThresholdClass *klass) GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass); GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass); - object_class->set_property = gimp_operation_point_filter_set_property; - object_class->get_property = gimp_operation_point_filter_get_property; + object_class->set_property = gimp_operation_threshold_set_property; + object_class->get_property = gimp_operation_threshold_get_property; + + point_class->process = gimp_operation_threshold_process; gegl_operation_class_set_keys (operation_class, "name", "gimp:threshold", @@ -60,16 +82,19 @@ gimp_operation_threshold_class_init (GimpOperationThresholdClass *klass) "description", "GIMP Threshold operation", NULL); - point_class->process = gimp_operation_threshold_process; + g_object_class_install_property (object_class, PROP_LOW, + g_param_spec_double ("low", + _("Low threshold"), + NULL, + 0.0, 1.0, 0.5, + GIMP_CONFIG_PARAM_FLAGS)); - g_object_class_install_property (object_class, - GIMP_OPERATION_POINT_FILTER_PROP_CONFIG, - g_param_spec_object ("config", - "Config", - "The config object", - GIMP_TYPE_THRESHOLD_CONFIG, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT)); + g_object_class_install_property (object_class, PROP_HIGH, + g_param_spec_double ("high", + _("High threshold"), + NULL, + 0.0, 1.0, 1.0, + GIMP_CONFIG_PARAM_FLAGS)); } static void @@ -77,7 +102,55 @@ gimp_operation_threshold_init (GimpOperationThreshold *self) { } -static gboolean +static void +gimp_operation_threshold_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GimpOperationThreshold *self = GIMP_OPERATION_THRESHOLD (object); + + switch (property_id) + { + case PROP_LOW: + g_value_set_double (value, self->low); + break; + + case PROP_HIGH: + g_value_set_double (value, self->high); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gimp_operation_threshold_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GimpOperationThreshold *self = GIMP_OPERATION_THRESHOLD (object); + + switch (property_id) + { + case PROP_LOW: + self->low = g_value_get_double (value); + break; + + case PROP_HIGH: + self->high = g_value_get_double (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + static gboolean gimp_operation_threshold_process (GeglOperation *operation, void *in_buf, void *out_buf, @@ -85,13 +158,9 @@ gimp_operation_threshold_process (GeglOperation *operation, const GeglRectangle *roi, gint level) { - GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation); - GimpThresholdConfig *config = GIMP_THRESHOLD_CONFIG (point->config); - gfloat *src = in_buf; - gfloat *dest = out_buf; - - if (! config) - return FALSE; + GimpOperationThreshold *threshold = GIMP_OPERATION_THRESHOLD (operation); + gfloat *src = in_buf; + gfloat *dest = out_buf; while (samples--) { @@ -100,7 +169,7 @@ gimp_operation_threshold_process (GeglOperation *operation, value = MAX (src[RED], src[GREEN]); value = MAX (value, src[BLUE]); - value = (value >= config->low && value <= config->high) ? 1.0 : 0.0; + value = (value >= threshold->low && value <= threshold->high) ? 1.0 : 0.0; dest[RED] = value; dest[GREEN] = value; diff --git a/app/operations/gimpoperationthreshold.h b/app/operations/gimpoperationthreshold.h index 877c0f89a1..d4f82ee4e5 100644 --- a/app/operations/gimpoperationthreshold.h +++ b/app/operations/gimpoperationthreshold.h @@ -39,6 +39,9 @@ typedef struct _GimpOperationThresholdClass GimpOperationThresholdClass; struct _GimpOperationThreshold { GimpOperationPointFilter parent_instance; + + gdouble low; + gdouble high; }; struct _GimpOperationThresholdClass diff --git a/app/operations/gimpthresholdconfig.c b/app/operations/gimpthresholdconfig.c deleted file mode 100644 index 4a01b7b84e..0000000000 --- a/app/operations/gimpthresholdconfig.c +++ /dev/null @@ -1,161 +0,0 @@ -/* GIMP - The GNU Image Manipulation Program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimpthresholdconfig.c - * Copyright (C) 2007 Michael Natterer - * - * 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 . - */ - -#include "config.h" - -#include -#include - -#include "libgimpconfig/gimpconfig.h" - -#include "operations-types.h" - -#include "gimpthresholdconfig.h" - -#include "gimp-intl.h" - - -enum -{ - PROP_0, - PROP_LOW, - PROP_HIGH -}; - - -static void gimp_threshold_config_iface_init (GimpConfigInterface *iface); - -static void gimp_threshold_config_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); -static void gimp_threshold_config_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); - -static gboolean gimp_threshold_config_equal (GimpConfig *a, - GimpConfig *b); - - -G_DEFINE_TYPE_WITH_CODE (GimpThresholdConfig, gimp_threshold_config, - GIMP_TYPE_SETTINGS, - G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, - gimp_threshold_config_iface_init)) - -#define parent_class gimp_threshold_config_parent_class - - -static void -gimp_threshold_config_class_init (GimpThresholdConfigClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass); - - object_class->set_property = gimp_threshold_config_set_property; - object_class->get_property = gimp_threshold_config_get_property; - - viewable_class->default_icon_name = "gimp-tool-threshold"; - - GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_LOW, - "low", - _("Low threshold"), - 0.0, 1.0, 0.5, 0); - - GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_HIGH, - "high", - _("High threshold"), - 0.0, 1.0, 1.0, 0); -} - -static void -gimp_threshold_config_iface_init (GimpConfigInterface *iface) -{ - iface->equal = gimp_threshold_config_equal; -} - -static void -gimp_threshold_config_init (GimpThresholdConfig *self) -{ -} - -static void -gimp_threshold_config_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - GimpThresholdConfig *self = GIMP_THRESHOLD_CONFIG (object); - - switch (property_id) - { - case PROP_LOW: - g_value_set_double (value, self->low); - break; - - case PROP_HIGH: - g_value_set_double (value, self->high); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -gimp_threshold_config_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GimpThresholdConfig *self = GIMP_THRESHOLD_CONFIG (object); - - switch (property_id) - { - case PROP_LOW: - self->low = g_value_get_double (value); - break; - - case PROP_HIGH: - self->high = g_value_get_double (value); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static gboolean -gimp_threshold_config_equal (GimpConfig *a, - GimpConfig *b) -{ - GimpThresholdConfig *config_a = GIMP_THRESHOLD_CONFIG (a); - GimpThresholdConfig *config_b = GIMP_THRESHOLD_CONFIG (b); - - if (config_a->low != config_b->low || - config_a->high != config_b->high) - { - return FALSE; - } - - return TRUE; -} diff --git a/app/operations/gimpthresholdconfig.h b/app/operations/gimpthresholdconfig.h deleted file mode 100644 index b8fc8ca95f..0000000000 --- a/app/operations/gimpthresholdconfig.h +++ /dev/null @@ -1,55 +0,0 @@ -/* GIMP - The GNU Image Manipulation Program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimpthresholdconfig.h - * Copyright (C) 2007 Michael Natterer - * - * 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 . - */ - -#ifndef __GIMP_THRESHOLD_CONFIG_H__ -#define __GIMP_THRESHOLD_CONFIG_H__ - - -#include "core/gimpsettings.h" - - -#define GIMP_TYPE_THRESHOLD_CONFIG (gimp_threshold_config_get_type ()) -#define GIMP_THRESHOLD_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_THRESHOLD_CONFIG, GimpThresholdConfig)) -#define GIMP_THRESHOLD_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_THRESHOLD_CONFIG, GimpThresholdConfigClass)) -#define GIMP_IS_THRESHOLD_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_THRESHOLD_CONFIG)) -#define GIMP_IS_THRESHOLD_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_THRESHOLD_CONFIG)) -#define GIMP_THRESHOLD_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_THRESHOLD_CONFIG, GimpThresholdConfigClass)) - - -typedef struct _GimpThresholdConfigClass GimpThresholdConfigClass; - -struct _GimpThresholdConfig -{ - GimpSettings parent_instance; - - gdouble low; - gdouble high; -}; - -struct _GimpThresholdConfigClass -{ - GimpSettingsClass parent_class; -}; - - -GType gimp_threshold_config_get_type (void) G_GNUC_CONST; - - -#endif /* __GIMP_THRESHOLD_CONFIG_H__ */ diff --git a/app/pdb/color-cmds.c b/app/pdb/color-cmds.c index 87a3212b2e..f044fb9018 100644 --- a/app/pdb/color-cmds.c +++ b/app/pdb/color-cmds.c @@ -43,7 +43,6 @@ #include "operations/gimpcurvesconfig.h" #include "operations/gimphuesaturationconfig.h" #include "operations/gimplevelsconfig.h" -#include "operations/gimpthresholdconfig.h" #include "plug-in/gimpplugin.h" #include "plug-in/gimppluginmanager.h" @@ -757,16 +756,17 @@ threshold_invoker (GimpProcedure *procedure, GIMP_PDB_ITEM_CONTENT, error) && gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error)) { - GObject *config = g_object_new (GIMP_TYPE_THRESHOLD_CONFIG, - "low", low_threshold / 255.0, - "high", high_threshold / 255.0, - NULL); + GeglNode *node = + gegl_node_new_child (NULL, + "operation", "gimp:threshold", + "low", low_threshold / 255.0, + "high", high_threshold / 255.0, + NULL); - gimp_drawable_apply_operation_by_name (drawable, progress, - _("Threshold"), - "gimp:threshold", - config); - g_object_unref (config); + gimp_drawable_apply_operation (drawable, progress, + C_("undo-type", "Threshold"), + node); + g_object_unref (node); } else success = FALSE; diff --git a/app/pdb/drawable-color-cmds.c b/app/pdb/drawable-color-cmds.c index 49257fc2df..8e9080ca60 100644 --- a/app/pdb/drawable-color-cmds.c +++ b/app/pdb/drawable-color-cmds.c @@ -43,7 +43,6 @@ #include "operations/gimpcurvesconfig.h" #include "operations/gimphuesaturationconfig.h" #include "operations/gimplevelsconfig.h" -#include "operations/gimpthresholdconfig.h" #include "plug-in/gimpplugin.h" #include "plug-in/gimppluginmanager.h" @@ -693,16 +692,17 @@ drawable_threshold_invoker (GimpProcedure *procedure, GIMP_PDB_ITEM_CONTENT, error) && gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error)) { - GObject *config = g_object_new (GIMP_TYPE_THRESHOLD_CONFIG, - "low", low_threshold / 255.0, - "high", high_threshold / 255.0, - NULL); + GeglNode *node = + gegl_node_new_child (NULL, + "operation", "gimp:threshold", + "low", low_threshold / 255.0, + "high", high_threshold / 255.0, + NULL); - gimp_drawable_apply_operation_by_name (drawable, progress, - C_("undo-type", "Threshold"), - "gimp:threshold", - config); - g_object_unref (config); + gimp_drawable_apply_operation (drawable, progress, + C_("undo-type", "Threshold"), + node); + g_object_unref (node); } else success = FALSE; diff --git a/po/POTFILES.in b/po/POTFILES.in index 8ad628e6d4..ad6c7db323 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -256,8 +256,8 @@ app/operations/gimpoperationcagetransform.c app/operations/gimpoperationdesaturate.c app/operations/gimpoperationposterize.c app/operations/gimpoperationsemiflatten.c +app/operations/gimpoperationthreshold.c app/operations/gimpoperationthresholdalpha.c -app/operations/gimpthresholdconfig.c app/gui/gui.c app/gui/gui-message.c diff --git a/tools/pdbgen/pdb/color.pdb b/tools/pdbgen/pdb/color.pdb index 5b78dacce1..d88cb4ca14 100644 --- a/tools/pdbgen/pdb/color.pdb +++ b/tools/pdbgen/pdb/color.pdb @@ -697,23 +697,23 @@ HELP ); %invoke = ( - headers => [ qw("operations/gimpthresholdconfig.h") ], code => <<'CODE' { if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, GIMP_PDB_ITEM_CONTENT, error) && gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error)) { - GObject *config = g_object_new (GIMP_TYPE_THRESHOLD_CONFIG, - "low", low_threshold / 255.0, - "high", high_threshold / 255.0, - NULL); + GeglNode *node = + gegl_node_new_child (NULL, + "operation", "gimp:threshold", + "low", low_threshold / 255.0, + "high", high_threshold / 255.0, + NULL); - gimp_drawable_apply_operation_by_name (drawable, progress, - _("Threshold"), - "gimp:threshold", - config); - g_object_unref (config); + gimp_drawable_apply_operation (drawable, progress, + C_("undo-type", "Threshold"), + node); + g_object_unref (node); } else success = FALSE; diff --git a/tools/pdbgen/pdb/drawable_color.pdb b/tools/pdbgen/pdb/drawable_color.pdb index ca5c299963..7854b4720c 100644 --- a/tools/pdbgen/pdb/drawable_color.pdb +++ b/tools/pdbgen/pdb/drawable_color.pdb @@ -757,23 +757,23 @@ HELP ); %invoke = ( - headers => [ qw("operations/gimpthresholdconfig.h") ], code => <<'CODE' { if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, GIMP_PDB_ITEM_CONTENT, error) && gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error)) { - GObject *config = g_object_new (GIMP_TYPE_THRESHOLD_CONFIG, - "low", low_threshold / 255.0, - "high", high_threshold / 255.0, - NULL); + GeglNode *node = + gegl_node_new_child (NULL, + "operation", "gimp:threshold", + "low", low_threshold / 255.0, + "high", high_threshold / 255.0, + NULL); - gimp_drawable_apply_operation_by_name (drawable, progress, - C_("undo-type", "Threshold"), - "gimp:threshold", - config); - g_object_unref (config); + gimp_drawable_apply_operation (drawable, progress, + C_("undo-type", "Threshold"), + node); + g_object_unref (node); } else success = FALSE;