gimp r24711 - in trunk: . app/gegl app/tools
- From: mitch svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r24711 - in trunk: . app/gegl app/tools
- Date: Fri, 25 Jan 2008 18:35:10 +0000 (GMT)
Author: mitch
Date: Fri Jan 25 18:35:10 2008
New Revision: 24711
URL: http://svn.gnome.org/viewvc/gimp?rev=24711&view=rev
Log:
2008-01-25 Michael Natterer <mitch gimp org>
* app/gegl/Makefile.am
* app/gegl/gegl-types.h
* app/gegl/gimpposterizeconfig.[ch]: new config object.
* app/gegl/gimpoperationposterize.[ch]
* app/tools/gimpposterizetool.[ch]: use it.
Added:
trunk/app/gegl/gimpposterizeconfig.c
trunk/app/gegl/gimpposterizeconfig.h
Modified:
trunk/ChangeLog
trunk/app/gegl/Makefile.am
trunk/app/gegl/gegl-types.h
trunk/app/gegl/gimpoperationposterize.c
trunk/app/gegl/gimpoperationposterize.h
trunk/app/tools/gimpposterizetool.c
trunk/app/tools/gimpposterizetool.h
Modified: trunk/app/gegl/Makefile.am
==============================================================================
--- trunk/app/gegl/Makefile.am (original)
+++ trunk/app/gegl/Makefile.am Fri Jan 25 18:35:10 2008
@@ -18,6 +18,8 @@
gimphuesaturationconfig.h \
gimplevelsconfig.c \
gimplevelsconfig.h \
+ gimpposterizeconfig.c \
+ gimpposterizeconfig.h \
gimpthresholdconfig.c \
gimpthresholdconfig.h \
\
Modified: trunk/app/gegl/gegl-types.h
==============================================================================
--- trunk/app/gegl/gegl-types.h (original)
+++ trunk/app/gegl/gegl-types.h Fri Jan 25 18:35:10 2008
@@ -47,6 +47,7 @@
typedef struct _GimpCurvesConfig GimpCurvesConfig;
typedef struct _GimpHueSaturationConfig GimpHueSaturationConfig;
typedef struct _GimpLevelsConfig GimpLevelsConfig;
+typedef struct _GimpPosterizeConfig GimpPosterizeConfig;
typedef struct _GimpThresholdConfig GimpThresholdConfig;
Modified: trunk/app/gegl/gimpoperationposterize.c
==============================================================================
--- trunk/app/gegl/gimpoperationposterize.c (original)
+++ trunk/app/gegl/gimpoperationposterize.c Fri Jan 25 18:35:10 2008
@@ -29,15 +29,17 @@
#include "gegl-types.h"
#include "gimpoperationposterize.h"
+#include "gimpposterizeconfig.h"
enum
{
PROP_0,
- PROP_LEVELS
+ PROP_CONFIG
};
+static void gimp_operation_posterize_finalize (GObject *object);
static void gimp_operation_posterize_get_property (GObject *object,
guint property_id,
GValue *value,
@@ -66,6 +68,7 @@
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
+ object_class->finalize = gimp_operation_posterize_finalize;
object_class->set_property = gimp_operation_posterize_set_property;
object_class->get_property = gimp_operation_posterize_get_property;
@@ -73,14 +76,13 @@
gegl_operation_class_set_name (operation_class, "gimp-posterize");
- g_object_class_install_property (object_class,
- PROP_LEVELS,
- g_param_spec_int ("levels",
- "Levels",
- "Posterize levels",
- 2, 256, 10,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_CONFIG,
+ g_param_spec_object ("config",
+ "Config",
+ "The config object",
+ GIMP_TYPE_POSTERIZE_CONFIG,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
}
static void
@@ -89,6 +91,20 @@
}
static void
+gimp_operation_posterize_finalize (GObject *object)
+{
+ GimpOperationPosterize *self = GIMP_OPERATION_POSTERIZE (object);
+
+ if (self->config)
+ {
+ g_object_unref (self->config);
+ self->config = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
gimp_operation_posterize_get_property (GObject *object,
guint property_id,
GValue *value,
@@ -98,8 +114,8 @@
switch (property_id)
{
- case PROP_LEVELS:
- g_value_set_int (value, self->levels);
+ case PROP_CONFIG:
+ g_value_set_object (value, self->config);
break;
default:
@@ -118,8 +134,10 @@
switch (property_id)
{
- case PROP_LEVELS:
- self->levels = g_value_get_int (value);
+ case PROP_CONFIG:
+ if (self->config)
+ g_object_unref (self->config);
+ self->config = g_value_dup_object (value);
break;
default:
@@ -135,9 +153,10 @@
glong samples)
{
GimpOperationPosterize *self = GIMP_OPERATION_POSTERIZE (operation);
+ GimpPosterizeConfig *config = self->config;
gfloat *src = in_buf;
gfloat *dest = out_buf;
- gfloat levels = self->levels - 1.0;
+ gfloat levels = config->levels - 1.0;
glong sample;
for (sample = 0; sample < samples; sample++)
Modified: trunk/app/gegl/gimpoperationposterize.h
==============================================================================
--- trunk/app/gegl/gimpoperationposterize.h (original)
+++ trunk/app/gegl/gimpoperationposterize.h Fri Jan 25 18:35:10 2008
@@ -27,10 +27,12 @@
#include <operation/gegl-operation-point-filter.h>
-#define GIMP_TYPE_OPERATION_POSTERIZE (gimp_operation_posterize_get_type ())
-#define GIMP_OPERATION_POSTERIZE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_POSTERIZE, GimpOperationPosterize))
-#define GIMP_OPERATION_POSTERIZE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_POSTERIZE, GimpOperationPosterizeClass))
-#define GIMP_OPERATION_POSTERIZE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_POSTERIZE, GimpOperationPosterizeClass))
+#define GIMP_TYPE_OPERATION_POSTERIZE (gimp_operation_posterize_get_type ())
+#define GIMP_OPERATION_POSTERIZE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_POSTERIZE, GimpOperationPosterize))
+#define GIMP_OPERATION_POSTERIZE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_POSTERIZE, GimpOperationPosterizeClass))
+#define GIMP_IS_OPERATION_POSTERIZE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_POSTERIZE))
+#define GIMP_IS_OPERATION_POSTERIZE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_POSTERIZE))
+#define GIMP_OPERATION_POSTERIZE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_POSTERIZE, GimpOperationPosterizeClass))
typedef struct _GimpOperationPosterizeClass GimpOperationPosterizeClass;
@@ -39,7 +41,7 @@
{
GeglOperationPointFilter parent_instance;
- gint levels;
+ GimpPosterizeConfig *config;
};
struct _GimpOperationPosterizeClass
Added: trunk/app/gegl/gimpposterizeconfig.c
==============================================================================
--- (empty file)
+++ trunk/app/gegl/gimpposterizeconfig.c Fri Jan 25 18:35:10 2008
@@ -0,0 +1,125 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpposterizeconfig.c
+ * Copyright (C) 2007 Michael Natterer <mitch gimp org>
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <gegl.h>
+
+#include "gegl-types.h"
+
+#include "gimpposterizeconfig.h"
+
+
+enum
+{
+ PROP_0,
+ PROP_LEVELS
+};
+
+
+static void gimp_posterize_config_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_posterize_config_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+
+G_DEFINE_TYPE (GimpPosterizeConfig, gimp_posterize_config,
+ G_TYPE_OBJECT)
+
+#define parent_class gimp_posterize_config_parent_class
+
+
+static void
+gimp_posterize_config_class_init (GimpPosterizeConfigClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->set_property = gimp_posterize_config_set_property;
+ object_class->get_property = gimp_posterize_config_get_property;
+
+ g_object_class_install_property (object_class, PROP_LEVELS,
+ g_param_spec_int ("levels",
+ "Levels",
+ "Posterize levels",
+ 2, 256, 3,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+}
+
+static void
+gimp_posterize_config_init (GimpPosterizeConfig *self)
+{
+}
+
+static void
+gimp_posterize_config_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GimpPosterizeConfig *self = GIMP_POSTERIZE_CONFIG (object);
+
+ switch (property_id)
+ {
+ case PROP_LEVELS:
+ g_value_set_int (value, self->levels);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gimp_posterize_config_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GimpPosterizeConfig *self = GIMP_POSTERIZE_CONFIG (object);
+
+ switch (property_id)
+ {
+ case PROP_LEVELS:
+ self->levels = g_value_get_int (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+/* public functions */
+
+void
+gimp_posterize_config_reset (GimpPosterizeConfig *config)
+{
+ g_return_if_fail (GIMP_IS_POSTERIZE_CONFIG (config));
+
+ config->levels = 3;
+}
Added: trunk/app/gegl/gimpposterizeconfig.h
==============================================================================
--- (empty file)
+++ trunk/app/gegl/gimpposterizeconfig.h Fri Jan 25 18:35:10 2008
@@ -0,0 +1,54 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpposterizeconfig.h
+ * Copyright (C) 2007 Michael Natterer <mitch gimp org>
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GIMP_POSTERIZE_CONFIG_H__
+#define __GIMP_POSTERIZE_CONFIG_H__
+
+
+#define GIMP_TYPE_POSTERIZE_CONFIG (gimp_posterize_config_get_type ())
+#define GIMP_POSTERIZE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_POSTERIZE_CONFIG, GimpPosterizeConfig))
+#define GIMP_POSTERIZE_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_POSTERIZE_CONFIG, GimpPosterizeConfigClass))
+#define GIMP_IS_POSTERIZE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_POSTERIZE_CONFIG))
+#define GIMP_IS_POSTERIZE_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_POSTERIZE_CONFIG))
+#define GIMP_POSTERIZE_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_POSTERIZE_CONFIG, GimpPosterizeConfigClass))
+
+
+typedef struct _GimpPosterizeConfigClass GimpPosterizeConfigClass;
+
+struct _GimpPosterizeConfig
+{
+ GObject parent_instance;
+
+ gint levels;
+};
+
+struct _GimpPosterizeConfigClass
+{
+ GObjectClass parent_class;
+};
+
+
+GType gimp_posterize_config_get_type (void) G_GNUC_CONST;
+
+void gimp_posterize_config_reset (GimpPosterizeConfig *config);
+
+
+#endif /* __GIMP_POSTERIZE_CONFIG_H__ */
Modified: trunk/app/tools/gimpposterizetool.c
==============================================================================
--- trunk/app/tools/gimpposterizetool.c (original)
+++ trunk/app/tools/gimpposterizetool.c Fri Jan 25 18:35:10 2008
@@ -21,6 +21,7 @@
#include <gegl.h>
#include <gtk/gtk.h>
+#include "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
@@ -28,6 +29,8 @@
#include "base/gimplut.h"
#include "base/lut-funcs.h"
+#include "gegl/gimpposterizeconfig.h"
+
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
@@ -41,8 +44,6 @@
#include "gimp-intl.h"
-#define POSTERIZE_DEFAULT_LEVELS 3
-
#define SLIDER_WIDTH 200
@@ -107,8 +108,7 @@
{
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (posterize_tool);
- posterize_tool->levels = POSTERIZE_DEFAULT_LEVELS;
- posterize_tool->lut = gimp_lut_new ();
+ posterize_tool->lut = gimp_lut_new ();
im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
im_tool->apply_data = posterize_tool->lut;
@@ -119,6 +119,12 @@
{
GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (object);
+ if (posterize_tool->config)
+ {
+ g_object_unref (posterize_tool->config);
+ posterize_tool->config = NULL;
+ }
+
if (posterize_tool->lut)
{
gimp_lut_free (posterize_tool->lut);
@@ -148,12 +154,12 @@
return FALSE;
}
- posterize_tool->levels = POSTERIZE_DEFAULT_LEVELS;
+ gimp_posterize_config_reset (posterize_tool->config);
GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
gtk_adjustment_set_value (posterize_tool->levels_data,
- posterize_tool->levels);
+ posterize_tool->config->levels);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (posterize_tool));
@@ -161,11 +167,22 @@
}
static GeglNode *
-gimp_posterize_tool_get_operation (GimpImageMapTool *im_tool)
+gimp_posterize_tool_get_operation (GimpImageMapTool *image_map_tool)
{
- return g_object_new (GEGL_TYPE_NODE,
+ GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (image_map_tool);
+ GeglNode *node;
+
+ node = g_object_new (GEGL_TYPE_NODE,
"operation", "gimp-posterize",
NULL);
+
+ posterize_tool->config = g_object_new (GIMP_TYPE_POSTERIZE_CONFIG, NULL);
+
+ gegl_node_set (node,
+ "config", posterize_tool->config,
+ NULL);
+
+ return node;
}
static void
@@ -173,12 +190,8 @@
{
GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (image_map_tool);
- gegl_node_set (image_map_tool->operation,
- "levels", posterize_tool->levels,
- NULL);
-
posterize_lut_setup (posterize_tool->lut,
- posterize_tool->levels,
+ posterize_tool->config->levels,
gimp_drawable_bytes (image_map_tool->drawable));
}
@@ -204,7 +217,7 @@
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("Posterize _levels:"), SLIDER_WIDTH, -1,
- posterize_tool->levels,
+ posterize_tool->config->levels,
2.0, 256.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
@@ -222,19 +235,24 @@
{
GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (image_map_tool);
- posterize_tool->levels = POSTERIZE_DEFAULT_LEVELS;
+ gimp_posterize_config_reset (posterize_tool->config);
gtk_adjustment_set_value (posterize_tool->levels_data,
- posterize_tool->levels);
+ posterize_tool->config->levels);
}
static void
gimp_posterize_tool_levels_changed (GtkAdjustment *adjustment,
GimpPosterizeTool *posterize_tool)
{
- if (posterize_tool->levels != adjustment->value)
+ GimpPosterizeConfig *config = posterize_tool->config;
+ gint value = ROUND (adjustment->value);
+
+ if (config->levels != value)
{
- posterize_tool->levels = adjustment->value;
+ g_object_set (config,
+ "levels", value,
+ NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (posterize_tool));
}
Modified: trunk/app/tools/gimpposterizetool.h
==============================================================================
--- trunk/app/tools/gimpposterizetool.h (original)
+++ trunk/app/tools/gimpposterizetool.h Fri Jan 25 18:35:10 2008
@@ -36,13 +36,13 @@
struct _GimpPosterizeTool
{
- GimpImageMapTool parent_instance;
+ GimpImageMapTool parent_instance;
- gint levels;
- GimpLut *lut;
+ GimpPosterizeConfig *config;
+ GimpLut *lut;
/* dialog */
- GtkAdjustment *levels_data;
+ GtkAdjustment *levels_data;
};
struct _GimpPosterizeToolClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]