From 987aaf0b9185564cf7ad30ca7b4496e70b722f9a Mon Sep 17 00:00:00 2001 From: William Skaggs Date: Thu, 31 Jan 2008 16:37:51 +0000 Subject: [PATCH] Bill Skaggs Merged 24710:24758 from trunk. svn path=/branches/weskaggs/; revision=24761 --- ChangeLog | 4 + app/base/tile-manager.c | 14 +- app/dialogs/keyboard-shortcuts-dialog.c | 2 + app/display/gimpdisplayshell-autoscroll.c | 1 - app/display/gimpdisplayshell-callbacks.c | 4 - app/display/gimpdisplayshell.c | 30 +- app/display/gimpdisplayshell.h | 1 - app/gegl/Makefile.am | 6 + app/gegl/gegl-types.h | 35 +- app/gegl/gimpbrightnesscontrastconfig.c | 159 +++++ app/gegl/gimpbrightnesscontrastconfig.h | 56 ++ app/gegl/gimpcolorbalanceconfig.c | 76 ++- app/gegl/gimpcolorbalanceconfig.h | 4 +- app/gegl/gimpcolorizeconfig.c | 21 +- app/gegl/gimpcolorizeconfig.h | 2 - app/gegl/gimpcurvesconfig.c | 86 ++- app/gegl/gimpcurvesconfig.h | 20 +- app/gegl/gimphuesaturationconfig.c | 75 ++- app/gegl/gimphuesaturationconfig.h | 4 +- app/gegl/gimplevelsconfig.c | 126 +++- app/gegl/gimplevelsconfig.h | 4 +- app/gegl/gimpoperationcolorbalance.c | 108 +--- app/gegl/gimpoperationcolorbalance.h | 9 +- app/gegl/gimpoperationcolorize.c | 113 +--- app/gegl/gimpoperationcolorize.h | 10 +- app/gegl/gimpoperationcurves.c | 108 +--- app/gegl/gimpoperationcurves.h | 9 +- app/gegl/gimpoperationdesaturate.c | 9 +- app/gegl/gimpoperationhuesaturation.c | 113 +--- app/gegl/gimpoperationhuesaturation.h | 10 +- app/gegl/gimpoperationlevels.c | 109 +--- app/gegl/gimpoperationlevels.h | 9 +- app/gegl/gimpoperationpointfilter.c | 107 ++++ app/gegl/gimpoperationpointfilter.h | 72 +++ app/gegl/gimpoperationposterize.c | 106 +--- app/gegl/gimpoperationposterize.h | 19 +- app/gegl/gimpoperationthreshold.c | 108 +--- app/gegl/gimpoperationthreshold.h | 9 +- app/gegl/gimpoperationtilesink.c | 60 +- app/gegl/gimpoperationtilesource.c | 41 +- app/gegl/gimpposterizeconfig.c | 117 ++++ app/gegl/gimpposterizeconfig.h | 52 ++ app/gegl/gimpthresholdconfig.c | 21 +- app/gegl/gimpthresholdconfig.h | 2 - app/tools/Makefile.am | 2 + app/tools/gimp-tools.c | 2 + app/tools/gimpbrightnesscontrasttool.c | 137 ++-- app/tools/gimpbrightnesscontrasttool.h | 15 +- app/tools/gimpcolorbalancetool.c | 140 ++-- app/tools/gimpcolorizetool.c | 91 +-- app/tools/gimpcurvestool.c | 111 ++-- app/tools/gimphuesaturationtool.c | 157 ++--- app/tools/gimpimagemaptool.c | 20 +- app/tools/gimpimagemaptool.h | 4 +- app/tools/gimplevelstool.c | 215 ++++--- app/tools/gimppolygonselecttool.c | 598 ++++++++++++++++++ app/tools/gimppolygonselecttool.h | 62 ++ app/tools/gimpposterizetool.c | 77 ++- app/tools/gimpposterizetool.h | 8 +- app/tools/gimpthresholdtool.c | 46 +- app/widgets/gimphelp-ids.h | 1 + app/widgets/gimphistogramview.c | 20 +- libgimpconfig/gimpconfig-serialize.c | 7 +- libgimpwidgets/gimpstock.c | 3 + libgimpwidgets/gimpstock.h | 1 + menus/image-menu.xml.in | 1 + modules/controller_dx_dinput.c | 9 +- plug-ins/common/cubism.c | 47 +- plug-ins/common/lcms.c | 52 +- plug-ins/common/wmf.c | 3 +- plug-ins/gimpressionist/brush.c | 17 + plug-ins/gimpressionist/brush.h | 18 + plug-ins/gimpressionist/color.c | 18 + plug-ins/gimpressionist/color.h | 18 + plug-ins/gimpressionist/general.c | 18 + plug-ins/gimpressionist/general.h | 18 + plug-ins/gimpressionist/gimp.c | 377 ++++++----- plug-ins/gimpressionist/gimpressionist.c | 18 + plug-ins/gimpressionist/gimpressionist.h | 17 + plug-ins/gimpressionist/globals.c | 18 + plug-ins/gimpressionist/infile.h | 18 + plug-ins/gimpressionist/orientation.c | 18 + plug-ins/gimpressionist/orientation.h | 18 + plug-ins/gimpressionist/orientmap.c | 18 + plug-ins/gimpressionist/orientmap.h | 19 + plug-ins/gimpressionist/paper.c | 18 + plug-ins/gimpressionist/paper.h | 18 + plug-ins/gimpressionist/placement.c | 18 + plug-ins/gimpressionist/placement.h | 18 + plug-ins/gimpressionist/plasma.c | 18 + plug-ins/gimpressionist/ppmtool.c | 18 + plug-ins/gimpressionist/ppmtool.h | 18 + plug-ins/gimpressionist/presets.c | 18 + plug-ins/gimpressionist/presets.h | 18 + plug-ins/gimpressionist/preview.c | 130 ++-- plug-ins/gimpressionist/preview.h | 18 + plug-ins/gimpressionist/random.h | 18 + plug-ins/gimpressionist/repaint.c | 18 + plug-ins/gimpressionist/size.c | 18 + plug-ins/gimpressionist/size.h | 18 + plug-ins/gimpressionist/sizemap.c | 18 + plug-ins/gimpressionist/utils.c | 21 +- plug-ins/pygimp/gimpmodule.c | 48 +- plug-ins/pygimp/pygimp-colors.c | 13 +- po/ChangeLog | 5 + po/POTFILES.in | 3 + themes/Default/images/Makefile.am | 2 + .../tools/stock-tool-polygon-select-16.png | Bin 0 -> 398 bytes .../tools/stock-tool-polygon-select-22.png | Bin 0 -> 568 bytes 109 files changed, 3247 insertions(+), 1753 deletions(-) create mode 100644 app/gegl/gimpbrightnesscontrastconfig.c create mode 100644 app/gegl/gimpbrightnesscontrastconfig.h create mode 100644 app/gegl/gimpoperationpointfilter.c create mode 100644 app/gegl/gimpoperationpointfilter.h create mode 100644 app/gegl/gimpposterizeconfig.c create mode 100644 app/gegl/gimpposterizeconfig.h create mode 100644 app/tools/gimppolygonselecttool.c create mode 100644 app/tools/gimppolygonselecttool.h create mode 100644 themes/Default/images/tools/stock-tool-polygon-select-16.png create mode 100644 themes/Default/images/tools/stock-tool-polygon-select-22.png diff --git a/ChangeLog b/ChangeLog index ccc000ab4b..acc4225039 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-01-31 Bill Skaggs + + Merged 24710:24758 from trunk. + 2008-01-31 Bill Skaggs * app/core/gimp.c: fix merge error from previous commit diff --git a/app/base/tile-manager.c b/app/base/tile-manager.c index 1ff53eff4d..f0f90449ce 100644 --- a/app/base/tile-manager.c +++ b/app/base/tile-manager.c @@ -400,7 +400,7 @@ tile_manager_map_tile (TileManager *tm, if (G_UNLIKELY (num < 0)) { - g_warning ("%s: tile coordinates out of range.", G_GNUC_FUNCTION); + g_warning ("%s: tile coordinates out of range.", G_STRLOC); return; } @@ -427,13 +427,13 @@ tile_manager_map (TileManager *tm, if (G_UNLIKELY ((tile_num < 0) || (tile_num >= ntiles))) { - g_warning ("%s: tile out of range", G_GNUC_FUNCTION); + g_warning ("%s: tile out of range", G_STRLOC); return; } if (G_UNLIKELY (! tm->tiles)) { - g_warning ("%s: empty tile level - initializing", G_GNUC_FUNCTION); + g_warning ("%s: empty tile level - initializing", G_STRLOC); tm->tiles = g_new (Tile *, ntiles); tiles = tm->tiles; @@ -475,14 +475,14 @@ tile_manager_map (TileManager *tm, #endif if (G_UNLIKELY (! srctile->valid)) - g_warning("%s: srctile not validated yet! please report", G_GNUC_FUNCTION); + g_warning("%s: srctile not validated yet! please report", G_STRLOC); if (G_UNLIKELY ((*tile_ptr)->ewidth != srctile->ewidth || (*tile_ptr)->eheight != srctile->eheight || (*tile_ptr)->bpp != srctile->bpp)) { g_warning ("%s: nonconformant map (%p -> %p)", - G_GNUC_FUNCTION, srctile, *tile_ptr); + G_STRLOC, srctile, *tile_ptr); } tile_detach (*tile_ptr, tm, tile_num); @@ -645,7 +645,7 @@ tile_manager_get_tile_coordinates (TileManager *tm, if (G_UNLIKELY (tl == NULL)) { - g_warning ("%s: tile not attached to manager", G_GNUC_FUNCTION); + g_warning ("%s: tile not attached to manager", G_STRLOC); return; } @@ -689,7 +689,7 @@ tile_manager_map_over_tile (TileManager *tm, if (G_UNLIKELY (tl == NULL)) { - g_warning ("%s: tile not attached to manager", G_GNUC_FUNCTION); + g_warning ("%s: tile not attached to manager", G_STRLOC); return; } diff --git a/app/dialogs/keyboard-shortcuts-dialog.c b/app/dialogs/keyboard-shortcuts-dialog.c index 9b1244a016..131b1ea3ee 100644 --- a/app/dialogs/keyboard-shortcuts-dialog.c +++ b/app/dialogs/keyboard-shortcuts-dialog.c @@ -67,6 +67,8 @@ keyboard_shortcuts_dialog_new (Gimp *gimp) gtk_widget_show (vbox); scrolled_window = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), + GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0); diff --git a/app/display/gimpdisplayshell-autoscroll.c b/app/display/gimpdisplayshell-autoscroll.c index ceb5a5cf6e..9224a31088 100644 --- a/app/display/gimpdisplayshell-autoscroll.c +++ b/app/display/gimpdisplayshell-autoscroll.c @@ -153,7 +153,6 @@ gimp_display_shell_autoscroll_timeout (gpointer data) &x, &y, &width, &height); gimp_display_shell_snap_coords (shell, - &image_coords, &image_coords, x, y, width, height); } diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c index 58ae07b6c3..a2c0394713 100644 --- a/app/display/gimpdisplayshell-callbacks.c +++ b/app/display/gimpdisplayshell-callbacks.c @@ -663,7 +663,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas, &x, &y, &width, &height); if (gimp_display_shell_snap_coords (shell, - &image_coords, &image_coords, x, y, width, height)) { @@ -1087,7 +1086,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas, &x, &y, &width, &height); if (gimp_display_shell_snap_coords (shell, - &image_coords, &image_coords, x, y, width, height)) { @@ -1147,7 +1145,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas, &x, &y, &width, &height); gimp_display_shell_snap_coords (shell, - &image_coords, &image_coords, x, y, width, height); } @@ -1242,7 +1239,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas, &x, &y, &width, &height); gimp_display_shell_snap_coords (shell, - &image_coords, &image_coords, x, y, width, height); } diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index f841b9e043..37deaaff2c 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -1227,32 +1227,31 @@ gimp_display_shell_get_unit (GimpDisplayShell *shell) gboolean gimp_display_shell_snap_coords (GimpDisplayShell *shell, GimpCoords *coords, - GimpCoords *snapped_coords, gint snap_offset_x, gint snap_offset_y, gint snap_width, gint snap_height) { - gboolean snap_to_guides = FALSE; - gboolean snap_to_grid = FALSE; - gboolean snap_to_canvas = FALSE; - gboolean snap_to_vectors = FALSE; - gboolean snapped = FALSE; + GimpImage *image; + gboolean snap_to_guides = FALSE; + gboolean snap_to_grid = FALSE; + gboolean snap_to_canvas = FALSE; + gboolean snap_to_vectors = FALSE; + gboolean snapped = FALSE; g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE); g_return_val_if_fail (coords != NULL, FALSE); - g_return_val_if_fail (snapped_coords != NULL, FALSE); - *snapped_coords = *coords; + image = shell->display->image; if (gimp_display_shell_get_snap_to_guides (shell) && - gimp_image_get_guides (shell->display->image)) + gimp_image_get_guides (image)) { snap_to_guides = TRUE; } if (gimp_display_shell_get_snap_to_grid (shell) && - gimp_image_get_grid (shell->display->image)) + gimp_image_get_grid (image)) { snap_to_grid = TRUE; } @@ -1260,18 +1259,17 @@ gimp_display_shell_snap_coords (GimpDisplayShell *shell, snap_to_canvas = gimp_display_shell_get_snap_to_canvas (shell); if (gimp_display_shell_get_snap_to_vectors (shell) && - gimp_image_get_active_vectors (shell->display->image)) + gimp_image_get_active_vectors (image)) { snap_to_vectors = TRUE; } if (snap_to_guides || snap_to_grid || snap_to_canvas || snap_to_vectors) { - gdouble tx, ty; gint snap_distance; + gdouble tx, ty; - snap_distance = - GIMP_DISPLAY_CONFIG (shell->display->image->gimp->config)->snap_distance; + snap_distance = GIMP_DISPLAY_CONFIG (image->gimp->config)->snap_distance; if (snap_width > 0 && snap_height > 0) { @@ -1308,8 +1306,8 @@ gimp_display_shell_snap_coords (GimpDisplayShell *shell, if (snapped) { - snapped_coords->x = tx - snap_offset_x; - snapped_coords->y = ty - snap_offset_y; + coords->x = tx - snap_offset_x; + coords->y = ty - snap_offset_y; } } diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h index ea5337a122..9d80019737 100644 --- a/app/display/gimpdisplayshell.h +++ b/app/display/gimpdisplayshell.h @@ -221,7 +221,6 @@ GimpUnit gimp_display_shell_get_unit (GimpDisplayShell *shell); gboolean gimp_display_shell_snap_coords (GimpDisplayShell *shell, GimpCoords *coords, - GimpCoords *snapped_coords, gint snap_offset_x, gint snap_offset_y, gint snap_width, diff --git a/app/gegl/Makefile.am b/app/gegl/Makefile.am index 47c3b9b4bc..c3ad95e9f2 100644 --- a/app/gegl/Makefile.am +++ b/app/gegl/Makefile.am @@ -8,6 +8,8 @@ libappgegl_a_SOURCES = \ gimp-gegl-utils.c \ gimp-gegl-utils.h \ \ + gimpbrightnesscontrastconfig.c \ + gimpbrightnesscontrastconfig.h \ gimpcolorbalanceconfig.c \ gimpcolorbalanceconfig.h \ gimpcolorizeconfig.c \ @@ -18,6 +20,8 @@ libappgegl_a_SOURCES = \ gimphuesaturationconfig.h \ gimplevelsconfig.c \ gimplevelsconfig.h \ + gimpposterizeconfig.c \ + gimpposterizeconfig.h \ gimpthresholdconfig.c \ gimpthresholdconfig.h \ \ @@ -33,6 +37,8 @@ libappgegl_a_SOURCES = \ gimpoperationhuesaturation.h \ gimpoperationlevels.c \ gimpoperationlevels.h \ + gimpoperationpointfilter.c \ + gimpoperationpointfilter.h \ gimpoperationposterize.c \ gimpoperationposterize.h \ gimpoperationthreshold.c \ diff --git a/app/gegl/gegl-types.h b/app/gegl/gegl-types.h index c5f399d054..26804e7595 100644 --- a/app/gegl/gegl-types.h +++ b/app/gegl/gegl-types.h @@ -28,26 +28,29 @@ /* operations */ -typedef struct _GimpOperationColorBalance GimpOperationColorBalance; -typedef struct _GimpOperationColorize GimpOperationColorize; -typedef struct _GimpOperationCurves GimpOperationCurves; -typedef struct _GimpOperationDesaturate GimpOperationDesaturate; -typedef struct _GimpOperationHueSaturation GimpOperationHueSaturation; -typedef struct _GimpOperationLevels GimpOperationLevels; -typedef struct _GimpOperationPosterize GimpOperationPosterize; -typedef struct _GimpOperationThreshold GimpOperationThreshold; -typedef struct _GimpOperationTileSink GimpOperationTileSink; -typedef struct _GimpOperationTileSource GimpOperationTileSource; +typedef struct _GimpOperationColorBalance GimpOperationColorBalance; +typedef struct _GimpOperationColorize GimpOperationColorize; +typedef struct _GimpOperationCurves GimpOperationCurves; +typedef struct _GimpOperationDesaturate GimpOperationDesaturate; +typedef struct _GimpOperationHueSaturation GimpOperationHueSaturation; +typedef struct _GimpOperationLevels GimpOperationLevels; +typedef struct _GimpOperationPointFilter GimpOperationPointFilter; +typedef struct _GimpOperationPosterize GimpOperationPosterize; +typedef struct _GimpOperationThreshold GimpOperationThreshold; +typedef struct _GimpOperationTileSink GimpOperationTileSink; +typedef struct _GimpOperationTileSource GimpOperationTileSource; /* operation config objects */ -typedef struct _GimpColorBalanceConfig GimpColorBalanceConfig; -typedef struct _GimpColorizeConfig GimpColorizeConfig; -typedef struct _GimpCurvesConfig GimpCurvesConfig; -typedef struct _GimpHueSaturationConfig GimpHueSaturationConfig; -typedef struct _GimpLevelsConfig GimpLevelsConfig; -typedef struct _GimpThresholdConfig GimpThresholdConfig; +typedef struct _GimpBrightnessContrastConfig GimpBrightnessContrastConfig; +typedef struct _GimpColorBalanceConfig GimpColorBalanceConfig; +typedef struct _GimpColorizeConfig GimpColorizeConfig; +typedef struct _GimpCurvesConfig GimpCurvesConfig; +typedef struct _GimpHueSaturationConfig GimpHueSaturationConfig; +typedef struct _GimpLevelsConfig GimpLevelsConfig; +typedef struct _GimpPosterizeConfig GimpPosterizeConfig; +typedef struct _GimpThresholdConfig GimpThresholdConfig; #endif /* __GEGL_TYPES_H__ */ diff --git a/app/gegl/gimpbrightnesscontrastconfig.c b/app/gegl/gimpbrightnesscontrastconfig.c new file mode 100644 index 0000000000..8c03f7c236 --- /dev/null +++ b/app/gegl/gimpbrightnesscontrastconfig.c @@ -0,0 +1,159 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpbrightnesscontrastconfig.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 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 + +#include "libgimpconfig/gimpconfig.h" + +#include "gegl-types.h" + +#include "gimpbrightnesscontrastconfig.h" + + +enum +{ + PROP_0, + PROP_BRIGHTNESS, + PROP_CONTRAST +}; + + +static void gimp_brightness_contrast_config_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); +static void gimp_brightness_contrast_config_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); + + +G_DEFINE_TYPE_WITH_CODE (GimpBrightnessContrastConfig, + gimp_brightness_contrast_config, + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, NULL)) + +#define parent_class gimp_brightness_contrast_config_parent_class + + +static void +gimp_brightness_contrast_config_class_init (GimpBrightnessContrastConfigClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->set_property = gimp_brightness_contrast_config_set_property; + object_class->get_property = gimp_brightness_contrast_config_get_property; + + g_object_class_install_property (object_class, PROP_BRIGHTNESS, + g_param_spec_double ("brightness", + "Brightness", + "Brightness", + -1.0, 1.0, 0.0, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT)); + + g_object_class_install_property (object_class, PROP_CONTRAST, + g_param_spec_double ("contrast", + "Contrast", + "Contrast", + -1.0, 1.0, 0.0, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT)); +} + +static void +gimp_brightness_contrast_config_init (GimpBrightnessContrastConfig *self) +{ +} + +static void +gimp_brightness_contrast_config_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GimpBrightnessContrastConfig *self = GIMP_BRIGHTNESS_CONTRAST_CONFIG (object); + + switch (property_id) + { + case PROP_BRIGHTNESS: + g_value_set_double (value, self->brightness); + break; + + case PROP_CONTRAST: + g_value_set_double (value, self->contrast); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gimp_brightness_contrast_config_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GimpBrightnessContrastConfig *self = GIMP_BRIGHTNESS_CONTRAST_CONFIG (object); + + switch (property_id) + { + case PROP_BRIGHTNESS: + self->brightness = g_value_get_double (value); + break; + + case PROP_CONTRAST: + self->contrast = g_value_get_double (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + +/* public functions */ + +void +gimp_brightness_contrast_config_set_node (GimpBrightnessContrastConfig *config, + GeglNode *node) +{ + gdouble brightness; + gdouble contrast; + + g_return_if_fail (GIMP_IS_BRIGHTNESS_CONTRAST_CONFIG (config)); + g_return_if_fail (GEGL_IS_NODE (node)); + + brightness = config->brightness / 2.0; + contrast = (config->contrast < 0 ? + (config->contrast + 1.0) : + config->contrast * 4.0 + 1.0); + + gegl_node_set (node, + "brightness", brightness, + "contrast", contrast, + NULL); +} diff --git a/app/gegl/gimpbrightnesscontrastconfig.h b/app/gegl/gimpbrightnesscontrastconfig.h new file mode 100644 index 0000000000..3558915817 --- /dev/null +++ b/app/gegl/gimpbrightnesscontrastconfig.h @@ -0,0 +1,56 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpbrightnesscontrastconfig.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 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_BRIGHTNESS_CONTRAST_CONFIG_H__ +#define __GIMP_BRIGHTNESS_CONTRAST_CONFIG_H__ + + +#define GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG (gimp_brightness_contrast_config_get_type ()) +#define GIMP_BRIGHTNESS_CONTRAST_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG, GimpBrightnessContrastConfig)) +#define GIMP_BRIGHTNESS_CONTRAST_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG, GimpBrightnessContrastConfigClass)) +#define GIMP_IS_BRIGHTNESS_CONTRAST_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG)) +#define GIMP_IS_BRIGHTNESS_CONTRAST_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG)) +#define GIMP_BRIGHTNESS_CONTRAST_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG, GimpBrightnessContrastConfigClass)) + + +typedef struct _GimpBrightnessContrastConfigClass GimpBrightnessContrastConfigClass; + +struct _GimpBrightnessContrastConfig +{ + GObject parent_instance; + + gdouble brightness; + gdouble contrast; +}; + +struct _GimpBrightnessContrastConfigClass +{ + GObjectClass parent_class; +}; + + +GType gimp_brightness_contrast_config_get_type (void) G_GNUC_CONST; + +void gimp_brightness_contrast_config_set_node (GimpBrightnessContrastConfig *config, + GeglNode *node); + + +#endif /* __GIMP_BRIGHTNESS_CONTRAST_CONFIG_H__ */ diff --git a/app/gegl/gimpcolorbalanceconfig.c b/app/gegl/gimpcolorbalanceconfig.c index 5bd673ecf0..6fe51c277d 100644 --- a/app/gegl/gimpcolorbalanceconfig.c +++ b/app/gegl/gimpcolorbalanceconfig.c @@ -25,6 +25,7 @@ #include "libgimpcolor/gimpcolor.h" #include "libgimpmath/gimpmath.h" +#include "libgimpconfig/gimpconfig.h" #include "gegl-types.h" @@ -45,6 +46,8 @@ enum }; +static void gimp_color_balance_config_iface_init (GimpConfigInterface *iface); + static void gimp_color_balance_config_get_property (GObject *object, guint property_id, GValue *value, @@ -54,15 +57,19 @@ static void gimp_color_balance_config_set_property (GObject *object, const GValue *value, GParamSpec *pspec); +static void gimp_color_balance_config_reset (GimpConfig *config); -G_DEFINE_TYPE (GimpColorBalanceConfig, gimp_color_balance_config, - G_TYPE_OBJECT) + +G_DEFINE_TYPE_WITH_CODE (GimpColorBalanceConfig, gimp_color_balance_config, + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, + gimp_color_balance_config_iface_init)) #define parent_class gimp_color_balance_config_parent_class static void -gimp_color_balance_config_class_init (GimpColorBalanceConfigClass * klass) +gimp_color_balance_config_class_init (GimpColorBalanceConfigClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -98,7 +105,7 @@ gimp_color_balance_config_class_init (GimpColorBalanceConfigClass * klass) g_param_spec_double ("yellow-blue", "Yellow-Blue", "Yellow-Blue", - -1.0, 1.0, 1.0, + -1.0, 1.0, 0.0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); @@ -111,10 +118,16 @@ gimp_color_balance_config_class_init (GimpColorBalanceConfigClass * klass) G_PARAM_CONSTRUCT)); } +static void +gimp_color_balance_config_iface_init (GimpConfigInterface *iface) +{ + iface->reset = gimp_color_balance_config_reset; +} + static void gimp_color_balance_config_init (GimpColorBalanceConfig *self) { - gimp_color_balance_config_reset (self); + gimp_config_reset (GIMP_CONFIG (self)); } static void @@ -165,6 +178,9 @@ gimp_color_balance_config_set_property (GObject *object, { case PROP_RANGE: self->range = g_value_get_enum (value); + g_object_notify (object, "cyan-red"); + g_object_notify (object, "magenta-green"); + g_object_notify (object, "yellow-blue"); break; case PROP_CYAN_RED: @@ -189,35 +205,41 @@ gimp_color_balance_config_set_property (GObject *object, } } +static void +gimp_color_balance_config_reset (GimpConfig *config) +{ + GimpColorBalanceConfig *cb_config = GIMP_COLOR_BALANCE_CONFIG (config); + GimpTransferMode range; + + g_object_freeze_notify (G_OBJECT (config)); + + for (range = GIMP_SHADOWS; range <= GIMP_HIGHLIGHTS; range++) + { + cb_config->range = range; + gimp_color_balance_config_reset_range (cb_config); + } + + gimp_config_reset_property (G_OBJECT (config), "range"); + gimp_config_reset_property (G_OBJECT (config), "preserve-luminosity"); + + g_object_thaw_notify (G_OBJECT (config)); +} + /* public functions */ void -gimp_color_balance_config_reset (GimpColorBalanceConfig *config) -{ - GimpTransferMode range; - - g_return_if_fail (GIMP_IS_COLOR_BALANCE_CONFIG (config)); - - config->range = GIMP_MIDTONES; - - for (range = GIMP_SHADOWS; range <= GIMP_HIGHLIGHTS; range++) - { - gimp_color_balance_config_reset_range (config, range); - } - - config->preserve_luminosity = TRUE; -} - -void -gimp_color_balance_config_reset_range (GimpColorBalanceConfig *config, - GimpTransferMode range) +gimp_color_balance_config_reset_range (GimpColorBalanceConfig *config) { g_return_if_fail (GIMP_IS_COLOR_BALANCE_CONFIG (config)); - config->cyan_red[range] = 0.0; - config->magenta_green[range] = 0.0; - config->yellow_blue[range] = 0.0; + g_object_freeze_notify (G_OBJECT (config)); + + gimp_config_reset_property (G_OBJECT (config), "cyan-red"); + gimp_config_reset_property (G_OBJECT (config), "magenta-green"); + gimp_config_reset_property (G_OBJECT (config), "yellow-blue"); + + g_object_thaw_notify (G_OBJECT (config)); } diff --git a/app/gegl/gimpcolorbalanceconfig.h b/app/gegl/gimpcolorbalanceconfig.h index 9461e127e1..28dc10cd19 100644 --- a/app/gegl/gimpcolorbalanceconfig.h +++ b/app/gegl/gimpcolorbalanceconfig.h @@ -54,9 +54,7 @@ struct _GimpColorBalanceConfigClass GType gimp_color_balance_config_get_type (void) G_GNUC_CONST; -void gimp_color_balance_config_reset (GimpColorBalanceConfig *config); -void gimp_color_balance_config_reset_range (GimpColorBalanceConfig *config, - GimpTransferMode range); +void gimp_color_balance_config_reset_range (GimpColorBalanceConfig *config); /* temp cruft */ void gimp_color_balance_config_to_cruft (GimpColorBalanceConfig *config, diff --git a/app/gegl/gimpcolorizeconfig.c b/app/gegl/gimpcolorizeconfig.c index 5e6a817541..51977271be 100644 --- a/app/gegl/gimpcolorizeconfig.c +++ b/app/gegl/gimpcolorizeconfig.c @@ -23,6 +23,8 @@ #include +#include "libgimpconfig/gimpconfig.h" + #include "gegl-types.h" /* temp cruft */ @@ -50,13 +52,15 @@ static void gimp_colorize_config_set_property (GObject *object, GParamSpec *pspec); -G_DEFINE_TYPE (GimpColorizeConfig, gimp_colorize_config, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_CODE (GimpColorizeConfig, gimp_colorize_config, + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, NULL)) #define parent_class gimp_colorize_config_parent_class static void -gimp_colorize_config_class_init (GimpColorizeConfigClass * klass) +gimp_colorize_config_class_init (GimpColorizeConfigClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -150,19 +154,6 @@ gimp_colorize_config_set_property (GObject *object, } -/* public functions */ - -void -gimp_colorize_config_reset (GimpColorizeConfig *config) -{ - g_return_if_fail (GIMP_IS_COLORIZE_CONFIG (config)); - - config->hue = 0.5; - config->saturation = 0.5; - config->lightness = 0.0; -} - - /* temp cruft */ void diff --git a/app/gegl/gimpcolorizeconfig.h b/app/gegl/gimpcolorizeconfig.h index 659ade03e6..ee0bcc6a45 100644 --- a/app/gegl/gimpcolorizeconfig.h +++ b/app/gegl/gimpcolorizeconfig.h @@ -50,8 +50,6 @@ struct _GimpColorizeConfigClass GType gimp_colorize_config_get_type (void) G_GNUC_CONST; -void gimp_colorize_config_reset (GimpColorizeConfig *config); - /* temp cruft */ void gimp_colorize_config_to_cruft (GimpColorizeConfig *config, Colorize *cruft); diff --git a/app/gegl/gimpcurvesconfig.c b/app/gegl/gimpcurvesconfig.c index c745853d16..7f127101c1 100644 --- a/app/gegl/gimpcurvesconfig.c +++ b/app/gegl/gimpcurvesconfig.c @@ -24,6 +24,7 @@ #include #include +#include #include "libgimpcolor/gimpcolor.h" #include "libgimpmath/gimpmath.h" @@ -49,24 +50,34 @@ enum }; -static void gimp_curves_config_finalize (GObject *object); -static void gimp_curves_config_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); -static void gimp_curves_config_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); +static void gimp_curves_config_iface_init (GimpConfigInterface *iface); + +static void gimp_curves_config_finalize (GObject *object); +static void gimp_curves_config_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); +static void gimp_curves_config_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); + +static void gimp_curves_config_reset (GimpConfig *config); + +static void gimp_curves_config_curve_dirty (GimpCurve *curve, + GimpCurvesConfig *config); -G_DEFINE_TYPE (GimpCurvesConfig, gimp_curves_config, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_CODE (GimpCurvesConfig, gimp_curves_config, + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, + gimp_curves_config_iface_init)) #define parent_class gimp_curves_config_parent_class static void -gimp_curves_config_class_init (GimpCurvesConfigClass * klass) +gimp_curves_config_class_init (GimpCurvesConfigClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -91,6 +102,12 @@ gimp_curves_config_class_init (GimpCurvesConfigClass * klass) G_PARAM_READWRITE)); } +static void +gimp_curves_config_iface_init (GimpConfigInterface *iface) +{ + iface->reset = gimp_curves_config_reset; +} + static void gimp_curves_config_init (GimpCurvesConfig *self) { @@ -101,9 +118,13 @@ gimp_curves_config_init (GimpCurvesConfig *self) channel++) { self->curve[channel] = GIMP_CURVE (gimp_curve_new ("curves config")); + + g_signal_connect_object (self->curve[channel], "dirty", + G_CALLBACK (gimp_curves_config_curve_dirty), + self, 0); } - gimp_curves_config_reset (self); + gimp_config_reset (GIMP_CONFIG (self)); } static void @@ -162,6 +183,7 @@ gimp_curves_config_set_property (GObject *object, { case PROP_CHANNEL: self->channel = g_value_get_enum (value); + g_object_notify (object, "curve"); break; case PROP_CURVE: @@ -176,33 +198,43 @@ gimp_curves_config_set_property (GObject *object, } } - -/* public functions */ - -void -gimp_curves_config_reset (GimpCurvesConfig *config) +static void +gimp_curves_config_reset (GimpConfig *config) { - GimpHistogramChannel channel; + GimpCurvesConfig *c_config = GIMP_CURVES_CONFIG (config); + GimpHistogramChannel channel; - g_return_if_fail (GIMP_IS_CURVES_CONFIG (config)); - - config->channel = GIMP_HISTOGRAM_VALUE; + g_object_freeze_notify (G_OBJECT (config)); for (channel = GIMP_HISTOGRAM_VALUE; channel <= GIMP_HISTOGRAM_ALPHA; channel++) { - gimp_curve_reset (config->curve[channel], FALSE); + c_config->channel = channel; + gimp_curves_config_reset_channel (c_config); } + + gimp_config_reset_property (G_OBJECT (config), "channel"); + + g_object_thaw_notify (G_OBJECT (config)); } +static void +gimp_curves_config_curve_dirty (GimpCurve *curve, + GimpCurvesConfig *config) +{ + g_object_notify (G_OBJECT (config), "curve"); +} + + +/* public functions */ + void -gimp_curves_config_reset_channel (GimpCurvesConfig *config, - GimpHistogramChannel channel) +gimp_curves_config_reset_channel (GimpCurvesConfig *config) { g_return_if_fail (GIMP_IS_CURVES_CONFIG (config)); - gimp_curve_reset (config->curve[channel], FALSE); + gimp_curve_reset (config->curve[config->channel], TRUE); } gboolean @@ -245,6 +277,8 @@ gimp_curves_config_load_cruft (GimpCurvesConfig *config, } } + g_object_freeze_notify (G_OBJECT (config)); + for (i = 0; i < 5; i++) { GimpCurve *curve = config->curve[i]; @@ -259,6 +293,8 @@ gimp_curves_config_load_cruft (GimpCurvesConfig *config, gimp_data_thaw (GIMP_DATA (curve)); } + g_object_thaw_notify (G_OBJECT (config)); + return TRUE; } diff --git a/app/gegl/gimpcurvesconfig.h b/app/gegl/gimpcurvesconfig.h index c4baedf5f7..049dd5b8b4 100644 --- a/app/gegl/gimpcurvesconfig.h +++ b/app/gegl/gimpcurvesconfig.h @@ -55,21 +55,19 @@ struct _GimpCurvesConfigClass GType gimp_curves_config_get_type (void) G_GNUC_CONST; -void gimp_curves_config_reset (GimpCurvesConfig *config); -void gimp_curves_config_reset_channel (GimpCurvesConfig *config, - GimpHistogramChannel channel); +void gimp_curves_config_reset_channel (GimpCurvesConfig *config); -gboolean gimp_curves_config_load_cruft (GimpCurvesConfig *config, - gpointer fp, - GError **error); -gboolean gimp_curves_config_save_cruft (GimpCurvesConfig *config, - gpointer fp); +gboolean gimp_curves_config_load_cruft (GimpCurvesConfig *config, + gpointer fp, + GError **error); +gboolean gimp_curves_config_save_cruft (GimpCurvesConfig *config, + gpointer fp); /* temp cruft */ -void gimp_curves_config_to_cruft (GimpCurvesConfig *config, - Curves *cruft, - gboolean is_color); +void gimp_curves_config_to_cruft (GimpCurvesConfig *config, + Curves *cruft, + gboolean is_color); #endif /* __GIMP_CURVES_CONFIG_H__ */ diff --git a/app/gegl/gimphuesaturationconfig.c b/app/gegl/gimphuesaturationconfig.c index 31e34893af..26f6d6be17 100644 --- a/app/gegl/gimphuesaturationconfig.c +++ b/app/gegl/gimphuesaturationconfig.c @@ -23,6 +23,8 @@ #include +#include "libgimpconfig/gimpconfig.h" + #include "gegl-types.h" /* temp cruft */ @@ -42,6 +44,8 @@ enum }; +static void gimp_hue_saturation_config_iface_init (GimpConfigInterface *iface); + static void gimp_hue_saturation_config_get_property (GObject *object, guint property_id, GValue *value, @@ -51,15 +55,19 @@ static void gimp_hue_saturation_config_set_property (GObject *object, const GValue *value, GParamSpec *pspec); +static void gimp_hue_saturation_config_reset (GimpConfig *config); -G_DEFINE_TYPE (GimpHueSaturationConfig, gimp_hue_saturation_config, - G_TYPE_OBJECT) + +G_DEFINE_TYPE_WITH_CODE (GimpHueSaturationConfig, gimp_hue_saturation_config, + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, + gimp_hue_saturation_config_iface_init)) #define parent_class gimp_hue_saturation_config_parent_class static void -gimp_hue_saturation_config_class_init (GimpHueSaturationConfigClass * klass) +gimp_hue_saturation_config_class_init (GimpHueSaturationConfigClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -108,10 +116,16 @@ gimp_hue_saturation_config_class_init (GimpHueSaturationConfigClass * klass) G_PARAM_CONSTRUCT)); } +static void +gimp_hue_saturation_config_iface_init (GimpConfigInterface *iface) +{ + iface->reset = gimp_hue_saturation_config_reset; +} + static void gimp_hue_saturation_config_init (GimpHueSaturationConfig *self) { - gimp_hue_saturation_config_reset (self); + gimp_config_reset (GIMP_CONFIG (self)); } static void @@ -162,6 +176,9 @@ gimp_hue_saturation_config_set_property (GObject *object, { case PROP_RANGE: self->range = g_value_get_enum (value); + g_object_notify (object, "hue"); + g_object_notify (object, "saturation"); + g_object_notify (object, "lightness"); break; case PROP_HUE: @@ -186,35 +203,41 @@ gimp_hue_saturation_config_set_property (GObject *object, } } +static void +gimp_hue_saturation_config_reset (GimpConfig *config) +{ + GimpHueSaturationConfig *hs_config = GIMP_HUE_SATURATION_CONFIG (config); + GimpHueRange range; + + g_object_freeze_notify (G_OBJECT (config)); + + for (range = GIMP_ALL_HUES; range <= GIMP_MAGENTA_HUES; range++) + { + hs_config->range = range; + gimp_hue_saturation_config_reset_range (hs_config); + } + + gimp_config_reset_property (G_OBJECT (config), "range"); + gimp_config_reset_property (G_OBJECT (config), "overlap"); + + g_object_thaw_notify (G_OBJECT (config)); +} + /* public functions */ void -gimp_hue_saturation_config_reset (GimpHueSaturationConfig *config) -{ - GimpHueRange range; - - g_return_if_fail (GIMP_IS_HUE_SATURATION_CONFIG (config)); - - config->range = GIMP_ALL_HUES; - - for (range = GIMP_ALL_HUES; range <= GIMP_MAGENTA_HUES; range++) - { - gimp_hue_saturation_config_reset_range (config, range); - } - - config->overlap = 0.0; -} - -void -gimp_hue_saturation_config_reset_range (GimpHueSaturationConfig *config, - GimpHueRange range) +gimp_hue_saturation_config_reset_range (GimpHueSaturationConfig *config) { g_return_if_fail (GIMP_IS_HUE_SATURATION_CONFIG (config)); - config->hue[range] = 0.0; - config->saturation[range] = 0.0; - config->lightness[range] = 0.0; + g_object_freeze_notify (G_OBJECT (config)); + + gimp_config_reset_property (G_OBJECT (config), "hue"); + gimp_config_reset_property (G_OBJECT (config), "saturation"); + gimp_config_reset_property (G_OBJECT (config), "lightness"); + + g_object_thaw_notify (G_OBJECT (config)); } diff --git a/app/gegl/gimphuesaturationconfig.h b/app/gegl/gimphuesaturationconfig.h index 086fce7207..bba62ef767 100644 --- a/app/gegl/gimphuesaturationconfig.h +++ b/app/gegl/gimphuesaturationconfig.h @@ -54,9 +54,7 @@ struct _GimpHueSaturationConfigClass GType gimp_hue_saturation_config_get_type (void) G_GNUC_CONST; -void gimp_hue_saturation_config_reset (GimpHueSaturationConfig *config); -void gimp_hue_saturation_config_reset_range (GimpHueSaturationConfig *config, - GimpHueRange range); +void gimp_hue_saturation_config_reset_range (GimpHueSaturationConfig *config); /* temp cruft */ void gimp_hue_saturation_config_to_cruft (GimpHueSaturationConfig *config, diff --git a/app/gegl/gimplevelsconfig.c b/app/gegl/gimplevelsconfig.c index 1eb7b52520..1c2941f8f1 100644 --- a/app/gegl/gimplevelsconfig.c +++ b/app/gegl/gimplevelsconfig.c @@ -55,6 +55,8 @@ enum }; +static void gimp_levels_config_iface_init (GimpConfigInterface *iface); + static void gimp_levels_config_get_property (GObject *object, guint property_id, GValue *value, @@ -64,14 +66,19 @@ static void gimp_levels_config_set_property (GObject *object, const GValue *value, GParamSpec *pspec); +static void gimp_levels_config_reset (GimpConfig *config); -G_DEFINE_TYPE (GimpLevelsConfig, gimp_levels_config, G_TYPE_OBJECT) + +G_DEFINE_TYPE_WITH_CODE (GimpLevelsConfig, gimp_levels_config, + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, + gimp_levels_config_iface_init)) #define parent_class gimp_levels_config_parent_class static void -gimp_levels_config_class_init (GimpLevelsConfigClass * klass) +gimp_levels_config_class_init (GimpLevelsConfigClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -128,10 +135,16 @@ gimp_levels_config_class_init (GimpLevelsConfigClass * klass) G_PARAM_CONSTRUCT)); } +static void +gimp_levels_config_iface_init (GimpConfigInterface *iface) +{ + iface->reset = gimp_levels_config_reset; +} + static void gimp_levels_config_init (GimpLevelsConfig *self) { - gimp_levels_config_reset (self); + gimp_config_reset (GIMP_CONFIG (self)); } static void @@ -186,6 +199,11 @@ gimp_levels_config_set_property (GObject *object, { case PROP_CHANNEL: self->channel = g_value_get_enum (value); + g_object_notify (object, "gamma"); + g_object_notify (object, "low-input"); + g_object_notify (object, "high-input"); + g_object_notify (object, "low-output"); + g_object_notify (object, "high-output"); break; case PROP_GAMMA: @@ -214,64 +232,80 @@ gimp_levels_config_set_property (GObject *object, } } - -/* public functions */ - -void -gimp_levels_config_reset (GimpLevelsConfig *config) +static void +gimp_levels_config_reset (GimpConfig *config) { - GimpHistogramChannel channel; + GimpLevelsConfig *l_config = GIMP_LEVELS_CONFIG (config); + GimpHistogramChannel channel; - g_return_if_fail (GIMP_IS_LEVELS_CONFIG (config)); - - config->channel = GIMP_HISTOGRAM_VALUE; + g_object_freeze_notify (G_OBJECT (config)); for (channel = GIMP_HISTOGRAM_VALUE; channel <= GIMP_HISTOGRAM_ALPHA; channel++) { - gimp_levels_config_reset_channel (config, channel); + l_config->channel = channel; + gimp_levels_config_reset_channel (l_config); } + + gimp_config_reset_property (G_OBJECT (config), "channel"); + + g_object_thaw_notify (G_OBJECT (config)); } + +/* public functions */ + void -gimp_levels_config_reset_channel (GimpLevelsConfig *config, - GimpHistogramChannel channel) +gimp_levels_config_reset_channel (GimpLevelsConfig *config) { g_return_if_fail (GIMP_IS_LEVELS_CONFIG (config)); - config->gamma[channel] = 1.0; - config->low_input[channel] = 0.0; - config->high_input[channel] = 1.0; - config->low_output[channel] = 0.0; - config->high_output[channel] = 1.0; + g_object_freeze_notify (G_OBJECT (config)); + + gimp_config_reset_property (G_OBJECT (config), "gamma"); + gimp_config_reset_property (G_OBJECT (config), "low-input"); + gimp_config_reset_property (G_OBJECT (config), "high-input"); + gimp_config_reset_property (G_OBJECT (config), "low-output"); + gimp_config_reset_property (G_OBJECT (config), "high-output"); + + g_object_thaw_notify (G_OBJECT (config)); } void -gimp_levels_config_stretch (GimpLevelsConfig *config, - GimpHistogram *histogram, - gboolean is_color) +gimp_levels_config_stretch (GimpLevelsConfig *config, + GimpHistogram *histogram, + gboolean is_color) { g_return_if_fail (GIMP_IS_LEVELS_CONFIG (config)); g_return_if_fail (histogram != NULL); + g_object_freeze_notify (G_OBJECT (config)); + if (is_color) { GimpHistogramChannel channel; - /* Set the overall value to defaults */ - gimp_levels_config_reset_channel (config, GIMP_HISTOGRAM_VALUE); + /* Set the overall value to defaults */ + channel = config->channel; + config->channel = GIMP_HISTOGRAM_VALUE; + gimp_levels_config_reset_channel (config); + config->channel = channel; for (channel = GIMP_HISTOGRAM_RED; channel <= GIMP_HISTOGRAM_BLUE; channel++) - gimp_levels_config_stretch_channel (config, histogram, channel); + { + gimp_levels_config_stretch_channel (config, histogram, channel); + } } else { gimp_levels_config_stretch_channel (config, histogram, GIMP_HISTOGRAM_VALUE); } + + g_object_thaw_notify (G_OBJECT (config)); } void @@ -285,6 +319,8 @@ gimp_levels_config_stretch_channel (GimpLevelsConfig *config, g_return_if_fail (GIMP_IS_LEVELS_CONFIG (config)); g_return_if_fail (histogram != NULL); + g_object_freeze_notify (G_OBJECT (config)); + config->gamma[channel] = 1.0; config->low_output[channel] = 0.0; config->high_output[channel] = 1.0; @@ -340,6 +376,14 @@ gimp_levels_config_stretch_channel (GimpLevelsConfig *config, } } } + + g_object_notify (G_OBJECT (config), "gamma"); + g_object_notify (G_OBJECT (config), "low-input"); + g_object_notify (G_OBJECT (config), "high-input"); + g_object_notify (G_OBJECT (config), "low-output"); + g_object_notify (G_OBJECT (config), "high-output"); + + g_object_thaw_notify (G_OBJECT (config)); } static gdouble @@ -379,13 +423,22 @@ gimp_levels_config_adjust_by_colors (GimpLevelsConfig *config, { g_return_if_fail (GIMP_IS_LEVELS_CONFIG (config)); + g_object_freeze_notify (G_OBJECT (config)); + if (black) - config->low_input[channel] = gimp_levels_config_input_from_color (channel, - black); + { + config->low_input[channel] = gimp_levels_config_input_from_color (channel, + black); + g_object_notify (G_OBJECT (config), "low-input"); + } + if (white) - config->high_input[channel] = gimp_levels_config_input_from_color (channel, - white); + { + config->high_input[channel] = gimp_levels_config_input_from_color (channel, + white); + g_object_notify (G_OBJECT (config), "high-input"); + } if (gray) { @@ -417,7 +470,10 @@ gimp_levels_config_adjust_by_colors (GimpLevelsConfig *config, /* Map selected color to corresponding lightness */ config->gamma[channel] = log (inten) / log (out_light); + g_object_notify (G_OBJECT (config), "gamma"); } + + g_object_thaw_notify (G_OBJECT (config)); } gboolean @@ -468,6 +524,8 @@ gimp_levels_config_load_cruft (GimpLevelsConfig *config, goto error; } + g_object_freeze_notify (G_OBJECT (config)); + for (i = 0; i < 5; i++) { config->low_input[i] = low_input[i] / 255.0; @@ -477,6 +535,14 @@ gimp_levels_config_load_cruft (GimpLevelsConfig *config, config->gamma[i] = gamma[i]; } + g_object_notify (G_OBJECT (config), "gamma"); + g_object_notify (G_OBJECT (config), "low-input"); + g_object_notify (G_OBJECT (config), "high-input"); + g_object_notify (G_OBJECT (config), "low-output"); + g_object_notify (G_OBJECT (config), "high-output"); + + g_object_thaw_notify (G_OBJECT (config)); + return TRUE; error: diff --git a/app/gegl/gimplevelsconfig.h b/app/gegl/gimplevelsconfig.h index 86c2a84c00..92c796bbdb 100644 --- a/app/gegl/gimplevelsconfig.h +++ b/app/gegl/gimplevelsconfig.h @@ -56,9 +56,7 @@ struct _GimpLevelsConfigClass GType gimp_levels_config_get_type (void) G_GNUC_CONST; -void gimp_levels_config_reset (GimpLevelsConfig *config); -void gimp_levels_config_reset_channel (GimpLevelsConfig *config, - GimpHistogramChannel channel); +void gimp_levels_config_reset_channel (GimpLevelsConfig *config); void gimp_levels_config_stretch (GimpLevelsConfig *config, GimpHistogram *histogram, diff --git a/app/gegl/gimpoperationcolorbalance.c b/app/gegl/gimpoperationcolorbalance.c index 3ea73824ce..f9c837a275 100644 --- a/app/gegl/gimpoperationcolorbalance.c +++ b/app/gegl/gimpoperationcolorbalance.c @@ -32,51 +32,34 @@ #include "gimpoperationcolorbalance.h" -enum -{ - PROP_0, - PROP_CONFIG -}; - - -static void gimp_operation_color_balance_finalize (GObject *object); -static void gimp_operation_color_balance_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); -static void gimp_operation_color_balance_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); - -static gboolean gimp_operation_color_balance_process (GeglOperation *operation, - void *in_buf, - void *out_buf, - glong samples); +static gboolean gimp_operation_color_balance_process (GeglOperation *operation, + void *in_buf, + void *out_buf, + glong samples); G_DEFINE_TYPE (GimpOperationColorBalance, gimp_operation_color_balance, - GEGL_TYPE_OPERATION_POINT_FILTER) + GIMP_TYPE_OPERATION_POINT_FILTER) #define parent_class gimp_operation_color_balance_parent_class static void -gimp_operation_color_balance_class_init (GimpOperationColorBalanceClass * klass) +gimp_operation_color_balance_class_init (GimpOperationColorBalanceClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass); GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass); - object_class->finalize = gimp_operation_color_balance_finalize; - object_class->set_property = gimp_operation_color_balance_set_property; - object_class->get_property = gimp_operation_color_balance_get_property; + object_class->set_property = gimp_operation_point_filter_set_property; + object_class->get_property = gimp_operation_point_filter_get_property; + + operation_class->name = "gimp-color-balance"; point_class->process = gimp_operation_color_balance_process; - gegl_operation_class_set_name (operation_class, "gimp-color-balance"); - - g_object_class_install_property (object_class, PROP_CONFIG, + g_object_class_install_property (object_class, + GIMP_OPERATION_POINT_FILTER_PROP_CONFIG, g_param_spec_object ("config", "Config", "The config object", @@ -90,62 +73,6 @@ gimp_operation_color_balance_init (GimpOperationColorBalance *self) { } -static void -gimp_operation_color_balance_finalize (GObject *object) -{ - GimpOperationColorBalance *self = GIMP_OPERATION_COLOR_BALANCE (object); - - if (self->config) - { - g_object_unref (self->config); - self->config = NULL; - } - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -gimp_operation_color_balance_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - GimpOperationColorBalance *self = GIMP_OPERATION_COLOR_BALANCE (object); - - switch (property_id) - { - case PROP_CONFIG: - g_value_set_object (value, self->config); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -gimp_operation_color_balance_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GimpOperationColorBalance *self = GIMP_OPERATION_COLOR_BALANCE (object); - - switch (property_id) - { - case PROP_CONFIG: - if (self->config) - g_object_unref (self->config); - self->config = g_value_dup_object (value); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - static inline gfloat gimp_operation_color_balance_map (gfloat value, gdouble shadows, @@ -188,16 +115,15 @@ gimp_operation_color_balance_process (GeglOperation *operation, void *out_buf, glong samples) { - GimpOperationColorBalance *self = GIMP_OPERATION_COLOR_BALANCE (operation); - GimpColorBalanceConfig *config = self->config; - gfloat *src = in_buf; - gfloat *dest = out_buf; - glong sample; + GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation); + GimpColorBalanceConfig *config = GIMP_COLOR_BALANCE_CONFIG (point->config); + gfloat *src = in_buf; + gfloat *dest = out_buf; if (! config) return FALSE; - for (sample = 0; sample < samples; sample++) + while (samples--) { gfloat r = src[RED_PIX]; gfloat g = src[GREEN_PIX]; diff --git a/app/gegl/gimpoperationcolorbalance.h b/app/gegl/gimpoperationcolorbalance.h index 465f8a4ffe..1a3128f623 100644 --- a/app/gegl/gimpoperationcolorbalance.h +++ b/app/gegl/gimpoperationcolorbalance.h @@ -23,8 +23,7 @@ #define __GIMP_OPERATION_COLOR_BALANCE_H__ -#include -#include +#include "gimpoperationpointfilter.h" #define GIMP_TYPE_OPERATION_COLOR_BALANCE (gimp_operation_color_balance_get_type ()) @@ -39,14 +38,12 @@ typedef struct _GimpOperationColorBalanceClass GimpOperationColorBalanceClass; struct _GimpOperationColorBalance { - GeglOperationPointFilter parent_instance; - - GimpColorBalanceConfig *config; + GimpOperationPointFilter parent_instance; }; struct _GimpOperationColorBalanceClass { - GeglOperationPointFilterClass parent_class; + GimpOperationPointFilterClass parent_class; }; diff --git a/app/gegl/gimpoperationcolorize.c b/app/gegl/gimpoperationcolorize.c index e9d5ff05b8..e588f27df8 100644 --- a/app/gegl/gimpoperationcolorize.c +++ b/app/gegl/gimpoperationcolorize.c @@ -31,51 +31,34 @@ #include "gimpoperationcolorize.h" -enum -{ - PROP_0, - PROP_CONFIG -}; - - -static void gimp_operation_colorize_finalize (GObject *object); -static void gimp_operation_colorize_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); -static void gimp_operation_colorize_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); - -static gboolean gimp_operation_colorize_process (GeglOperation *operation, - void *in_buf, - void *out_buf, - glong samples); +static gboolean gimp_operation_colorize_process (GeglOperation *operation, + void *in_buf, + void *out_buf, + glong samples); G_DEFINE_TYPE (GimpOperationColorize, gimp_operation_colorize, - GEGL_TYPE_OPERATION_POINT_FILTER) + GIMP_TYPE_OPERATION_POINT_FILTER) #define parent_class gimp_operation_colorize_parent_class static void -gimp_operation_colorize_class_init (GimpOperationColorizeClass * klass) +gimp_operation_colorize_class_init (GimpOperationColorizeClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass); GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass); - object_class->finalize = gimp_operation_colorize_finalize; - object_class->set_property = gimp_operation_colorize_set_property; - object_class->get_property = gimp_operation_colorize_get_property; + object_class->set_property = gimp_operation_point_filter_set_property; + object_class->get_property = gimp_operation_point_filter_get_property; + + operation_class->name = "gimp-colorize"; point_class->process = gimp_operation_colorize_process; - gegl_operation_class_set_name (operation_class, "gimp-colorize"); - - g_object_class_install_property (object_class, PROP_CONFIG, + g_object_class_install_property (object_class, + GIMP_OPERATION_POINT_FILTER_PROP_CONFIG, g_param_spec_object ("config", "Config", "The config object", @@ -89,79 +72,25 @@ gimp_operation_colorize_init (GimpOperationColorize *self) { } -static void -gimp_operation_colorize_finalize (GObject *object) -{ - GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (object); - - if (self->config) - { - g_object_unref (self->config); - self->config = NULL; - } - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -gimp_operation_colorize_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (object); - - switch (property_id) - { - case PROP_CONFIG: - g_value_set_object (value, self->config); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -gimp_operation_colorize_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (object); - - switch (property_id) - { - case PROP_CONFIG: - if (self->config) - g_object_unref (self->config); - self->config = g_value_dup_object (value); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - static gboolean gimp_operation_colorize_process (GeglOperation *operation, void *in_buf, void *out_buf, glong samples) { - GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (operation); - GimpColorizeConfig *config = self->config; - gfloat *src = in_buf; - gfloat *dest = out_buf; - GimpHSL hsl; - glong sample; + GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation); + GimpColorizeConfig *config = GIMP_COLORIZE_CONFIG (point->config); + gfloat *src = in_buf; + gfloat *dest = out_buf; + GimpHSL hsl; + + if (! config) + return FALSE; hsl.h = config->hue; hsl.s = config->saturation; - for (sample = 0; sample < samples; sample++) + while (samples--) { GimpRGB rgb; gfloat lum = GIMP_RGB_LUMINANCE (src[RED_PIX], diff --git a/app/gegl/gimpoperationcolorize.h b/app/gegl/gimpoperationcolorize.h index 8377b891db..416c4a5e3f 100644 --- a/app/gegl/gimpoperationcolorize.h +++ b/app/gegl/gimpoperationcolorize.h @@ -22,8 +22,8 @@ #ifndef __GIMP_OPERATION_COLORIZE_H__ #define __GIMP_OPERATION_COLORIZE_H__ -#include -#include + +#include "gimpoperationpointfilter.h" #define GIMP_TYPE_OPERATION_COLORIZE (gimp_operation_colorize_get_type ()) @@ -38,14 +38,12 @@ typedef struct _GimpOperationColorizeClass GimpOperationColorizeClass; struct _GimpOperationColorize { - GeglOperationPointFilter parent_instance; - - GimpColorizeConfig *config; + GimpOperationPointFilter parent_instance; }; struct _GimpOperationColorizeClass { - GeglOperationPointFilterClass parent_class; + GimpOperationPointFilterClass parent_class; }; diff --git a/app/gegl/gimpoperationcurves.c b/app/gegl/gimpoperationcurves.c index c4c055ba8b..c5d9074908 100644 --- a/app/gegl/gimpoperationcurves.c +++ b/app/gegl/gimpoperationcurves.c @@ -32,51 +32,34 @@ #include "gimpoperationcurves.h" -enum -{ - PROP_0, - PROP_CONFIG -}; - - -static void gimp_operation_curves_finalize (GObject *object); -static void gimp_operation_curves_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); -static void gimp_operation_curves_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); - -static gboolean gimp_operation_curves_process (GeglOperation *operation, - void *in_buf, - void *out_buf, - glong samples); +static gboolean gimp_operation_curves_process (GeglOperation *operation, + void *in_buf, + void *out_buf, + glong samples); G_DEFINE_TYPE (GimpOperationCurves, gimp_operation_curves, - GEGL_TYPE_OPERATION_POINT_FILTER) + GIMP_TYPE_OPERATION_POINT_FILTER) #define parent_class gimp_operation_curves_parent_class static void -gimp_operation_curves_class_init (GimpOperationCurvesClass * klass) +gimp_operation_curves_class_init (GimpOperationCurvesClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass); GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass); - object_class->finalize = gimp_operation_curves_finalize; - object_class->set_property = gimp_operation_curves_set_property; - object_class->get_property = gimp_operation_curves_get_property; + object_class->set_property = gimp_operation_point_filter_set_property; + object_class->get_property = gimp_operation_point_filter_get_property; + + operation_class->name = "gimp-curves"; point_class->process = gimp_operation_curves_process; - gegl_operation_class_set_name (operation_class, "gimp-curves"); - - g_object_class_install_property (object_class, PROP_CONFIG, + g_object_class_install_property (object_class, + GIMP_OPERATION_POINT_FILTER_PROP_CONFIG, g_param_spec_object ("config", "Config", "The config object", @@ -90,62 +73,6 @@ gimp_operation_curves_init (GimpOperationCurves *self) { } -static void -gimp_operation_curves_finalize (GObject *object) -{ - GimpOperationCurves *self = GIMP_OPERATION_CURVES (object); - - if (self->config) - { - g_object_unref (self->config); - self->config = NULL; - } - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -gimp_operation_curves_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - GimpOperationCurves *self = GIMP_OPERATION_CURVES (object); - - switch (property_id) - { - case PROP_CONFIG: - g_value_set_object (value, self->config); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -gimp_operation_curves_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GimpOperationCurves *self = GIMP_OPERATION_CURVES (object); - - switch (property_id) - { - case PROP_CONFIG: - if (self->config) - g_object_unref (self->config); - self->config = g_value_dup_object (value); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - static inline gdouble gimp_operation_curves_map (gdouble value, GimpCurve *curve) @@ -176,16 +103,15 @@ gimp_operation_curves_process (GeglOperation *operation, void *out_buf, glong samples) { - GimpOperationCurves *self = GIMP_OPERATION_CURVES (operation); - GimpCurvesConfig *config = self->config; - gfloat *src = in_buf; - gfloat *dest = out_buf; - glong sample; + GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation); + GimpCurvesConfig *config = GIMP_CURVES_CONFIG (point->config); + gfloat *src = in_buf; + gfloat *dest = out_buf; if (! config) return FALSE; - for (sample = 0; sample < samples; sample++) + while (samples--) { gint channel; diff --git a/app/gegl/gimpoperationcurves.h b/app/gegl/gimpoperationcurves.h index f39522e7bb..e1657b60c0 100644 --- a/app/gegl/gimpoperationcurves.h +++ b/app/gegl/gimpoperationcurves.h @@ -23,8 +23,7 @@ #define __GIMP_OPERATION_CURVES_H__ -#include -#include +#include "gimpoperationpointfilter.h" #define GIMP_TYPE_OPERATION_CURVES (gimp_operation_curves_get_type ()) @@ -39,14 +38,12 @@ typedef struct _GimpOperationCurvesClass GimpOperationCurvesClass; struct _GimpOperationCurves { - GeglOperationPointFilter parent_instance; - - GimpCurvesConfig *config; + GimpOperationPointFilter parent_instance; }; struct _GimpOperationCurvesClass { - GeglOperationPointFilterClass parent_class; + GimpOperationPointFilterClass parent_class; }; diff --git a/app/gegl/gimpoperationdesaturate.c b/app/gegl/gimpoperationdesaturate.c index e9719fd263..c0af908ce5 100644 --- a/app/gegl/gimpoperationdesaturate.c +++ b/app/gegl/gimpoperationdesaturate.c @@ -59,7 +59,7 @@ G_DEFINE_TYPE (GimpOperationDesaturate, gimp_operation_desaturate, static void -gimp_operation_desaturate_class_init (GimpOperationDesaturateClass * klass) +gimp_operation_desaturate_class_init (GimpOperationDesaturateClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass); @@ -68,9 +68,9 @@ gimp_operation_desaturate_class_init (GimpOperationDesaturateClass * klass) object_class->set_property = gimp_operation_desaturate_set_property; object_class->get_property = gimp_operation_desaturate_get_property; - point_class->process = gimp_operation_desaturate_process; + operation_class->name = "gimp-desaturate"; - gegl_operation_class_set_name (operation_class, "gimp-desaturate"); + point_class->process = gimp_operation_desaturate_process; g_object_class_install_property (object_class, PROP_MODE, @@ -137,9 +137,8 @@ gimp_operation_desaturate_process (GeglOperation *operation, GimpOperationDesaturate *self = GIMP_OPERATION_DESATURATE (operation); gfloat *src = in_buf; gfloat *dest = out_buf; - glong sample; - for (sample = 0; sample < samples; sample++) + while (samples--) { gfloat value = 0.0; diff --git a/app/gegl/gimpoperationhuesaturation.c b/app/gegl/gimpoperationhuesaturation.c index 02f352348c..c8aee31d43 100644 --- a/app/gegl/gimpoperationhuesaturation.c +++ b/app/gegl/gimpoperationhuesaturation.c @@ -32,51 +32,34 @@ #include "gimpoperationhuesaturation.h" -enum -{ - PROP_0, - PROP_CONFIG -}; - - -static void gimp_operation_hue_saturation_finalize (GObject *object); -static void gimp_operation_hue_saturation_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); -static void gimp_operation_hue_saturation_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); - -static gboolean gimp_operation_hue_saturation_process (GeglOperation *operation, - void *in_buf, - void *out_buf, - glong samples); +static gboolean gimp_operation_hue_saturation_process (GeglOperation *operation, + void *in_buf, + void *out_buf, + glong samples); G_DEFINE_TYPE (GimpOperationHueSaturation, gimp_operation_hue_saturation, - GEGL_TYPE_OPERATION_POINT_FILTER) + GIMP_TYPE_OPERATION_POINT_FILTER) #define parent_class gimp_operation_hue_saturation_parent_class static void -gimp_operation_hue_saturation_class_init (GimpOperationHueSaturationClass * klass) +gimp_operation_hue_saturation_class_init (GimpOperationHueSaturationClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass); GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass); - object_class->finalize = gimp_operation_hue_saturation_finalize; - object_class->set_property = gimp_operation_hue_saturation_set_property; - object_class->get_property = gimp_operation_hue_saturation_get_property; + object_class->set_property = gimp_operation_point_filter_set_property; + object_class->get_property = gimp_operation_point_filter_get_property; + + operation_class->name = "gimp-hue-saturation"; point_class->process = gimp_operation_hue_saturation_process; - gegl_operation_class_set_name (operation_class, "gimp-hue-saturation"); - - g_object_class_install_property (object_class, PROP_CONFIG, + g_object_class_install_property (object_class, + GIMP_OPERATION_POINT_FILTER_PROP_CONFIG, g_param_spec_object ("config", "Config", "The config object", @@ -90,62 +73,6 @@ gimp_operation_hue_saturation_init (GimpOperationHueSaturation *self) { } -static void -gimp_operation_hue_saturation_finalize (GObject *object) -{ - GimpOperationHueSaturation *self = GIMP_OPERATION_HUE_SATURATION (object); - - if (self->config) - { - g_object_unref (self->config); - self->config = NULL; - } - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -gimp_operation_hue_saturation_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - GimpOperationHueSaturation *self = GIMP_OPERATION_HUE_SATURATION (object); - - switch (property_id) - { - case PROP_CONFIG: - g_value_set_object (value, self->config); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -gimp_operation_hue_saturation_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GimpOperationHueSaturation *self = GIMP_OPERATION_HUE_SATURATION (object); - - switch (property_id) - { - case PROP_CONFIG: - if (self->config) - g_object_unref (self->config); - self->config = g_value_dup_object (value); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - static inline gdouble map_hue (GimpHueSaturationConfig *config, GimpHueRange range, @@ -200,14 +127,16 @@ gimp_operation_hue_saturation_process (GeglOperation *operation, void *out_buf, glong samples) { - GimpOperationHueSaturation *self = GIMP_OPERATION_HUE_SATURATION (operation); - GimpHueSaturationConfig *config = self->config; - gfloat *src = in_buf; - gfloat *dest = out_buf; - gfloat overlap = config->overlap / 2.0; - glong sample; + GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation); + GimpHueSaturationConfig *config = GIMP_HUE_SATURATION_CONFIG (point->config); + gfloat *src = in_buf; + gfloat *dest = out_buf; + gfloat overlap = config->overlap / 2.0; - for (sample = 0; sample < samples; sample++) + if (! config) + return FALSE; + + while (samples--) { GimpRGB rgb; GimpHSL hsl; diff --git a/app/gegl/gimpoperationhuesaturation.h b/app/gegl/gimpoperationhuesaturation.h index e795aaa70d..5e10ea08bc 100644 --- a/app/gegl/gimpoperationhuesaturation.h +++ b/app/gegl/gimpoperationhuesaturation.h @@ -22,8 +22,8 @@ #ifndef __GIMP_OPERATION_HUE_SATURATION_H__ #define __GIMP_OPERATION_HUE_SATURATION_H__ -#include -#include + +#include "gimpoperationpointfilter.h" #define GIMP_TYPE_OPERATION_HUE_SATURATION (gimp_operation_hue_saturation_get_type ()) @@ -38,14 +38,12 @@ typedef struct _GimpOperationHueSaturationClass GimpOperationHueSaturationClass; struct _GimpOperationHueSaturation { - GeglOperationPointFilter parent_instance; - - GimpHueSaturationConfig *config; + GimpOperationPointFilter parent_instance; }; struct _GimpOperationHueSaturationClass { - GeglOperationPointFilterClass parent_class; + GimpOperationPointFilterClass parent_class; }; diff --git a/app/gegl/gimpoperationlevels.c b/app/gegl/gimpoperationlevels.c index 0cc054f9b8..a20c263ec0 100644 --- a/app/gegl/gimpoperationlevels.c +++ b/app/gegl/gimpoperationlevels.c @@ -32,51 +32,34 @@ #include "gimpoperationlevels.h" -enum -{ - PROP_0, - PROP_CONFIG -}; - - -static void gimp_operation_levels_finalize (GObject *object); -static void gimp_operation_levels_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); -static void gimp_operation_levels_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); - -static gboolean gimp_operation_levels_process (GeglOperation *operation, - void *in_buf, - void *out_buf, - glong samples); +static gboolean gimp_operation_levels_process (GeglOperation *operation, + void *in_buf, + void *out_buf, + glong samples); G_DEFINE_TYPE (GimpOperationLevels, gimp_operation_levels, - GEGL_TYPE_OPERATION_POINT_FILTER) + GIMP_TYPE_OPERATION_POINT_FILTER) #define parent_class gimp_operation_levels_parent_class static void -gimp_operation_levels_class_init (GimpOperationLevelsClass * klass) +gimp_operation_levels_class_init (GimpOperationLevelsClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass); GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass); - object_class->finalize = gimp_operation_levels_finalize; - object_class->set_property = gimp_operation_levels_set_property; - object_class->get_property = gimp_operation_levels_get_property; + object_class->set_property = gimp_operation_point_filter_set_property; + object_class->get_property = gimp_operation_point_filter_get_property; + + operation_class->name = "gimp-levels"; point_class->process = gimp_operation_levels_process; - gegl_operation_class_set_name (operation_class, "gimp-levels"); - - g_object_class_install_property (object_class, PROP_CONFIG, + g_object_class_install_property (object_class, + GIMP_OPERATION_POINT_FILTER_PROP_CONFIG, g_param_spec_object ("config", "Config", "The config object", @@ -90,62 +73,6 @@ gimp_operation_levels_init (GimpOperationLevels *self) { } -static void -gimp_operation_levels_finalize (GObject *object) -{ - GimpOperationLevels *self = GIMP_OPERATION_LEVELS (object); - - if (self->config) - { - g_object_unref (self->config); - self->config = NULL; - } - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -gimp_operation_levels_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - GimpOperationLevels *self = GIMP_OPERATION_LEVELS (object); - - switch (property_id) - { - case PROP_CONFIG: - g_value_set_object (value, self->config); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -gimp_operation_levels_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GimpOperationLevels *self = GIMP_OPERATION_LEVELS (object); - - switch (property_id) - { - case PROP_CONFIG: - if (self->config) - g_object_unref (self->config); - self->config = g_value_dup_object (value); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - static inline gdouble gimp_operation_levels_map (gdouble value, gdouble gamma, @@ -183,16 +110,15 @@ gimp_operation_levels_process (GeglOperation *operation, void *out_buf, glong samples) { - GimpOperationLevels *self = GIMP_OPERATION_LEVELS (operation); - GimpLevelsConfig *config = self->config; - gfloat *src = in_buf; - gfloat *dest = out_buf; - glong sample; + GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation); + GimpLevelsConfig *config = GIMP_LEVELS_CONFIG (point->config); + gfloat *src = in_buf; + gfloat *dest = out_buf; if (! config) return FALSE; - for (sample = 0; sample < samples; sample++) + while (samples--) { gint channel; @@ -252,4 +178,3 @@ gimp_operation_levels_map_input (GimpLevelsConfig *config, return value; } - diff --git a/app/gegl/gimpoperationlevels.h b/app/gegl/gimpoperationlevels.h index 2aa084661c..b2ad5213b3 100644 --- a/app/gegl/gimpoperationlevels.h +++ b/app/gegl/gimpoperationlevels.h @@ -23,8 +23,7 @@ #define __GIMP_OPERATION_LEVELS_H__ -#include -#include +#include "gimpoperationpointfilter.h" #define GIMP_TYPE_OPERATION_LEVELS (gimp_operation_levels_get_type ()) @@ -39,14 +38,12 @@ typedef struct _GimpOperationLevelsClass GimpOperationLevelsClass; struct _GimpOperationLevels { - GeglOperationPointFilter parent_instance; - - GimpLevelsConfig *config; + GimpOperationPointFilter parent_instance; }; struct _GimpOperationLevelsClass { - GeglOperationPointFilterClass parent_class; + GimpOperationPointFilterClass parent_class; }; diff --git a/app/gegl/gimpoperationpointfilter.c b/app/gegl/gimpoperationpointfilter.c new file mode 100644 index 0000000000..b4672cc702 --- /dev/null +++ b/app/gegl/gimpoperationpointfilter.c @@ -0,0 +1,107 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpoperationpointfilter.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 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 + +#include "gegl-types.h" + +#include "gimpoperationpointfilter.h" + + +static void gimp_operation_point_filter_finalize (GObject *object); + + +G_DEFINE_TYPE (GimpOperationPointFilter, gimp_operation_point_filter, + GEGL_TYPE_OPERATION_POINT_FILTER) + +#define parent_class gimp_operation_point_filter_parent_class + + +static void +gimp_operation_point_filter_class_init (GimpOperationPointFilterClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = gimp_operation_point_filter_finalize; +} + +static void +gimp_operation_point_filter_init (GimpOperationPointFilter *self) +{ +} + +static void +gimp_operation_point_filter_finalize (GObject *object) +{ + GimpOperationPointFilter *self = GIMP_OPERATION_POINT_FILTER (object); + + if (self->config) + { + g_object_unref (self->config); + self->config = NULL; + } + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +void +gimp_operation_point_filter_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GimpOperationPointFilter *self = GIMP_OPERATION_POINT_FILTER (object); + + switch (property_id) + { + case GIMP_OPERATION_POINT_FILTER_PROP_CONFIG: + g_value_set_object (value, self->config); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +void +gimp_operation_point_filter_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GimpOperationPointFilter *self = GIMP_OPERATION_POINT_FILTER (object); + + switch (property_id) + { + case GIMP_OPERATION_POINT_FILTER_PROP_CONFIG: + if (self->config) + g_object_unref (self->config); + self->config = g_value_dup_object (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} diff --git a/app/gegl/gimpoperationpointfilter.h b/app/gegl/gimpoperationpointfilter.h new file mode 100644 index 0000000000..6203b536ca --- /dev/null +++ b/app/gegl/gimpoperationpointfilter.h @@ -0,0 +1,72 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpoperationpointfilter.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 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_OPERATION_POINT_FILTER_H__ +#define __GIMP_OPERATION_POINT_FILTER_H__ + + +#include +#include + + +enum +{ + GIMP_OPERATION_POINT_FILTER_PROP_0, + GIMP_OPERATION_POINT_FILTER_PROP_CONFIG +}; + + +#define GIMP_TYPE_OPERATION_POINT_FILTER (gimp_operation_point_filter_get_type ()) +#define GIMP_OPERATION_POINT_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_POINT_FILTER, GimpOperationPointFilter)) +#define GIMP_OPERATION_POINT_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_POINT_FILTER, GimpOperationPointFilterClass)) +#define GIMP_IS_OPERATION_POINT_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_POINT_FILTER)) +#define GIMP_IS_OPERATION_POINT_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_POINT_FILTER)) +#define GIMP_OPERATION_POINT_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_POINT_FILTER, GimpOperationPointFilterClass)) + + +typedef struct _GimpOperationPointFilterClass GimpOperationPointFilterClass; + +struct _GimpOperationPointFilter +{ + GeglOperationPointFilter parent_instance; + + GObject *config; +}; + +struct _GimpOperationPointFilterClass +{ + GeglOperationPointFilterClass parent_class; +}; + + +GType gimp_operation_point_filter_get_type (void) G_GNUC_CONST; + +void gimp_operation_point_filter_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); +void gimp_operation_point_filter_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); + + +#endif /* __GIMP_OPERATION_POINT_FILTER_H__ */ diff --git a/app/gegl/gimpoperationposterize.c b/app/gegl/gimpoperationposterize.c index 82b2aa9227..f978e40901 100644 --- a/app/gegl/gimpoperationposterize.c +++ b/app/gegl/gimpoperationposterize.c @@ -29,58 +29,43 @@ #include "gegl-types.h" #include "gimpoperationposterize.h" +#include "gimpposterizeconfig.h" -enum -{ - PROP_0, - PROP_LEVELS -}; - - -static void gimp_operation_posterize_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); -static void gimp_operation_posterize_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); - -static gboolean gimp_operation_posterize_process (GeglOperation *operation, - void *in_buf, - void *out_buf, - glong samples); +static gboolean gimp_operation_posterize_process (GeglOperation *operation, + void *in_buf, + void *out_buf, + glong samples); G_DEFINE_TYPE (GimpOperationPosterize, gimp_operation_posterize, - GEGL_TYPE_OPERATION_POINT_FILTER) + GIMP_TYPE_OPERATION_POINT_FILTER) #define parent_class gimp_operation_posterize_parent_class static void -gimp_operation_posterize_class_init (GimpOperationPosterizeClass * klass) +gimp_operation_posterize_class_init (GimpOperationPosterizeClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass); GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass); - object_class->set_property = gimp_operation_posterize_set_property; - object_class->get_property = gimp_operation_posterize_get_property; + object_class->set_property = gimp_operation_point_filter_set_property; + object_class->get_property = gimp_operation_point_filter_get_property; + + operation_class->name = "gimp-posterize"; point_class->process = gimp_operation_posterize_process; - 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)); + GIMP_OPERATION_POINT_FILTER_PROP_CONFIG, + g_param_spec_object ("config", + "Config", + "The config object", + GIMP_TYPE_POSTERIZE_CONFIG, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT)); } static void @@ -88,59 +73,22 @@ gimp_operation_posterize_init (GimpOperationPosterize *self) { } -static void -gimp_operation_posterize_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - GimpOperationPosterize *self = GIMP_OPERATION_POSTERIZE (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_operation_posterize_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GimpOperationPosterize *self = GIMP_OPERATION_POSTERIZE (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; - } -} - static gboolean gimp_operation_posterize_process (GeglOperation *operation, void *in_buf, void *out_buf, glong samples) { - GimpOperationPosterize *self = GIMP_OPERATION_POSTERIZE (operation); - gfloat *src = in_buf; - gfloat *dest = out_buf; - gfloat levels = self->levels - 1.0; - glong sample; + GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation); + GimpPosterizeConfig *config = GIMP_POSTERIZE_CONFIG (point->config); + gfloat *src = in_buf; + gfloat *dest = out_buf; + gfloat levels = config->levels - 1.0; - for (sample = 0; sample < samples; sample++) + if (! config) + return FALSE; + + while (samples--) { dest[RED_PIX] = RINT (src[RED_PIX] * levels) / levels; dest[GREEN_PIX] = RINT (src[GREEN_PIX] * levels) / levels; diff --git a/app/gegl/gimpoperationposterize.h b/app/gegl/gimpoperationposterize.h index 4e05df0a1d..650a3bc61d 100644 --- a/app/gegl/gimpoperationposterize.h +++ b/app/gegl/gimpoperationposterize.h @@ -23,28 +23,27 @@ #define __GIMP_OPERATION_POSTERIZE_H__ -#include -#include +#include "gimpoperationpointfilter.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; struct _GimpOperationPosterize { - GeglOperationPointFilter parent_instance; - - gint levels; + GimpOperationPointFilter parent_instance; }; struct _GimpOperationPosterizeClass { - GeglOperationPointFilterClass parent_class; + GimpOperationPointFilterClass parent_class; }; diff --git a/app/gegl/gimpoperationthreshold.c b/app/gegl/gimpoperationthreshold.c index 92e957a5b0..f23558cf37 100644 --- a/app/gegl/gimpoperationthreshold.c +++ b/app/gegl/gimpoperationthreshold.c @@ -31,51 +31,34 @@ #include "gimpthresholdconfig.h" -enum -{ - PROP_0, - PROP_CONFIG -}; - - -static void gimp_operation_threshold_finalize (GObject *object); -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, - void *out_buf, - glong samples); +static gboolean gimp_operation_threshold_process (GeglOperation *operation, + void *in_buf, + void *out_buf, + glong samples); G_DEFINE_TYPE (GimpOperationThreshold, gimp_operation_threshold, - GEGL_TYPE_OPERATION_POINT_FILTER) + GIMP_TYPE_OPERATION_POINT_FILTER) #define parent_class gimp_operation_threshold_parent_class static void -gimp_operation_threshold_class_init (GimpOperationThresholdClass * klass) +gimp_operation_threshold_class_init (GimpOperationThresholdClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass); GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass); - object_class->finalize = gimp_operation_threshold_finalize; - object_class->set_property = gimp_operation_threshold_set_property; - object_class->get_property = gimp_operation_threshold_get_property; + object_class->set_property = gimp_operation_point_filter_set_property; + object_class->get_property = gimp_operation_point_filter_get_property; + + operation_class->name = "gimp-threshold"; point_class->process = gimp_operation_threshold_process; - gegl_operation_class_set_name (operation_class, "gimp-threshold"); - - g_object_class_install_property (object_class, PROP_CONFIG, + g_object_class_install_property (object_class, + GIMP_OPERATION_POINT_FILTER_PROP_CONFIG, g_param_spec_object ("config", "Config", "The config object", @@ -89,78 +72,21 @@ gimp_operation_threshold_init (GimpOperationThreshold *self) { } -static void -gimp_operation_threshold_finalize (GObject *object) -{ - GimpOperationThreshold *self = GIMP_OPERATION_THRESHOLD (object); - - if (self->config) - { - g_object_unref (self->config); - self->config = NULL; - } - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -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_CONFIG: - g_value_set_object (value, self->config); - 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_CONFIG: - if (self->config) - g_object_unref (self->config); - self->config = g_value_dup_object (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, glong samples) { - GimpOperationThreshold *self = GIMP_OPERATION_THRESHOLD (operation); - GimpThresholdConfig *config = self->config; - gfloat *src = in_buf; - gfloat *dest = out_buf; - glong sample; + 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; - for (sample = 0; sample < samples; sample++) + while (samples--) { gfloat value; diff --git a/app/gegl/gimpoperationthreshold.h b/app/gegl/gimpoperationthreshold.h index 56968c32aa..b8c20e3830 100644 --- a/app/gegl/gimpoperationthreshold.h +++ b/app/gegl/gimpoperationthreshold.h @@ -23,8 +23,7 @@ #define __GIMP_OPERATION_THRESHOLD_H__ -#include -#include +#include "gimpoperationpointfilter.h" #define GIMP_TYPE_OPERATION_THRESHOLD (gimp_operation_threshold_get_type ()) @@ -39,14 +38,12 @@ typedef struct _GimpOperationThresholdClass GimpOperationThresholdClass; struct _GimpOperationThreshold { - GeglOperationPointFilter parent_instance; - - GimpThresholdConfig *config; + GimpOperationPointFilter parent_instance; }; struct _GimpOperationThresholdClass { - GeglOperationPointFilterClass parent_class; + GimpOperationPointFilterClass parent_class; }; diff --git a/app/gegl/gimpoperationtilesink.c b/app/gegl/gimpoperationtilesink.c index bf85bf587e..00bf279e32 100644 --- a/app/gegl/gimpoperationtilesink.c +++ b/app/gegl/gimpoperationtilesink.c @@ -74,7 +74,7 @@ static guint tile_sink_signals[LAST_SIGNAL] = { 0 }; static void -gimp_operation_tile_sink_class_init (GimpOperationTileSinkClass * klass) +gimp_operation_tile_sink_class_init (GimpOperationTileSinkClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass); @@ -94,10 +94,11 @@ gimp_operation_tile_sink_class_init (GimpOperationTileSinkClass * klass) object_class->set_property = gimp_operation_tile_sink_set_property; object_class->get_property = gimp_operation_tile_sink_get_property; + operation_class->name = "gimp-tilemanager-sink"; + sink_class->process = gimp_operation_tile_sink_process; sink_class->needs_full = FALSE; - gegl_operation_class_set_name (operation_class, "gimp-tilemanager-sink");; g_object_class_install_property (object_class, PROP_TILE_MANAGER, g_param_spec_boxed ("tile-manager", @@ -191,41 +192,38 @@ gimp_operation_tile_sink_process (GeglOperation *operation, const GeglRectangle *result) { GimpOperationTileSink *self = GIMP_OPERATION_TILE_SINK (operation); + const Babl *format; + PixelRegion destPR; + guint bpp; + gpointer pr; - if (self->tile_manager) - { - const Babl *format; - PixelRegion destPR; - guint bpp = tile_manager_bpp (self->tile_manager); - gpointer pr; + if (! self->tile_manager) + return FALSE; - if (self->linear) - format = gimp_bpp_to_babl_format_linear (bpp); - else - format = gimp_bpp_to_babl_format (bpp); + bpp = tile_manager_bpp (self->tile_manager); - pixel_region_init (&destPR, self->tile_manager, - result->x, result->y, - result->width, result->height, - TRUE); - - for (pr = pixel_regions_register (1, &destPR); - pr; - pr = pixel_regions_process (pr)) - { - GeglRectangle rect = { destPR.x, destPR.y, destPR.w, destPR.h }; - - gegl_buffer_get (input, - 1.0, &rect, format, destPR.data, destPR.rowstride); - } - - g_signal_emit (operation, tile_sink_signals[DATA_WRITTEN], 0, - result); - } + if (self->linear) + format = gimp_bpp_to_babl_format_linear (bpp); else + format = gimp_bpp_to_babl_format (bpp); + + pixel_region_init (&destPR, self->tile_manager, + result->x, result->y, + result->width, result->height, + TRUE); + + for (pr = pixel_regions_register (1, &destPR); + pr; + pr = pixel_regions_process (pr)) { - g_warning ("no tilemanager?"); + GeglRectangle rect = { destPR.x, destPR.y, destPR.w, destPR.h }; + + gegl_buffer_get (input, + 1.0, &rect, format, destPR.data, destPR.rowstride); } + g_signal_emit (operation, tile_sink_signals[DATA_WRITTEN], 0, + result); + return TRUE; } diff --git a/app/gegl/gimpoperationtilesource.c b/app/gegl/gimpoperationtilesource.c index 7821f47a6d..e6e8de1d26 100644 --- a/app/gegl/gimpoperationtilesource.c +++ b/app/gegl/gimpoperationtilesource.c @@ -69,7 +69,7 @@ G_DEFINE_TYPE (GimpOperationTileSource, gimp_operation_tile_source, static void -gimp_operation_tile_source_class_init (GimpOperationTileSourceClass * klass) +gimp_operation_tile_source_class_init (GimpOperationTileSourceClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass); @@ -79,6 +79,7 @@ gimp_operation_tile_source_class_init (GimpOperationTileSourceClass * klass) object_class->set_property = gimp_operation_tile_source_set_property; object_class->get_property = gimp_operation_tile_source_get_property; + operation_class->name = "gimp-tilemanager-source"; operation_class->prepare = gimp_operation_tile_source_prepare; operation_class->get_defined_region = gimp_operation_tile_source_get_defined_region; operation_class->adjust_result_region = NULL; /* the default source is @@ -89,7 +90,6 @@ gimp_operation_tile_source_class_init (GimpOperationTileSourceClass * klass) source_class->process = gimp_operation_tile_source_process; - gegl_operation_class_set_name (operation_class, "gimp-tilemanager-source");; g_object_class_install_property (object_class, PROP_TILE_MANAGER, g_param_spec_boxed ("tile-manager", @@ -220,28 +220,27 @@ gimp_operation_tile_source_process (GeglOperation *operation, const GeglRectangle *result) { GimpOperationTileSource *self = GIMP_OPERATION_TILE_SOURCE (operation); + const Babl *format; + PixelRegion srcPR; + gpointer pr; - if (self->tile_manager) + if (! self->tile_manager) + return FALSE; + + format = gegl_operation_get_format (operation, "output"); + + pixel_region_init (&srcPR, self->tile_manager, + result->x, result->y, + result->width, result->height, + FALSE); + + for (pr = pixel_regions_register (1, &srcPR); + pr; + pr = pixel_regions_process (pr)) { - const Babl *format; - PixelRegion srcPR; - gpointer pr; + GeglRectangle rect = { srcPR.x, srcPR.y, srcPR.w, srcPR.h }; - format = gegl_operation_get_format (operation, "output"); - - pixel_region_init (&srcPR, self->tile_manager, - result->x, result->y, - result->width, result->height, - FALSE); - - for (pr = pixel_regions_register (1, &srcPR); - pr; - pr = pixel_regions_process (pr)) - { - GeglRectangle rect = { srcPR.x, srcPR.y, srcPR.w, srcPR.h }; - - gegl_buffer_set (output, &rect, format, srcPR.data, srcPR.rowstride); - } + gegl_buffer_set (output, &rect, format, srcPR.data, srcPR.rowstride); } return TRUE; diff --git a/app/gegl/gimpposterizeconfig.c b/app/gegl/gimpposterizeconfig.c new file mode 100644 index 0000000000..f8560ff083 --- /dev/null +++ b/app/gegl/gimpposterizeconfig.c @@ -0,0 +1,117 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpposterizeconfig.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 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 + +#include "libgimpconfig/gimpconfig.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_WITH_CODE (GimpPosterizeConfig, gimp_posterize_config, + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, NULL)) + +#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; + } +} diff --git a/app/gegl/gimpposterizeconfig.h b/app/gegl/gimpposterizeconfig.h new file mode 100644 index 0000000000..a003a344d8 --- /dev/null +++ b/app/gegl/gimpposterizeconfig.h @@ -0,0 +1,52 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpposterizeconfig.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 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; + + +#endif /* __GIMP_POSTERIZE_CONFIG_H__ */ diff --git a/app/gegl/gimpthresholdconfig.c b/app/gegl/gimpthresholdconfig.c index 02b800a018..05c48e7fd6 100644 --- a/app/gegl/gimpthresholdconfig.c +++ b/app/gegl/gimpthresholdconfig.c @@ -23,6 +23,8 @@ #include +#include "libgimpconfig/gimpconfig.h" + #include "gegl-types.h" /* temp cruft */ @@ -49,14 +51,15 @@ static void gimp_threshold_config_set_property (GObject *object, GParamSpec *pspec); -G_DEFINE_TYPE (GimpThresholdConfig, gimp_threshold_config, - G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_CODE (GimpThresholdConfig, gimp_threshold_config, + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, NULL)) #define parent_class gimp_threshold_config_parent_class static void -gimp_threshold_config_class_init (GimpThresholdConfigClass * klass) +gimp_threshold_config_class_init (GimpThresholdConfigClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -134,18 +137,6 @@ gimp_threshold_config_set_property (GObject *object, } -/* public functions */ - -void -gimp_threshold_config_reset (GimpThresholdConfig *config) -{ - g_return_if_fail (GIMP_IS_THRESHOLD_CONFIG (config)); - - config->low = 0.5; - config->high = 1.0; -} - - /* temp cruft */ void diff --git a/app/gegl/gimpthresholdconfig.h b/app/gegl/gimpthresholdconfig.h index 347948e862..403f440b93 100644 --- a/app/gegl/gimpthresholdconfig.h +++ b/app/gegl/gimpthresholdconfig.h @@ -49,8 +49,6 @@ struct _GimpThresholdConfigClass GType gimp_threshold_config_get_type (void) G_GNUC_CONST; -void gimp_threshold_config_reset (GimpThresholdConfig *config); - /* temp cruft */ void gimp_threshold_config_to_cruft (GimpThresholdConfig *config, Threshold *cruft); diff --git a/app/tools/Makefile.am b/app/tools/Makefile.am index f6d3d5edf1..0c7b21b527 100644 --- a/app/tools/Makefile.am +++ b/app/tools/Makefile.am @@ -118,6 +118,8 @@ libapptools_a_sources = \ gimpperspectiveclonetool.h \ gimpperspectivetool.c \ gimpperspectivetool.h \ + gimppolygonselecttool.c \ + gimppolygonselecttool.h \ gimpposterizetool.c \ gimpposterizetool.h \ gimprectangleselecttool.c \ diff --git a/app/tools/gimp-tools.c b/app/tools/gimp-tools.c index 994eee5a29..82adfb9852 100644 --- a/app/tools/gimp-tools.c +++ b/app/tools/gimp-tools.c @@ -69,6 +69,7 @@ #include "gimppenciltool.h" #include "gimpperspectiveclonetool.h" #include "gimpperspectivetool.h" +#include "gimppolygonselecttool.h" #include "gimpposterizetool.h" #include "gimpthresholdtool.h" #include "gimprectangleselecttool.h" @@ -167,6 +168,7 @@ gimp_tools_init (Gimp *gimp) gimp_iscissors_tool_register, gimp_by_color_select_tool_register, gimp_fuzzy_select_tool_register, + gimp_polygon_select_tool_register, gimp_free_select_tool_register, gimp_ellipse_select_tool_register, gimp_rect_select_tool_register diff --git a/app/tools/gimpbrightnesscontrasttool.c b/app/tools/gimpbrightnesscontrasttool.c index b413fa5551..dc7a57a026 100644 --- a/app/tools/gimpbrightnesscontrasttool.c +++ b/app/tools/gimpbrightnesscontrasttool.c @@ -18,9 +18,12 @@ #include "config.h" +#include + #include #include +#include "libgimpconfig/gimpconfig.h" #include "libgimpwidgets/gimpwidgets.h" #include "tools-types.h" @@ -28,6 +31,8 @@ #include "base/gimplut.h" #include "base/lut-funcs.h" +#include "gegl/gimpbrightnesscontrastconfig.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -69,12 +74,15 @@ static void gimp_brightness_contrast_tool_motion (GimpTool GimpDisplay *display); static GeglNode * - gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *image_map_tool); + gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *image_map_tool, + GObject **config); static void gimp_brightness_contrast_tool_map (GimpImageMapTool *image_map_tool); static void gimp_brightness_contrast_tool_dialog (GimpImageMapTool *image_map_tool); -static void gimp_brightness_contrast_tool_reset (GimpImageMapTool *image_map_tool); -static void brightness_contrast_update_sliders (GimpBrightnessContrastTool *bc_tool); +static void brightness_contrast_config_notify (GObject *object, + GParamSpec *pspec, + GimpBrightnessContrastTool *bc_tool); + static void brightness_contrast_brightness_changed (GtkAdjustment *adj, GimpBrightnessContrastTool *bc_tool); static void brightness_contrast_contrast_changed (GtkAdjustment *adj, @@ -122,7 +130,6 @@ gimp_brightness_contrast_tool_class_init (GimpBrightnessContrastToolClass *klass im_tool_class->get_operation = gimp_brightness_contrast_tool_get_operation; im_tool_class->map = gimp_brightness_contrast_tool_map; im_tool_class->dialog = gimp_brightness_contrast_tool_dialog; - im_tool_class->reset = gimp_brightness_contrast_tool_reset; } static void @@ -130,9 +137,7 @@ gimp_brightness_contrast_tool_init (GimpBrightnessContrastTool *bc_tool) { GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (bc_tool); - bc_tool->brightness = 0.0; - bc_tool->contrast = 0.0; - bc_tool->lut = gimp_lut_new (); + bc_tool->lut = gimp_lut_new (); im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process; im_tool->apply_data = bc_tool->lut; @@ -172,19 +177,27 @@ gimp_brightness_contrast_tool_initialize (GimpTool *tool, return FALSE; } - bc_tool->brightness = 0.0; - bc_tool->contrast = 0.0; + gimp_config_reset (GIMP_CONFIG (bc_tool->config)); GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error); - brightness_contrast_update_sliders (bc_tool); - return TRUE; } static GeglNode * -gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *im_tool) +gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *im_tool, + GObject **config) { + GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool); + + bc_tool->config = g_object_new (GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG, NULL); + + *config = G_OBJECT (bc_tool->config); + + g_signal_connect_object (bc_tool->config, "notify", + G_CALLBACK (brightness_contrast_config_notify), + G_OBJECT (bc_tool), 0); + return g_object_new (GEGL_TYPE_NODE, "operation", "brightness-contrast", NULL); @@ -194,22 +207,13 @@ static void gimp_brightness_contrast_tool_map (GimpImageMapTool *im_tool) { GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool); - gdouble brightness; - gdouble contrast; - brightness = bc_tool->brightness / 256.0; - contrast = (bc_tool->contrast < 0 ? - (bc_tool->contrast + 127.0) / 127.0 : - bc_tool->contrast * 4.0 / 127.0 + 1); - - gegl_node_set (im_tool->operation, - "brightness", brightness, - "contrast", contrast, - NULL); + gimp_brightness_contrast_config_set_node (bc_tool->config, + im_tool->operation); brightness_contrast_lut_setup (bc_tool->lut, - bc_tool->brightness / 255.0, - bc_tool->contrast / 127.0, + bc_tool->config->brightness / 2.0, + bc_tool->config->contrast, gimp_drawable_bytes (im_tool->drawable)); } @@ -223,10 +227,10 @@ gimp_brightness_contrast_tool_button_press (GimpTool *tool, { GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool); - bc_tool->x = coords->x - bc_tool->contrast; - bc_tool->y = coords->y + bc_tool->brightness; - bc_tool->dx = bc_tool->contrast; - bc_tool->dy = - bc_tool->brightness; + bc_tool->x = coords->x - bc_tool->config->contrast * 127.0; + bc_tool->y = coords->y + bc_tool->config->brightness * 127.0; + bc_tool->dx = bc_tool->config->contrast * 127.0; + bc_tool->dy = - bc_tool->config->brightness * 127.0; gimp_tool_control_activate (tool->control); tool->display = display; @@ -249,7 +253,7 @@ gimp_brightness_contrast_tool_button_release (GimpTool *tool, return; if (release_type == GIMP_BUTTON_RELEASE_CANCEL) - gimp_brightness_contrast_tool_reset (im_tool); + gimp_config_reset (GIMP_CONFIG (bc_tool->config)); gimp_image_map_tool_preview (im_tool); } @@ -262,18 +266,16 @@ gimp_brightness_contrast_tool_motion (GimpTool *tool, GimpDisplay *display) { GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool); - GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool); gimp_tool_control_pause (tool->control); bc_tool->dx = (coords->x - bc_tool->x); bc_tool->dy = - (coords->y - bc_tool->y); - bc_tool->brightness = CLAMP (bc_tool->dy, -127.0, 127.0); - bc_tool->contrast = CLAMP (bc_tool->dx, -127.0, 127.0); - - brightness_contrast_update_sliders (bc_tool); - gimp_image_map_tool_preview (im_tool); + g_object_set (bc_tool->config, + "brightness", CLAMP (bc_tool->dy, -127.0, 127.0) / 127.0, + "contrast", CLAMP (bc_tool->dx, -127.0, 127.0) / 127.0, + NULL); gimp_tool_control_resume (tool->control); } @@ -286,10 +288,11 @@ gimp_brightness_contrast_tool_motion (GimpTool *tool, static void gimp_brightness_contrast_tool_dialog (GimpImageMapTool *im_tool) { - GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool); - GtkWidget *table; - GtkWidget *slider; - GtkObject *data; + GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool); + GimpBrightnessContrastConfig *config = bc_tool->config; + GtkWidget *table; + GtkWidget *slider; + GtkObject *data; /* The table containing sliders */ table = gtk_table_new (2, 3, FALSE); @@ -302,7 +305,7 @@ gimp_brightness_contrast_tool_dialog (GimpImageMapTool *im_tool) /* Create the brightness scale widget */ data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, _("_Brightness:"), SLIDER_WIDTH, -1, - bc_tool->brightness, + config->brightness * 127.0, -127.0, 127.0, 1.0, 10.0, 0, TRUE, 0.0, 0.0, NULL, NULL); @@ -317,7 +320,7 @@ gimp_brightness_contrast_tool_dialog (GimpImageMapTool *im_tool) /* Create the contrast scale widget */ data = gimp_scale_entry_new (GTK_TABLE (table), 0, 1, _("Con_trast:"), SLIDER_WIDTH, -1, - bc_tool->contrast, + config->contrast * 127.0, -127.0, 127.0, 1.0, 10.0, 0, TRUE, 0.0, 0.0, NULL, NULL); @@ -331,32 +334,41 @@ gimp_brightness_contrast_tool_dialog (GimpImageMapTool *im_tool) } static void -gimp_brightness_contrast_tool_reset (GimpImageMapTool *im_tool) +brightness_contrast_config_notify (GObject *object, + GParamSpec *pspec, + GimpBrightnessContrastTool *bc_tool) { - GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool); + GimpBrightnessContrastConfig *config = GIMP_BRIGHTNESS_CONTRAST_CONFIG (object); - bc_tool->brightness = 0.0; - bc_tool->contrast = 0.0; + if (! bc_tool->brightness_data) + return; - brightness_contrast_update_sliders (bc_tool); -} + if (! strcmp (pspec->name, "brightness")) + { + gtk_adjustment_set_value (bc_tool->brightness_data, + config->brightness * 127.0); + } + else if (! strcmp (pspec->name, "contrast")) + { + gtk_adjustment_set_value (bc_tool->contrast_data, + config->contrast * 127.0); + } -static void -brightness_contrast_update_sliders (GimpBrightnessContrastTool *bc_tool) -{ - gtk_adjustment_set_value (bc_tool->brightness_data, bc_tool->brightness); - gtk_adjustment_set_value (bc_tool->contrast_data, bc_tool->contrast); + gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (bc_tool)); } static void brightness_contrast_brightness_changed (GtkAdjustment *adjustment, GimpBrightnessContrastTool *bc_tool) { - if (bc_tool->brightness != adjustment->value) - { - bc_tool->brightness = adjustment->value; + GimpBrightnessContrastConfig *config = bc_tool->config; + gdouble value = adjustment->value / 127.0; - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (bc_tool)); + if (config->brightness != value) + { + g_object_set (config, + "brightness", value, + NULL); } } @@ -364,10 +376,13 @@ static void brightness_contrast_contrast_changed (GtkAdjustment *adjustment, GimpBrightnessContrastTool *bc_tool) { - if (bc_tool->contrast != adjustment->value) - { - bc_tool->contrast = adjustment->value; + GimpBrightnessContrastConfig *config = bc_tool->config; + gdouble value = adjustment->value / 127.0; - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (bc_tool)); + if (config->contrast != value) + { + g_object_set (config, + "contrast", value, + NULL); } } diff --git a/app/tools/gimpbrightnesscontrasttool.h b/app/tools/gimpbrightnesscontrasttool.h index 7ad26f608d..a0203c4d6b 100644 --- a/app/tools/gimpbrightnesscontrasttool.h +++ b/app/tools/gimpbrightnesscontrasttool.h @@ -36,18 +36,17 @@ typedef struct _GimpBrightnessContrastToolClass GimpBrightnessContrastToolClass; struct _GimpBrightnessContrastTool { - GimpImageMapTool parent_instance; + GimpImageMapTool parent_instance; - gdouble x, y; - gdouble dx, dy; + GimpBrightnessContrastConfig *config; + GimpLut *lut; - gdouble brightness; - gdouble contrast; - GimpLut *lut; + gdouble x, y; + gdouble dx, dy; /* dialog */ - GtkAdjustment *brightness_data; - GtkAdjustment *contrast_data; + GtkAdjustment *brightness_data; + GtkAdjustment *contrast_data; }; struct _GimpBrightnessContrastToolClass diff --git a/app/tools/gimpcolorbalancetool.c b/app/tools/gimpcolorbalancetool.c index f358181717..b66c3c80c5 100644 --- a/app/tools/gimpcolorbalancetool.c +++ b/app/tools/gimpcolorbalancetool.c @@ -18,9 +18,12 @@ #include "config.h" +#include + #include #include +#include "libgimpconfig/gimpconfig.h" #include "libgimpwidgets/gimpwidgets.h" #include "tools-types.h" @@ -50,12 +53,16 @@ static gboolean gimp_color_balance_tool_initialize (GimpTool *tool, GimpDisplay *display, GError **error); -static GeglNode * gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool); +static GeglNode * gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool, + GObject **config); static void gimp_color_balance_tool_map (GimpImageMapTool *im_tool); static void gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool); static void gimp_color_balance_tool_reset (GimpImageMapTool *im_tool); -static void color_balance_update (GimpColorBalanceTool *cb_tool); +static void color_balance_config_notify (GObject *object, + GParamSpec *pspec, + GimpColorBalanceTool *cb_tool); + static void color_balance_range_callback (GtkWidget *widget, GimpColorBalanceTool *cb_tool); static void color_balance_range_reset_callback (GtkWidget *widget, @@ -129,12 +136,6 @@ gimp_color_balance_tool_finalize (GObject *object) { GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (object); - if (cb_tool->config) - { - g_object_unref (cb_tool->config); - cb_tool->config = NULL; - } - g_slice_free (ColorBalance, cb_tool->color_balance); G_OBJECT_CLASS (parent_class)->finalize (object); @@ -160,20 +161,16 @@ gimp_color_balance_tool_initialize (GimpTool *tool, return FALSE; } - gimp_color_balance_config_reset (cb_tool->config); + gimp_config_reset (GIMP_CONFIG (cb_tool->config)); GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error); - gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (cb_tool->range_radio), - cb_tool->config->range); - - color_balance_update (cb_tool); - return TRUE; } static GeglNode * -gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool) +gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool, + GObject **config) { GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool); GeglNode *node; @@ -184,6 +181,12 @@ gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool) cb_tool->config = g_object_new (GIMP_TYPE_COLOR_BALANCE_CONFIG, NULL); + *config = G_OBJECT (cb_tool->config); + + g_signal_connect_object (cb_tool->config, "notify", + G_CALLBACK (color_balance_config_notify), + G_OBJECT (cb_tool), 0); + gegl_node_set (node, "config", cb_tool->config, NULL); @@ -205,7 +208,8 @@ gimp_color_balance_tool_map (GimpImageMapTool *image_map_tool) /**************************/ static GtkAdjustment * -create_levels_scale (const gchar *left, +create_levels_scale (gdouble value, + const gchar *left, const gchar *right, GtkWidget *table, gint col) @@ -222,7 +226,8 @@ create_levels_scale (const gchar *left, gtk_widget_show (label); spinbutton = gimp_spin_button_new (&adj, - 0, -100.0, 100.0, 1.0, 10.0, 0.0, 1.0, 0); + value, -100.0, 100.0, + 1.0, 10.0, 0.0, 1.0, 0); slider = gtk_hscale_new (GTK_ADJUSTMENT (adj)); gtk_scale_set_draw_value (GTK_SCALE (slider), FALSE); @@ -247,18 +252,21 @@ create_levels_scale (const gchar *left, static void gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool) { - GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool); - GtkWidget *vbox; - GtkWidget *hbox; - GtkWidget *table; - GtkWidget *button; - GtkWidget *frame; + GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool); + GimpColorBalanceConfig *config = cb_tool->config; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *table; + GtkWidget *button; + GtkWidget *frame; frame = gimp_enum_radio_frame_new (GIMP_TYPE_TRANSFER_MODE, gtk_label_new (_("Select Range to Adjust")), G_CALLBACK (color_balance_range_callback), cb_tool, &cb_tool->range_radio); + gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (cb_tool->range_radio), + config->range); gtk_box_pack_start (GTK_BOX (im_tool->main_vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); @@ -277,22 +285,28 @@ gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool) gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); - cb_tool->cyan_red_adj = create_levels_scale (_("Cyan"), _("Red"), - table, 0); + cb_tool->cyan_red_adj = + create_levels_scale (config->cyan_red[config->range] * 100.0, + _("Cyan"), _("Red"), + table, 0); g_signal_connect (cb_tool->cyan_red_adj, "value-changed", G_CALLBACK (color_balance_cr_changed), cb_tool); - cb_tool->magenta_green_adj = create_levels_scale (_("Magenta"), _("Green"), - table, 1); + cb_tool->magenta_green_adj = + create_levels_scale (config->magenta_green[config->range] * 100.0, + _("Magenta"), _("Green"), + table, 1); g_signal_connect (cb_tool->magenta_green_adj, "value-changed", G_CALLBACK (color_balance_mg_changed), cb_tool); - cb_tool->yellow_blue_adj = create_levels_scale (_("Yellow"), _("Blue"), - table, 2); + cb_tool->yellow_blue_adj = + create_levels_scale (config->yellow_blue[config->range] * 100.0, + _("Yellow"), _("Blue"), + table, 2); g_signal_connect (cb_tool->yellow_blue_adj, "value-changed", G_CALLBACK (color_balance_yb_changed), @@ -313,7 +327,7 @@ gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool) cb_tool->preserve_toggle = gtk_check_button_new_with_mnemonic (_("Preserve _luminosity")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb_tool->preserve_toggle), - cb_tool->config->preserve_luminosity); + config->preserve_luminosity); gtk_box_pack_end (GTK_BOX (im_tool->main_vbox), cb_tool->preserve_toggle, FALSE, FALSE, 0); gtk_widget_show (cb_tool->preserve_toggle); @@ -329,28 +343,53 @@ gimp_color_balance_tool_reset (GimpImageMapTool *im_tool) GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool); GimpTransferMode range = cb_tool->config->range; - gimp_color_balance_config_reset (cb_tool->config); + g_object_freeze_notify (G_OBJECT (cb_tool->config)); + + gimp_config_reset (GIMP_CONFIG (cb_tool->config)); g_object_set (cb_tool->config, "range", range, NULL); - color_balance_update (cb_tool); + g_object_thaw_notify (G_OBJECT (cb_tool->config)); } static void -color_balance_update (GimpColorBalanceTool *cb_tool) +color_balance_config_notify (GObject *object, + GParamSpec *pspec, + GimpColorBalanceTool *cb_tool) { - GimpColorBalanceConfig *config = cb_tool->config; + GimpColorBalanceConfig *config = GIMP_COLOR_BALANCE_CONFIG (object); - gtk_adjustment_set_value (cb_tool->cyan_red_adj, - config->cyan_red[config->range] * 100.0); - gtk_adjustment_set_value (cb_tool->magenta_green_adj, - config->magenta_green[config->range] * 100.0); - gtk_adjustment_set_value (cb_tool->yellow_blue_adj, - config->yellow_blue[config->range] * 100.0); + if (! cb_tool->cyan_red_adj) + return; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb_tool->preserve_toggle), - config->preserve_luminosity); + if (! strcmp (pspec->name, "range")) + { + gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (cb_tool->range_radio), + config->range); + } + else if (! strcmp (pspec->name, "cyan-red")) + { + gtk_adjustment_set_value (cb_tool->cyan_red_adj, + config->cyan_red[config->range] * 100.0); + } + else if (! strcmp (pspec->name, "magenta-green")) + { + gtk_adjustment_set_value (cb_tool->magenta_green_adj, + config->magenta_green[config->range] * 100.0); + } + else if (! strcmp (pspec->name, "yellow-blue")) + { + gtk_adjustment_set_value (cb_tool->yellow_blue_adj, + config->yellow_blue[config->range] * 100.0); + } + else if (! strcmp (pspec->name, "preserve-luminosity")) + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb_tool->preserve_toggle), + config->preserve_luminosity); + } + + gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool)); } static void @@ -365,8 +404,6 @@ color_balance_range_callback (GtkWidget *widget, g_object_set (cb_tool->config, "range", range, NULL); - - color_balance_update (cb_tool); } } @@ -374,12 +411,7 @@ static void color_balance_range_reset_callback (GtkWidget *widget, GimpColorBalanceTool *cb_tool) { - gimp_color_balance_config_reset_range (cb_tool->config, - cb_tool->config->range); - - color_balance_update (cb_tool); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool)); + gimp_color_balance_config_reset_range (cb_tool->config); } static void @@ -394,8 +426,6 @@ color_balance_preserve_toggled (GtkWidget *widget, g_object_set (config, "preserve-luminosity", active, NULL); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool)); } } @@ -411,8 +441,6 @@ color_balance_cr_changed (GtkAdjustment *adjustment, g_object_set (config, "cyan-red", value, NULL); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool)); } } @@ -428,8 +456,6 @@ color_balance_mg_changed (GtkAdjustment *adjustment, g_object_set (config, "magenta-green", value, NULL); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool)); } } @@ -445,7 +471,5 @@ color_balance_yb_changed (GtkAdjustment *adjustment, g_object_set (config, "yellow-blue", value, NULL); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool)); } } diff --git a/app/tools/gimpcolorizetool.c b/app/tools/gimpcolorizetool.c index aa11ef7a2b..7df8a0c128 100644 --- a/app/tools/gimpcolorizetool.c +++ b/app/tools/gimpcolorizetool.c @@ -18,9 +18,12 @@ #include "config.h" +#include + #include #include +#include "libgimpconfig/gimpconfig.h" #include "libgimpwidgets/gimpwidgets.h" #include "tools-types.h" @@ -53,12 +56,15 @@ static gboolean gimp_colorize_tool_initialize (GimpTool *tool, GimpDisplay *display, GError **error); -static GeglNode * gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool); +static GeglNode * gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool, + GObject **config); static void gimp_colorize_tool_map (GimpImageMapTool *im_tool); static void gimp_colorize_tool_dialog (GimpImageMapTool *im_tool); -static void gimp_colorize_tool_reset (GimpImageMapTool *im_tool); -static void colorize_update_sliders (GimpColorizeTool *col_tool); +static void gimp_colorize_tool_config_notify (GObject *object, + GParamSpec *pspec, + GimpColorizeTool *col_tool); + static void colorize_hue_changed (GtkAdjustment *adj, GimpColorizeTool *col_tool); static void colorize_saturation_changed (GtkAdjustment *adj, @@ -104,7 +110,6 @@ gimp_colorize_tool_class_init (GimpColorizeToolClass *klass) im_tool_class->get_operation = gimp_colorize_tool_get_operation; im_tool_class->map = gimp_colorize_tool_map; im_tool_class->dialog = gimp_colorize_tool_dialog; - im_tool_class->reset = gimp_colorize_tool_reset; } static void @@ -125,12 +130,6 @@ gimp_colorize_tool_finalize (GObject *object) { GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (object); - if (col_tool->config) - { - g_object_unref (col_tool->config); - col_tool->config = NULL; - } - g_slice_free (Colorize, col_tool->colorize); G_OBJECT_CLASS (parent_class)->finalize (object); @@ -154,31 +153,36 @@ gimp_colorize_tool_initialize (GimpTool *tool, return FALSE; } - gimp_colorize_config_reset (col_tool->config); + gimp_config_reset (GIMP_CONFIG (col_tool->config)); GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error); - colorize_update_sliders (col_tool); - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool)); return TRUE; } static GeglNode * -gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool) +gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool, + GObject **config) { - GimpColorizeTool *tool = GIMP_COLORIZE_TOOL (im_tool); + GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (im_tool); GeglNode *node; node = g_object_new (GEGL_TYPE_NODE, "operation", "gimp-colorize", NULL); - tool->config = g_object_new (GIMP_TYPE_COLORIZE_CONFIG, NULL); + col_tool->config = g_object_new (GIMP_TYPE_COLORIZE_CONFIG, NULL); + + *config = G_OBJECT (col_tool->config); + + g_signal_connect_object (col_tool->config, "notify", + G_CALLBACK (gimp_colorize_tool_config_notify), + G_OBJECT (col_tool), 0); gegl_node_set (node, - "config", tool->config, + "config", col_tool->config, NULL); return node; @@ -187,7 +191,7 @@ gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool) static void gimp_colorize_tool_map (GimpImageMapTool *image_map_tool) { - GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool); + GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool); gimp_colorize_config_to_cruft (col_tool->config, col_tool->colorize); } @@ -226,7 +230,8 @@ gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool) /* Create the hue scale widget */ data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, _("_Hue:"), SLIDER_WIDTH, -1, - 0.0, 0.0, 360.0, 1.0, 15.0, 0, + col_tool->config->hue * 360.0, + 0.0, 360.0, 1.0, 15.0, 0, TRUE, 0.0, 0.0, NULL, NULL); col_tool->hue_data = GTK_ADJUSTMENT (data); @@ -240,7 +245,8 @@ gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool) /* Create the saturation scale widget */ data = gimp_scale_entry_new (GTK_TABLE (table), 0, 1, _("_Saturation:"), SLIDER_WIDTH, -1, - 0.0, 0.0, 100.0, 1.0, 10.0, 0, + col_tool->config->saturation * 100.0, + 0.0, 100.0, 1.0, 10.0, 0, TRUE, 0.0, 0.0, NULL, NULL); col_tool->saturation_data = GTK_ADJUSTMENT (data); @@ -254,7 +260,8 @@ gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool) /* Create the lightness scale widget */ data = gimp_scale_entry_new (GTK_TABLE (table), 0, 2, _("_Lightness:"), SLIDER_WIDTH, -1, - 0.0, -100.0, 100.0, 1.0, 10.0, 0, + col_tool->config->lightness * 100.0, + -100.0, 100.0, 1.0, 10.0, 0, TRUE, 0.0, 0.0, NULL, NULL); col_tool->lightness_data = GTK_ADJUSTMENT (data); @@ -267,24 +274,32 @@ gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool) } static void -gimp_colorize_tool_reset (GimpImageMapTool *image_map_tool) +gimp_colorize_tool_config_notify (GObject *object, + GParamSpec *pspec, + GimpColorizeTool *col_tool) { - GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool); + GimpColorizeConfig *config = GIMP_COLORIZE_CONFIG (object); - gimp_colorize_config_reset (col_tool->config); + if (! col_tool->hue_data) + return; - colorize_update_sliders (col_tool); -} + if (! strcmp (pspec->name, "hue")) + { + gtk_adjustment_set_value (col_tool->hue_data, + config->hue * 360.0); + } + else if (! strcmp (pspec->name, "saturation")) + { + gtk_adjustment_set_value (col_tool->saturation_data, + config->saturation * 100.0); + } + else if (! strcmp (pspec->name, "lightness")) + { + gtk_adjustment_set_value (col_tool->lightness_data, + config->lightness * 100.0); + } -static void -colorize_update_sliders (GimpColorizeTool *col_tool) -{ - gtk_adjustment_set_value (col_tool->hue_data, - col_tool->config->hue * 360.0); - gtk_adjustment_set_value (col_tool->saturation_data, - col_tool->config->saturation * 100.0); - gtk_adjustment_set_value (col_tool->lightness_data, - col_tool->config->lightness * 100.0); + gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool)); } static void @@ -298,8 +313,6 @@ colorize_hue_changed (GtkAdjustment *adjustment, g_object_set (col_tool->config, "hue", value, NULL); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool)); } } @@ -314,8 +327,6 @@ colorize_saturation_changed (GtkAdjustment *adjustment, g_object_set (col_tool->config, "saturation", value, NULL); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool)); } } @@ -330,7 +341,5 @@ colorize_lightness_changed (GtkAdjustment *adjustment, g_object_set (col_tool->config, "lightness", value, NULL); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool)); } } diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c index 3b0b3c30cb..c60c879b9f 100644 --- a/app/tools/gimpcurvestool.c +++ b/app/tools/gimpcurvestool.c @@ -22,6 +22,7 @@ #include #include "libgimpcolor/gimpcolor.h" +#include "libgimpconfig/gimpconfig.h" #include "libgimpwidgets/gimpwidgets.h" #include "tools-types.h" @@ -83,7 +84,8 @@ static void gimp_curves_tool_color_picked (GimpColorTool *color_t GimpImageType sample_type, GimpRGB *color, gint color_index); -static GeglNode * gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool); +static GeglNode * gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool, + GObject **config); static void gimp_curves_tool_map (GimpImageMapTool *image_map_tool); static void gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool); static void gimp_curves_tool_reset (GimpImageMapTool *image_map_tool); @@ -93,8 +95,10 @@ static gboolean gimp_curves_tool_settings_load (GimpImageMapTool *image_m static gboolean gimp_curves_tool_settings_save (GimpImageMapTool *image_map_tool, gpointer fp); -static void curves_curve_callback (GimpCurve *curve, +static void gimp_curves_tool_config_notify (GObject *object, + GParamSpec *pspec, GimpCurvesTool *tool); + static void curves_channel_callback (GtkWidget *widget, GimpCurvesTool *tool); static void curves_channel_reset_callback (GtkWidget *widget, @@ -186,12 +190,6 @@ gimp_curves_tool_finalize (GObject *object) { GimpCurvesTool *tool = GIMP_CURVES_TOOL (object); - if (tool->config) - { - g_object_unref (tool->config); - tool->config = NULL; - } - gimp_lut_free (tool->lut); if (tool->hist) @@ -210,7 +208,6 @@ gimp_curves_tool_initialize (GimpTool *tool, { GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (tool); GimpDrawable *drawable = gimp_image_get_active_drawable (display->image); - gint i; if (! drawable) return FALSE; @@ -222,8 +219,7 @@ gimp_curves_tool_initialize (GimpTool *tool, return FALSE; } - for (i = 0; i < G_N_ELEMENTS (c_tool->config->curve); i++) - gimp_curve_reset (c_tool->config->curve[i], TRUE); + gimp_config_reset (GIMP_CONFIG (c_tool->config)); if (! c_tool->hist) c_tool->hist = gimp_histogram_new (); @@ -382,11 +378,11 @@ gimp_curves_tool_color_picked (GimpColorTool *color_tool, } static GeglNode * -gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool) +gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool, + GObject **config) { GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool); GeglNode *node; - gint i; node = g_object_new (GEGL_TYPE_NODE, "operation", "gimp-curves", @@ -394,12 +390,11 @@ gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool) tool->config = g_object_new (GIMP_TYPE_CURVES_CONFIG, NULL); - for (i = 0; i < G_N_ELEMENTS (tool->config->curve); i++) - { - g_signal_connect_object (tool->config->curve[i], "dirty", - G_CALLBACK (curves_curve_callback), - tool, 0); - } + *config = G_OBJECT (tool->config); + + g_signal_connect_object (tool->config, "notify", + G_CALLBACK (gimp_curves_tool_config_notify), + tool, 0); gegl_node_set (node, "config", tool->config, @@ -605,13 +600,15 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool) static void gimp_curves_tool_reset (GimpImageMapTool *image_map_tool) { - GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool); - GimpHistogramChannel channel = tool->config->channel; + GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool); + GimpHistogramChannel channel; - gimp_curves_config_reset (tool->config); - g_object_set (tool->config, - "channel", channel, - NULL); + for (channel = GIMP_HISTOGRAM_VALUE; + channel <= GIMP_HISTOGRAM_ALPHA; + channel++) + { + gimp_curve_reset (tool->config->curve[channel], FALSE); + } } static gboolean @@ -621,15 +618,7 @@ gimp_curves_tool_settings_load (GimpImageMapTool *image_map_tool, { GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool); - if (gimp_curves_config_load_cruft (tool->config, fp, error)) - { - gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (tool->curve_type), - GIMP_CURVE_SMOOTH); - - return TRUE; - } - - return FALSE; + return gimp_curves_config_load_cruft (tool->config, fp, error); } static gboolean @@ -642,15 +631,16 @@ gimp_curves_tool_settings_save (GimpImageMapTool *image_map_tool, } static void -curves_curve_callback (GimpCurve *curve, - GimpCurvesTool *tool) +gimp_curves_tool_config_notify (GObject *object, + GParamSpec *pspec, + GimpCurvesTool *tool) { - GimpCurvesConfig *config = tool->config; + GimpCurvesConfig *config = GIMP_CURVES_CONFIG (object); - if (curve != config->curve[config->channel]) + if (! tool->xrange) return; - if (tool->xrange) + if (! strcmp (pspec->name, "channel")) { switch (config->channel) { @@ -672,25 +662,6 @@ curves_curve_callback (GimpCurve *curve, config->curve[GIMP_HISTOGRAM_BLUE]->curve); break; } - } - - if (GIMP_IMAGE_MAP_TOOL (tool)->drawable) - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool)); -} - -static void -curves_channel_callback (GtkWidget *widget, - GimpCurvesTool *tool) -{ - gint value; - - if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value)) - { - GimpCurvesConfig *config = tool->config; - - g_object_set (config, - "channel", value, - NULL); gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (tool->graph), config->channel); @@ -702,11 +673,29 @@ curves_channel_callback (GtkWidget *widget, gimp_curve_view_set_curve (GIMP_CURVE_VIEW (tool->graph), config->curve[config->channel]); - + } + else if (! strcmp (pspec->name, "curve")) + { gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (tool->curve_type), config->curve[config->channel]->curve_type); + } - curves_curve_callback (config->curve[config->channel], tool); + gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool)); +} + +static void +curves_channel_callback (GtkWidget *widget, + GimpCurvesTool *tool) +{ + GimpCurvesConfig *config = tool->config; + gint value; + + if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value) && + config->channel != value) + { + g_object_set (config, + "channel", value, + NULL); } } @@ -714,7 +703,7 @@ static void curves_channel_reset_callback (GtkWidget *widget, GimpCurvesTool *tool) { - gimp_curves_config_reset_channel (tool->config, tool->config->channel); + gimp_curve_reset (tool->config->curve[tool->config->channel], FALSE); } static gboolean diff --git a/app/tools/gimphuesaturationtool.c b/app/tools/gimphuesaturationtool.c index 9233ff9ae2..21b70a2d22 100644 --- a/app/tools/gimphuesaturationtool.c +++ b/app/tools/gimphuesaturationtool.c @@ -18,9 +18,12 @@ #include "config.h" +#include + #include #include +#include "libgimpconfig/gimpconfig.h" #include "libgimpwidgets/gimpwidgets.h" #include "tools-types.h" @@ -56,12 +59,16 @@ static gboolean gimp_hue_saturation_tool_initialize (GimpTool *tool GimpDisplay *display, GError **error); -static GeglNode * gimp_hue_saturation_tool_get_operation (GimpImageMapTool *im_tool); +static GeglNode * gimp_hue_saturation_tool_get_operation (GimpImageMapTool *im_tool, + GObject **config); static void gimp_hue_saturation_tool_map (GimpImageMapTool *im_tool); static void gimp_hue_saturation_tool_dialog (GimpImageMapTool *im_tool); static void gimp_hue_saturation_tool_reset (GimpImageMapTool *im_tool); -static void hue_saturation_update_sliders (GimpHueSaturationTool *hs_tool); +static void hue_saturation_config_notify (GObject *object, + GParamSpec *pspec, + GimpHueSaturationTool *hs_tool); + static void hue_saturation_update_color_areas (GimpHueSaturationTool *hs_tool); static void hue_saturation_range_callback (GtkWidget *widget, @@ -137,12 +144,6 @@ gimp_hue_saturation_tool_finalize (GObject *object) { GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (object); - if (hs_tool->config) - { - g_object_unref (hs_tool->config); - hs_tool->config = NULL; - } - g_slice_free (HueSaturation, hs_tool->hue_saturation); G_OBJECT_CLASS (parent_class)->finalize (object); @@ -168,21 +169,16 @@ gimp_hue_saturation_tool_initialize (GimpTool *tool, return FALSE; } - gimp_hue_saturation_config_reset (hs_tool->config); + gimp_config_reset (GIMP_CONFIG (hs_tool->config)); GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error); - gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (hs_tool->range_radio), - hs_tool->config->range); - - hue_saturation_update_sliders (hs_tool); - hue_saturation_update_color_areas (hs_tool); - return TRUE; } static GeglNode * -gimp_hue_saturation_tool_get_operation (GimpImageMapTool *im_tool) +gimp_hue_saturation_tool_get_operation (GimpImageMapTool *im_tool, + GObject **config) { GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (im_tool); GeglNode *node; @@ -193,6 +189,12 @@ gimp_hue_saturation_tool_get_operation (GimpImageMapTool *im_tool) hs_tool->config = g_object_new (GIMP_TYPE_HUE_SATURATION_CONFIG, NULL); + *config = G_OBJECT (hs_tool->config); + + g_signal_connect_object (hs_tool->config, "notify", + G_CALLBACK (hue_saturation_config_notify), + G_OBJECT (hs_tool), 0); + gegl_node_set (node, "config", hs_tool->config, NULL); @@ -216,19 +218,20 @@ gimp_hue_saturation_tool_map (GimpImageMapTool *image_map_tool) static void gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool) { - GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool); - GtkWidget *vbox; - GtkWidget *abox; - GtkWidget *table; - GtkWidget *slider; - GtkWidget *button; - GtkWidget *frame; - GtkWidget *hbox; - GtkObject *data; - GtkSizeGroup *label_group; - GtkSizeGroup *spinner_group; - GSList *group = NULL; - gint i; + GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool); + GimpHueSaturationConfig *config = hs_tool->config; + GtkWidget *vbox; + GtkWidget *abox; + GtkWidget *table; + GtkWidget *slider; + GtkWidget *button; + GtkWidget *frame; + GtkWidget *hbox; + GtkObject *data; + GtkSizeGroup *label_group; + GtkSizeGroup *spinner_group; + GSList *group = NULL; + gint i; const struct { @@ -342,7 +345,8 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool) data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, _("_Overlap:"), SLIDER_WIDTH, -1, - 0.0, 0, 100.0, 1.0, 15.0, 0, + config->overlap * 100.0, + 0.0, 100.0, 1.0, 15.0, 0, TRUE, 0.0, 0.0, NULL, NULL); hs_tool->overlap_data = GTK_ADJUSTMENT (data); @@ -378,7 +382,8 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool) /* Create the hue scale widget */ data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, _("_Hue:"), SLIDER_WIDTH, -1, - 0.0, -180.0, 180.0, 1.0, 15.0, 0, + config->hue[config->range] * 180.0, + -180.0, 180.0, 1.0, 15.0, 0, TRUE, 0.0, 0.0, NULL, NULL); hs_tool->hue_data = GTK_ADJUSTMENT (data); @@ -396,7 +401,8 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool) /* Create the lightness scale widget */ data = gimp_scale_entry_new (GTK_TABLE (table), 0, 1, _("_Lightness:"), SLIDER_WIDTH, -1, - 0.0, -100.0, 100.0, 1.0, 10.0, 0, + config->lightness[config->range] * 100.0, + -100.0, 100.0, 1.0, 10.0, 0, TRUE, 0.0, 0.0, NULL, NULL); hs_tool->lightness_data = GTK_ADJUSTMENT (data); @@ -414,7 +420,8 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool) /* Create the saturation scale widget */ data = gimp_scale_entry_new (GTK_TABLE (table), 0, 2, _("_Saturation:"), SLIDER_WIDTH, -1, - 0.0, -100.0, 100.0, 1.0, 10.0, 0, + config->saturation[config->range] * 100.0, + -100.0, 100.0, 1.0, 10.0, 0, TRUE, 0.0, 0.0, NULL, NULL); hs_tool->saturation_data = GTK_ADJUSTMENT (data); @@ -440,6 +447,11 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool) g_signal_connect (button, "clicked", G_CALLBACK (hue_saturation_range_reset_callback), hs_tool); + + gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (hs_tool->range_radio), + config->range); + + hue_saturation_update_color_areas (hs_tool); } static void @@ -448,28 +460,55 @@ gimp_hue_saturation_tool_reset (GimpImageMapTool *image_map_tool) GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool); GimpHueRange range = hs_tool->config->range; - gimp_hue_saturation_config_reset (hs_tool->config); + g_object_freeze_notify (G_OBJECT (hs_tool->config)); + + gimp_config_reset (GIMP_CONFIG (hs_tool->config)); g_object_set (hs_tool->config, "range", range, NULL); - hue_saturation_update_sliders (hs_tool); - hue_saturation_update_color_areas (hs_tool); + g_object_thaw_notify (G_OBJECT (hs_tool->config)); } static void -hue_saturation_update_sliders (GimpHueSaturationTool *hs_tool) +hue_saturation_config_notify (GObject *object, + GParamSpec *pspec, + GimpHueSaturationTool *hs_tool) { - GimpHueSaturationConfig *config = hs_tool->config; + GimpHueSaturationConfig *config = GIMP_HUE_SATURATION_CONFIG (object); - gtk_adjustment_set_value (hs_tool->hue_data, - config->hue[config->range] * 180.0); - gtk_adjustment_set_value (hs_tool->lightness_data, - config->lightness[config->range] * 100.0); - gtk_adjustment_set_value (hs_tool->saturation_data, - config->saturation[config->range] * 100.0); - gtk_adjustment_set_value (hs_tool->overlap_data, - config->overlap * 100.0); + if (! hs_tool->hue_data) + return; + + if (! strcmp (pspec->name, "range")) + { + gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (hs_tool->range_radio), + config->range); + } + else if (! strcmp (pspec->name, "hue")) + { + gtk_adjustment_set_value (hs_tool->hue_data, + config->hue[config->range] * 180.0); + } + else if (! strcmp (pspec->name, "lightness")) + { + gtk_adjustment_set_value (hs_tool->lightness_data, + config->lightness[config->range] * 100.0); + } + else if (! strcmp (pspec->name, "saturation")) + { + gtk_adjustment_set_value (hs_tool->saturation_data, + config->saturation[config->range] * 100.0); + } + else if (! strcmp (pspec->name, "overlap")) + { + gtk_adjustment_set_value (hs_tool->overlap_data, + config->overlap * 100.0); + } + + hue_saturation_update_color_areas (hs_tool); + + gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool)); } static void @@ -511,8 +550,6 @@ hue_saturation_range_callback (GtkWidget *widget, g_object_set (hs_tool->config, "range", range, NULL); - - hue_saturation_update_sliders (hs_tool); } } @@ -520,13 +557,7 @@ static void hue_saturation_range_reset_callback (GtkWidget *widget, GimpHueSaturationTool *hs_tool) { - gimp_hue_saturation_config_reset_range (hs_tool->config, - hs_tool->config->range); - - hue_saturation_update_sliders (hs_tool); - hue_saturation_update_color_areas (hs_tool); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool)); + gimp_hue_saturation_config_reset_range (hs_tool->config); } static void @@ -541,10 +572,6 @@ hue_saturation_hue_changed (GtkAdjustment *adjustment, g_object_set (config, "hue", value, NULL); - - hue_saturation_update_color_areas (hs_tool); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool)); } } @@ -560,10 +587,6 @@ hue_saturation_lightness_changed (GtkAdjustment *adjustment, g_object_set (config, "lightness", value, NULL); - - hue_saturation_update_color_areas (hs_tool); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool)); } } @@ -579,10 +602,6 @@ hue_saturation_saturation_changed (GtkAdjustment *adjustment, g_object_set (config, "saturation", value, NULL); - - hue_saturation_update_color_areas (hs_tool); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool)); } } @@ -598,9 +617,5 @@ hue_saturation_overlap_changed (GtkAdjustment *adjustment, g_object_set (config, "overlap", value, NULL); - - hue_saturation_update_color_areas (hs_tool); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool)); } } diff --git a/app/tools/gimpimagemaptool.c b/app/tools/gimpimagemaptool.c index f6e7af5fea..aac2b76573 100644 --- a/app/tools/gimpimagemaptool.c +++ b/app/tools/gimpimagemaptool.c @@ -26,6 +26,7 @@ #include #include "libgimpbase/gimpbase.h" +#include "libgimpconfig/gimpconfig.h" #include "libgimpwidgets/gimpwidgets.h" #include "tools-types.h" @@ -163,6 +164,7 @@ gimp_image_map_tool_init (GimpImageMapTool *image_map_tool) image_map_tool->drawable = NULL; image_map_tool->operation = NULL; + image_map_tool->config = NULL; image_map_tool->image_map = NULL; image_map_tool->shell = NULL; @@ -187,7 +189,8 @@ gimp_image_map_tool_constructor (GType type, klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool); if (klass->get_operation) - image_map_tool->operation = klass->get_operation (image_map_tool); + image_map_tool->operation = klass->get_operation (image_map_tool, + &image_map_tool->config); return object; } @@ -203,6 +206,12 @@ gimp_image_map_tool_finalize (GObject *object) image_map_tool->operation = NULL; } + if (image_map_tool->config) + { + g_object_unref (image_map_tool->config); + image_map_tool->config = NULL; + } + if (image_map_tool->shell) { gtk_widget_destroy (image_map_tool->shell); @@ -480,7 +489,14 @@ gimp_image_map_tool_dialog (GimpImageMapTool *tool) static void gimp_image_map_tool_reset (GimpImageMapTool *tool) { - GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->reset (tool); + if (GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->reset) + { + GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->reset (tool); + } + else if (tool->config) + { + gimp_config_reset (GIMP_CONFIG (tool->config)); + } } static void diff --git a/app/tools/gimpimagemaptool.h b/app/tools/gimpimagemaptool.h index 49096e3ff3..d2a7760024 100644 --- a/app/tools/gimpimagemaptool.h +++ b/app/tools/gimpimagemaptool.h @@ -42,6 +42,7 @@ struct _GimpImageMapTool GimpDrawable *drawable; GeglNode *operation; + GObject *config; GimpImageMapApplyFunc apply_func; gpointer apply_data; @@ -69,7 +70,8 @@ struct _GimpImageMapToolClass const gchar *save_dialog_title; /* virtual functions */ - GeglNode * (* get_operation) (GimpImageMapTool *image_map_tool); + GeglNode * (* get_operation) (GimpImageMapTool *image_map_tool, + GObject **config); void (* map) (GimpImageMapTool *image_map_tool); void (* dialog) (GimpImageMapTool *image_map_tool); void (* reset) (GimpImageMapTool *image_map_tool); diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c index b8503d9c6f..025afb1b23 100644 --- a/app/tools/gimplevelstool.c +++ b/app/tools/gimplevelstool.c @@ -22,6 +22,7 @@ #include #include "libgimpmath/gimpmath.h" +#include "libgimpconfig/gimpconfig.h" #include "libgimpwidgets/gimpwidgets.h" #include "tools-types.h" @@ -74,7 +75,8 @@ static void gimp_levels_tool_color_picked (GimpColorTool *color_tool GimpRGB *color, gint color_index); -static GeglNode * gimp_levels_tool_get_operation (GimpImageMapTool *im_tool); +static GeglNode * gimp_levels_tool_get_operation (GimpImageMapTool *im_tool, + GObject **config); static void gimp_levels_tool_map (GimpImageMapTool *im_tool); static void gimp_levels_tool_dialog (GimpImageMapTool *im_tool); static void gimp_levels_tool_dialog_unmap (GtkWidget *dialog, @@ -86,7 +88,10 @@ static gboolean gimp_levels_tool_settings_load (GimpImageMapTool *im_tool, static gboolean gimp_levels_tool_settings_save (GimpImageMapTool *im_tool, gpointer fp); -static void levels_update_adjustments (GimpLevelsTool *tool); +static void gimp_levels_tool_config_notify (GObject *object, + GParamSpec *pspec, + GimpLevelsTool *tool); + static void levels_update_input_bar (GimpLevelsTool *tool); static void levels_channel_callback (GtkWidget *widget, @@ -184,12 +189,6 @@ gimp_levels_tool_finalize (GObject *object) { GimpLevelsTool *tool = GIMP_LEVELS_TOOL (object); - if (tool->config) - { - g_object_unref (tool->config); - tool->config = NULL; - } - gimp_lut_free (tool->lut); if (tool->hist) @@ -219,11 +218,11 @@ gimp_levels_tool_initialize (GimpTool *tool, return FALSE; } + gimp_config_reset (GIMP_CONFIG (l_tool->config)); + if (! l_tool->hist) l_tool->hist = gimp_histogram_new (); - gimp_levels_config_reset (l_tool->config); - l_tool->color = gimp_drawable_is_rgb (drawable); l_tool->alpha = gimp_drawable_has_alpha (drawable); @@ -236,11 +235,6 @@ gimp_levels_tool_initialize (GimpTool *tool, gimp_int_combo_box_set_sensitivity (GIMP_INT_COMBO_BOX (l_tool->channel_menu), levels_menu_sensitivity, l_tool, NULL); - gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (l_tool->channel_menu), - l_tool->config->channel); - - levels_update_adjustments (l_tool); - gimp_drawable_calculate_histogram (drawable, l_tool->hist); gimp_histogram_view_set_histogram (GIMP_HISTOGRAM_VIEW (l_tool->hist_view), l_tool->hist); @@ -249,7 +243,8 @@ gimp_levels_tool_initialize (GimpTool *tool, } static GeglNode * -gimp_levels_tool_get_operation (GimpImageMapTool *im_tool) +gimp_levels_tool_get_operation (GimpImageMapTool *im_tool, + GObject **config) { GimpLevelsTool *tool = GIMP_LEVELS_TOOL (im_tool); GeglNode *node; @@ -260,6 +255,12 @@ gimp_levels_tool_get_operation (GimpImageMapTool *im_tool) tool->config = g_object_new (GIMP_TYPE_LEVELS_CONFIG, NULL); + *config = G_OBJECT (tool->config); + + g_signal_connect_object (tool->config, "notify", + G_CALLBACK (gimp_levels_tool_config_notify), + G_OBJECT (tool), 0); + gegl_node_set (node, "config", tool->config, NULL); @@ -336,23 +337,24 @@ gimp_levels_tool_color_picker_new (GimpLevelsTool *tool, static void gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool) { - GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool); - GimpToolOptions *tool_options = GIMP_TOOL_GET_OPTIONS (image_map_tool); - GtkListStore *store; - GtkWidget *vbox; - GtkWidget *vbox2; - GtkWidget *vbox3; - GtkWidget *hbox; - GtkWidget *hbox2; - GtkWidget *label; - GtkWidget *menu; - GtkWidget *frame; - GtkWidget *hbbox; - GtkWidget *button; - GtkWidget *spinbutton; - GtkWidget *bar; - GtkObject *data; - gint border; + GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool); + GimpToolOptions *tool_options = GIMP_TOOL_GET_OPTIONS (image_map_tool); + GimpLevelsConfig *config = tool->config; + GtkListStore *store; + GtkWidget *vbox; + GtkWidget *vbox2; + GtkWidget *vbox3; + GtkWidget *hbox; + GtkWidget *hbox2; + GtkWidget *label; + GtkWidget *menu; + GtkWidget *frame; + GtkWidget *hbbox; + GtkWidget *button; + GtkWidget *spinbutton; + GtkWidget *bar; + GtkObject *data; + gint border; /* The option menu for selecting channels */ hbox = gtk_hbox_new (FALSE, 6); @@ -482,7 +484,9 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool) gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0); gtk_widget_show (button); - spinbutton = gimp_spin_button_new (&data, 0, 0, 255, 1, 10, 10, 0.5, 0); + spinbutton = gimp_spin_button_new (&data, + config->low_input[config->channel] * 255.0, + 0, 255, 1, 10, 10, 0.5, 0); gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); @@ -495,7 +499,9 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool) tool->low_input); /* input gamma spin */ - spinbutton = gimp_spin_button_new (&data, 1, 0.1, 10, 0.01, 0.1, 1, 0.5, 2); + spinbutton = gimp_spin_button_new (&data, + config->gamma[config->channel], + 0.1, 10, 0.01, 0.1, 1, 0.5, 2); gtk_box_pack_start (GTK_BOX (hbox), spinbutton, TRUE, FALSE, 0); gimp_help_set_help_data (spinbutton, _("Gamma"), NULL); gtk_widget_show (spinbutton); @@ -524,7 +530,9 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool) gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0); gtk_widget_show (button); - spinbutton = gimp_spin_button_new (&data, 255, 0, 255, 1, 10, 10, 0.5, 0); + spinbutton = gimp_spin_button_new (&data, + config->high_input[config->channel] * 255.0, + 0, 255, 1, 10, 10, 0.5, 0); gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); @@ -584,7 +592,9 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool) gtk_widget_show (hbox); /* low output spin */ - spinbutton = gimp_spin_button_new (&data, 0, 0, 255, 1, 10, 10, 0.5, 0); + spinbutton = gimp_spin_button_new (&data, + config->low_output[config->channel] * 255.0, + 0, 255, 1, 10, 10, 0.5, 0); gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); @@ -597,7 +607,9 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool) tool->low_output); /* high output spin */ - spinbutton = gimp_spin_button_new (&data, 255, 0, 255, 1, 10, 10, 0.5, 0); + spinbutton = gimp_spin_button_new (&data, + config->high_output[config->channel] * 255.0, + 0, 255, 1, 10, 10, 0.5, 0); gtk_box_pack_end (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0); gtk_widget_show (spinbutton); @@ -664,6 +676,9 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool) g_signal_connect (image_map_tool->shell, "unmap", G_CALLBACK (gimp_levels_tool_dialog_unmap), tool); + + gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->channel_menu), + config->channel); } static void @@ -681,12 +696,14 @@ gimp_levels_tool_reset (GimpImageMapTool *image_map_tool) GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool); GimpHistogramChannel channel = tool->config->channel; - gimp_levels_config_reset (tool->config); + g_object_freeze_notify (G_OBJECT (tool->config)); + + gimp_config_reset (GIMP_CONFIG (tool->config)); g_object_set (tool->config, "channel", channel, NULL); - levels_update_adjustments (tool); + g_object_thaw_notify (G_OBJECT (tool->config)); } static gboolean @@ -696,14 +713,7 @@ gimp_levels_tool_settings_load (GimpImageMapTool *image_map_tool, { GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool); - if (gimp_levels_config_load_cruft (tool->config, fp, error)) - { - levels_update_adjustments (tool); - - return TRUE; - } - - return FALSE; + return gimp_levels_config_load_cruft (tool->config, fp, error); } static gboolean @@ -716,36 +726,62 @@ gimp_levels_tool_settings_save (GimpImageMapTool *image_map_tool, } static void -levels_update_adjustments (GimpLevelsTool *tool) +gimp_levels_tool_config_notify (GObject *object, + GParamSpec *pspec, + GimpLevelsTool *tool) { - GimpLevelsConfig *config = tool->config; + GimpLevelsConfig *config = GIMP_LEVELS_CONFIG (object); - tool->low_input->upper = 255; - tool->high_input->lower = 0; - tool->gamma_linear->lower = 0; - tool->gamma_linear->upper = 255; + if (! tool->low_input) + return; - gtk_adjustment_set_value (tool->low_input, - config->low_input[config->channel] * 255.0); - gtk_adjustment_set_value (tool->gamma, - config->gamma[config->channel]); - gtk_adjustment_set_value (tool->high_input, - config->high_input[config->channel] * 255.0); + if (! strcmp (pspec->name, "channel")) + { + gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (tool->hist_view), + config->channel); + gimp_color_bar_set_channel (GIMP_COLOR_BAR (tool->output_bar), + config->channel); + gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->channel_menu), + config->channel); + } + else if (! strcmp (pspec->name, "gamma") || + ! strcmp (pspec->name, "low-input") || + ! strcmp (pspec->name, "high-input")) + { + tool->low_input->upper = 255; + tool->high_input->lower = 0; + tool->gamma_linear->lower = 0; + tool->gamma_linear->upper = 255; - tool->low_input->upper = tool->high_input->value; - tool->high_input->lower = tool->low_input->value; - tool->gamma_linear->lower = tool->low_input->value; - tool->gamma_linear->upper = tool->high_input->value; - gtk_adjustment_changed (tool->low_input); - gtk_adjustment_changed (tool->high_input); - gtk_adjustment_changed (tool->gamma_linear); + gtk_adjustment_set_value (tool->low_input, + config->low_input[config->channel] * 255.0); + gtk_adjustment_set_value (tool->gamma, + config->gamma[config->channel]); + gtk_adjustment_set_value (tool->high_input, + config->high_input[config->channel] * 255.0); - gtk_adjustment_set_value (tool->low_output, - config->low_output[config->channel] * 255.0); - gtk_adjustment_set_value (tool->high_output, - config->high_output[config->channel] * 255.0); + tool->low_input->upper = tool->high_input->value; + tool->high_input->lower = tool->low_input->value; + tool->gamma_linear->lower = tool->low_input->value; + tool->gamma_linear->upper = tool->high_input->value; + gtk_adjustment_changed (tool->low_input); + gtk_adjustment_changed (tool->high_input); + gtk_adjustment_changed (tool->gamma_linear); - levels_update_input_bar (tool); + levels_update_input_bar (tool); + } + else if (! strcmp (pspec->name, "low-output")) + { + gtk_adjustment_set_value (tool->low_output, + config->low_output[config->channel] * 255.0); + } + else if (! strcmp (pspec->name, "high-output")) + { + gtk_adjustment_set_value (tool->high_output, + config->high_output[config->channel] * 255.0); + } + + gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool)); } static void @@ -809,18 +845,12 @@ levels_channel_callback (GtkWidget *widget, { gint value; - if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value)) + if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value) && + tool->config->channel != value) { g_object_set (tool->config, "channel", value, NULL); - - gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (tool->hist_view), - tool->config->channel); - gimp_color_bar_set_channel (GIMP_COLOR_BAR (tool->output_bar), - tool->config->channel); - - levels_update_adjustments (tool); } } @@ -828,10 +858,7 @@ static void levels_channel_reset_callback (GtkWidget *widget, GimpLevelsTool *tool) { - gimp_levels_config_reset_channel (tool->config, tool->config->channel); - levels_update_adjustments (tool); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool)); + gimp_levels_config_reset_channel (tool->config); } static gboolean @@ -866,9 +893,6 @@ levels_stretch_callback (GtkWidget *widget, GimpLevelsTool *tool) { gimp_levels_config_stretch (tool->config, tool->hist, tool->color); - levels_update_adjustments (tool); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool)); } static void @@ -922,9 +946,6 @@ levels_low_input_changed (GtkAdjustment *adjustment, g_object_set (config, "low-input", value / 255.0, NULL); - levels_update_input_bar (tool); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool)); } levels_linear_gamma_update (tool); @@ -941,9 +962,6 @@ levels_gamma_changed (GtkAdjustment *adjustment, g_object_set (config, "gamma", adjustment->value, NULL); - levels_update_input_bar (tool); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool)); } levels_linear_gamma_update (tool); @@ -966,9 +984,6 @@ levels_high_input_changed (GtkAdjustment *adjustment, g_object_set (config, "high-input", value / 255.0, NULL); - levels_update_input_bar (tool); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool)); } levels_linear_gamma_update (tool); @@ -986,8 +1001,6 @@ levels_low_output_changed (GtkAdjustment *adjustment, g_object_set (config, "low-output", value / 255.0, NULL); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool)); } } @@ -1003,8 +1016,6 @@ levels_high_output_changed (GtkAdjustment *adjustment, g_object_set (config, "high-output", value / 255.0, NULL); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool)); } } @@ -1102,8 +1113,4 @@ gimp_levels_tool_color_picked (GimpColorTool *color_tool, levels_input_adjust_by_color (tool->config, value, tool->config->channel, color); } - - levels_update_adjustments (tool); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool)); } diff --git a/app/tools/gimppolygonselecttool.c b/app/tools/gimppolygonselecttool.c new file mode 100644 index 0000000000..0abd3e54fe --- /dev/null +++ b/app/tools/gimppolygonselecttool.c @@ -0,0 +1,598 @@ +/* GIMP - The GNU Image Manipulation Program + * + * A polygonal selection tool for GIMP + * Copyright (C) 2007 Martin Nordholts + * + * Based on gimpfreeselecttool.c which is + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 +#include + +#include "libgimpmath/gimpmath.h" +#include "libgimpwidgets/gimpwidgets.h" + +#include "tools-types.h" + +#include "core/gimpchannel.h" +#include "core/gimpchannel-select.h" +#include "core/gimpimage.h" +#include "core/gimplayer-floating-sel.h" + +#include "widgets/gimphelp-ids.h" + +#include "display/gimpdisplay.h" + +#include "gimppolygonselecttool.h" +#include "gimpselectionoptions.h" +#include "gimptoolcontrol.h" + +#include "gimp-intl.h" + + +#define DEFAULT_MAX_INC 1024 + +#define POINT_GRAB_THRESHOLD_SQ 100 + + +struct _GimpPolygonSelectTool +{ + GimpSelectionTool parent_instance; + + /* Point which is part of he polygon already. */ + GimpVector2 *grabbed_point; + + /* Save the grabbed point state so we can cancel a movement + * operation. + */ + GimpVector2 saved_grabbed_point; + + /* Point which is used to draw the polygon but which is not part of + * it yet. + */ + GimpVector2 pending_point; + gboolean show_pending_point; + + /* The points of the polygon. */ + GimpVector2 *points; + + /* The number of points used for the actual selection. */ + gint num_points; + + gint max_segs; +}; + + +static void gimp_polygon_select_tool_finalize (GObject *object); +static void gimp_polygon_select_tool_control (GimpTool *tool, + GimpToolAction action, + GimpDisplay *display); +static void gimp_polygon_select_tool_oper_update (GimpTool *tool, + GimpCoords *coords, + GdkModifierType state, + gboolean proximity, + GimpDisplay *display); +static void gimp_polygon_select_tool_button_press (GimpTool *tool, + GimpCoords *coords, + guint32 time, + GdkModifierType state, + GimpDisplay *display); +static void gimp_polygon_select_tool_motion (GimpTool *tool, + GimpCoords *coords, + guint32 time, + GdkModifierType state, + GimpDisplay *display); +static void gimp_polygon_select_tool_button_release (GimpTool *tool, + GimpCoords *coords, + guint32 time, + GdkModifierType state, + GimpButtonReleaseType release_type, + GimpDisplay *display); +static gboolean gimp_polygon_select_tool_key_press (GimpTool *tool, + GdkEventKey *kevent, + GimpDisplay *display); + +static void gimp_polygon_select_tool_start (GimpPolygonSelectTool *poly_sel_tool, + GimpDisplay *display); +static void gimp_polygon_select_tool_commit (GimpPolygonSelectTool *poly_sel_tool, + GimpDisplay *display); +static void gimp_polygon_select_tool_halt (GimpPolygonSelectTool *poly_sel_tool); + +static void gimp_polygon_select_tool_draw (GimpDrawTool *draw_tool); + +static void gimp_polygon_select_tool_real_select (GimpPolygonSelectTool *poly_sel_tool, + GimpDisplay *display); + +static GimpVector2 *gimp_polygon_select_tool_add_point (GimpPolygonSelectTool *poly_sel_tool, + gdouble x, + gdouble y); +static void gimp_polygon_select_tool_remove_last (GimpPolygonSelectTool *poly_sel_tool); +static void gimp_polygon_select_tool_select_closet_point + (GimpPolygonSelectTool *poly_sel_tool, + GimpDisplay *display, + GimpCoords *coords); +static gboolean gimp_polygon_select_tool_should_close (GimpPolygonSelectTool *poly_sel_tool, + GimpDisplay *display, + GimpCoords *coords); + + +G_DEFINE_TYPE (GimpPolygonSelectTool, gimp_polygon_select_tool, + GIMP_TYPE_SELECTION_TOOL); + + +#define parent_class gimp_polygon_select_tool_parent_class + + +void +gimp_polygon_select_tool_register (GimpToolRegisterCallback callback, + gpointer data) +{ + (* callback) (GIMP_TYPE_POLYGON_SELECT_TOOL, + GIMP_TYPE_SELECTION_OPTIONS, + gimp_selection_options_gui, + 0, + "gimp-polygon-select-tool", + _("Polygon Select"), + _("Polygon Select Tool: Select a hand-drawn polygon"), + N_("_Polygon Select"), "G", + NULL, GIMP_HELP_TOOL_POLYGON_SELECT, + GIMP_STOCK_TOOL_POLYGON_SELECT, + data); +} + +static void +gimp_polygon_select_tool_class_init (GimpPolygonSelectToolClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass); + GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass); + + object_class->finalize = gimp_polygon_select_tool_finalize; + + tool_class->control = gimp_polygon_select_tool_control; + tool_class->oper_update = gimp_polygon_select_tool_oper_update; + tool_class->button_press = gimp_polygon_select_tool_button_press; + tool_class->motion = gimp_polygon_select_tool_motion; + tool_class->button_release = gimp_polygon_select_tool_button_release; + tool_class->key_press = gimp_polygon_select_tool_key_press; + + draw_tool_class->draw = gimp_polygon_select_tool_draw; + + klass->select = gimp_polygon_select_tool_real_select; +} + +static void +gimp_polygon_select_tool_init (GimpPolygonSelectTool *poly_sel_tool) +{ + GimpTool *tool = GIMP_TOOL (poly_sel_tool); + + gimp_tool_control_set_scroll_lock (tool->control, FALSE); + gimp_tool_control_set_wants_click (tool->control, TRUE); + gimp_tool_control_set_tool_cursor (tool->control, + GIMP_TOOL_CURSOR_FREE_SELECT); + + poly_sel_tool->points = NULL; + poly_sel_tool->max_segs = 0; +} + +static void +gimp_polygon_select_tool_finalize (GObject *object) +{ + GimpPolygonSelectTool *poly_sel_tool = GIMP_POLYGON_SELECT_TOOL (object); + + if (poly_sel_tool->points) + { + g_free (poly_sel_tool->points); + poly_sel_tool->points = NULL; + } + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +gimp_polygon_select_tool_control (GimpTool *tool, + GimpToolAction action, + GimpDisplay *display) +{ + switch (action) + { + case GIMP_TOOL_ACTION_PAUSE: + case GIMP_TOOL_ACTION_RESUME: + break; + + case GIMP_TOOL_ACTION_HALT: + gimp_polygon_select_tool_halt (GIMP_POLYGON_SELECT_TOOL (tool)); + break; + } + + GIMP_TOOL_CLASS (parent_class)->control (tool, action, display); +} + +static void +gimp_polygon_select_tool_oper_update (GimpTool *tool, + GimpCoords *coords, + GdkModifierType state, + gboolean proximity, + GimpDisplay *display) +{ + GimpPolygonSelectTool *poly_sel_tool = GIMP_POLYGON_SELECT_TOOL (tool); + + if (tool->display == display) + { + gimp_polygon_select_tool_select_closet_point (poly_sel_tool, + display, + coords); + + gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); + + if (poly_sel_tool->grabbed_point || poly_sel_tool->num_points == 0) + { + poly_sel_tool->show_pending_point = FALSE; + } + else + { + poly_sel_tool->show_pending_point = TRUE; + + poly_sel_tool->pending_point.x = coords->x; + poly_sel_tool->pending_point.y = coords->y; + } + + gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); + } +} + +static void +gimp_polygon_select_tool_button_press (GimpTool *tool, + GimpCoords *coords, + guint32 time, + GdkModifierType state, + GimpDisplay *display) +{ + GimpPolygonSelectTool *poly_sel_tool = GIMP_POLYGON_SELECT_TOOL (tool); + + if (display != tool->display) + { + gimp_polygon_select_tool_start (poly_sel_tool, display); + + gimp_selection_tool_start_edit (GIMP_SELECTION_TOOL (poly_sel_tool), + coords); + } + + if (poly_sel_tool->grabbed_point) + { + poly_sel_tool->saved_grabbed_point = *poly_sel_tool->grabbed_point; + } +} + +static void +gimp_polygon_select_tool_motion (GimpTool *tool, + GimpCoords *coords, + guint32 time, + GdkModifierType state, + GimpDisplay *display) +{ + if (tool->display == display) + { + GimpPolygonSelectTool *poly_sel_tool = GIMP_POLYGON_SELECT_TOOL (tool); + GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool); + + gimp_draw_tool_pause (draw_tool); + + if (poly_sel_tool->grabbed_point) + { + poly_sel_tool->grabbed_point->x = coords->x; + poly_sel_tool->grabbed_point->y = coords->y; + } + else + { + poly_sel_tool->pending_point.x = coords->x; + poly_sel_tool->pending_point.y = coords->y; + } + + gimp_draw_tool_resume (draw_tool); + } +} + +static void +gimp_polygon_select_tool_button_release (GimpTool *tool, + GimpCoords *coords, + guint32 time, + GdkModifierType state, + GimpButtonReleaseType release_type, + GimpDisplay *display) +{ + GimpPolygonSelectTool *poly_sel_tool = GIMP_POLYGON_SELECT_TOOL (tool); + + switch (release_type) + { + case GIMP_BUTTON_RELEASE_CLICK: + if (gimp_polygon_select_tool_should_close (poly_sel_tool, + display, + coords)) + { + gimp_polygon_select_tool_commit (poly_sel_tool, + display); + break; + } + + /* Fall through */ + + case GIMP_BUTTON_RELEASE_NORMAL: + if (! poly_sel_tool->grabbed_point) + { + gimp_polygon_select_tool_add_point (poly_sel_tool, coords->x, coords->y); + } + else + { + /* We don't need to do anything since the grabbed point have + * already been moved in _motion. + */ + } + break; + + case GIMP_BUTTON_RELEASE_CANCEL: + { + gimp_draw_tool_pause (GIMP_DRAW_TOOL (poly_sel_tool)); + + if (poly_sel_tool->grabbed_point) + { + *poly_sel_tool->grabbed_point = poly_sel_tool->saved_grabbed_point; + } + + gimp_draw_tool_resume (GIMP_DRAW_TOOL (poly_sel_tool)); + } + break; + + case GIMP_BUTTON_RELEASE_NO_MOTION: + if (gimp_image_floating_sel (display->image)) + { + /* If there is a floating selection, anchor it */ + floating_sel_anchor (gimp_image_floating_sel (display->image)); + } + else + { + /* Otherwise, clear the selection mask */ + gimp_channel_clear (gimp_image_get_mask (display->image), NULL, TRUE); + } + break; + } +} + +static gboolean +gimp_polygon_select_tool_key_press (GimpTool *tool, + GdkEventKey *kevent, + GimpDisplay *display) +{ + GimpPolygonSelectTool *poly_sel_tool = GIMP_POLYGON_SELECT_TOOL (tool); + gboolean handled_key = FALSE; + + switch (kevent->keyval) + { + case GDK_BackSpace: + gimp_polygon_select_tool_remove_last (poly_sel_tool); + handled_key = TRUE; + break; + + case GDK_KP_Enter: + case GDK_Return: + gimp_polygon_select_tool_commit (poly_sel_tool, display); + handled_key = TRUE; + break; + + case GDK_Escape: + gimp_polygon_select_tool_halt (poly_sel_tool); + handled_key = TRUE; + break; + + default: + handled_key = FALSE; + break; + } + + return handled_key; +} + +static void +gimp_polygon_select_tool_start (GimpPolygonSelectTool *poly_sel_tool, + GimpDisplay *display) +{ + GimpTool *tool = GIMP_TOOL (poly_sel_tool); + GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool); + + gimp_polygon_select_tool_halt (poly_sel_tool); + + gimp_tool_control_activate (tool->control); + + tool->display = display; + + poly_sel_tool->num_points = 0; + poly_sel_tool->grabbed_point = NULL; + poly_sel_tool->show_pending_point = FALSE; + + gimp_draw_tool_start (draw_tool, display); +} + +static void +gimp_polygon_select_tool_commit (GimpPolygonSelectTool *poly_sel_tool, + GimpDisplay *display) +{ + gimp_polygon_select_tool_select (poly_sel_tool, display); + + gimp_polygon_select_tool_halt (poly_sel_tool); +} + +static void +gimp_polygon_select_tool_halt (GimpPolygonSelectTool *poly_sel_tool) +{ + GimpTool *tool = GIMP_TOOL (poly_sel_tool); + GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (poly_sel_tool); + + if (gimp_draw_tool_is_active (draw_tool)) + gimp_draw_tool_stop (draw_tool); + + if (gimp_tool_control_is_active (tool->control)) + gimp_tool_control_halt (tool->control); + + poly_sel_tool->grabbed_point = NULL; + poly_sel_tool->show_pending_point = FALSE; + poly_sel_tool->num_points = 0; + + tool->display = NULL; +} + +static void +gimp_polygon_select_tool_draw (GimpDrawTool *draw_tool) +{ + GimpPolygonSelectTool *poly_sel_tool = GIMP_POLYGON_SELECT_TOOL (draw_tool); + + gimp_draw_tool_draw_lines (draw_tool, + (const gdouble *) poly_sel_tool->points, + poly_sel_tool->num_points, + FALSE, FALSE); + + if (poly_sel_tool->show_pending_point) + { + gimp_draw_tool_draw_line (draw_tool, + poly_sel_tool->points[poly_sel_tool->num_points - 1].x, + poly_sel_tool->points[poly_sel_tool->num_points - 1].y, + poly_sel_tool->pending_point.x, + poly_sel_tool->pending_point.y, + FALSE); + } +} + +void +gimp_polygon_select_tool_select (GimpPolygonSelectTool *poly_sel_tool, + GimpDisplay *display) +{ + g_return_if_fail (GIMP_IS_POLYGON_SELECT_TOOL (poly_sel_tool)); + g_return_if_fail (GIMP_IS_DISPLAY (display)); + + GIMP_POLYGON_SELECT_TOOL_GET_CLASS (poly_sel_tool)->select (poly_sel_tool, display); +} + + +static void +gimp_polygon_select_tool_real_select (GimpPolygonSelectTool *poly_sel_tool, + GimpDisplay *display) +{ + GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (poly_sel_tool); + + gimp_channel_select_polygon (gimp_image_get_mask (display->image), + Q_("command|Polygon Select"), + poly_sel_tool->num_points, + poly_sel_tool->points, + options->operation, + options->antialias, + options->feather, + options->feather_radius, + options->feather_radius, + TRUE); +} + +static GimpVector2 * +gimp_polygon_select_tool_add_point (GimpPolygonSelectTool *poly_sel_tool, + gdouble x, + gdouble y) +{ + if (poly_sel_tool->num_points >= poly_sel_tool->max_segs) + { + poly_sel_tool->max_segs += DEFAULT_MAX_INC; + + poly_sel_tool->points = g_realloc (poly_sel_tool->points, + sizeof (GimpVector2) * poly_sel_tool->max_segs); + } + + poly_sel_tool->points[poly_sel_tool->num_points].x = x; + poly_sel_tool->points[poly_sel_tool->num_points].y = y; + + return &poly_sel_tool->points[poly_sel_tool->num_points++]; +} + +static void +gimp_polygon_select_tool_remove_last (GimpPolygonSelectTool *poly_sel_tool) +{ + GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (poly_sel_tool); + + gimp_draw_tool_pause (draw_tool); + + if (poly_sel_tool->num_points == 0) + { + gimp_polygon_select_tool_halt (poly_sel_tool); + } + else + { + poly_sel_tool->num_points--; + } + + gimp_draw_tool_resume (draw_tool); +} + +static void +gimp_polygon_select_tool_select_closet_point (GimpPolygonSelectTool *poly_sel_tool, + GimpDisplay *display, + GimpCoords *coords) +{ + GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (poly_sel_tool); + gdouble shortest_dist_sq; + int i; + + poly_sel_tool->grabbed_point = NULL; + shortest_dist_sq = POINT_GRAB_THRESHOLD_SQ; + + for (i = 0; i < poly_sel_tool->num_points; i++) + { + gdouble dist_sq; + + dist_sq = gimp_draw_tool_calc_distance_square (draw_tool, + display, + coords->x, + coords->y, + poly_sel_tool->points[i].x, + poly_sel_tool->points[i].y); + if (dist_sq < shortest_dist_sq) + { + poly_sel_tool->grabbed_point = &poly_sel_tool->points[i]; + } + } +} + +static gboolean +gimp_polygon_select_tool_should_close (GimpPolygonSelectTool *poly_sel_tool, + GimpDisplay *display, + GimpCoords *coords) +{ + gboolean should_close = FALSE; + + if (poly_sel_tool->num_points > 0) + { + gdouble dist_sq; + + dist_sq = gimp_draw_tool_calc_distance_square (GIMP_DRAW_TOOL (poly_sel_tool), + display, + coords->x, + coords->y, + poly_sel_tool->points[0].x, + poly_sel_tool->points[0].y); + should_close = dist_sq < POINT_GRAB_THRESHOLD_SQ; + } + + return should_close; +} diff --git a/app/tools/gimppolygonselecttool.h b/app/tools/gimppolygonselecttool.h new file mode 100644 index 0000000000..eca3d1ef1d --- /dev/null +++ b/app/tools/gimppolygonselecttool.h @@ -0,0 +1,62 @@ +/* GIMP - The GNU Image Manipulation Program + * + * A polygonal selection tool for GIMP + * Copyright (C) 2007 Martin Nordholts + * + * Based on gimpfreeselecttool.h which is + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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_POLYGON_SELECT_TOOL_H +#define GIMP_POLYGON_SELECT_TOOL_H + + +#include "gimpselectiontool.h" + + +#define GIMP_TYPE_POLYGON_SELECT_TOOL (gimp_polygon_select_tool_get_type ()) +#define GIMP_POLYGON_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_POLYGON_SELECT_TOOL, GimpPolygonSelectTool)) +#define GIMP_POLYGON_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_POLYGON_SELECT_TOOL, GimpPolygonSelectToolClass)) +#define GIMP_IS_POLYGON_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_POLYGON_SELECT_TOOL)) +#define GIMP_IS_POLYGON_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_POLYGON_SELECT_TOOL)) +#define GIMP_POLYGON_SELECT_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_POLYGON_SELECT_TOOL, GimpPolygonSelectToolClass)) + + +typedef struct _GimpPolygonSelectTool GimpPolygonSelectTool; +typedef struct _GimpPolygonSelectToolClass GimpPolygonSelectToolClass; + +struct _GimpPolygonSelectToolClass +{ + GimpSelectionToolClass parent_class; + + /* virtual function */ + + void (* select) (GimpPolygonSelectTool *poly_select_tool, + GimpDisplay *display); +}; + + +void gimp_polygon_select_tool_register (GimpToolRegisterCallback callback, + gpointer data); + +GType gimp_polygon_select_tool_get_type (void) G_GNUC_CONST; + +void gimp_polygon_select_tool_select (GimpPolygonSelectTool *poly_sel, + GimpDisplay *display); + + +#endif /* GIMP_POLYGON_SELECT_TOOL_H */ diff --git a/app/tools/gimpposterizetool.c b/app/tools/gimpposterizetool.c index 8431f4a772..9d62c18b3f 100644 --- a/app/tools/gimpposterizetool.c +++ b/app/tools/gimpposterizetool.c @@ -21,6 +21,8 @@ #include #include +#include "libgimpmath/gimpmath.h" +#include "libgimpconfig/gimpconfig.h" #include "libgimpwidgets/gimpwidgets.h" #include "tools-types.h" @@ -28,6 +30,8 @@ #include "base/gimplut.h" #include "base/lut-funcs.h" +#include "gegl/gimpposterizeconfig.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" @@ -41,8 +45,6 @@ #include "gimp-intl.h" -#define POSTERIZE_DEFAULT_LEVELS 3 - #define SLIDER_WIDTH 200 @@ -52,10 +54,14 @@ static gboolean gimp_posterize_tool_initialize (GimpTool *tool, GimpDisplay *display, GError **error); -static GeglNode * gimp_posterize_tool_get_operation (GimpImageMapTool *im_tool); +static GeglNode * gimp_posterize_tool_get_operation (GimpImageMapTool *im_tool, + GObject **config); static void gimp_posterize_tool_map (GimpImageMapTool *im_tool); static void gimp_posterize_tool_dialog (GimpImageMapTool *im_tool); -static void gimp_posterize_tool_reset (GimpImageMapTool *im_tool); + +static void gimp_posterize_tool_config_notify (GObject *object, + GParamSpec *pspec, + GimpPosterizeTool *posterize_tool); static void gimp_posterize_tool_levels_changed (GtkAdjustment *adjustment, GimpPosterizeTool *posterize_tool); @@ -99,7 +105,6 @@ gimp_posterize_tool_class_init (GimpPosterizeToolClass *klass) im_tool_class->get_operation = gimp_posterize_tool_get_operation; im_tool_class->map = gimp_posterize_tool_map; im_tool_class->dialog = gimp_posterize_tool_dialog; - im_tool_class->reset = gimp_posterize_tool_reset; } static void @@ -107,8 +112,7 @@ gimp_posterize_tool_init (GimpPosterizeTool *posterize_tool) { 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; @@ -148,12 +152,12 @@ gimp_posterize_tool_initialize (GimpTool *tool, return FALSE; } - posterize_tool->levels = POSTERIZE_DEFAULT_LEVELS; + gimp_config_reset (GIMP_CONFIG (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 +165,29 @@ gimp_posterize_tool_initialize (GimpTool *tool, } static GeglNode * -gimp_posterize_tool_get_operation (GimpImageMapTool *im_tool) +gimp_posterize_tool_get_operation (GimpImageMapTool *image_map_tool, + GObject **config) { - 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); + + *config = G_OBJECT (posterize_tool->config); + + g_signal_connect_object (posterize_tool->config, "notify", + G_CALLBACK (gimp_posterize_tool_config_notify), + G_OBJECT (posterize_tool), 0); + + gegl_node_set (node, + "config", posterize_tool->config, + NULL); + + return node; } static void @@ -173,12 +195,8 @@ gimp_posterize_tool_map (GimpImageMapTool *image_map_tool) { 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 +222,7 @@ gimp_posterize_tool_dialog (GimpImageMapTool *image_map_tool) 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); @@ -218,24 +236,31 @@ gimp_posterize_tool_dialog (GimpImageMapTool *image_map_tool) } static void -gimp_posterize_tool_reset (GimpImageMapTool *image_map_tool) +gimp_posterize_tool_config_notify (GObject *object, + GParamSpec *pspec, + GimpPosterizeTool *posterize_tool) { - GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (image_map_tool); + GimpPosterizeConfig *config = GIMP_POSTERIZE_CONFIG (object); - posterize_tool->levels = POSTERIZE_DEFAULT_LEVELS; + if (! posterize_tool->levels_data) + return; - gtk_adjustment_set_value (posterize_tool->levels_data, - posterize_tool->levels); + gtk_adjustment_set_value (posterize_tool->levels_data, config->levels); + + gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (posterize_tool)); } static void gimp_posterize_tool_levels_changed (GtkAdjustment *adjustment, GimpPosterizeTool *posterize_tool) { - if (posterize_tool->levels != adjustment->value) - { - posterize_tool->levels = adjustment->value; + GimpPosterizeConfig *config = posterize_tool->config; + gint value = ROUND (adjustment->value); - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (posterize_tool)); + if (config->levels != value) + { + g_object_set (config, + "levels", value, + NULL); } } diff --git a/app/tools/gimpposterizetool.h b/app/tools/gimpposterizetool.h index 95e05ae2d6..c7b58326ec 100644 --- a/app/tools/gimpposterizetool.h +++ b/app/tools/gimpposterizetool.h @@ -36,13 +36,13 @@ typedef struct _GimpPosterizeToolClass GimpPosterizeToolClass; 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 diff --git a/app/tools/gimpthresholdtool.c b/app/tools/gimpthresholdtool.c index 8b52d099cd..ca7aee5915 100644 --- a/app/tools/gimpthresholdtool.c +++ b/app/tools/gimpthresholdtool.c @@ -21,6 +21,7 @@ #include #include +#include "libgimpconfig/gimpconfig.h" #include "libgimpwidgets/gimpwidgets.h" #include "tools-types.h" @@ -54,10 +55,14 @@ static gboolean gimp_threshold_tool_initialize (GimpTool *tool, GimpDisplay *display, GError **error); -static GeglNode * gimp_threshold_tool_get_operation (GimpImageMapTool *im_tool); +static GeglNode * gimp_threshold_tool_get_operation (GimpImageMapTool *im_tool, + GObject **config); static void gimp_threshold_tool_map (GimpImageMapTool *im_tool); static void gimp_threshold_tool_dialog (GimpImageMapTool *im_tool); -static void gimp_threshold_tool_reset (GimpImageMapTool *im_tool); + +static void gimp_threshold_tool_config_notify (GObject *object, + GParamSpec *pspec, + GimpThresholdTool *t_tool); static void gimp_threshold_tool_histogram_range (GimpHistogramView *view, gint start, @@ -106,7 +111,6 @@ gimp_threshold_tool_class_init (GimpThresholdToolClass *klass) im_tool_class->get_operation = gimp_threshold_tool_get_operation; im_tool_class->map = gimp_threshold_tool_map; im_tool_class->dialog = gimp_threshold_tool_dialog; - im_tool_class->reset = gimp_threshold_tool_reset; } static void @@ -126,12 +130,6 @@ gimp_threshold_tool_finalize (GObject *object) { GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (object); - if (t_tool->config) - { - g_object_unref (t_tool->config); - t_tool->config = NULL; - } - g_slice_free (Threshold, t_tool->threshold); if (t_tool->hist) @@ -161,11 +159,11 @@ gimp_threshold_tool_initialize (GimpTool *tool, return FALSE; } + gimp_config_reset (GIMP_CONFIG (t_tool->config)); + if (! t_tool->hist) t_tool->hist = gimp_histogram_new (); - gimp_threshold_config_reset (t_tool->config); - t_tool->threshold->color = gimp_drawable_is_rgb (drawable); GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error); @@ -190,7 +188,8 @@ gimp_threshold_tool_initialize (GimpTool *tool, } static GeglNode * -gimp_threshold_tool_get_operation (GimpImageMapTool *image_map_tool) +gimp_threshold_tool_get_operation (GimpImageMapTool *image_map_tool, + GObject **config) { GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (image_map_tool); GeglNode *node; @@ -201,6 +200,12 @@ gimp_threshold_tool_get_operation (GimpImageMapTool *image_map_tool) t_tool->config = g_object_new (GIMP_TYPE_THRESHOLD_CONFIG, NULL); + *config = G_OBJECT (t_tool->config); + + g_signal_connect_object (t_tool->config, "notify", + G_CALLBACK (gimp_threshold_tool_config_notify), + G_OBJECT (t_tool), 0); + gegl_node_set (node, "config", t_tool->config, NULL); @@ -273,15 +278,18 @@ gimp_threshold_tool_dialog (GimpImageMapTool *image_map_tool) } static void -gimp_threshold_tool_reset (GimpImageMapTool *image_map_tool) +gimp_threshold_tool_config_notify (GObject *object, + GParamSpec *pspec, + GimpThresholdTool *t_tool) { - GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (image_map_tool); + GimpThresholdConfig *config = GIMP_THRESHOLD_CONFIG (object); - gimp_threshold_config_reset (t_tool->config); + if (t_tool->histogram_box) + gimp_histogram_view_set_range (t_tool->histogram_box->view, + config->low * 255.999, + config->high * 255.999); - gimp_histogram_view_set_range (t_tool->histogram_box->view, - t_tool->config->low * 255.999, - t_tool->config->high * 255.999); + gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool)); } static void @@ -300,8 +308,6 @@ gimp_threshold_tool_histogram_range (GimpHistogramView *widget, "low", low, "high", high, NULL); - - gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool)); } } diff --git a/app/widgets/gimphelp-ids.h b/app/widgets/gimphelp-ids.h index 0bd2d6f9dd..7733a46a3c 100644 --- a/app/widgets/gimphelp-ids.h +++ b/app/widgets/gimphelp-ids.h @@ -270,6 +270,7 @@ #define GIMP_HELP_TOOL_PENCIL "gimp-tool-pencil" #define GIMP_HELP_TOOL_PERSPECTIVE "gimp-tool-perspective" #define GIMP_HELP_TOOL_PERSPECTIVE_CLONE "gimp-tool-perspective-clone" +#define GIMP_HELP_TOOL_POLYGON_SELECT "gimp-tool-polygon-select" #define GIMP_HELP_TOOL_POSTERIZE "gimp-tool-posterize" #define GIMP_HELP_TOOL_RECT_SELECT "gimp-tool-rect-select" #define GIMP_HELP_TOOL_ROTATE "gimp-tool-rotate" diff --git a/app/widgets/gimphistogramview.c b/app/widgets/gimphistogramview.c index 623107b017..5630a13bf1 100644 --- a/app/widgets/gimphistogramview.c +++ b/app/widgets/gimphistogramview.c @@ -623,7 +623,8 @@ gimp_histogram_view_set_channel (GimpHistogramView *view, { g_return_if_fail (GIMP_IS_HISTOGRAM_VIEW (view)); - g_object_set (view, "histogram-channel", channel, NULL); + if (channel != view->channel) + g_object_set (view, "histogram-channel", channel, NULL); } GimpHistogramChannel @@ -640,7 +641,8 @@ gimp_histogram_view_set_scale (GimpHistogramView *view, { g_return_if_fail (GIMP_IS_HISTOGRAM_VIEW (view)); - g_object_set (view, "histogram-scale", scale, NULL); + if (scale != view->scale) + g_object_set (view, "histogram-scale", scale, NULL); } GimpHistogramScale @@ -658,13 +660,17 @@ gimp_histogram_view_set_range (GimpHistogramView *view, { g_return_if_fail (GIMP_IS_HISTOGRAM_VIEW (view)); - view->start = MIN (start, end); - view->end = MAX (start, end); + if (view->start != MIN (start, end) || + view->end != MAX (start, end)) + { + view->start = MIN (start, end); + view->end = MAX (start, end); - gtk_widget_queue_draw (GTK_WIDGET (view)); + gtk_widget_queue_draw (GTK_WIDGET (view)); - g_signal_emit (view, histogram_view_signals[RANGE_CHANGED], 0, - view->start, view->end); + g_signal_emit (view, histogram_view_signals[RANGE_CHANGED], 0, + view->start, view->end); + } } void diff --git a/libgimpconfig/gimpconfig-serialize.c b/libgimpconfig/gimpconfig-serialize.c index caa43fa961..4c02527364 100644 --- a/libgimpconfig/gimpconfig-serialize.c +++ b/libgimpconfig/gimpconfig-serialize.c @@ -143,9 +143,10 @@ gimp_config_serialize_changed_properties (GimpConfig *config, } /** - * gimp_config_serialize_properties: - * @config: a #GimpConfig. - * @writer: a #GimpConfigWriter. + * gimp_config_serialize_property: + * @config: a #GimpConfig. + * @param_spec: a #GParamSpec. + * @writer: a #GimpConfigWriter. * * This function serializes a single object property to the @writer. * diff --git a/libgimpwidgets/gimpstock.c b/libgimpwidgets/gimpstock.c index 89c27ed169..9b3a6f6852 100644 --- a/libgimpwidgets/gimpstock.c +++ b/libgimpwidgets/gimpstock.c @@ -313,6 +313,7 @@ static const GtkStockItem gimp_stock_items[] = { GIMP_STOCK_TOOL_PENCIL, NULL, 0, 0, LIBGIMP_DOMAIN }, { GIMP_STOCK_TOOL_PERSPECTIVE, N_("_Transform"), 0, 0, LIBGIMP_DOMAIN }, { GIMP_STOCK_TOOL_PERSPECTIVE_CLONE, NULL, 0, 0, LIBGIMP_DOMAIN }, + { GIMP_STOCK_TOOL_POLYGON_SELECT, NULL, 0, 0, LIBGIMP_DOMAIN }, { GIMP_STOCK_TOOL_POSTERIZE, NULL, 0, 0, LIBGIMP_DOMAIN }, { GIMP_STOCK_TOOL_RECT_SELECT, NULL, 0, 0, LIBGIMP_DOMAIN }, { GIMP_STOCK_TOOL_ROTATE, N_("_Rotate"), 0, 0, LIBGIMP_DOMAIN }, @@ -463,6 +464,7 @@ gimp_stock_button_pixbufs[] = { GIMP_STOCK_TOOL_PENCIL, stock_tool_pencil_22 }, { GIMP_STOCK_TOOL_PERSPECTIVE, stock_tool_perspective_22 }, { GIMP_STOCK_TOOL_PERSPECTIVE_CLONE, stock_tool_perspective_clone_22 }, + { GIMP_STOCK_TOOL_POLYGON_SELECT, stock_tool_polygon_select_22 }, { GIMP_STOCK_TOOL_POSTERIZE, stock_tool_posterize_22 }, { GIMP_STOCK_TOOL_RECT_SELECT, stock_tool_rect_select_22 }, { GIMP_STOCK_TOOL_ROTATE, stock_tool_rotate_22 }, @@ -624,6 +626,7 @@ gimp_stock_menu_pixbufs[] = { GIMP_STOCK_TOOL_PENCIL, stock_tool_pencil_16 }, { GIMP_STOCK_TOOL_PERSPECTIVE, stock_tool_perspective_16 }, { GIMP_STOCK_TOOL_PERSPECTIVE_CLONE, stock_tool_perspective_clone_16 }, + { GIMP_STOCK_TOOL_POLYGON_SELECT, stock_tool_polygon_select_16 }, { GIMP_STOCK_TOOL_POSTERIZE, stock_tool_posterize_16 }, { GIMP_STOCK_TOOL_RECT_SELECT, stock_tool_rect_select_16 }, { GIMP_STOCK_TOOL_ROTATE, stock_tool_rotate_16 }, diff --git a/libgimpwidgets/gimpstock.h b/libgimpwidgets/gimpstock.h index 06fbaa3deb..6491a302b6 100644 --- a/libgimpwidgets/gimpstock.h +++ b/libgimpwidgets/gimpstock.h @@ -130,6 +130,7 @@ G_BEGIN_DECLS #define GIMP_STOCK_TOOL_PENCIL "gimp-tool-pencil" #define GIMP_STOCK_TOOL_PERSPECTIVE "gimp-tool-perspective" #define GIMP_STOCK_TOOL_PERSPECTIVE_CLONE "gimp-tool-perspective-clone" +#define GIMP_STOCK_TOOL_POLYGON_SELECT "gimp-tool-polygon-select" #define GIMP_STOCK_TOOL_POSTERIZE "gimp-tool-posterize" #define GIMP_STOCK_TOOL_RECT_SELECT "gimp-tool-rect-select" #define GIMP_STOCK_TOOL_ROTATE "gimp-tool-rotate" diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in index c266e1336f..f794666025 100644 --- a/menus/image-menu.xml.in +++ b/menus/image-menu.xml.in @@ -494,6 +494,7 @@ + diff --git a/modules/controller_dx_dinput.c b/modules/controller_dx_dinput.c index f2e2229a3a..c4eb68ce2e 100644 --- a/modules/controller_dx_dinput.c +++ b/modules/controller_dx_dinput.c @@ -64,7 +64,7 @@ enum #define NUM_EVENTS_PER_SLIDER 2 /* Slider decrease and increase */ #define NUM_EVENTS_PER_POV 3 /* POV view vector X and Y view and return */ -#define CONTROLLER_TYPE_DX_DINPUT (controller_dx_input_get_type ()) +#define CONTROLLER_TYPE_DX_DINPUT (controller_dx_dinput_get_type ()) #define CONTROLLER_DX_DINPUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTROLLER_TYPE_DX_DINPUT, ControllerDXDInput)) #define CONTROLLER_DX_DINPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTROLLER_TYPE_DX_DINPUT, ControllerDXDInputClass)) #define CONTROLLER_IS_DX_DINPUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTROLLER_TYPE_DX_DINPUT)) @@ -161,7 +161,7 @@ static const GimpModuleInfo dx_dinput_info = }; -G_DEFINE_DYNAMIC_TYPE (ControllerDXInput, controller_dx_input, +G_DEFINE_DYNAMIC_TYPE (ControllerDXDInput, controller_dx_dinput, GIMP_TYPE_CONTROLLER) @@ -240,7 +240,7 @@ dx_dinput_dispose (GObject *object) dx_dinput_set_device (controller, NULL); - G_OBJECT_CLASS (controller_dx_input_parent_class)->dispose (object); + G_OBJECT_CLASS (controller_dx_dinput_parent_class)->dispose (object); } static void @@ -280,7 +280,7 @@ dx_dinput_finalize (GObject *object) controller->store = NULL; } - G_OBJECT_CLASS (controller_dx_input_parent_class)->finalize (object); + G_OBJECT_CLASS (controller_dx_dinput_parent_class)->finalize (object); } static void @@ -892,7 +892,6 @@ dump_data_format (const DIDATAFORMAT *format) #undef BIT g_print ("\n"); g_print (" dwFlags:"); -#define BIT(x) if (oformat->dwFlags & DIDOI_ASPECT##x) g_print (" DIDOI_ASPECT"#x) switch (oformat->dwFlags & DIDOI_ASPECTACCEL) { case DIDOI_ASPECTPOSITION: g_print (" DIDOI_ASPECTPOSITION"); break; diff --git a/plug-ins/common/cubism.c b/plug-ins/common/cubism.c index 929099789e..40aac7f6f1 100644 --- a/plug-ins/common/cubism.c +++ b/plug-ins/common/cubism.c @@ -424,12 +424,13 @@ cubism (GimpDrawable *drawable, pr = gimp_pixel_rgns_process (pr)) { count = src_rgn.w * src_rgn.h; - dest = src_rgn.data; + dest = src_rgn.data; while (count--) for (i = 0; i < bytes; i++) *dest++ = bg_col[i]; } + dest = NULL; } @@ -440,11 +441,10 @@ cubism (GimpDrawable *drawable, randomize_indices (num_tiles, random_indices); - count = 0; gimp_pixel_rgn_init (&src_rgn, drawable, x1, y1, x2 - x1, y2 - y1, FALSE, FALSE); - while (count < num_tiles) + for (count = 0; count < num_tiles; count++) { i = random_indices[count] / (cols + 1); j = random_indices[count] % (cols + 1); @@ -473,14 +473,13 @@ cubism (GimpDrawable *drawable, gimp_pixel_rgn_get_pixel (&src_rgn, col, ix, iy); - if (!has_alpha || col[bytes - 1]) + if (! has_alpha || col[bytes - 1]) fill_poly_color (&poly, drawable, preview, col, dest); - count++; - if (!preview) + if (! preview) { - if ((count % 5) == 0) - gimp_progress_update ((double) count / (double) num_tiles); + if (count % 8 == 0) + gimp_progress_update ((gdouble) count / (gdouble) num_tiles); } } @@ -510,17 +509,12 @@ calc_alpha_blend (gdouble *vec, { gdouble r; - if (!one_over_dist) + if (! one_over_dist) return 1.0; - else - { - r = (vec[0] * x + vec[1] * y) * one_over_dist; - if (r < 0.2) - r = 0.2; - else if (r > 1.0) - r = 1.0; - } - return r; + + r = (vec[0] * x + vec[1] * y) * one_over_dist; + + return CLAMP (r, 0.2, 1.0); } static void @@ -611,8 +605,8 @@ fill_poly_color (Polygon *poly, if (poly->npts) { - gint poly_npts = poly->npts; GimpVector2 *curptr; + gint poly_npts = poly->npts; xs = (gint) (poly->pts[poly_npts-1].x); ys = (gint) (poly->pts[poly_npts-1].y); @@ -685,7 +679,10 @@ fill_poly_color (Polygon *poly, if (val > 0) { xx = (gdouble) j / (gdouble) SUPERSAMPLE + min_x; - alpha = (gint) (val * calc_alpha_blend (vec, one_over_dist, xx - sx, yy - sy)); + alpha = (gint) (val * calc_alpha_blend (vec, + one_over_dist, + xx - sx, + yy - sy)); if (preview) { for (b = 0; b < bytes; b++) @@ -698,13 +695,13 @@ fill_poly_color (Polygon *poly, #ifndef USE_READABLE_BUT_SLOW_CODE { - guchar *buf_iter = buf, - *col_iter = col, - *buf_end = buf+bytes; + guchar *buf_iter = buf; + guchar *col_iter = col; + guchar *buf_end = buf + bytes; for(; buf_iter < buf_end; buf_iter++, col_iter++) - *buf_iter = ((guint)(*col_iter * alpha) - + (((guint)*buf_iter) + *buf_iter = ((guint) (*col_iter * alpha) + + (((guint) *buf_iter) * (256 - alpha))) >> 8; } #else /* original, pre-ECL code */ diff --git a/plug-ins/common/lcms.c b/plug-ins/common/lcms.c index a81df36bf2..1886725b31 100644 --- a/plug-ins/common/lcms.c +++ b/plug-ins/common/lcms.c @@ -795,8 +795,7 @@ lcms_image_set_profile (gint32 image, if (! file) { - g_message (_("Could not open '%s' for reading: %s"), - gimp_filename_to_utf8 (filename), error->message); + g_message (error->message); g_error_free (error); return FALSE; @@ -948,7 +947,7 @@ lcms_image_transform_rgb (gint32 image, break; default: - g_warning ("%s: unexpected bpp", G_GNUC_FUNCTION); + g_warning ("%s: unexpected bpp", G_STRLOC); continue; } @@ -1100,9 +1099,7 @@ lcms_load_profile (const gchar *filename, if (! file) { - g_message (_("Could not open '%s' for reading: %s"), - gimp_filename_to_utf8 (filename), - error->message); + g_message (error->message); g_error_free (error); return NULL; @@ -1533,15 +1530,13 @@ lcms_dialog (GimpColorConfig *config, &values->bpc); } - run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK); - - gtk_widget_hide (dialog); - - if (run) + while ((run = gimp_dialog_run (GIMP_DIALOG (dialog))) == GTK_RESPONSE_OK) { gchar *filename = gimp_color_profile_combo_box_get_active (box); cmsHPROFILE dest_profile; + gtk_widget_set_sensitive (dialog, FALSE); + if (filename) { dest_profile = lcms_load_profile (filename, NULL); @@ -1551,23 +1546,32 @@ lcms_dialog (GimpColorConfig *config, dest_profile = cmsCreate_sRGBProfile (); } - if (lcms_icc_profile_is_rgb (dest_profile)) + if (dest_profile) { - if (apply) - success = lcms_image_apply_profile (image, - src_profile, dest_profile, - filename, - values->intent, values->bpc); + if (lcms_icc_profile_is_rgb (dest_profile)) + { + if (apply) + success = lcms_image_apply_profile (image, + src_profile, dest_profile, + filename, + values->intent, + values->bpc); + else + success = lcms_image_set_profile (image, + dest_profile, filename, TRUE); + } else - success = lcms_image_set_profile (image, - dest_profile, filename, TRUE); - } - else - { - gimp_message (_("Destination profile is not for RGB color space.")); + { + gimp_message (_("Destination profile is not for RGB color space.")); + } + + cmsCloseProfile (dest_profile); } - cmsCloseProfile (dest_profile); + if (success) + break; + else + gtk_widget_set_sensitive (dialog, TRUE); } gtk_widget_destroy (dialog); diff --git a/plug-ins/common/wmf.c b/plug-ins/common/wmf.c index 4c23c826e7..176e6e892e 100644 --- a/plug-ins/common/wmf.c +++ b/plug-ins/common/wmf.c @@ -977,8 +977,7 @@ load_image (const gchar *filename) { if (error) { - g_message (_("Could not open '%s' for reading: %s"), - gimp_filename_to_utf8 (filename), error->message); + g_message (error->message); g_error_free (error); } else diff --git a/plug-ins/gimpressionist/brush.c b/plug-ins/gimpressionist/brush.c index c64da56bc9..33104e8232 100644 --- a/plug-ins/gimpressionist/brush.c +++ b/plug-ins/gimpressionist/brush.c @@ -1,3 +1,20 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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" diff --git a/plug-ins/gimpressionist/brush.h b/plug-ins/gimpressionist/brush.h index 2129eb2b01..dd05b8fd5a 100644 --- a/plug-ins/gimpressionist/brush.h +++ b/plug-ins/gimpressionist/brush.h @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 __BRUSH_H #define __BRUSH_H diff --git a/plug-ins/gimpressionist/color.c b/plug-ins/gimpressionist/color.c index def67f4ca4..cd45d359f7 100644 --- a/plug-ins/gimpressionist/color.c +++ b/plug-ins/gimpressionist/color.c @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 diff --git a/plug-ins/gimpressionist/color.h b/plug-ins/gimpressionist/color.h index 798ae66681..fab26045c4 100644 --- a/plug-ins/gimpressionist/color.h +++ b/plug-ins/gimpressionist/color.h @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 __COLOR_H #define __COLOR_H diff --git a/plug-ins/gimpressionist/general.c b/plug-ins/gimpressionist/general.c index 065c9cfe70..2cd3024ac2 100644 --- a/plug-ins/gimpressionist/general.c +++ b/plug-ins/gimpressionist/general.c @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 diff --git a/plug-ins/gimpressionist/general.h b/plug-ins/gimpressionist/general.h index 5de8d14a26..90261b0bd9 100644 --- a/plug-ins/gimpressionist/general.h +++ b/plug-ins/gimpressionist/general.h @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 __GENERAL_H #define __GENERAL_H diff --git a/plug-ins/gimpressionist/gimp.c b/plug-ins/gimpressionist/gimp.c index 82f800169d..9dddd713e8 100644 --- a/plug-ins/gimpressionist/gimp.c +++ b/plug-ins/gimpressionist/gimp.c @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 @@ -45,9 +63,7 @@ infile_copy_to_ppm (ppm_t * p) { if (!PPM_IS_INITED (&infile)) grabarea (); -#if 0 - updatepreview (NULL, (void *)2); /* Force grabarea () */ -#endif + ppm_copy (&infile, p); } @@ -217,233 +233,248 @@ void grabarea (void) { GimpPixelRgn src_rgn; - guchar *src_row; - guchar *src; - gint alpha, bpp; - gboolean has_alpha; - gint x, y; ppm_t *p; gint x1, y1, x2, y2; + gint x, y; + gint width, height; gint row, col; - int rowstride; + gint rowstride; + gpointer pr; gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2); - bpp = gimp_drawable_bpp (drawable->drawable_id); - has_alpha = gimp_drawable_has_alpha (drawable->drawable_id); - alpha = (has_alpha) ? bpp - 1 : bpp; + width = x2 - x1; + height = y2 - y1; - ppm_new (&infile, x2-x1, y2-y1); + ppm_new (&infile, width, height); p = &infile; - if (has_alpha) - { - ppm_new (&inalpha, x2-x1, y2-y1); - } + + if (gimp_drawable_has_alpha (drawable->drawable_id)) + ppm_new (&inalpha, width, height); rowstride = p->width * 3; - src_row = g_new (guchar, (x2 - x1) * bpp); + gimp_pixel_rgn_init (&src_rgn, + drawable, x1, y1, width, height, FALSE, FALSE); - gimp_pixel_rgn_init (&src_rgn, drawable, - 0, 0, x2 - x1, y2 - y1, - FALSE, FALSE); - - if (bpp == 3) - { /* RGB */ - int bpr = (x2 - x1) * 3; - - for (row = 0, y = y1; y < y2; row++, y++) - { - gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, (x2 - x1)); - memcpy (p->col + row * rowstride, src_row, bpr); - } - } - else if (bpp > 3) - { /* RGBA */ - for (row = 0, y = y1; y < y2; row++, y++) - { - guchar *tmprow = p->col + row * rowstride; - guchar *tmparow = inalpha.col + row * rowstride; - - gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, (x2 - x1)); - src = src_row; - - for (col = 0, x = x1; x < x2; col++, x++) - { - int k = col * 3; - - tmprow[k+0] = src[0]; - tmprow[k+1] = src[1]; - tmprow[k+2] = src[2]; - tmparow[k] = 255 - src[3]; - src += src_rgn.bpp; - } - } - } - else if (bpp == 2) + for (pr = gimp_pixel_rgns_register (1, &src_rgn); + pr != NULL; + pr = gimp_pixel_rgns_process (pr)) { - /* GrayA */ - for (row = 0, y = y1; y < y2; row++, y++) + const guchar *src = src_rgn.data; + + switch (src_rgn.bpp) { - guchar *tmprow = p->col + row * rowstride; - guchar *tmparow = inalpha.col + row * rowstride; - - gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, (x2 - x1)); - src = src_row; - - for (col = 0, x = x1; x < x2; col++, x++) + case 1: + for (y = 0, row = src_rgn.y - y1; y < src_rgn.h; y++, row++) { - int k = col * 3; + const guchar *s = src; + guchar *tmprow = p->col + row * rowstride; - tmprow[k+0] = src[0]; - tmprow[k+1] = src[0]; - tmprow[k+2] = src[0]; - tmparow[k] = 255 - src[1]; - src += src_rgn.bpp; + for (x = 0, col = src_rgn.x - x1; x < src_rgn.w; x++, col++) + { + gint k = col * 3; + + tmprow[k + 0] = s[0]; + tmprow[k + 1] = s[0]; + tmprow[k + 2] = s[0]; + + s++; + } + + src += src_rgn.rowstride; } + break; + + case 2: + for (y = 0, row = src_rgn.y - y1; y < src_rgn.h; y++, row++) + { + const guchar *s = src; + guchar *tmprow = p->col + row * rowstride; + guchar *tmparow = inalpha.col + row * rowstride; + + for (x = 0, col = src_rgn.x - x1; x < src_rgn.w; x++, col++) + { + gint k = col * 3; + + tmprow[k + 0] = s[0]; + tmprow[k + 1] = s[0]; + tmprow[k + 2] = s[0]; + tmparow[k] = 255 - s[1]; + + s += 2; + } + + src += src_rgn.rowstride; + } + break; + + case 3: + col = src_rgn.x - x1; + + for (y = 0, row = src_rgn.y - y1; y < src_rgn.h; y++, row++) + { + memcpy (p->col + row * rowstride + col * 3, src, src_rgn.w * 3); + + src += src_rgn.rowstride; + } + break; + + case 4: + for (y = 0, row = src_rgn.y - y1; y < src_rgn.h; y++, row++) + { + const guchar *s = src; + guchar *tmprow = p->col + row * rowstride; + guchar *tmparow = inalpha.col + row * rowstride; + + for (x = 0, col = src_rgn.x - x1; x < src_rgn.w; x++, col++) + { + gint k = col * 3; + + tmprow[k + 0] = s[0]; + tmprow[k + 1] = s[1]; + tmprow[k + 2] = s[2]; + tmparow[k] = 255 - s[3]; + + s += 4; + } + + src += src_rgn.rowstride; + } + break; } } - else - { /* Gray */ - for (row = 0, y = y1; y < y2; row++, y++) - { - guchar *tmprow = p->col + row * rowstride; - - gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, (x2 - x1)); - src = src_row; - for (col = 0, x = x1; x < x2; col++, x++) - { - int k = col * 3; - - tmprow[k+0] = src[0]; - tmprow[k+1] = src[0]; - tmprow[k+2] = src[0]; - src += src_rgn.bpp; - } - } - } - g_free (src_row); } static void gimpressionist_main (void) { GimpPixelRgn dest_rgn; - guchar *dest_row; - guchar *dest; - gint alpha, bpp; - gboolean has_alpha; - gint x, y; ppm_t *p; gint x1, y1, x2, y2; + gint x, y; + gint width, height; gint row, col; - int rowstride; + gint rowstride; + gint count; + glong done; + glong total; + gpointer pr; gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2); - bpp = gimp_drawable_bpp (drawable->drawable_id); - has_alpha = gimp_drawable_has_alpha (drawable->drawable_id); - alpha = (has_alpha) ? bpp - 1 : bpp; + width = x2 - x1; + height = y2 - y1; - dest_row = g_new (guchar, (x2 - x1) * bpp); + total = width * height; gimp_progress_init (_("Painting")); - if (!PPM_IS_INITED (&infile)) - { - grabarea (); - } + if (! PPM_IS_INITED (&infile)) + grabarea (); repaint (&infile, (img_has_alpha) ? &inalpha : NULL); - gimp_pixel_rgn_init (&dest_rgn, drawable, - 0, 0, x2 - x1, y2 - y1, - TRUE, TRUE); - p = &infile; rowstride = p->width * 3; - if (bpp == 3) + gimp_pixel_rgn_init (&dest_rgn, + drawable, x1, y1, width, height, TRUE, TRUE); + + for (pr = gimp_pixel_rgns_register (1, &dest_rgn), count = 0, done = 0; + pr != NULL; + pr = gimp_pixel_rgns_process (pr), count++) { - int bpr = (x2 - x1) * 3; + guchar *dest = dest_rgn.data; - for (row = 0, y = y1; y < y2; row++, y++) + switch (dest_rgn.bpp) { - if (row % 10 == 0) - gimp_progress_update (0.8 + 0.2 * ((double)row / (y2 - y1))); - memcpy (dest_row, p->col + row * rowstride, bpr); - gimp_pixel_rgn_set_row (&dest_rgn, dest_row, x1, y, (x2 - x1)); - } - } - else if (bpp == 4) - { - - for (row = 0, y = y1; y < y2; row++, y++) - { - guchar *tmprow = p->col + row * rowstride; - - if (row % 10 == 0) - gimp_progress_update (0.8 + 0.2 * ((double)row / (y2-y1))); - dest = dest_row; - - for (col = 0, x = x1; x < x2; col++, x++) + case 1: + for (y = 0, row = dest_rgn.y - y1; y < dest_rgn.h; y++, row++) { - int k = col * 3; + guchar *d = dest; + const guchar *tmprow = p->col + row * rowstride; - dest[0] = tmprow[k+0]; - dest[1] = tmprow[k+1]; - dest[2] = tmprow[k+2]; - dest[3] = 255 - inalpha.col[row * rowstride + k]; - dest += dest_rgn.bpp; + for (x = 0, col = dest_rgn.x - x1; x < dest_rgn.w; x++, col++) + { + gint k = col * 3; + + *d++ = GIMP_RGB_LUMINANCE (tmprow[k + 0], + tmprow[k + 1], + tmprow[k + 2]); + } + + dest += dest_rgn.rowstride; } - gimp_pixel_rgn_set_row (&dest_rgn, dest_row, x1, y, (x2 - x1)); - } - } - else if (bpp == 2) - { - for (row = 0, y = y1; y < y2; row++, y++) - { - guchar *tmprow = p->col + row * rowstride; + break; - if (row % 10 == 0) - gimp_progress_update (0.8 + 0.2 * ((double)row / (y2-y1))); - dest = dest_row; - - for (col = 0, x = x1; x < x2; col++, x++) + case 2: + for (y = 0, row = dest_rgn.y - y1; y < dest_rgn.h; y++, row++) { - int k = col * 3; + guchar *d = dest; + const guchar *tmprow = p->col + row * rowstride; + const guchar *tmparow = inalpha.col + row * rowstride; - dest[0] = (tmprow[k+0] + tmprow[k+1] + tmprow[k+2]) / 3; - dest[1] = 255 - inalpha.col[row * rowstride + k]; - dest += dest_rgn.bpp; + for (x = 0, col = dest_rgn.x - x1; x < dest_rgn.w; x++, col++) + { + gint k = col * 3; + gint value = GIMP_RGB_LUMINANCE (tmprow[k + 0], + tmprow[k + 1], + tmprow[k + 2]); + + d[0] = value; + d[1] = 255 - tmparow[k]; + + d += 2; + } + + dest += dest_rgn.rowstride; } - gimp_pixel_rgn_set_row (&dest_rgn, dest_row, x1, y, (x2 - x1)); - } - } - else - { - for (row = 0, y = y1; y < y2; row++, y++) - { - guchar *tmprow = p->col + row * rowstride; + break; - if (row % 10 == 0) - gimp_progress_update (0.8 + 0.2 * ((double)row / (y2-y1))); - dest = dest_row; + case 3: + col = dest_rgn.x - x1; - for (col = 0, x = x1; x < x2; col++, x++) + for (y = 0, row = dest_rgn.y - y1; y < dest_rgn.h; y++, row++) { - int k = col * 3; - dest[0] = (tmprow[k+0] + tmprow[k+1] + tmprow[k+2]) / 3; - dest += dest_rgn.bpp; - } - gimp_pixel_rgn_set_row (&dest_rgn, dest_row, x1, y, (x2 - x1)); - } - } + memcpy (dest, p->col + row * rowstride + col * 3, dest_rgn.w * 3); - g_free (dest_row); + dest += dest_rgn.rowstride; + } + break; + + case 4: + for (y = 0, row = dest_rgn.y - y1; y < dest_rgn.h; y++, row++) + { + guchar *d = dest; + const guchar *tmprow = p->col + row * rowstride; + const guchar *tmparow = inalpha.col + row * rowstride; + + for (x = 0, col = dest_rgn.x - x1; x < dest_rgn.w; x++, col++) + { + gint k = col * 3; + + d[0] = tmprow[k + 0]; + d[1] = tmprow[k + 1]; + d[2] = tmprow[k + 2]; + d[3] = 255 - tmparow[k]; + + d += 4; + } + + dest += dest_rgn.rowstride; + } + break; + } + + done += dest_rgn.w * dest_rgn.h; + + if (count % 16 == 0) + gimp_progress_update (0.8 + 0.2 * done / total); + } gimp_drawable_flush (drawable); gimp_drawable_merge_shadow (drawable->drawable_id, TRUE); - gimp_drawable_update (drawable->drawable_id, x1, y1, (x2 - x1), (y2 - y1)); + gimp_drawable_update (drawable->drawable_id, x1, y1, width, height); } diff --git a/plug-ins/gimpressionist/gimpressionist.c b/plug-ins/gimpressionist/gimpressionist.c index 902394f888..58f63407cb 100644 --- a/plug-ins/gimpressionist/gimpressionist.c +++ b/plug-ins/gimpressionist/gimpressionist.c @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 diff --git a/plug-ins/gimpressionist/gimpressionist.h b/plug-ins/gimpressionist/gimpressionist.h index 155fa6b313..65dd9b4eb7 100644 --- a/plug-ins/gimpressionist/gimpressionist.h +++ b/plug-ins/gimpressionist/gimpressionist.h @@ -1,3 +1,20 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 __GIMPRESSIONIST_H #define __GIMPRESSIONIST_H diff --git a/plug-ins/gimpressionist/globals.c b/plug-ins/gimpressionist/globals.c index 235c2298cf..9642e53653 100644 --- a/plug-ins/gimpressionist/globals.c +++ b/plug-ins/gimpressionist/globals.c @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 diff --git a/plug-ins/gimpressionist/infile.h b/plug-ins/gimpressionist/infile.h index d5bf486199..4133d2f19d 100644 --- a/plug-ins/gimpressionist/infile.h +++ b/plug-ins/gimpressionist/infile.h @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 __INFILE_H #define __INFILE_H diff --git a/plug-ins/gimpressionist/orientation.c b/plug-ins/gimpressionist/orientation.c index 8ba8ef828f..1622ff35b6 100644 --- a/plug-ins/gimpressionist/orientation.c +++ b/plug-ins/gimpressionist/orientation.c @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 diff --git a/plug-ins/gimpressionist/orientation.h b/plug-ins/gimpressionist/orientation.h index 78cb78b3c9..b864f271ee 100644 --- a/plug-ins/gimpressionist/orientation.h +++ b/plug-ins/gimpressionist/orientation.h @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 __ORIENTATION_H #define __ORIENTATION_H diff --git a/plug-ins/gimpressionist/orientmap.c b/plug-ins/gimpressionist/orientmap.c index 09a2199cce..ffbe5182e0 100644 --- a/plug-ins/gimpressionist/orientmap.c +++ b/plug-ins/gimpressionist/orientmap.c @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 diff --git a/plug-ins/gimpressionist/orientmap.h b/plug-ins/gimpressionist/orientmap.h index f2392274a7..ebbbf1cfcd 100644 --- a/plug-ins/gimpressionist/orientmap.h +++ b/plug-ins/gimpressionist/orientmap.h @@ -1,5 +1,24 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 __ORIENTMAP_H #define __ORIENTMAP_H + void create_orientmap_dialog (GtkWidget *parent); void update_orientmap_dialog (void); void orientation_map_free_resources(void); diff --git a/plug-ins/gimpressionist/paper.c b/plug-ins/gimpressionist/paper.c index ecfd9d479c..c8d3874982 100644 --- a/plug-ins/gimpressionist/paper.c +++ b/plug-ins/gimpressionist/paper.c @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 diff --git a/plug-ins/gimpressionist/paper.h b/plug-ins/gimpressionist/paper.h index 70c04b0a43..82bbc7467a 100644 --- a/plug-ins/gimpressionist/paper.h +++ b/plug-ins/gimpressionist/paper.h @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 __PAPER_H #define __PAPER_H diff --git a/plug-ins/gimpressionist/placement.c b/plug-ins/gimpressionist/placement.c index e4be83f3e1..2f5ed3b5c2 100644 --- a/plug-ins/gimpressionist/placement.c +++ b/plug-ins/gimpressionist/placement.c @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 diff --git a/plug-ins/gimpressionist/placement.h b/plug-ins/gimpressionist/placement.h index 7898e86267..15913a0c15 100644 --- a/plug-ins/gimpressionist/placement.h +++ b/plug-ins/gimpressionist/placement.h @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 __PLACEMENT_H #define __PLACEMENT_H diff --git a/plug-ins/gimpressionist/plasma.c b/plug-ins/gimpressionist/plasma.c index 5129591ffa..5f3f6efd9e 100644 --- a/plug-ins/gimpressionist/plasma.c +++ b/plug-ins/gimpressionist/plasma.c @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 diff --git a/plug-ins/gimpressionist/ppmtool.c b/plug-ins/gimpressionist/ppmtool.c index f11f5de54d..94d7cdbcf1 100644 --- a/plug-ins/gimpressionist/ppmtool.c +++ b/plug-ins/gimpressionist/ppmtool.c @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 diff --git a/plug-ins/gimpressionist/ppmtool.h b/plug-ins/gimpressionist/ppmtool.h index 824bc357e8..47964aaf7e 100644 --- a/plug-ins/gimpressionist/ppmtool.h +++ b/plug-ins/gimpressionist/ppmtool.h @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 __PPM_TOOL_H #define __PPM_TOOL_H diff --git a/plug-ins/gimpressionist/presets.c b/plug-ins/gimpressionist/presets.c index 48666ab775..17151bff6c 100644 --- a/plug-ins/gimpressionist/presets.c +++ b/plug-ins/gimpressionist/presets.c @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 diff --git a/plug-ins/gimpressionist/presets.h b/plug-ins/gimpressionist/presets.h index 516734cf89..48a80a765c 100644 --- a/plug-ins/gimpressionist/presets.h +++ b/plug-ins/gimpressionist/presets.h @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 __PRESETS_H #define __PRESETS_H diff --git a/plug-ins/gimpressionist/preview.c b/plug-ins/gimpressionist/preview.c index 35b3e61d5b..37d4c8f467 100644 --- a/plug-ins/gimpressionist/preview.c +++ b/plug-ins/gimpressionist/preview.c @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 @@ -74,79 +92,49 @@ preview_free_resources (void) void updatepreview (GtkWidget *wg, gpointer d) { - /* This portion is remmed out because of the remming out of the - * code below. - * -- Shlomi Fish - * */ -#if 0 - guchar buf[PREVIEWSIZE*3]; - - if (!PPM_IS_INITED (&infile) && d) - grabarea(); -#endif - - /* It seems that infile.col must be true here. (after grabarea() that is.) - * Thus, I'm removing this entire portion of the code in hope that - * it works OK afterwards. - * -- Shlomi Fish - * */ -#if 0 - if (!PPM_IS_INITED (&infile) && !d) { - guchar *buffer; - - buffer = g_new0 (guchar, 3*PREVIEWSIZE*PREVIEWSIZE); - gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview), - 0, 0, PREVIEWSIZE, PREVIEWSIZE, - GIMP_RGB_IMAGE, - buffer, - PREVIEWSIZE * 3); - - g_free (buffer); - } - else -#endif - { - if (!PPM_IS_INITED (&backup_ppm)) - { - infile_copy_to_ppm (&backup_ppm); - if ((backup_ppm.width != PREVIEWSIZE) || - (backup_ppm.height != PREVIEWSIZE)) - resize_fast (&backup_ppm, PREVIEWSIZE, PREVIEWSIZE); - if (img_has_alpha) - { - infile_copy_alpha_to_ppm (&alpha_backup_ppm); - if ((alpha_backup_ppm.width != PREVIEWSIZE) || - (alpha_backup_ppm.height != PREVIEWSIZE)) - resize_fast (&alpha_backup_ppm, PREVIEWSIZE, PREVIEWSIZE); - } - } - if (!PPM_IS_INITED (&preview_ppm)) - { - ppm_copy (&backup_ppm, &preview_ppm); - - if (img_has_alpha) - ppm_copy (&alpha_backup_ppm, &alpha_ppm); - } - if (d) - { - store_values (); - - if (GPOINTER_TO_INT (d) != 2) - repaint (&preview_ppm, &alpha_ppm); - } + if (!PPM_IS_INITED (&backup_ppm)) + { + infile_copy_to_ppm (&backup_ppm); + if ((backup_ppm.width != PREVIEWSIZE) || + (backup_ppm.height != PREVIEWSIZE)) + resize_fast (&backup_ppm, PREVIEWSIZE, PREVIEWSIZE); if (img_has_alpha) - drawalpha (&preview_ppm, &alpha_ppm); - - gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview), - 0, 0, PREVIEWSIZE, PREVIEWSIZE, - GIMP_RGB_IMAGE, - preview_ppm.col, - PREVIEWSIZE * 3); - - ppm_kill (&preview_ppm); - if (img_has_alpha) - ppm_kill (&alpha_ppm); + { + infile_copy_alpha_to_ppm (&alpha_backup_ppm); + if ((alpha_backup_ppm.width != PREVIEWSIZE) || + (alpha_backup_ppm.height != PREVIEWSIZE)) + resize_fast (&alpha_backup_ppm, PREVIEWSIZE, PREVIEWSIZE); + } } + + if (!PPM_IS_INITED (&preview_ppm)) + { + ppm_copy (&backup_ppm, &preview_ppm); + + if (img_has_alpha) + ppm_copy (&alpha_backup_ppm, &alpha_ppm); + } + + if (d) + { + store_values (); + + if (GPOINTER_TO_INT (d) != 2) + repaint (&preview_ppm, &alpha_ppm); + } + + if (img_has_alpha) + drawalpha (&preview_ppm, &alpha_ppm); + + gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview), + 0, 0, PREVIEWSIZE, PREVIEWSIZE, + GIMP_RGB_IMAGE, + preview_ppm.col, + PREVIEWSIZE * 3); + + ppm_kill (&preview_ppm); + if (img_has_alpha) + ppm_kill (&alpha_ppm); } static void diff --git a/plug-ins/gimpressionist/preview.h b/plug-ins/gimpressionist/preview.h index bc772d65b2..d4b5245ef5 100644 --- a/plug-ins/gimpressionist/preview.h +++ b/plug-ins/gimpressionist/preview.h @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 __PREVIEW_H #define __PREVIEW_H diff --git a/plug-ins/gimpressionist/random.h b/plug-ins/gimpressionist/random.h index 34a984b3a6..2c8ebdb272 100644 --- a/plug-ins/gimpressionist/random.h +++ b/plug-ins/gimpressionist/random.h @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 __RAND_H #define __RAND_H diff --git a/plug-ins/gimpressionist/repaint.c b/plug-ins/gimpressionist/repaint.c index febc1d2f9e..0a2cc23368 100644 --- a/plug-ins/gimpressionist/repaint.c +++ b/plug-ins/gimpressionist/repaint.c @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 diff --git a/plug-ins/gimpressionist/size.c b/plug-ins/gimpressionist/size.c index 05f5a07369..eb6ff64b79 100644 --- a/plug-ins/gimpressionist/size.c +++ b/plug-ins/gimpressionist/size.c @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 diff --git a/plug-ins/gimpressionist/size.h b/plug-ins/gimpressionist/size.h index b186f1d2fb..08746e8f7b 100644 --- a/plug-ins/gimpressionist/size.h +++ b/plug-ins/gimpressionist/size.h @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 __SIZE_H #define __SIZE_H diff --git a/plug-ins/gimpressionist/sizemap.c b/plug-ins/gimpressionist/sizemap.c index 8e6613b535..3df0cec2e1 100644 --- a/plug-ins/gimpressionist/sizemap.c +++ b/plug-ins/gimpressionist/sizemap.c @@ -1,3 +1,21 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 diff --git a/plug-ins/gimpressionist/utils.c b/plug-ins/gimpressionist/utils.c index c7e2e1bc54..9e01d95751 100644 --- a/plug-ins/gimpressionist/utils.c +++ b/plug-ins/gimpressionist/utils.c @@ -1,7 +1,26 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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. + */ + /* * utils.c - various utility routines that don't fit anywhere else. Usually * these routines don't affect the state of the program. - * */ + */ + #include "config.h" #include diff --git a/plug-ins/pygimp/gimpmodule.c b/plug-ins/pygimp/gimpmodule.c index fe57515138..a3d01204d0 100644 --- a/plug-ins/pygimp/gimpmodule.c +++ b/plug-ins/pygimp/gimpmodule.c @@ -837,30 +837,12 @@ pygimp_set_background(PyObject *self, PyObject *args) GimpRGB rgb; if (PyArg_ParseTuple(args, "O:set_background", &color)) { - if (! pygimp_rgb_from_pyobject (color, &rgb)) { - PyErr_Clear(); - PyArg_ParseTuple(args, "O!:set_background", PyGimpRGB_Type, &color); + if (!pygimp_rgb_from_pyobject(color, &rgb)) return NULL; - } } else { - int r, g, b; - PyErr_Clear(); - if (!PyArg_ParseTuple(args, "(iii):set_background", &r, &g, &b)) { - PyErr_Clear(); - if (!PyArg_ParseTuple(args, "iii:set_background", &r, &g, &b)) { - PyErr_Clear(); - PyArg_ParseTuple(args, "O!:set_background", - PyGimpRGB_Type, &color); - return NULL; - } - } - - r = CLAMP(r, 0, 255); - g = CLAMP(g, 0, 255); - b = CLAMP(b, 0, 255); - - gimp_rgba_set_uchar(&rgb, r, g, b, 255); + if (!pygimp_rgb_from_pyobject(args, &rgb)) + return NULL; } gimp_context_set_background(&rgb); @@ -876,30 +858,12 @@ pygimp_set_foreground(PyObject *self, PyObject *args) GimpRGB rgb; if (PyArg_ParseTuple(args, "O:set_foreground", &color)) { - if (! pygimp_rgb_from_pyobject (color, &rgb)) { - PyErr_Clear(); - PyArg_ParseTuple(args, "O!:set_foreground", PyGimpRGB_Type, &color); + if (!pygimp_rgb_from_pyobject(color, &rgb)) return NULL; - } } else { - int r, g, b; - PyErr_Clear(); - if (!PyArg_ParseTuple(args, "(iii):set_foreground", &r, &g, &b)) { - PyErr_Clear(); - if (!PyArg_ParseTuple(args, "iii:set_foreground", &r, &g, &b)) { - PyErr_Clear(); - PyArg_ParseTuple(args, "O!:set_foreground", - PyGimpRGB_Type, &color); - return NULL; - } - } - - r = CLAMP(r, 0, 255); - g = CLAMP(g, 0, 255); - b = CLAMP(b, 0, 255); - - gimp_rgba_set_uchar(&rgb, r, g, b, 255); + if (!pygimp_rgb_from_pyobject(args, &rgb)) + return NULL; } gimp_context_set_foreground(&rgb); diff --git a/plug-ins/pygimp/pygimp-colors.c b/plug-ins/pygimp/pygimp-colors.c index d69b3b2263..8aa8d32184 100644 --- a/plug-ins/pygimp/pygimp-colors.c +++ b/plug-ins/pygimp/pygimp-colors.c @@ -2372,7 +2372,6 @@ pygimp_rgb_from_pyobject(PyObject *object, GimpRGB *color) return 0; } } else if (PySequence_Check(object)) { - GimpRGB rgb; PyObject *r, *g, *b, *a = NULL; if (!PyArg_ParseTuple(object, "OOO|O", &r, &g, &b, &a)) @@ -2380,13 +2379,13 @@ pygimp_rgb_from_pyobject(PyObject *object, GimpRGB *color) #define SET_MEMBER(m) G_STMT_START { \ if (PyInt_Check(m)) \ - rgb.m = (double) PyInt_AS_LONG(m) / 255.0; \ + color->m = (double) PyInt_AS_LONG(m) / 255.0; \ else if (PyFloat_Check(m)) \ - rgb.m = PyFloat_AS_DOUBLE(m); \ + color->m = PyFloat_AS_DOUBLE(m); \ else { \ PyErr_SetString(PyExc_TypeError, \ #m " must be an int or a float"); \ - return -1; \ + return 0; \ } \ } G_STMT_END @@ -2397,7 +2396,11 @@ pygimp_rgb_from_pyobject(PyObject *object, GimpRGB *color) if (a) SET_MEMBER(a); else - rgb.a = 1.0; + color->a = 1.0; + + gimp_rgb_clamp(color); + + return 1; } PyErr_SetString(PyExc_TypeError, "could not convert to GimpRGB"); diff --git a/po/ChangeLog b/po/ChangeLog index e924d26524..cdc3424cb5 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,8 @@ +2008-01-28 Michael Natterer + + * POTFILES.in: add app/gegl/gimpcurvesconfig.c and + app/gegl/gimplevelsconfig.c + 2008-01-18 Alexandre Prokoudine * ru.po: Updated Russian translation. diff --git a/po/POTFILES.in b/po/POTFILES.in index 6800e4e9ee..8ef1cec0cd 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -208,6 +208,9 @@ app/file/file-procedure.c app/file/file-save.c app/file/file-utils.c +app/gegl/gimpcurvesconfig.c +app/gegl/gimplevelsconfig.c + app/gui/gui.c app/gui/gui-message.c app/gui/session.c diff --git a/themes/Default/images/Makefile.am b/themes/Default/images/Makefile.am index 2fe3117a98..829ed00998 100644 --- a/themes/Default/images/Makefile.am +++ b/themes/Default/images/Makefile.am @@ -315,6 +315,8 @@ STOCK_TOOL_IMAGES = \ tools/stock-tool-perspective-22.png \ tools/stock-tool-perspective-clone-16.png \ tools/stock-tool-perspective-clone-22.png \ + tools/stock-tool-polygon-select-16.png \ + tools/stock-tool-polygon-select-22.png \ tools/stock-tool-posterize-16.png \ tools/stock-tool-posterize-22.png \ tools/stock-tool-rect-select-16.png \ diff --git a/themes/Default/images/tools/stock-tool-polygon-select-16.png b/themes/Default/images/tools/stock-tool-polygon-select-16.png new file mode 100644 index 0000000000000000000000000000000000000000..568639dc0adf0a6139f9fde12c91361f02363a1b GIT binary patch literal 398 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|I14-?iy0WW zg+Z8+Vb&Z8pdfpRr>`sfb#6&EV*`J|Hd&yMWQl7;iF1B#Zfaf$gL6@8Vo7R>LV0FM zhJw4NZ$Nk>pEyv_Z%-G;5R21SC*Acr>>$v(U(?R<;C6wfW=jGOcDJ$3V)s)}+$re7 z@|xf7yqx|f>CLw;M9)pVnOJu2%uM+o!k0=!eZzZyan5FNP4K+PDk4+AZ&H&S`wXjj zlQf%+9n#Fsp1XaV(bK}xM)678f0L6LySkM084diqzn>4EFhQc}q4y_;^YeWtC8jZ+ zX4((?o#9sQ_dPQ61b@g?Y*6sd&-^`0Nk5s5;q+5W*SJ|TH}3OOKk)t+W7nP@37Nai pI|Hk#WfJmUr%iil{^S2?@we|Rjd!LPzXk>agQu&X%Q~loCIJ1In5_T+ literal 0 HcmV?d00001 diff --git a/themes/Default/images/tools/stock-tool-polygon-select-22.png b/themes/Default/images/tools/stock-tool-polygon-select-22.png new file mode 100644 index 0000000000000000000000000000000000000000..7b523e8372b8a97a575e25ef816167852e773c68 GIT binary patch literal 568 zcmV-80>}M{P)Px#32;bRa{vGi!~g&e!~vBn4jTXf00(qQO+^RS3mFC~B+kqGcmMzZ8FWQhbVF}# zZDnqB07G(RVRU6=Aa`kWXdp*PO;A^X4i^9b0i{VqK~y-)?bOXmR#6nj@!!@r`$7qW zYE+{pA(-|0h2TVR;C0ln%jy;s6de?$qWKYBK+pvkO|r7R8k~Jzk0&z;A%fOnv)Jcs z{_8oZz1fJ(?e(7&r?#^B zxdm1650l*~DWwy< zz7{yGtSuQG86(IM4XCO}&Z2%IEAqWse{mA@D~}_>?*4X9arH76m53}?A5Bfn{8sS^ zw#=R1Vz44P3?Zb_@1At893R1AM@H9Mp>YF^Ibu!2{gGEezw? z%G#2Yl6J-ue8wTZ;yWTWy5mYwJ6!U$qPD)2+^{Ycz#+aA@Ta2sBMwum^*ROADYgvY zQUT_=6&r<)@U5)6&=GPvV_u}P`dh=L2~LfIE^KW6mG}V~B|X!hD|g5M0000