Commit 9ceb205c authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/tools/gimpdrawtool.[ch] app/tools/gimppainttool.[ch]

2001-11-20  Michael Natterer  <mitch@gimp.org>

	* app/tools/gimpdrawtool.[ch]
	* app/tools/gimppainttool.[ch]
	* app/tools/gimprectselecttool.[ch]
	* app/tools/gimptool.[ch]
	* app/tools/gimptransformtool.[ch]: use simple virtual functions
	instead of signals for all tools because they are much faster and
	don't need to be signals at all.
parent 625b5c71
2001-11-20 Michael Natterer <mitch@gimp.org>
* app/tools/gimpdrawtool.[ch]
* app/tools/gimppainttool.[ch]
* app/tools/gimprectselecttool.[ch]
* app/tools/gimptool.[ch]
* app/tools/gimptransformtool.[ch]: use simple virtual functions
instead of signals for all tools because they are much faster and
don't need to be signals at all.
2001-11-20 Michael Natterer <mitch@gimp.org>
* app/core/gimp.c: put a g_object_ref() on a different line.
......
......@@ -72,14 +72,8 @@
#define STATUSBAR_SIZE 128
enum
{
PAINT,
LAST_SIGNAL
};
/* local function prototypes */
static void gimp_paint_tool_class_init (GimpPaintToolClass *klass);
static void gimp_paint_tool_init (GimpPaintTool *paint_tool);
......@@ -209,9 +203,6 @@ static MaskBuf *kernel_brushes[SUBSAMPLE + 1][SUBSAMPLE + 1];
static MaskBuf *last_brush_mask = NULL;
static gboolean cache_invalid = FALSE;
static guint gimp_paint_tool_signals[LAST_SIGNAL] = { 0 };
static GimpDrawToolClass *parent_class = NULL;
......@@ -254,17 +245,6 @@ gimp_paint_tool_class_init (GimpPaintToolClass *klass)
parent_class = g_type_class_peek_parent (klass);
gimp_paint_tool_signals[PAINT] =
g_signal_new ("paint",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpPaintToolClass, paint),
NULL, NULL,
gimp_cclosure_marshal_VOID__POINTER_INT,
G_TYPE_NONE, 2,
G_TYPE_POINTER,
G_TYPE_INT);
tool_class->control = gimp_paint_tool_control;
tool_class->button_press = gimp_paint_tool_button_press;
tool_class->button_release = gimp_paint_tool_button_release;
......@@ -853,12 +833,11 @@ gimp_paint_tool_sample_color (GimpDrawable *drawable,
}
void
gimp_paint_tool_paint (GimpPaintTool *tool,
gimp_paint_tool_paint (GimpPaintTool *paint_tool,
GimpDrawable *drawable,
PaintState state)
{
g_signal_emit (G_OBJECT(tool), gimp_paint_tool_signals[PAINT], 0,
drawable, state);
GIMP_PAINT_TOOL_GET_CLASS (paint_tool)->paint (paint_tool, drawable, state);
}
gboolean
......
......@@ -91,6 +91,8 @@ struct _GimpPaintToolClass
{
GimpDrawToolClass parent_class;
/* virtual function */
void (* paint) (GimpPaintTool *tool,
GimpDrawable *drawable,
PaintState paint_state);
......
......@@ -72,14 +72,8 @@
#define STATUSBAR_SIZE 128
enum
{
PAINT,
LAST_SIGNAL
};
/* local function prototypes */
static void gimp_paint_tool_class_init (GimpPaintToolClass *klass);
static void gimp_paint_tool_init (GimpPaintTool *paint_tool);
......@@ -209,9 +203,6 @@ static MaskBuf *kernel_brushes[SUBSAMPLE + 1][SUBSAMPLE + 1];
static MaskBuf *last_brush_mask = NULL;
static gboolean cache_invalid = FALSE;
static guint gimp_paint_tool_signals[LAST_SIGNAL] = { 0 };
static GimpDrawToolClass *parent_class = NULL;
......@@ -254,17 +245,6 @@ gimp_paint_tool_class_init (GimpPaintToolClass *klass)
parent_class = g_type_class_peek_parent (klass);
gimp_paint_tool_signals[PAINT] =
g_signal_new ("paint",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpPaintToolClass, paint),
NULL, NULL,
gimp_cclosure_marshal_VOID__POINTER_INT,
G_TYPE_NONE, 2,
G_TYPE_POINTER,
G_TYPE_INT);
tool_class->control = gimp_paint_tool_control;
tool_class->button_press = gimp_paint_tool_button_press;
tool_class->button_release = gimp_paint_tool_button_release;
......@@ -853,12 +833,11 @@ gimp_paint_tool_sample_color (GimpDrawable *drawable,
}
void
gimp_paint_tool_paint (GimpPaintTool *tool,
gimp_paint_tool_paint (GimpPaintTool *paint_tool,
GimpDrawable *drawable,
PaintState state)
{
g_signal_emit (G_OBJECT(tool), gimp_paint_tool_signals[PAINT], 0,
drawable, state);
GIMP_PAINT_TOOL_GET_CLASS (paint_tool)->paint (paint_tool, drawable, state);
}
gboolean
......
......@@ -91,6 +91,8 @@ struct _GimpPaintToolClass
{
GimpDrawToolClass parent_class;
/* virtual function */
void (* paint) (GimpPaintTool *tool,
GimpDrawable *drawable,
PaintState paint_state);
......
......@@ -30,12 +30,6 @@
#include "gimpdrawtool.h"
enum
{
DRAW,
LAST_SIGNAL
};
static void gimp_draw_tool_class_init (GimpDrawToolClass *klass);
static void gimp_draw_tool_init (GimpDrawTool *draw_tool);
......@@ -63,12 +57,9 @@ static inline void gimp_draw_tool_shift_to_center
gdouble *shifted_y);
static guint gimp_draw_tool_signals[LAST_SIGNAL] = { 0 };
static GimpToolClass *parent_class = NULL;
GType
gimp_draw_tool_get_type (void)
{
......@@ -108,18 +99,11 @@ gimp_draw_tool_class_init (GimpDrawToolClass *klass)
parent_class = g_type_class_peek_parent (klass);
gimp_draw_tool_signals[DRAW] =
g_signal_new ("draw",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpDrawToolClass, draw),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
object_class->finalize = gimp_draw_tool_finalize;
tool_class->control = gimp_draw_tool_control;
klass->draw = NULL;
}
static void
......@@ -211,7 +195,7 @@ gimp_draw_tool_start (GimpDrawTool *draw_tool,
draw_tool->cap_style,
draw_tool->join_style);
g_signal_emit (G_OBJECT (draw_tool), gimp_draw_tool_signals[DRAW], 0);
GIMP_DRAW_TOOL_GET_CLASS (draw_tool)->draw (draw_tool);
draw_tool->draw_state = GIMP_DRAW_TOOL_STATE_VISIBLE;
}
......@@ -224,7 +208,7 @@ gimp_draw_tool_stop (GimpDrawTool *draw_tool)
if (draw_tool->draw_state == GIMP_DRAW_TOOL_STATE_INVISIBLE)
return;
g_signal_emit (G_OBJECT (draw_tool), gimp_draw_tool_signals[DRAW], 0);
GIMP_DRAW_TOOL_GET_CLASS (draw_tool)->draw (draw_tool);
draw_tool->draw_state = GIMP_DRAW_TOOL_STATE_INVISIBLE;
}
......@@ -236,7 +220,7 @@ gimp_draw_tool_pause (GimpDrawTool *draw_tool)
{
draw_tool->draw_state = GIMP_DRAW_TOOL_STATE_INVISIBLE;
g_signal_emit (G_OBJECT (draw_tool), gimp_draw_tool_signals[DRAW], 0);
GIMP_DRAW_TOOL_GET_CLASS (draw_tool)->draw (draw_tool);
}
draw_tool->paused_count++;
......@@ -254,7 +238,7 @@ gimp_draw_tool_resume (GimpDrawTool *draw_tool)
{
draw_tool->draw_state = GIMP_DRAW_TOOL_STATE_VISIBLE;
g_signal_emit (G_OBJECT (draw_tool), gimp_draw_tool_signals[DRAW], 0);
GIMP_DRAW_TOOL_GET_CLASS (draw_tool)->draw (draw_tool);
}
}
......
......@@ -70,6 +70,8 @@ struct _GimpDrawToolClass
{
GimpToolClass parent_class;
/* virtual function */
void (* draw) (GimpDrawTool *draw_tool);
};
......
......@@ -72,14 +72,8 @@
#define STATUSBAR_SIZE 128
enum
{
PAINT,
LAST_SIGNAL
};
/* local function prototypes */
static void gimp_paint_tool_class_init (GimpPaintToolClass *klass);
static void gimp_paint_tool_init (GimpPaintTool *paint_tool);
......@@ -209,9 +203,6 @@ static MaskBuf *kernel_brushes[SUBSAMPLE + 1][SUBSAMPLE + 1];
static MaskBuf *last_brush_mask = NULL;
static gboolean cache_invalid = FALSE;
static guint gimp_paint_tool_signals[LAST_SIGNAL] = { 0 };
static GimpDrawToolClass *parent_class = NULL;
......@@ -254,17 +245,6 @@ gimp_paint_tool_class_init (GimpPaintToolClass *klass)
parent_class = g_type_class_peek_parent (klass);
gimp_paint_tool_signals[PAINT] =
g_signal_new ("paint",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpPaintToolClass, paint),
NULL, NULL,
gimp_cclosure_marshal_VOID__POINTER_INT,
G_TYPE_NONE, 2,
G_TYPE_POINTER,
G_TYPE_INT);
tool_class->control = gimp_paint_tool_control;
tool_class->button_press = gimp_paint_tool_button_press;
tool_class->button_release = gimp_paint_tool_button_release;
......@@ -853,12 +833,11 @@ gimp_paint_tool_sample_color (GimpDrawable *drawable,
}
void
gimp_paint_tool_paint (GimpPaintTool *tool,
gimp_paint_tool_paint (GimpPaintTool *paint_tool,
GimpDrawable *drawable,
PaintState state)
{
g_signal_emit (G_OBJECT(tool), gimp_paint_tool_signals[PAINT], 0,
drawable, state);
GIMP_PAINT_TOOL_GET_CLASS (paint_tool)->paint (paint_tool, drawable, state);
}
gboolean
......
......@@ -91,6 +91,8 @@ struct _GimpPaintToolClass
{
GimpDrawToolClass parent_class;
/* virtual function */
void (* paint) (GimpPaintTool *tool,
GimpDrawable *drawable,
PaintState paint_state);
......
......@@ -53,13 +53,6 @@
#define STATUSBAR_SIZE 128
enum
{
RECT_SELECT,
LAST_SIGNAL
};
static void gimp_rect_select_tool_class_init (GimpRectSelectToolClass *klass);
static void gimp_rect_select_tool_init (GimpRectSelectTool *rect_select);
......@@ -88,8 +81,6 @@ static void gimp_rect_select_tool_real_rect_select (GimpRectSelectTool *rect_t
gint h);
static guint rect_select_signals[LAST_SIGNAL] = { 0 };
static GimpSelectionToolClass *parent_class = NULL;
static SelectionOptions *rect_options = NULL;
......@@ -153,19 +144,6 @@ gimp_rect_select_tool_class_init (GimpRectSelectToolClass *klass)
parent_class = g_type_class_peek_parent (klass);
rect_select_signals[RECT_SELECT] =
g_signal_new ("rect_select",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpRectSelectToolClass, rect_select),
NULL, NULL,
gimp_cclosure_marshal_VOID__INT_INT_INT_INT,
G_TYPE_NONE, 4,
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INT);
tool_class->button_press = gimp_rect_select_tool_button_press;
tool_class->button_release = gimp_rect_select_tool_button_release;
tool_class->motion = gimp_rect_select_tool_motion;
......@@ -643,6 +621,6 @@ gimp_rect_select_tool_rect_select (GimpRectSelectTool *rect_tool,
}
}
g_signal_emit (G_OBJECT (rect_tool), rect_select_signals[RECT_SELECT], 0,
x, y, w, h);
GIMP_RECT_SELECT_TOOL_GET_CLASS (rect_tool)->rect_select (rect_tool,
x, y, w, h);
}
......@@ -54,6 +54,8 @@ struct _GimpRectSelectToolClass
{
GimpSelectionToolClass parent_class;
/* virtual function */
void (* rect_select) (GimpRectSelectTool *rect_tool,
gint x,
gint y,
......
......@@ -36,21 +36,6 @@
#include "libgimp/gimpintl.h"
enum
{
INITIALIZE,
CONTROL,
BUTTON_PRESS,
BUTTON_RELEASE,
MOTION,
ARROW_KEY,
MODIFIER_KEY,
OPER_UPDATE,
CURSOR_UPDATE,
LAST_SIGNAL
};
static void gimp_tool_class_init (GimpToolClass *klass);
static void gimp_tool_init (GimpTool *tool);
......@@ -92,8 +77,6 @@ static void gimp_tool_real_cursor_update (GimpTool *tool,
GimpDisplay *gdisp);
static guint gimp_tool_signals[LAST_SIGNAL] = { 0 };
static GimpObjectClass *parent_class = NULL;
static gint global_tool_ID = 0;
......@@ -132,114 +115,6 @@ gimp_tool_class_init (GimpToolClass *klass)
{
parent_class = g_type_class_peek_parent (klass);
gimp_tool_signals[INITIALIZE] =
g_signal_new ("initialize",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpToolClass, initialize),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GIMP_TYPE_DISPLAY);
gimp_tool_signals[CONTROL] =
g_signal_new ("control",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpToolClass, control),
NULL, NULL,
gimp_cclosure_marshal_VOID__INT_OBJECT,
G_TYPE_NONE, 2,
G_TYPE_INT,
GIMP_TYPE_DISPLAY);
gimp_tool_signals[BUTTON_PRESS] =
g_signal_new ("button_press",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpToolClass, button_press),
NULL, NULL,
gimp_cclosure_marshal_VOID__POINTER_UINT_INT_OBJECT,
G_TYPE_NONE, 4,
G_TYPE_POINTER,
G_TYPE_UINT,
G_TYPE_INT,
GIMP_TYPE_DISPLAY);
gimp_tool_signals[BUTTON_RELEASE] =
g_signal_new ("button_release",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpToolClass, button_release),
NULL, NULL,
gimp_cclosure_marshal_VOID__POINTER_UINT_INT_OBJECT,
G_TYPE_NONE, 4,
G_TYPE_POINTER,
G_TYPE_UINT,
G_TYPE_INT,
GIMP_TYPE_DISPLAY);
gimp_tool_signals[MOTION] =
g_signal_new ("motion",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpToolClass, motion),
NULL, NULL,
gimp_cclosure_marshal_VOID__POINTER_UINT_INT_OBJECT,
G_TYPE_NONE, 4,
G_TYPE_POINTER,
G_TYPE_UINT,
G_TYPE_INT,
GIMP_TYPE_DISPLAY);
gimp_tool_signals[ARROW_KEY] =
g_signal_new ("arrow_key",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpToolClass, arrow_key),
NULL, NULL,
gimp_cclosure_marshal_VOID__POINTER_OBJECT,
G_TYPE_NONE, 2,
G_TYPE_POINTER,
GIMP_TYPE_DISPLAY);
gimp_tool_signals[MODIFIER_KEY] =
g_signal_new ("modifier_key",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpToolClass, modifier_key),
NULL, NULL,
gimp_cclosure_marshal_VOID__INT_BOOLEAN_INT_OBJECT,
G_TYPE_NONE, 4,
G_TYPE_INT,
G_TYPE_BOOLEAN,
G_TYPE_INT,
GIMP_TYPE_DISPLAY);
gimp_tool_signals[OPER_UPDATE] =
g_signal_new ("oper_update",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpToolClass, oper_update),
NULL, NULL,
gimp_cclosure_marshal_VOID__POINTER_INT_OBJECT,
G_TYPE_NONE, 3,
G_TYPE_POINTER,
G_TYPE_INT,
GIMP_TYPE_DISPLAY);
gimp_tool_signals[CURSOR_UPDATE] =
g_signal_new ("cursor_update",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpToolClass, cursor_update),
NULL, NULL,
gimp_cclosure_marshal_VOID__POINTER_INT_OBJECT,
G_TYPE_NONE, 3,
G_TYPE_POINTER,
G_TYPE_INT,
GIMP_TYPE_DISPLAY);
klass->initialize = gimp_tool_real_initialize;
klass->control = gimp_tool_real_control;
klass->button_press = gimp_tool_real_button_press;
......@@ -276,8 +151,7 @@ gimp_tool_initialize (GimpTool *tool,
{
g_return_if_fail (GIMP_IS_TOOL (tool));
g_signal_emit (G_OBJECT (tool), gimp_tool_signals[INITIALIZE], 0,
gdisp);
GIMP_TOOL_GET_CLASS (tool)->initialize (tool, gdisp);
}
void
......@@ -287,8 +161,7 @@ gimp_tool_control (GimpTool *tool,
{
g_return_if_fail (GIMP_IS_TOOL (tool));
g_signal_emit (G_OBJECT (tool), gimp_tool_signals[CONTROL], 0,
action, gdisp);
GIMP_TOOL_GET_CLASS (tool)->control (tool, action, gdisp);
}
void
......@@ -302,8 +175,7 @@ gimp_tool_button_press (GimpTool *tool,
g_return_if_fail (coords != NULL);
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
g_signal_emit (G_OBJECT (tool), gimp_tool_signals[BUTTON_PRESS], 0,
coords, time, state, gdisp);
GIMP_TOOL_GET_CLASS (tool)->button_press (tool, coords, time, state, gdisp);
}
void
......@@ -317,8 +189,7 @@ gimp_tool_button_release (GimpTool *tool,
g_return_if_fail (coords != NULL);
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
g_signal_emit (G_OBJECT (tool), gimp_tool_signals[BUTTON_RELEASE], 0,
coords, time, state, gdisp);
GIMP_TOOL_GET_CLASS (tool)->button_release (tool, coords, time, state, gdisp);
}
void
......@@ -332,8 +203,7 @@ gimp_tool_motion (GimpTool *tool,
g_return_if_fail (coords != NULL);
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
g_signal_emit (G_OBJECT (tool), gimp_tool_signals[MOTION], 0,
coords, time, state, gdisp);
GIMP_TOOL_GET_CLASS (tool)->motion (tool, coords, time, state, gdisp);
}
void
......@@ -344,8 +214,7 @@ gimp_tool_arrow_key (GimpTool *tool,
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
g_signal_emit (G_OBJECT (tool), gimp_tool_signals[ARROW_KEY], 0,
kevent, gdisp);
GIMP_TOOL_GET_CLASS (tool)->arrow_key (tool, kevent, gdisp);
}
void
......@@ -358,8 +227,7 @@ gimp_tool_modifier_key (GimpTool *tool,
g_return_if_fail (GIMP_IS_TOOL (tool));
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
g_signal_emit (G_OBJECT (tool), gimp_tool_signals[MODIFIER_KEY], 0,
key, press, state, gdisp);
GIMP_TOOL_GET_CLASS (tool)->modifier_key (tool, key, press, state, gdisp);
}
void
......@@ -372,8 +240,7 @@ gimp_tool_oper_update (GimpTool *tool,
g_return_if_fail (coords != NULL);
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
g_signal_emit (G_OBJECT (tool), gimp_tool_signals[OPER_UPDATE], 0,
coords, state, gdisp);
GIMP_TOOL_GET_CLASS (tool)->oper_update (tool, coords, state, gdisp);
}
void
......@@ -386,8 +253,7 @@ gimp_tool_cursor_update (GimpTool *tool,
g_return_if_fail (coords != NULL);
g_return_if_fail (GIMP_IS_DISPLAY (gdisp));
g_signal_emit (G_OBJECT (tool), gimp_tool_signals[CURSOR_UPDATE], 0,
coords, state, gdisp);
GIMP_TOOL_GET_CLASS (tool)->cursor_update (tool, coords, state, gdisp);
}
......
......@@ -72,6 +72,8 @@ struct _GimpToolClass
{
GimpObjectClass parent_class;
/* virtual functions */
void (* initialize) (GimpTool *tool,
GimpDisplay *gdisp);
void (* control) (GimpTool *tool,
......
......@@ -66,12 +66,6 @@
#define HANDLE 10
enum
{
TRANSFORM,
LAST_SIGNAL
};
/* local function prototypes */
......@@ -133,8 +127,6 @@ static gboolean transform_info_inited = FALSE;
static GimpDrawToolClass *parent_class = NULL;
static guint gimp_transform_tool_signals[LAST_SIGNAL] = { 0 };
GType
gimp_transform_tool_get_type (void)
......@@ -177,17 +169,6 @@ gimp_transform_tool_class_init (GimpTransformToolClass *klass)
parent_class = g_type_class_peek_parent (klass);
gimp_transform_tool_signals[TRANSFORM] =
g_signal_new ("transform",