Commit 613e328f authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

added boolean return value to GimpTool::initialize(). Returning FALSE

2004-01-21  Michael Natterer  <mitch@gimp.org>

	* app/tools/gimptool.[ch]: added boolean return value to
	GimpTool::initialize(). Returning FALSE means the tool could not
	be initialized and doesn't want to receive button events.
	Return TRUE from the default implementation.

	* app/tools/tool_manager.[ch]: added boolean return value to
	tool_manager_initialize_active(). Don't set the tool's display or
	drawable if initialize() returns FALSE.

	* app/display/gimpdisplayshell-callbacks.c: don't send button
	events to the tool if initialize() returns FALSE.

	* 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: return FALSE for NULL and indexed
	drawables.

	* app/tools/gimpimagemaptool.c: always return TRUE because our
	subclasses already checked if the active drawable is OK.

	* app/tools/gimptransformtool.c: return FALSE for layers with
	masks. Fixes bug #132089. Some random cleanups.
parent 32bb528d
2004-01-21 Michael Natterer <mitch@gimp.org>
* app/tools/gimptool.[ch]: added boolean return value to
GimpTool::initialize(). Returning FALSE means the tool could not
be initialized and doesn't want to receive button events.
Return TRUE from the default implementation.
* app/tools/tool_manager.[ch]: added boolean return value to
tool_manager_initialize_active(). Don't set the tool's display or
drawable if initialize() returns FALSE.
* app/display/gimpdisplayshell-callbacks.c: don't send button
events to the tool if initialize() returns FALSE.
* 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: return FALSE for NULL and indexed
drawables.
* app/tools/gimpimagemaptool.c: always return TRUE because our
subclasses already checked if the active drawable is OK.
* app/tools/gimptransformtool.c: return FALSE for layers with
masks. Fixes bug #132089. Some random cleanups.
2004-01-21 DindinX <david@dindinx.org>
 
* plug-ins/common/plugindetails.c: correctly resize both panels of the
......@@ -642,6 +642,8 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
(! gimp_image_is_empty (gimage) ||
gimp_tool_control_handles_empty_image (active_tool->control)))
{
gboolean initialized = TRUE;
if (gimp_tool_control_auto_snap_to (active_tool->control))
{
gint x, y, width, height;
......@@ -661,7 +663,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
*/
if (! active_tool->drawable)
{
tool_manager_initialize_active (gimp, gdisp);
initialized = tool_manager_initialize_active (gimp, gdisp);
}
else if ((active_tool->drawable !=
gimp_image_active_drawable (gimage)) &&
......@@ -671,12 +673,13 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
*/
gimp_context_tool_changed (gimp_get_user_context (gimp));
tool_manager_initialize_active (gimp, gdisp);
initialized = tool_manager_initialize_active (gimp, gdisp);
}
tool_manager_button_press_active (gimp,
&image_coords, time, state,
gdisp);
if (initialized)
tool_manager_button_press_active (gimp,
&image_coords, time, state,
gdisp);
}
break;
......
......@@ -48,24 +48,24 @@
#define ALL (BRIGHTNESS | CONTRAST)
static void gimp_brightness_contrast_tool_class_init (GimpBrightnessContrastToolClass *klass);
static void gimp_brightness_contrast_tool_init (GimpBrightnessContrastTool *bc_tool);
static void gimp_brightness_contrast_tool_class_init (GimpBrightnessContrastToolClass *klass);
static void gimp_brightness_contrast_tool_init (GimpBrightnessContrastTool *bc_tool);
static void gimp_brightness_contrast_tool_finalize (GObject *object);
static void gimp_brightness_contrast_tool_finalize (GObject *object);
static void gimp_brightness_contrast_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp);
static gboolean gimp_brightness_contrast_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp);
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 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 (GimpBrightnessContrastTool *bc_tool,
gint update);
static void brightness_contrast_brightness_adjustment_update (GtkAdjustment *adj,
gpointer data);
static void brightness_contrast_contrast_adjustment_update (GtkAdjustment *adj,
gpointer data);
static void brightness_contrast_update (GimpBrightnessContrastTool *bc_tool,
gint update);
static void brightness_contrast_brightness_adjustment_update (GtkAdjustment *adj,
gpointer data);
static void brightness_contrast_contrast_adjustment_update (GtkAdjustment *adj,
gpointer data);
static GimpImageMapToolClass *parent_class = NULL;
......@@ -165,7 +165,7 @@ gimp_brightness_contrast_tool_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
static gboolean
gimp_brightness_contrast_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp)
{
......@@ -175,12 +175,12 @@ gimp_brightness_contrast_tool_initialize (GimpTool *tool,
drawable = gimp_image_active_drawable (gdisp->gimage);
if (! drawable)
return;
return FALSE;
if (gimp_drawable_is_indexed (drawable))
{
g_message (_("Brightness-Contrast does not operate on indexed layers."));
return;
return FALSE;
}
bc_tool->brightness = 0.0;
......@@ -189,6 +189,8 @@ gimp_brightness_contrast_tool_initialize (GimpTool *tool,
GIMP_TOOL_CLASS (parent_class)->initialize (tool, gdisp);
brightness_contrast_update (bc_tool, ALL);
return TRUE;
}
static void
......
......@@ -54,29 +54,29 @@
static void gimp_color_balance_tool_class_init (GimpColorBalanceToolClass *klass);
static void gimp_color_balance_tool_init (GimpColorBalanceTool *cb_tool);
static void gimp_color_balance_tool_finalize (GObject *object);
static void gimp_color_balance_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp);
static void gimp_color_balance_tool_map (GimpImageMapTool *image_map_tool);
static void gimp_color_balance_tool_dialog (GimpImageMapTool *image_map_tool);
static void gimp_color_balance_tool_reset (GimpImageMapTool *image_map_tool);
static void color_balance_update (GimpColorBalanceTool *cb_tool,
gint update);
static void color_balance_range_callback (GtkWidget *widget,
GimpColorBalanceTool *cb_tool);
static void color_balance_range_reset_callback (GtkWidget *widget,
GimpColorBalanceTool *cb_tool);
static void color_balance_preserve_update (GtkWidget *widget,
GimpColorBalanceTool *cb_tool);
static void color_balance_cr_adjustment_update (GtkAdjustment *adj,
GimpColorBalanceTool *cb_tool);
static void color_balance_mg_adjustment_update (GtkAdjustment *adj,
GimpColorBalanceTool *cb_tool);
static void color_balance_yb_adjustment_update (GtkAdjustment *adj,
GimpColorBalanceTool *cb_tool);
static void gimp_color_balance_tool_finalize (GObject *object);
static gboolean gimp_color_balance_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp);
static void gimp_color_balance_tool_map (GimpImageMapTool *image_map_tool);
static void gimp_color_balance_tool_dialog (GimpImageMapTool *image_map_tool);
static void gimp_color_balance_tool_reset (GimpImageMapTool *image_map_tool);
static void color_balance_update (GimpColorBalanceTool *cb_tool,
gint update);
static void color_balance_range_callback (GtkWidget *widget,
GimpColorBalanceTool *cb_tool);
static void color_balance_range_reset_callback (GtkWidget *widget,
GimpColorBalanceTool *cb_tool);
static void color_balance_preserve_update (GtkWidget *widget,
GimpColorBalanceTool *cb_tool);
static void color_balance_cr_adjustment_update (GtkAdjustment *adj,
GimpColorBalanceTool *cb_tool);
static void color_balance_mg_adjustment_update (GtkAdjustment *adj,
GimpColorBalanceTool *cb_tool);
static void color_balance_yb_adjustment_update (GtkAdjustment *adj,
GimpColorBalanceTool *cb_tool);
static GimpImageMapToolClass *parent_class = NULL;
......@@ -177,7 +177,7 @@ gimp_color_balance_tool_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
static gboolean
gimp_color_balance_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp)
{
......@@ -187,12 +187,12 @@ gimp_color_balance_tool_initialize (GimpTool *tool,
drawable = gimp_image_active_drawable (gdisp->gimage);
if (! drawable)
return;
return FALSE;
if (! gimp_drawable_is_rgb (drawable))
{
g_message (_("Color balance operates only on RGB color layers."));
return;
return FALSE;
}
color_balance_init (cb_tool->color_balance);
......@@ -202,6 +202,8 @@ gimp_color_balance_tool_initialize (GimpTool *tool,
GIMP_TOOL_CLASS (parent_class)->initialize (tool, gdisp);
color_balance_update (cb_tool, ALL);
return TRUE;
}
static void
......
......@@ -55,26 +55,26 @@
/* local function prototypes */
static void gimp_colorize_tool_class_init (GimpColorizeToolClass *klass);
static void gimp_colorize_tool_init (GimpColorizeTool *tool);
static void gimp_colorize_tool_class_init (GimpColorizeToolClass *klass);
static void gimp_colorize_tool_init (GimpColorizeTool *tool);
static void gimp_colorize_tool_finalize (GObject *object);
static void gimp_colorize_tool_finalize (GObject *object);
static void gimp_colorize_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp);
static gboolean gimp_colorize_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp);
static void gimp_colorize_tool_map (GimpImageMapTool *image_map_tool);
static void gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool);
static void gimp_colorize_tool_reset (GimpImageMapTool *image_map_tool);
static void gimp_colorize_tool_map (GimpImageMapTool *image_map_tool);
static void gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool);
static void gimp_colorize_tool_reset (GimpImageMapTool *image_map_tool);
static void colorize_update (GimpColorizeTool *col_tool,
gint update);
static void colorize_hue_adj_update (GtkAdjustment *adj,
GimpColorizeTool *col_tool);
static void colorize_saturation_adj_update (GtkAdjustment *adj,
GimpColorizeTool *col_tool);
static void colorize_lightness_adj_update (GtkAdjustment *adj,
GimpColorizeTool *col_tool);
static void colorize_update (GimpColorizeTool *col_tool,
gint update);
static void colorize_hue_adj_update (GtkAdjustment *adj,
GimpColorizeTool *col_tool);
static void colorize_saturation_adj_update (GtkAdjustment *adj,
GimpColorizeTool *col_tool);
static void colorize_lightness_adj_update (GtkAdjustment *adj,
GimpColorizeTool *col_tool);
/* private variables */
......@@ -179,7 +179,7 @@ gimp_colorize_tool_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
static gboolean
gimp_colorize_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp)
{
......@@ -189,12 +189,12 @@ gimp_colorize_tool_initialize (GimpTool *tool,
drawable = gimp_image_active_drawable (gdisp->gimage);
if (! drawable)
return;
return FALSE;
if (! gimp_drawable_is_rgb (drawable))
{
g_message (_("Colorize operates only on RGB color layers."));
return;
return FALSE;
}
colorize_init (col_tool->colorize);
......@@ -204,6 +204,8 @@ gimp_colorize_tool_initialize (GimpTool *tool,
colorize_update (col_tool, ALL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
return FALSE;
}
static void
......
......@@ -90,64 +90,64 @@
/* local function prototypes */
static void gimp_curves_tool_class_init (GimpCurvesToolClass *klass);
static void gimp_curves_tool_init (GimpCurvesTool *c_tool);
static void gimp_curves_tool_finalize (GObject *object);
static void gimp_curves_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp);
static void gimp_curves_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_curves_tool_color_picked (GimpColorTool *color_tool,
GimpImageType sample_type,
GimpRGB *color,
gint color_index);
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);
static void curves_add_point (GimpCurvesTool *c_tool,
gint x,
gint y,
gint cchan);
static void curves_update (GimpCurvesTool *c_tool,
gint update);
static void curves_channel_callback (GtkWidget *widget,
GimpCurvesTool *c_tool);
static void curves_channel_reset_callback (GtkWidget *widget,
GimpCurvesTool *c_tool);
static gboolean curves_set_sensitive_callback (GimpHistogramChannel channel,
GimpCurvesTool *c_tool);
static void curves_curve_type_callback (GtkWidget *widget,
GimpCurvesTool *c_tool);
static void curves_load_callback (GtkWidget *widget,
GimpCurvesTool *c_tool);
static void curves_save_callback (GtkWidget *widget,
GimpCurvesTool *c_tool);
static gboolean curves_graph_events (GtkWidget *widget,
GdkEvent *event,
GimpCurvesTool *c_tool);
static gboolean curves_graph_expose (GtkWidget *widget,
GdkEventExpose *eevent,
GimpCurvesTool *c_tool);
static void file_dialog_create (GimpCurvesTool *c_tool);
static void file_dialog_response (GtkWidget *dialog,
gint response_id,
GimpCurvesTool *c_tool);
static gboolean curves_read_from_file (GimpCurvesTool *c_tool,
FILE *file);
static void curves_write_to_file (GimpCurvesTool *c_tool,
FILE *file);
static void gimp_curves_tool_class_init (GimpCurvesToolClass *klass);
static void gimp_curves_tool_init (GimpCurvesTool *c_tool);
static void gimp_curves_tool_finalize (GObject *object);
static gboolean gimp_curves_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp);
static void gimp_curves_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_curves_tool_color_picked (GimpColorTool *color_tool,
GimpImageType sample_type,
GimpRGB *color,
gint color_index);
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);
static void curves_add_point (GimpCurvesTool *c_tool,
gint x,
gint y,
gint cchan);
static void curves_update (GimpCurvesTool *c_tool,
gint update);
static void curves_channel_callback (GtkWidget *widget,
GimpCurvesTool *c_tool);
static void curves_channel_reset_callback (GtkWidget *widget,
GimpCurvesTool *c_tool);
static gboolean curves_set_sensitive_callback (GimpHistogramChannel channel,
GimpCurvesTool *c_tool);
static void curves_curve_type_callback (GtkWidget *widget,
GimpCurvesTool *c_tool);
static void curves_load_callback (GtkWidget *widget,
GimpCurvesTool *c_tool);
static void curves_save_callback (GtkWidget *widget,
GimpCurvesTool *c_tool);
static gboolean curves_graph_events (GtkWidget *widget,
GdkEvent *event,
GimpCurvesTool *c_tool);
static gboolean curves_graph_expose (GtkWidget *widget,
GdkEventExpose *eevent,
GimpCurvesTool *c_tool);
static void file_dialog_create (GimpCurvesTool *c_tool);
static void file_dialog_response (GtkWidget *dialog,
gint response_id,
GimpCurvesTool *c_tool);
static gboolean curves_read_from_file (GimpCurvesTool *c_tool,
FILE *file);
static void curves_write_to_file (GimpCurvesTool *c_tool,
FILE *file);
static GimpImageMapToolClass *parent_class = NULL;
......@@ -285,7 +285,7 @@ gimp_curves_tool_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
static gboolean
gimp_curves_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp)
{
......@@ -295,12 +295,12 @@ gimp_curves_tool_initialize (GimpTool *tool,
drawable = gimp_image_active_drawable (gdisp->gimage);
if (! drawable)
return;
return FALSE;
if (gimp_drawable_is_indexed (drawable))
{
g_message (_("Curves for indexed layers cannot be adjusted."));
return;
return FALSE;
}
if (! c_tool->hist)
......@@ -338,6 +338,8 @@ gimp_curves_tool_initialize (GimpTool *tool,
gimp_drawable_calculate_histogram (drawable, c_tool->hist);
gimp_histogram_view_set_histogram (GIMP_HISTOGRAM_VIEW (c_tool->graph),
c_tool->hist);
return TRUE;
}
static void
......
......@@ -55,30 +55,30 @@
/* local function prototypes */
static void gimp_hue_saturation_tool_class_init (GimpHueSaturationToolClass *klass);
static void gimp_hue_saturation_tool_init (GimpHueSaturationTool *tool);
static void gimp_hue_saturation_tool_class_init (GimpHueSaturationToolClass *klass);
static void gimp_hue_saturation_tool_init (GimpHueSaturationTool *tool);
static void gimp_hue_saturation_tool_finalize (GObject *object);
static void gimp_hue_saturation_tool_finalize (GObject *object);
static void gimp_hue_saturation_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp);
static gboolean gimp_hue_saturation_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp);
static void gimp_hue_saturation_tool_map (GimpImageMapTool *image_map_tool);
static void gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool);
static void gimp_hue_saturation_tool_reset (GimpImageMapTool *image_map_tool);
static void gimp_hue_saturation_tool_map (GimpImageMapTool *image_map_tool);
static void gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool);
static void gimp_hue_saturation_tool_reset (GimpImageMapTool *image_map_tool);
static void hue_saturation_update (GimpHueSaturationTool *hs_tool,
gint update);
static void hue_saturation_partition_callback (GtkWidget *widget,
gpointer data);
static void hue_saturation_partition_reset_callback (GtkWidget *widget,
gpointer data);
static void hue_saturation_hue_adjustment_update (GtkAdjustment *adj,
gpointer data);
static void hue_saturation_lightness_adjustment_update (GtkAdjustment *adj,
gpointer data);
static void hue_saturation_saturation_adjustment_update (GtkAdjustment *adj,
gpointer data);
static void hue_saturation_update (GimpHueSaturationTool *hs_tool,
gint update);
static void hue_saturation_partition_callback (GtkWidget *widget,
gpointer data);
static void hue_saturation_partition_reset_callback (GtkWidget *widget,
gpointer data);
static void hue_saturation_hue_adjustment_update (GtkAdjustment *adj,
gpointer data);
static void hue_saturation_lightness_adjustment_update (GtkAdjustment *adj,
gpointer data);
static void hue_saturation_saturation_adjustment_update (GtkAdjustment *adj,
gpointer data);
/* private variables */
......@@ -194,7 +194,7 @@ gimp_hue_saturation_tool_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
static gboolean
gimp_hue_saturation_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp)
{
......@@ -204,12 +204,12 @@ gimp_hue_saturation_tool_initialize (GimpTool *tool,
drawable = gimp_image_active_drawable (gdisp->gimage);
if (! drawable)
return;
return FALSE;
if (! gimp_drawable_is_rgb (drawable))
{
g_message (_("Hue-Saturation operates only on RGB color layers."));
return;
return FALSE;
}
hue_saturation_init (hs_tool->hue_saturation);
......@@ -217,6 +217,8 @@ gimp_hue_saturation_tool_initialize (GimpTool *tool,
GIMP_TOOL_CLASS (parent_class)->initialize (tool, gdisp);
hue_saturation_update (hs_tool, ALL);
return TRUE;
}
static void
......
......@@ -48,36 +48,36 @@
/* local function prototypes */
static void gimp_image_map_tool_class_init (GimpImageMapToolClass *klass);
static void gimp_image_map_tool_init (GimpImageMapTool *image_map_tool);
static void gimp_image_map_tool_class_init (GimpImageMapToolClass *klass);
static void gimp_image_map_tool_init (GimpImageMapTool *image_map_tool);
static void gimp_image_map_tool_finalize (GObject *object);
static void gimp_image_map_tool_finalize (GObject *object);
static void gimp_image_map_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp);
static void gimp_image_map_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *gdisp);
static gboolean gimp_image_map_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp);
static void gimp_image_map_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *gdisp);
static gboolean gimp_image_map_tool_pick_color (GimpColorTool *color_tool,
gint x,
gint y,
GimpImageType *sample_type,
GimpRGB *color,
gint *color_index);
static void gimp_image_map_tool_map (GimpImageMapTool *image_map_tool);
static void gimp_image_map_tool_dialog (GimpImageMapTool *image_map_tool);
static void gimp_image_map_tool_reset (GimpImageMapTool *image_map_tool);
static gboolean gimp_image_map_tool_pick_color (GimpColorTool *color_tool,
gint x,
gint y,
GimpImageType *sample_type,
GimpRGB *color,
gint *color_index);
static void gimp_image_map_tool_map (GimpImageMapTool *image_map_tool);
static void gimp_image_map_tool_dialog (GimpImageMapTool *image_map_tool);
static void gimp_image_map_tool_reset (GimpImageMapTool *image_map_tool);
static void gimp_image_map_tool_flush (GimpImageMap *image_map,
GimpImageMapTool *image_map_tool);
static void gimp_image_map_tool_flush (GimpImageMap *image_map,
GimpImageMapTool *image_map_tool);
static void gimp_image_map_tool_response (GtkWidget *widget,
gint response_id,
GimpImageMapTool *image_map_tool);
static void gimp_image_map_tool_response (GtkWidget *widget,
gint response_id,
GimpImageMapTool *image_map_tool);
static void gimp_image_map_tool_preview_toggled (GtkWidget *widget,