Commit 33b2d27e authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

new GimpSignalType gimp_sigtype_int_int_int.

1999-10-17  Michael Natterer  <mitch@gimp.org>

	* app/gimpsignal.[ch]: new GimpSignalType gimp_sigtype_int_int_int.

	* app/gimpcontext.[ch]: set/get colors as separate r/g/b values
	instead of a guchar[3] array.
	The "[foreground|background]_changed" signal handlers must have
	the following signature now:
	color_changed_callback (GimpContext *, gint, gint, gint, gpointer).
parent f6509840
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpsignal.[ch]: new GimpSignalType gimp_sigtype_int_int_int.
* app/gimpcontext.[ch]: set/get colors as separate r/g/b values
instead of a guchar[3] array.
The "[foreground|background]_changed" signal handlers must have
the following signature now:
color_changed_callback (GimpContext *, gint, gint, gint, gpointer).
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
......
......@@ -103,10 +103,16 @@ gimp_context_set_arg (GtkObject *object,
gimp_context_set_tool (context, GTK_VALUE_INT (*arg));
break;
case ARG_FOREGROUND:
gimp_context_set_foreground (context, GTK_VALUE_POINTER (*arg));
{
guchar *col = GTK_VALUE_POINTER (*arg);
gimp_context_set_foreground (context, col[0], col[1], col[2]);
}
break;
case ARG_BACKGROUND:
gimp_context_set_background (context, GTK_VALUE_POINTER (*arg));
{
guchar *col = GTK_VALUE_POINTER (*arg);
gimp_context_set_background (context, col[0], col[1], col[2]);
}
break;
case ARG_OPACITY:
gimp_context_set_opacity (context, GTK_VALUE_DOUBLE (*arg));
......@@ -150,22 +156,14 @@ gimp_context_get_arg (GtkObject *object,
break;
case ARG_FOREGROUND:
{
guchar *dest = GTK_VALUE_POINTER (*arg);
guchar src[3];
gimp_context_get_foreground (context, src);
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
guchar *col = GTK_VALUE_POINTER (*arg);
gimp_context_get_foreground (context, &col[0], &col[1], &col[2]);
}
break;
case ARG_BACKGROUND:
{
guchar *dest = GTK_VALUE_POINTER (*arg);
guchar src[3];
gimp_context_get_background (context, src);
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
guchar *col = GTK_VALUE_POINTER (*arg);
gimp_context_get_background (context, &col[0], &col[1], &col[2]);
}
break;
case ARG_OPACITY:
......@@ -265,7 +263,7 @@ gimp_context_class_init (GimpContextClass *klass)
object_class->type,
GTK_SIGNAL_OFFSET (GimpContextClass,
foreground_changed),
gimp_sigtype_pointer);
gimp_sigtype_int_int_int);
gimp_context_signals[BACKGROUND_CHANGED] =
gimp_signal_new ("background_changed",
......@@ -273,7 +271,7 @@ gimp_context_class_init (GimpContextClass *klass)
object_class->type,
GTK_SIGNAL_OFFSET (GimpContextClass,
background_changed),
gimp_sigtype_pointer);
gimp_sigtype_int_int_int);
gimp_context_signals[OPACITY_CHANGED] =
gimp_signal_new ("opacity_changed",
......@@ -427,19 +425,17 @@ gimp_context_new (gchar *name,
if (template)
{
guchar col[3];
context->image = gimp_context_get_image (template);
context->display = gimp_context_get_display (template);
context->tool = gimp_context_get_tool (template);
gimp_context_get_foreground (template, col);
context->foreground[0] = col[0];
context->foreground[1] = col[1];
context->foreground[2] = col[2];
gimp_context_get_background (template, col);
context->background[0] = col[0];
context->background[1] = col[1];
context->background[2] = col[2];
gimp_context_get_foreground (template,
&context->foreground[0],
&context->foreground[1],
&context->foreground[2]);
gimp_context_get_background (template,
&context->background[0],
&context->background[1],
&context->background[2]);
context->opacity = gimp_context_get_opacity (template);
context->paint_mode = gimp_context_get_paint_mode (template);
context->brush = gimp_context_get_brush (template);
......@@ -706,36 +702,40 @@ gimp_context_define_tool (GimpContext *context,
void
gimp_context_get_foreground (GimpContext *context,
guchar foreground[3])
guchar *r,
guchar *g,
guchar *b)
{
context_check_current (context);
context_return_if_fail (context);
context_find_defined (context, foreground_defined);
foreground[0] = context->foreground[0];
foreground[1] = context->foreground[1];
foreground[2] = context->foreground[2];
*r = context->foreground[0];
*g = context->foreground[1];
*b = context->foreground[2];
}
void
gimp_context_set_foreground (GimpContext *context,
guchar foreground[3])
gint r,
gint g,
gint b)
{
context_check_current (context);
context_return_if_fail (context);
context_find_defined (context, foreground_defined);
if (context->foreground[0] == foreground[0] &&
context->foreground[1] == foreground[1] &&
context->foreground[2] == foreground[2]) return;
if (context->foreground[0] == r &&
context->foreground[1] == g &&
context->foreground[2] == b) return;
context->foreground[0] = foreground[0];
context->foreground[1] = foreground[1];
context->foreground[2] = foreground[2];
context->foreground[0] = r;
context->foreground[1] = g;
context->foreground[2] = b;
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[FOREGROUND_CHANGED],
context->foreground);
r, g, b);
}
gboolean
......@@ -753,14 +753,10 @@ gimp_context_define_foreground (GimpContext *context,
context_return_if_fail (context);
if (defined)
{
guchar col[3];
gimp_context_get_foreground (context, col);
context->foreground[0] = col[0];
context->foreground[1] = col[1];
context->foreground[2] = col[2];
}
gimp_context_get_foreground (context,
&context->foreground[0],
&context->foreground[1],
&context->foreground[2]);
context->foreground_defined = defined;
}
......@@ -769,36 +765,40 @@ gimp_context_define_foreground (GimpContext *context,
void
gimp_context_get_background (GimpContext *context,
guchar background[3])
guchar *r,
guchar *g,
guchar *b)
{
context_check_current (context);
context_return_if_fail (context);
context_find_defined (context, background_defined);
background[0] = context->background[0];
background[1] = context->background[1];
background[2] = context->background[2];
*r = context->background[0];
*g = context->background[1];
*b = context->background[2];
}
void
gimp_context_set_background (GimpContext *context,
guchar background[3])
gint r,
gint g,
gint b)
{
context_check_current (context);
context_return_if_fail (context);
context_find_defined (context, background_defined);
if (context->background[0] == background[0] &&
context->background[1] == background[1] &&
context->background[2] == background[2]) return;
if (context->background[0] == r &&
context->background[1] == g &&
context->background[2] == b) return;
context->background[0] = background[0];
context->background[1] = background[1];
context->background[2] = background[2];
context->background[0] = r;
context->background[1] = g;
context->background[2] = b;
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[BACKGROUND_CHANGED],
context->background);
r, g, b);
}
gboolean
......@@ -816,14 +816,10 @@ gimp_context_define_background (GimpContext *context,
context_return_if_fail (context);
if (defined)
{
guchar col[3];
gimp_context_get_background (context, col);
context->background[0] = col[0];
context->background[1] = col[1];
context->background[2] = col[2];
}
gimp_context_get_background (context,
&context->background[0],
&context->background[1],
&context->background[2]);
context->background_defined = defined;
}
......
......@@ -59,7 +59,8 @@ typedef enum
GIMP_CONTEXT_ARG_GRADIENT,
GIMP_CONTEXT_ARG_ALL = GIMP_CONTEXT_ARG_IMAGE |
GIMP_CONTEXT_ARG_DISPLAY |
GIMP_CONTEXT_ARG_TOOL
GIMP_CONTEXT_ARG_TOOL |
GIMP_CONTEXT_ARG_PAINT
} GimpContextArgs;
typedef struct _GimpContext GimpContext;
......@@ -110,18 +111,32 @@ struct _GimpContextClass
{
GimpObjectClass parent_class;
void (* image_changed) (GimpContext *context, gpointer image);
void (* display_changed) (GimpContext *context, gpointer display);
void (* tool_changed) (GimpContext *context, gint tool_type);
void (* foreground_changed) (GimpContext *context, guchar foreground[3]);
void (* background_changed) (GimpContext *context, guchar background[3]);
void (* opacity_changed) (GimpContext *context, gdouble opacity);
void (* paint_mode_changed) (GimpContext *context, gint paint_mode);
void (* brush_changed) (GimpContext *context, gpointer brush);
void (* pattern_changed) (GimpContext *context, gpointer pattern);
void (* gradient_changed) (GimpContext *context, gpointer gradient);
void (* image_changed) (GimpContext *context,
GimpImage *image);
void (* display_changed) (GimpContext *context,
GDisplay *display);
void (* tool_changed) (GimpContext *context,
ToolType tool);
void (* foreground_changed) (GimpContext *context,
gint r,
gint g,
gint b);
void (* background_changed) (GimpContext *context,
gint r,
gint g,
gint b);
void (* opacity_changed) (GimpContext *context,
gdouble opacity);
void (* paint_mode_changed) (GimpContext *context,
LayerModeEffects paint_mode);
void (* brush_changed) (GimpContext *context,
GimpBrush *brush);
void (* pattern_changed) (GimpContext *context,
GPattern *pattern);
void (* gradient_changed) (GimpContext *context,
gradient_t *gradient);
};
GtkType gimp_context_get_type (void);
......@@ -199,9 +214,13 @@ void gimp_context_define_tool (GimpContext *context,
/* foreground color */
void gimp_context_get_foreground (GimpContext *context,
guchar foreground[3]);
guchar *r,
guchar *g,
guchar *b);
void gimp_context_set_foreground (GimpContext *context,
guchar foreground[3]);
gint r,
gint g,
gint b);
gboolean gimp_context_foreground_defined (GimpContext *context);
void gimp_context_define_foreground (GimpContext *context,
gboolean defined);
......@@ -209,9 +228,13 @@ void gimp_context_define_foreground (GimpContext *context,
/* background color */
void gimp_context_get_background (GimpContext *context,
guchar background[3]);
guchar *r,
guchar *g,
guchar *b);
void gimp_context_set_background (GimpContext *context,
guchar background[3]);
gint r,
gint g,
gint b);
gboolean gimp_context_background_defined (GimpContext *context);
void gimp_context_define_background (GimpContext *context,
gboolean defined);
......
......@@ -103,10 +103,16 @@ gimp_context_set_arg (GtkObject *object,
gimp_context_set_tool (context, GTK_VALUE_INT (*arg));
break;
case ARG_FOREGROUND:
gimp_context_set_foreground (context, GTK_VALUE_POINTER (*arg));
{
guchar *col = GTK_VALUE_POINTER (*arg);
gimp_context_set_foreground (context, col[0], col[1], col[2]);
}
break;
case ARG_BACKGROUND:
gimp_context_set_background (context, GTK_VALUE_POINTER (*arg));
{
guchar *col = GTK_VALUE_POINTER (*arg);
gimp_context_set_background (context, col[0], col[1], col[2]);
}
break;
case ARG_OPACITY:
gimp_context_set_opacity (context, GTK_VALUE_DOUBLE (*arg));
......@@ -150,22 +156,14 @@ gimp_context_get_arg (GtkObject *object,
break;
case ARG_FOREGROUND:
{
guchar *dest = GTK_VALUE_POINTER (*arg);
guchar src[3];
gimp_context_get_foreground (context, src);
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
guchar *col = GTK_VALUE_POINTER (*arg);
gimp_context_get_foreground (context, &col[0], &col[1], &col[2]);
}
break;
case ARG_BACKGROUND:
{
guchar *dest = GTK_VALUE_POINTER (*arg);
guchar src[3];
gimp_context_get_background (context, src);
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
guchar *col = GTK_VALUE_POINTER (*arg);
gimp_context_get_background (context, &col[0], &col[1], &col[2]);
}
break;
case ARG_OPACITY:
......@@ -265,7 +263,7 @@ gimp_context_class_init (GimpContextClass *klass)
object_class->type,
GTK_SIGNAL_OFFSET (GimpContextClass,
foreground_changed),
gimp_sigtype_pointer);
gimp_sigtype_int_int_int);
gimp_context_signals[BACKGROUND_CHANGED] =
gimp_signal_new ("background_changed",
......@@ -273,7 +271,7 @@ gimp_context_class_init (GimpContextClass *klass)
object_class->type,
GTK_SIGNAL_OFFSET (GimpContextClass,
background_changed),
gimp_sigtype_pointer);
gimp_sigtype_int_int_int);
gimp_context_signals[OPACITY_CHANGED] =
gimp_signal_new ("opacity_changed",
......@@ -427,19 +425,17 @@ gimp_context_new (gchar *name,
if (template)
{
guchar col[3];
context->image = gimp_context_get_image (template);
context->display = gimp_context_get_display (template);
context->tool = gimp_context_get_tool (template);
gimp_context_get_foreground (template, col);
context->foreground[0] = col[0];
context->foreground[1] = col[1];
context->foreground[2] = col[2];
gimp_context_get_background (template, col);
context->background[0] = col[0];
context->background[1] = col[1];
context->background[2] = col[2];
gimp_context_get_foreground (template,
&context->foreground[0],
&context->foreground[1],
&context->foreground[2]);
gimp_context_get_background (template,
&context->background[0],
&context->background[1],
&context->background[2]);
context->opacity = gimp_context_get_opacity (template);
context->paint_mode = gimp_context_get_paint_mode (template);
context->brush = gimp_context_get_brush (template);
......@@ -706,36 +702,40 @@ gimp_context_define_tool (GimpContext *context,
void
gimp_context_get_foreground (GimpContext *context,
guchar foreground[3])
guchar *r,
guchar *g,
guchar *b)
{
context_check_current (context);
context_return_if_fail (context);
context_find_defined (context, foreground_defined);
foreground[0] = context->foreground[0];
foreground[1] = context->foreground[1];
foreground[2] = context->foreground[2];
*r = context->foreground[0];
*g = context->foreground[1];
*b = context->foreground[2];
}
void
gimp_context_set_foreground (GimpContext *context,
guchar foreground[3])
gint r,
gint g,
gint b)
{
context_check_current (context);
context_return_if_fail (context);
context_find_defined (context, foreground_defined);
if (context->foreground[0] == foreground[0] &&
context->foreground[1] == foreground[1] &&
context->foreground[2] == foreground[2]) return;
if (context->foreground[0] == r &&
context->foreground[1] == g &&
context->foreground[2] == b) return;
context->foreground[0] = foreground[0];
context->foreground[1] = foreground[1];
context->foreground[2] = foreground[2];
context->foreground[0] = r;
context->foreground[1] = g;
context->foreground[2] = b;
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[FOREGROUND_CHANGED],
context->foreground);
r, g, b);
}
gboolean
......@@ -753,14 +753,10 @@ gimp_context_define_foreground (GimpContext *context,
context_return_if_fail (context);
if (defined)
{
guchar col[3];
gimp_context_get_foreground (context, col);
context->foreground[0] = col[0];
context->foreground[1] = col[1];
context->foreground[2] = col[2];
}
gimp_context_get_foreground (context,
&context->foreground[0],
&context->foreground[1],
&context->foreground[2]);
context->foreground_defined = defined;
}
......@@ -769,36 +765,40 @@ gimp_context_define_foreground (GimpContext *context,
void
gimp_context_get_background (GimpContext *context,
guchar background[3])
guchar *r,
guchar *g,
guchar *b)
{
context_check_current (context);
context_return_if_fail (context);
context_find_defined (context, background_defined);
background[0] = context->background[0];
background[1] = context->background[1];
background[2] = context->background[2];
*r = context->background[0];
*g = context->background[1];
*b = context->background[2];
}
void
gimp_context_set_background (GimpContext *context,
guchar background[3])
gint r,
gint g,
gint b)
{
context_check_current (context);
context_return_if_fail (context);
context_find_defined (context, background_defined);
if (context->background[0] == background[0] &&
context->background[1] == background[1] &&
context->background[2] == background[2]) return;
if (context->background[0] == r &&
context->background[1] == g &&
context->background[2] == b) return;
context->background[0] = background[0];
context->background[1] = background[1];
context->background[2] = background[2];
context->background[0] = r;
context->background[1] = g;
context->background[2] = b;
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[BACKGROUND_CHANGED],
context->background);
r, g, b);
}
gboolean
......@@ -816,14 +816,10 @@ gimp_context_define_background (GimpContext *context,
context_return_if_fail (context);
if (defined)
{
guchar col[3];
gimp_context_get_background (context, col);
context->background[0] = col[0];
context->background[1] = col[1];
context->background[2] = col[2];
}
gimp_context_get_background (context,
&context->background[0],
&context->background[1],
&context->background[2]);
context->background_defined = defined;
}
......
......@@ -59,7 +59,8 @@ typedef enum
GIMP_CONTEXT_ARG_GRADIENT,
GIMP_CONTEXT_ARG_ALL = GIMP_CONTEXT_ARG_IMAGE |
GIMP_CONTEXT_ARG_DISPLAY |
GIMP_CONTEXT_ARG_TOOL
GIMP_CONTEXT_ARG_TOOL |
GIMP_CONTEXT_ARG_PAINT
} GimpContextArgs;
typedef struct _GimpContext GimpContext;
......@@ -110,18 +111,32 @@ struct _GimpContextClass
{
GimpObjectClass parent_class;
void (* image_changed) (GimpContext *context, gpointer image);
void (* display_changed) (GimpContext *context, gpointer display);
void (* tool_changed) (GimpContext *context, gint tool_type);
void (* foreground_changed) (GimpContext *context, guchar foreground[3]);
void (* background_changed) (GimpContext *context, guchar background[3]);
void (* opacity_changed) (GimpContext *context, gdouble opacity);
void (* paint_mode_changed) (GimpContext *context, gint paint_mode);
void (* brush_changed) (GimpContext *context, gpointer brush);
void (* pattern_changed) (GimpContext *context, gpointer pattern);
void (* gradient_changed) (GimpContext *context, gpointer gradient);
void (* image_changed) (GimpContext *context,
GimpImage *image);
void (* display_changed) (GimpContext *context,
GDisplay *display);
void (* tool_changed) (GimpContext *context,
ToolType tool);
void (* foreground_changed) (GimpContext *context,
gint r,
gint g,
gint b);
void (* background_changed) (GimpContext *context,
gint r,
gint g,
gint b);
void (* opacity_changed) (GimpContext *context,
gdouble opacity);
void (* paint_mode_changed) (GimpContext *context,
LayerModeEffects paint_mode);
void (* brush_changed) (GimpContext *context,
GimpBrush *brush);
void (* pattern_changed) (GimpContext *context,
GPattern *pattern);
void (* gradient_changed) (GimpContext *context,
gradient_t *gradient);
};
GtkType gimp_context_get_type (void);
......@@ -199,9 +214,13 @@ void gimp_context_define_tool (GimpContext *context,
/* foreground color */
void gimp_context_get_foreground (GimpContext *context,
guchar foreground[3]);
guchar *r,
guchar *g,
guchar *b);
void gimp_context_set_foreground (GimpContext *context,
guchar foreground[3]);
gint r,
gint g,
gint b);
gboolean gimp_context_foreground_defined (GimpContext *context);
void gimp_context_define_foreground (GimpContext *context,
gboolean defined);
......@@ -209,9 +228,13 @@ void gimp_context_define_foreground (GimpContext *context,
/* background color */
void gimp_context_get_background (GimpContext *context,
guchar background[3]);
guchar *r,
guchar *g,
guchar *b);
void gimp_context_set_background (GimpContext *context,
guchar background[3]);
gint r,
gint g,
gint b);
gboolean gimp_context_background_defined (GimpContext *context);
void gimp_context_define_background (GimpContext *context,
gboolean defined);
......
......@@ -134,6 +134,36 @@ static GimpSignalType sigtype_double =
GimpSignalType* const gimp_sigtype_double = &sigtype_double;
static void
gimp_marshaller_int_int_int (GtkObject *object,
GtkSignalFunc func,
gpointer func_data,
GtkArg *args)
{
(* (GimpHandlerIntIntInt) func) (object,
GTK_VALUE_INT (args[0]),
GTK_VALUE_INT (args[1]),
GTK_VALUE_INT (args[2]),
func_data);
}
static TypeArr int_int_int_types =
{
GTK_TYPE_INT,
GTK_TYPE_INT,
GTK_TYPE_INT
};
static GimpSignalType sigtype_int_int_int =
{
gimp_marshaller_int_int_int,
GTK_TYPE_NONE,
3,
int_int_int_types
};
GimpSignalType* const gimp_sigtype_int_int_int = &sigtype_int_int_int;
static void
gimp_marshaller_int_int_int_int (GtkObject *object,
GtkSignalFunc func,
......
......@@ -28,16 +28,24 @@ typedef const struct _GimpSignalType GimpSignalType;
/* The arguments are encoded in the names.. */
extern GimpSignalType* const gimp_sigtype_void;
typedef void (*GimpHandlerVoid) (GtkObject*, gpointer);
typedef void (*GimpHandlerVoid) (GtkObject*,
gpointer);
extern GimpSignalType* const gimp_sigtype_pointer;
typedef void (*GimpHandlerPointer) (GtkObject*, gpointer, gpointer);
typedef void (*GimpHandlerPointer) (GtkObject*, gpointer,
gpointer);
extern GimpSignalType* const gimp_sigtype_int;
typedef void (*GimpHandlerInt) (GtkObject*, gint, gpointer);
typedef void (*GimpHandlerInt) (GtkObject*, gint,
gpointer);
extern GimpSignalType* const gimp_sigtype_double;
typedef void (*GimpHandlerDouble) (GtkObject*, gdouble, gpointer);
typedef void (*GimpHandlerDouble) (GtkObject*, gdouble,
gpointer);
extern GimpSignalType* const gimp_sigtype_int_int_int;
typedef void (*GimpHandlerIntIntInt) (GtkObject*, gint, gint, gint,
gpointer);
extern GimpSignalType* const gimp_sigtype_int_int_int_int;
typedef void (*GimpHandlerIntIntIntInt) (GtkObject*, gint, gint, gint, gint,
......
Markdown is supported