[gimp] app: remove GimpThresholdConfig
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: remove GimpThresholdConfig
- Date: Fri, 22 Jan 2016 21:38:58 +0000 (UTC)
commit cd47aac4351c3ebbefdc01eaef354568c7fffa28
Author: Michael Natterer <mitch gimp org>
Date: Fri Jan 22 22:37:23 2016 +0100
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 | 113 +++++++++++++++++----
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, 135 insertions(+), 284 deletions(-)
---
diff --git a/app/operations/Makefile.am b/app/operations/Makefile.am
index a6f8b10..4d169f8 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 41a89ed..e3f322e 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 8fee277..c71d196 100644
--- a/app/operations/gimpoperationthreshold.c
+++ b/app/operations/gimpoperationthreshold.c
@@ -24,11 +24,31 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
+#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,
- 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_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, 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 877c0f8..d4f82ee 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/pdb/color-cmds.c b/app/pdb/color-cmds.c
index 87a3212..f044fb9 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 49257fc..8e9080c 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 8ad628e..ad6c7db 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 5b78dac..d88cb4c 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 ca5c299..7854b47 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]