Commit 1d2c795f authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

when trying to activate the previously selected layer after a layer

2003-11-13  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpimage-undo-push.c (undo_pop_layer): when trying to
	activate the previously selected layer after a layer removal, also
	look at gimage->layer_stack, just as gimp_image_remove_layer()
	does. Should fix regression from 1.2 when there was no avtive
	layer after certain undo operations. Fixes bug #126781.
	Reordered instructions to match gimp_image_remove_layer().

	* app/tools/gimpbrightnesscontrasttool.c
	* app/tools/gimpcolorbalancetool.c
	* app/tools/gimpcolorizetool.c
	* app/tools/gimpcurvestool.c
	* app/tools/gimphuesaturationtool.c
	* app/tools/gimplevelstool.c
	* app/tools/gimpposterizetool.c
	* app/tools/gimpthresholdtool.c: although the crash triggering bug
	is fixed, the image_map tools should not crash when invoked
	without active drawable: changed all _initialize() functions to
	silently return if there is no active drawable.

	Changed "drawable" to "layer" in all user visible warnings about
	indexed or non-RGB drawables. Cleanup.
parent a07815f5
2003-11-13 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-undo-push.c (undo_pop_layer): when trying to
activate the previously selected layer after a layer removal, also
look at gimage->layer_stack, just as gimp_image_remove_layer()
does. Should fix regression from 1.2 when there was no avtive
layer after certain undo operations. Fixes bug #126781.
Reordered instructions to match gimp_image_remove_layer().
* app/tools/gimpbrightnesscontrasttool.c
* app/tools/gimpcolorbalancetool.c
* app/tools/gimpcolorizetool.c
* app/tools/gimpcurvestool.c
* app/tools/gimphuesaturationtool.c
* app/tools/gimplevelstool.c
* app/tools/gimpposterizetool.c
* app/tools/gimpthresholdtool.c: although the crash triggering bug
is fixed, the image_map tools should not crash when invoked
without active drawable: changed all _initialize() functions to
silently return if there is no active drawable.
Changed "drawable" to "layer" in all user visible warnings about
indexed or non-RGB drawables. Cleanup.
2003-11-13 Simon Budig <simon@gimp.org>
* app/core/gimpdrawable-stroke.c: removed erraneous offset by
......@@ -1508,26 +1508,11 @@ undo_pop_layer (GimpUndo *undo,
/* record the current position */
lu->prev_position = gimp_image_get_layer_index (undo->gimage, layer);
if (layer == gimp_image_get_active_layer (undo->gimage))
{
if (lu->prev_layer)
{
gimp_image_set_active_layer (undo->gimage, lu->prev_layer);
}
else
{
undo->gimage->active_layer = NULL;
gimp_image_active_layer_changed (undo->gimage);
}
}
/* remove the layer */
gimp_container_remove (undo->gimage->layers, GIMP_OBJECT (layer));
undo->gimage->layer_stack = g_slist_remove (undo->gimage->layer_stack,
layer);
gimp_item_removed (GIMP_ITEM (layer));
/* reset the gimage values */
if (gimp_layer_is_floating_sel (layer))
{
......@@ -1538,6 +1523,26 @@ undo_pop_layer (GimpUndo *undo,
gimp_image_floating_selection_changed (undo->gimage);
}
if (layer == gimp_image_get_active_layer (undo->gimage))
{
if (lu->prev_layer)
{
gimp_image_set_active_layer (undo->gimage, lu->prev_layer);
}
else if (undo->gimage->layer_stack)
{
gimp_image_set_active_layer (undo->gimage,
undo->gimage->layer_stack->data);
}
else
{
undo->gimage->active_layer = NULL;
gimp_image_active_layer_changed (undo->gimage);
}
}
gimp_item_removed (GIMP_ITEM (layer));
if (gimp_container_num_children (undo->gimage->layers) == 1 &&
! gimp_drawable_has_alpha (GIMP_LIST (undo->gimage->layers)->list->data))
{
......
......@@ -154,9 +154,7 @@ gimp_brightness_contrast_tool_init (GimpBrightnessContrastTool *bc_tool)
static void
gimp_brightness_contrast_tool_finalize (GObject *object)
{
GimpBrightnessContrastTool *bc_tool;
bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (object);
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (object);
if (bc_tool->lut)
{
......@@ -171,13 +169,17 @@ static void
gimp_brightness_contrast_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp)
{
GimpBrightnessContrastTool *bc_tool;
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool);
GimpDrawable *drawable;
drawable = gimp_image_active_drawable (gdisp->gimage);
bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool);
if (! drawable)
return;
if (gimp_drawable_is_indexed (gimp_image_active_drawable (gdisp->gimage)))
if (gimp_drawable_is_indexed (drawable))
{
g_message (_("Brightness-Contrast does not operate on indexed drawables."));
g_message (_("Brightness-Contrast does not operate on indexed layers."));
return;
}
......@@ -193,10 +195,8 @@ static void
gimp_brightness_contrast_tool_map (GimpImageMapTool *image_map_tool)
{
GimpBrightnessContrastTool *bc_tool;
GimpTool *tool;
bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (image_map_tool);
tool = GIMP_TOOL (image_map_tool);
brightness_contrast_lut_setup (bc_tool->lut,
bc_tool->brightness / 255.0,
......
......@@ -66,17 +66,17 @@ static void gimp_color_balance_tool_reset (GimpImageMapTool *image_map_to
static void color_balance_update (GimpColorBalanceTool *cb_tool,
gint update);
static void color_balance_range_callback (GtkWidget *widget,
gpointer data);
GimpColorBalanceTool *cb_tool);
static void color_balance_range_reset_callback (GtkWidget *widget,
gpointer data);
GimpColorBalanceTool *cb_tool);
static void color_balance_preserve_update (GtkWidget *widget,
gpointer data);
GimpColorBalanceTool *cb_tool);
static void color_balance_cr_adjustment_update (GtkAdjustment *adj,
gpointer data);
GimpColorBalanceTool *cb_tool);
static void color_balance_mg_adjustment_update (GtkAdjustment *adj,
gpointer data);
GimpColorBalanceTool *cb_tool);
static void color_balance_yb_adjustment_update (GtkAdjustment *adj,
gpointer data);
GimpColorBalanceTool *cb_tool);
static GimpImageMapToolClass *parent_class = NULL;
......@@ -166,9 +166,7 @@ gimp_color_balance_tool_init (GimpColorBalanceTool *cb_tool)
static void
gimp_color_balance_tool_finalize (GObject *object)
{
GimpColorBalanceTool *cb_tool;
cb_tool = GIMP_COLOR_BALANCE_TOOL (object);
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (object);
if (cb_tool->color_balance)
{
......@@ -183,13 +181,17 @@ static void
gimp_color_balance_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp)
{
GimpColorBalanceTool *cb_tool;
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (tool);
GimpDrawable *drawable;
drawable = gimp_image_active_drawable (gdisp->gimage);
cb_tool = GIMP_COLOR_BALANCE_TOOL (tool);
if (! drawable)
return;
if (! gimp_drawable_is_rgb (gimp_image_active_drawable (gdisp->gimage)))
if (! gimp_drawable_is_rgb (drawable))
{
g_message (_("Color balance operates only on RGB color drawables."));
g_message (_("Color balance operates only on RGB color layers."));
return;
}
......@@ -205,9 +207,7 @@ gimp_color_balance_tool_initialize (GimpTool *tool,
static void
gimp_color_balance_tool_map (GimpImageMapTool *image_map_tool)
{
GimpColorBalanceTool *cb_tool;
cb_tool = GIMP_COLOR_BALANCE_TOOL (image_map_tool);
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (image_map_tool);
color_balance_create_lookup_tables (cb_tool->color_balance);
gimp_image_map_apply (image_map_tool->image_map,
......@@ -263,7 +263,7 @@ create_levels_scale (const gchar *left,
static void
gimp_color_balance_tool_dialog (GimpImageMapTool *image_map_tool)
{
GimpColorBalanceTool *cb_tool;
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (image_map_tool);
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *table;
......@@ -271,8 +271,6 @@ gimp_color_balance_tool_dialog (GimpImageMapTool *image_map_tool)
GtkWidget *button;
GtkWidget *frame;
cb_tool = GIMP_COLOR_BALANCE_TOOL (image_map_tool);
frame = gimp_enum_radio_frame_new (GIMP_TYPE_TRANSFER_MODE,
gtk_label_new (_("Select Range to Modify")),
2,
......@@ -353,9 +351,7 @@ gimp_color_balance_tool_dialog (GimpImageMapTool *image_map_tool)
static void
gimp_color_balance_tool_reset (GimpImageMapTool *image_map_tool)
{
GimpColorBalanceTool *cb_tool;
cb_tool = GIMP_COLOR_BALANCE_TOOL (image_map_tool);
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (image_map_tool);
color_balance_init (cb_tool->color_balance);
color_balance_update (cb_tool, ALL);
......@@ -387,25 +383,17 @@ color_balance_update (GimpColorBalanceTool *cb_tool,
}
static void
color_balance_range_callback (GtkWidget *widget,
gpointer data)
color_balance_range_callback (GtkWidget *widget,
GimpColorBalanceTool *cb_tool)
{
GimpColorBalanceTool *cb_tool;
cb_tool = GIMP_COLOR_BALANCE_TOOL (data);
gimp_radio_button_update (widget, &cb_tool->transfer_mode);
color_balance_update (cb_tool, ALL);
}
static void
color_balance_range_reset_callback (GtkWidget *widget,
gpointer data)
color_balance_range_reset_callback (GtkWidget *widget,
GimpColorBalanceTool *cb_tool)
{
GimpColorBalanceTool *cb_tool;
cb_tool = GIMP_COLOR_BALANCE_TOOL (data);
color_balance_range_reset (cb_tool->color_balance,
cb_tool->transfer_mode);
color_balance_update (cb_tool, ALL);
......@@ -414,13 +402,10 @@ color_balance_range_reset_callback (GtkWidget *widget,
}
static void
color_balance_preserve_update (GtkWidget *widget,
gpointer data)
color_balance_preserve_update (GtkWidget *widget,
GimpColorBalanceTool *cb_tool)
{
GimpColorBalanceTool *cb_tool;
gboolean active;
cb_tool = GIMP_COLOR_BALANCE_TOOL (data);
gboolean active;
active = GTK_TOGGLE_BUTTON (widget)->active;
......@@ -433,13 +418,10 @@ color_balance_preserve_update (GtkWidget *widget,
}
static void
color_balance_cr_adjustment_update (GtkAdjustment *adjustment,
gpointer data)
color_balance_cr_adjustment_update (GtkAdjustment *adjustment,
GimpColorBalanceTool *cb_tool)
{
GimpColorBalanceTool *cb_tool;
GimpTransferMode tm;
cb_tool = GIMP_COLOR_BALANCE_TOOL (data);
GimpTransferMode tm;
tm = cb_tool->transfer_mode;
......@@ -452,13 +434,10 @@ color_balance_cr_adjustment_update (GtkAdjustment *adjustment,
}
static void
color_balance_mg_adjustment_update (GtkAdjustment *adjustment,
gpointer data)
color_balance_mg_adjustment_update (GtkAdjustment *adjustment,
GimpColorBalanceTool *cb_tool)
{
GimpColorBalanceTool *cb_tool;
GimpTransferMode tm;
cb_tool = GIMP_COLOR_BALANCE_TOOL (data);
GimpTransferMode tm;
tm = cb_tool->transfer_mode;
......@@ -471,13 +450,10 @@ color_balance_mg_adjustment_update (GtkAdjustment *adjustment,
}
static void
color_balance_yb_adjustment_update (GtkAdjustment *adjustment,
gpointer data)
color_balance_yb_adjustment_update (GtkAdjustment *adjustment,
GimpColorBalanceTool *cb_tool)
{
GimpColorBalanceTool *cb_tool;
GimpTransferMode tm;
cb_tool = GIMP_COLOR_BALANCE_TOOL (data);
GimpTransferMode tm;
tm = cb_tool->transfer_mode;
......
......@@ -168,9 +168,7 @@ gimp_colorize_tool_init (GimpColorizeTool *col_tool)
static void
gimp_colorize_tool_finalize (GObject *object)
{
GimpColorizeTool *col_tool;
col_tool = GIMP_COLORIZE_TOOL (object);
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (object);
if (col_tool->colorize)
{
......@@ -185,13 +183,17 @@ static void
gimp_colorize_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp)
{
GimpColorizeTool *col_tool;
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (tool);
GimpDrawable *drawable;
drawable = gimp_image_active_drawable (gdisp->gimage);
col_tool = GIMP_COLORIZE_TOOL (tool);
if (! drawable)
return;
if (! gimp_drawable_is_rgb (gimp_image_active_drawable (gdisp->gimage)))
if (! gimp_drawable_is_rgb (drawable))
{
g_message (_("Colorize operates only on RGB color drawables."));
g_message (_("Colorize operates only on RGB color layers."));
return;
}
......@@ -207,9 +209,7 @@ gimp_colorize_tool_initialize (GimpTool *tool,
static void
gimp_colorize_tool_map (GimpImageMapTool *image_map_tool)
{
GimpColorizeTool *col_tool;
col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
gimp_image_map_apply (image_map_tool->image_map,
(GimpImageMapApplyFunc) colorize,
......@@ -224,15 +224,13 @@ gimp_colorize_tool_map (GimpImageMapTool *image_map_tool)
static void
gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool)
{
GimpColorizeTool *col_tool;
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
GtkWidget *table;
GtkWidget *slider;
GtkWidget *frame;
GtkWidget *vbox;
GtkObject *data;
col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
frame = gtk_frame_new (_("Select Color"));
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), frame,
FALSE, FALSE, 0);
......@@ -296,9 +294,7 @@ gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool)
static void
gimp_colorize_tool_reset (GimpImageMapTool *image_map_tool)
{
GimpColorizeTool *col_tool;
col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
colorize_init (col_tool->colorize);
......
......@@ -247,9 +247,7 @@ gimp_curves_tool_init (GimpCurvesTool *c_tool)
static void
gimp_curves_tool_finalize (GObject *object)
{
GimpCurvesTool *c_tool;
c_tool = GIMP_CURVES_TOOL (object);
GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (object);
if (c_tool->curves)
{
......@@ -279,19 +277,20 @@ static void
gimp_curves_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp)
{
GimpCurvesTool *c_tool;
GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (tool);
GimpDrawable *drawable;
c_tool = GIMP_CURVES_TOOL (tool);
drawable = gimp_image_active_drawable (gdisp->gimage);
if (! drawable)
return;
if (gimp_drawable_is_indexed (gimp_image_active_drawable (gdisp->gimage)))
if (gimp_drawable_is_indexed (drawable))
{
g_message (_("Curves for indexed drawables cannot be adjusted."));
g_message (_("Curves for indexed layers cannot be adjusted."));
return;
}
drawable = gimp_image_active_drawable (gdisp->gimage);
curves_init (c_tool->curves);
c_tool->color = gimp_drawable_is_rgb (drawable);
......@@ -325,11 +324,9 @@ gimp_curves_tool_button_release (GimpTool *tool,
GdkModifierType state,
GimpDisplay *gdisp)
{
GimpCurvesTool *c_tool;
GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (tool);
GimpDrawable *drawable;
c_tool = GIMP_CURVES_TOOL (tool);
drawable = gimp_image_active_drawable (gdisp->gimage);
if (state & GDK_SHIFT_MASK)
......@@ -427,9 +424,7 @@ curves_add_point (GimpCurvesTool *c_tool,
static void
gimp_curves_tool_map (GimpImageMapTool *image_map_tool)
{
GimpCurvesTool *c_tool;
c_tool = GIMP_CURVES_TOOL (image_map_tool);
GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (image_map_tool);
gimp_lut_setup (c_tool->lut,
(GimpLutFunc) curves_lut_func,
......@@ -449,7 +444,7 @@ gimp_curves_tool_map (GimpImageMapTool *image_map_tool)
static void
gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
{
GimpCurvesTool *c_tool;
GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (image_map_tool);
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *hbbox;
......@@ -458,8 +453,6 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
GtkWidget *table;
GtkWidget *button;
c_tool = GIMP_CURVES_TOOL (image_map_tool);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), hbox,
FALSE, FALSE, 0);
......@@ -612,11 +605,9 @@ gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
static void
gimp_curves_tool_reset (GimpImageMapTool *image_map_tool)
{
GimpCurvesTool *c_tool;
GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (image_map_tool);
GimpHistogramChannel channel;
c_tool = GIMP_CURVES_TOOL (image_map_tool);
c_tool->grab_point = -1;
for (channel = GIMP_HISTOGRAM_VALUE;
......
......@@ -183,9 +183,7 @@ gimp_hue_saturation_tool_init (GimpHueSaturationTool *hs_tool)
static void
gimp_hue_saturation_tool_finalize (GObject *object)
{
GimpHueSaturationTool *hs_tool;
hs_tool = GIMP_HUE_SATURATION_TOOL (object);
GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (object);
if (hs_tool->hue_saturation)
{
......@@ -200,11 +198,15 @@ static void
gimp_hue_saturation_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp)
{
GimpHueSaturationTool *hs_tool;
GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (tool);
GimpDrawable *drawable;
hs_tool = GIMP_HUE_SATURATION_TOOL (tool);
drawable = gimp_image_active_drawable (gdisp->gimage);
if (! gimp_drawable_is_rgb (gimp_image_active_drawable (gdisp->gimage)))
if (! drawable)
return;
if (! gimp_drawable_is_rgb (drawable))
{
g_message (_("Hue-Saturation operates only on RGB color drawables."));
return;
......@@ -220,9 +222,7 @@ gimp_hue_saturation_tool_initialize (GimpTool *tool,
static void
gimp_hue_saturation_tool_map (GimpImageMapTool *image_map_tool)
{
GimpHueSaturationTool *hs_tool;
hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool);
GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool);
gimp_image_map_apply (image_map_tool->image_map,
(GimpImageMapApplyFunc) hue_saturation,
......@@ -237,7 +237,7 @@ gimp_hue_saturation_tool_map (GimpImageMapTool *image_map_tool)
static void
gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
{
GimpHueSaturationTool *hs_tool;
GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool);
GtkWidget *abox;
GtkWidget *table;
GtkWidget *slider;
......@@ -268,8 +268,6 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
{ N_("_M"), 3, 2, 4, 2 }
};
hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool);
frame = gtk_frame_new (_("Select Primary Color to Modify"));
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), frame,
FALSE, FALSE, 0);
......@@ -417,9 +415,7 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
static void
gimp_hue_saturation_tool_reset (GimpImageMapTool *image_map_tool)
{
GimpHueSaturationTool *hs_tool;
hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool);
GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool);
hue_saturation_init (hs_tool->hue_saturation);
hue_saturation_update (hs_tool, ALL);
......
......@@ -270,16 +270,17 @@ static void
gimp_levels_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp)
{
GimpLevelsTool *l_tool;
GimpLevelsTool *l_tool = GIMP_LEVELS_TOOL (tool);
GimpDrawable *drawable;
l_tool = GIMP_LEVELS_TOOL (tool);
drawable = gimp_image_active_drawable (gdisp->gimage);
if (! drawable)
return;
if (gimp_drawable_is_indexed (drawable))
{
g_message (_("Levels for indexed drawables cannot be adjusted."));
g_message (_("Levels for indexed layers cannot be adjusted."));
return;
}
......@@ -322,9 +323,7 @@ gimp_levels_tool_initialize (GimpTool *tool,
static void
gimp_levels_tool_map (GimpImageMapTool *image_map_tool)
{
GimpLevelsTool *l_tool;
l_tool = GIMP_LEVELS_TOOL (image_map_tool);
GimpLevelsTool *l_tool = GIMP_LEVELS_TOOL (image_map_tool);
gimp_image_map_apply (image_map_tool->image_map,
(GimpImageMapApplyFunc) gimp_lut_process_2,
......@@ -382,7 +381,7 @@ gimp_levels_tool_color_picker_new (GimpLevelsTool *tool,
static void
gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
{
GimpLevelsTool *l_tool;
GimpLevelsTool *l_tool = GIMP_LEVELS_TOOL (image_map_tool);
GimpToolOptions *tool_options;
GtkWidget *vbox;
GtkWidget *vbox2;
......@@ -398,8 +397,6 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
GtkWidget *spinbutton;
GtkObject *data;
l_tool = GIMP_LEVELS_TOOL (image_map_tool);
hbox = gtk_hbox_new (TRUE, 0);
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), hbox,
TRUE, TRUE, 0);
......
......@@ -146,9 +146,7 @@ gimp_posterize_tool_init (GimpPosterizeTool *posterize_tool)
static void
gimp_posterize_tool_finalize (GObject *object)
{
GimpPosterizeTool *posterize_tool;
posterize_tool = GIMP_POSTERIZE_TOOL (object);
GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (object);
if (posterize_tool->lut)
{
......@@ -163,13 +161,17 @@ static void
gimp_posterize_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp)
{
GimpPosterizeTool *posterize_tool;
GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (tool);
GimpDrawable *drawable;
drawable = gimp_image_active_drawable (gdisp->gimage);
posterize_tool = GIMP_POSTERIZE_TOOL (tool);
if (! drawable)
return;
if (gimp_drawable_is_indexed (gimp_image_active_drawable (gdisp->gimage)))
if (gimp_drawable_is_indexed (drawable))
{
g_message (_("Posterize does not operate on indexed drawables."));
g_message (_("Posterize does not operate on indexed layers."));
return;
}
......@@ -186,11 +188,7 @@ gimp_posterize_tool_initialize (GimpTool *tool,
static void
gimp_posterize_tool_map (GimpImageMapTool *image_map_tool)
{
GimpPosterizeTool *posterize_tool;
GimpTool *tool;
posterize_tool = GIMP_POSTERIZE_TOOL (image_map_tool);
tool = GIMP_TOOL (image_map_tool);
GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (image_map_tool);
posterize_lut_setup (posterize_tool->lut,
posterize_tool->levels,
......@@ -208,13 +206,11 @@ gimp_posterize_tool_map (GimpImageMapTool *image_map_tool)
static void
gimp_posterize_tool_dialog (GimpImageMapTool *image_map_tool)
{
GimpPosterizeTool *posterize_tool;
GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (image_map_tool);
GtkWidget *table;
GtkWidget *slider;
GtkObject *data;
posterize_tool = GIMP_POSTERIZE_TOOL (image_map_tool);