[gimp/soc-2011-seamless-clone2] app: do more stuff generically in gimp_image_map_tool_initialize()
- From: Clayton Walker <claytonw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2011-seamless-clone2] app: do more stuff generically in gimp_image_map_tool_initialize()
- Date: Wed, 8 May 2013 15:14:13 +0000 (UTC)
commit 6136e93a644e193e51361c2dc9bbf360ecde34ee
Author: Michael Natterer <mitch gimp org>
Date: Tue Apr 16 23:28:02 2013 +0200
app: do more stuff generically in gimp_image_map_tool_initialize()
- reset the config object if it exists
- trigger the first preview of the filter
- remove the same stuff from all subclasses
app/tools/gimpbrightnesscontrasttool.c | 22 ---------------
app/tools/gimpcolorbalancetool.c | 7 +---
app/tools/gimpcolorizetool.c | 9 +-----
app/tools/gimpcurvestool.c | 5 ---
app/tools/gimpdesaturatetool.c | 4 ---
app/tools/gimphuesaturationtool.c | 7 +---
app/tools/gimpimagemaptool.c | 7 +++++
app/tools/gimplevelstool.c | 5 ---
app/tools/gimpoperationtool.c | 47 ++-----------------------------
app/tools/gimpposterizetool.c | 11 -------
app/tools/gimpthresholdtool.c | 7 -----
11 files changed, 16 insertions(+), 115 deletions(-)
---
diff --git a/app/tools/gimpbrightnesscontrasttool.c b/app/tools/gimpbrightnesscontrasttool.c
index 55a6c11..b925c09 100644
--- a/app/tools/gimpbrightnesscontrasttool.c
+++ b/app/tools/gimpbrightnesscontrasttool.c
@@ -48,10 +48,6 @@
#define SLIDER_WIDTH 200
-static gboolean gimp_brightness_contrast_tool_initialize (GimpTool *tool,
- GimpDisplay *display,
- GError **error);
-
static void gimp_brightness_contrast_tool_button_press (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
@@ -117,7 +113,6 @@ gimp_brightness_contrast_tool_class_init (GimpBrightnessContrastToolClass *klass
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
- tool_class->initialize = gimp_brightness_contrast_tool_initialize;
tool_class->button_press = gimp_brightness_contrast_tool_button_press;
tool_class->button_release = gimp_brightness_contrast_tool_button_release;
tool_class->motion = gimp_brightness_contrast_tool_motion;
@@ -136,23 +131,6 @@ gimp_brightness_contrast_tool_init (GimpBrightnessContrastTool *bc_tool)
{
}
-static gboolean
-gimp_brightness_contrast_tool_initialize (GimpTool *tool,
- GimpDisplay *display,
- GError **error)
-{
- GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool);
- GimpImage *image = gimp_display_get_image (display);
- GimpDrawable *drawable = gimp_image_get_active_drawable (image);
-
- if (! drawable)
- return FALSE;
-
- gimp_config_reset (GIMP_CONFIG (bc_tool->config));
-
- return GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
-}
-
static GeglNode *
gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config,
diff --git a/app/tools/gimpcolorbalancetool.c b/app/tools/gimpcolorbalancetool.c
index 7d97990..7601a44 100644
--- a/app/tools/gimpcolorbalancetool.c
+++ b/app/tools/gimpcolorbalancetool.c
@@ -123,9 +123,8 @@ gimp_color_balance_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error)
{
- GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (tool);
- GimpImage *image = gimp_display_get_image (display);
- GimpDrawable *drawable = gimp_image_get_active_drawable (image);
+ GimpImage *image = gimp_display_get_image (display);
+ GimpDrawable *drawable = gimp_image_get_active_drawable (image);
if (! drawable)
return FALSE;
@@ -137,8 +136,6 @@ gimp_color_balance_tool_initialize (GimpTool *tool,
return FALSE;
}
- gimp_config_reset (GIMP_CONFIG (cb_tool->config));
-
return GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
}
diff --git a/app/tools/gimpcolorizetool.c b/app/tools/gimpcolorizetool.c
index d4b6d62..28be5e9 100644
--- a/app/tools/gimpcolorizetool.c
+++ b/app/tools/gimpcolorizetool.c
@@ -127,9 +127,8 @@ gimp_colorize_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error)
{
- GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (tool);
- GimpImage *image = gimp_display_get_image (display);
- GimpDrawable *drawable = gimp_image_get_active_drawable (image);
+ GimpImage *image = gimp_display_get_image (display);
+ GimpDrawable *drawable = gimp_image_get_active_drawable (image);
if (! drawable)
return FALSE;
@@ -141,15 +140,11 @@ gimp_colorize_tool_initialize (GimpTool *tool,
return FALSE;
}
- gimp_config_reset (GIMP_CONFIG (col_tool->config));
-
if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
{
return FALSE;
}
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
-
return TRUE;
}
diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c
index 20aed9c..9d2b2ea 100644
--- a/app/tools/gimpcurvestool.c
+++ b/app/tools/gimpcurvestool.c
@@ -198,11 +198,6 @@ gimp_curves_tool_initialize (GimpTool *tool,
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
GimpHistogram *histogram;
- if (! drawable)
- return FALSE;
-
- gimp_config_reset (GIMP_CONFIG (c_tool->config));
-
if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
{
return FALSE;
diff --git a/app/tools/gimpdesaturatetool.c b/app/tools/gimpdesaturatetool.c
index 99bc83c..4f813bc 100644
--- a/app/tools/gimpdesaturatetool.c
+++ b/app/tools/gimpdesaturatetool.c
@@ -118,8 +118,6 @@ gimp_desaturate_tool_initialize (GimpTool *tool,
return FALSE;
}
- gimp_config_reset (GIMP_CONFIG (desaturate_tool->config));
-
if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
{
return FALSE;
@@ -128,8 +126,6 @@ gimp_desaturate_tool_initialize (GimpTool *tool,
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (desaturate_tool->button),
desaturate_tool->config->mode);
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (desaturate_tool));
-
return TRUE;
}
diff --git a/app/tools/gimphuesaturationtool.c b/app/tools/gimphuesaturationtool.c
index dd81c06..851cd9f 100644
--- a/app/tools/gimphuesaturationtool.c
+++ b/app/tools/gimphuesaturationtool.c
@@ -131,9 +131,8 @@ gimp_hue_saturation_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error)
{
- GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (tool);
- GimpImage *image = gimp_display_get_image (display);
- GimpDrawable *drawable = gimp_image_get_active_drawable (image);
+ GimpImage *image = gimp_display_get_image (display);
+ GimpDrawable *drawable = gimp_image_get_active_drawable (image);
if (! drawable)
return FALSE;
@@ -145,8 +144,6 @@ gimp_hue_saturation_tool_initialize (GimpTool *tool,
return FALSE;
}
- gimp_config_reset (GIMP_CONFIG (hs_tool->config));
-
return GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
}
diff --git a/app/tools/gimpimagemaptool.c b/app/tools/gimpimagemaptool.c
index d47fd08..fcc4236 100644
--- a/app/tools/gimpimagemaptool.c
+++ b/app/tools/gimpimagemaptool.c
@@ -274,6 +274,9 @@ gimp_image_map_tool_initialize (GimpTool *tool,
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
GimpDisplayShell *display_shell = gimp_display_get_shell (display);
+ if (! drawable)
+ return FALSE;
+
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)))
{
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
@@ -296,6 +299,9 @@ gimp_image_map_tool_initialize (GimpTool *tool,
/* set display so the dialog can be hidden on display destruction */
tool->display = display;
+ if (image_map_tool->config)
+ gimp_config_reset (GIMP_CONFIG (image_map_tool->config));
+
if (! image_map_tool->dialog)
{
GimpImageMapToolClass *klass;
@@ -424,6 +430,7 @@ gimp_image_map_tool_initialize (GimpTool *tool,
image_map_tool->drawable = drawable;
gimp_image_map_tool_create_map (image_map_tool);
+ gimp_image_map_tool_preview (image_map_tool);
return TRUE;
}
diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c
index 525b701..8f4cdaa 100644
--- a/app/tools/gimplevelstool.c
+++ b/app/tools/gimplevelstool.c
@@ -205,11 +205,6 @@ gimp_levels_tool_initialize (GimpTool *tool,
gdouble step;
gint digits;
- if (! drawable)
- return FALSE;
-
- gimp_config_reset (GIMP_CONFIG (l_tool->config));
-
if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
{
return FALSE;
diff --git a/app/tools/gimpoperationtool.c b/app/tools/gimpoperationtool.c
index 259b355..2cbc8c9 100644
--- a/app/tools/gimpoperationtool.c
+++ b/app/tools/gimpoperationtool.c
@@ -55,10 +55,6 @@
static void gimp_operation_tool_finalize (GObject *object);
-static gboolean gimp_operation_tool_initialize (GimpTool *tool,
- GimpDisplay *display,
- GError **error);
-
static GeglNode * gimp_operation_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config,
gchar **undo_desc);
@@ -106,13 +102,10 @@ static void
gimp_operation_tool_class_init (GimpOperationToolClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
object_class->finalize = gimp_operation_tool_finalize;
- tool_class->initialize = gimp_operation_tool_initialize;
-
im_tool_class->dialog_desc = _("GEGL Operation");
im_tool_class->get_operation = gimp_operation_tool_get_operation;
@@ -155,31 +148,6 @@ gimp_operation_tool_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-static gboolean
-gimp_operation_tool_initialize (GimpTool *tool,
- GimpDisplay *display,
- GError **error)
-{
- GimpOperationTool *o_tool = GIMP_OPERATION_TOOL (tool);
- GimpImage *image = gimp_display_get_image (display);
- GimpDrawable *drawable = gimp_image_get_active_drawable (image);
-
- if (! drawable)
- return FALSE;
-
- if (o_tool->config)
- gimp_config_reset (GIMP_CONFIG (o_tool->config));
-
- if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
- {
- return FALSE;
- }
-
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
-
- return TRUE;
-}
-
static GeglNode *
gimp_operation_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config,
@@ -315,25 +283,16 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
g_return_if_fail (operation != NULL);
if (tool->operation)
- {
- g_free (tool->operation);
- tool->operation = NULL;
- }
+ g_free (tool->operation);
if (tool->undo_desc)
- {
- g_free (tool->undo_desc);
- tool->undo_desc = NULL;
- }
+ g_free (tool->undo_desc);
tool->operation = g_strdup (operation);
tool->undo_desc = g_strdup (undo_desc);
if (tool->config)
- {
- g_object_unref (tool->config);
- tool->config = NULL;
- }
+ g_object_unref (tool->config);
tool->config = gimp_gegl_get_config_proxy (tool->operation,
GIMP_TYPE_IMAGE_MAP_CONFIG);
diff --git a/app/tools/gimpposterizetool.c b/app/tools/gimpposterizetool.c
index bcb5ec1..4f91a33 100644
--- a/app/tools/gimpposterizetool.c
+++ b/app/tools/gimpposterizetool.c
@@ -109,15 +109,6 @@ gimp_posterize_tool_initialize (GimpTool *tool,
GError **error)
{
GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (tool);
- GimpImage *image = gimp_display_get_image (display);
- GimpDrawable *drawable;
-
- drawable = gimp_image_get_active_drawable (image);
-
- if (! drawable)
- return FALSE;
-
- gimp_config_reset (GIMP_CONFIG (posterize_tool->config));
if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
{
@@ -127,8 +118,6 @@ gimp_posterize_tool_initialize (GimpTool *tool,
gtk_adjustment_set_value (posterize_tool->levels_data,
posterize_tool->config->levels);
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (posterize_tool));
-
return TRUE;
}
diff --git a/app/tools/gimpthresholdtool.c b/app/tools/gimpthresholdtool.c
index 0c2d08c..6f8fa7d 100644
--- a/app/tools/gimpthresholdtool.c
+++ b/app/tools/gimpthresholdtool.c
@@ -142,11 +142,6 @@ gimp_threshold_tool_initialize (GimpTool *tool,
GimpImage *image = gimp_display_get_image (display);
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
- if (! drawable)
- return FALSE;
-
- gimp_config_reset (GIMP_CONFIG (t_tool->config));
-
if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
{
return FALSE;
@@ -156,8 +151,6 @@ gimp_threshold_tool_initialize (GimpTool *tool,
gimp_histogram_view_set_histogram (t_tool->histogram_box->view,
t_tool->histogram);
- gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));
-
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]