Commit 863b2491 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

it's more intelligent to implement the parent_context stuff with

2000-02-22  Michael Natterer  <mitch@gimp.org>

	* app/gimpcontext.[ch]: it's more intelligent to implement the
	parent_context stuff with gtk_signal_connect_object() instead of
	having internal callbacks for each context attribute.
	Exported the existing gimp_context_*_changed() functions and
	changed them to do nothing but emitting the signal.

	* app/app_procs.c
	* app/tools.c
	* app/transform_tool.c: use gimp_context_tool_changed() instead of
	gtk_signal_emit_by_name().
parent a4f6d59a
2000-02-22 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: it's more intelligent to implement the
parent_context stuff with gtk_signal_connect_object() instead of
having internal callbacks for each context attribute.
Exported the existing gimp_context_*_changed() functions and
changed them to do nothing but emitting the signal.
* app/app_procs.c
* app/tools.c
* app/transform_tool.c: use gimp_context_tool_changed() instead of
gtk_signal_emit_by_name().
2000-02-22 Michael Natterer <mitch@gimp.org>
* app/color_area.[ch]
......
......@@ -608,8 +608,7 @@ app_init (void)
/* EEK: force signal emission */
if (gimp_context_get_tool (gimp_context_get_user ()) == RECT_SELECT)
{
gtk_signal_emit_by_name (GTK_OBJECT (gimp_context_get_user ()),
"tool_changed", RECT_SELECT);
gimp_context_tool_changed (gimp_context_get_user ());
}
else
{
......
......@@ -52,27 +52,18 @@ static void gimp_context_real_set_image (GimpContext *context,
GimpImage *image);
static void gimp_context_copy_image (GimpContext *src,
GimpContext *dest);
static void gimp_context_image_changed (GimpContext *parent,
GimpImage *image,
GimpContext *child);
/* display */
static void gimp_context_real_set_display (GimpContext *context,
GDisplay *display);
static void gimp_context_copy_display (GimpContext *src,
GimpContext *dest);
static void gimp_context_display_changed (GimpContext *parent,
GDisplay *display,
GimpContext *child);
/* tool */
static void gimp_context_real_set_tool (GimpContext *context,
ToolType tool);
static void gimp_context_copy_tool (GimpContext *src,
GimpContext *dest);
static void gimp_context_tool_changed (GimpContext *parent,
ToolType tool,
GimpContext *child);
/* foreground */
static void gimp_context_real_set_foreground (GimpContext *context,
......@@ -81,11 +72,6 @@ static void gimp_context_real_set_foreground (GimpContext *context,
gint b);
static void gimp_context_copy_foreground (GimpContext *src,
GimpContext *dest);
static void gimp_context_foreground_changed (GimpContext *parent,
gint r,
gint g,
gint b,
GimpContext *child);
/* background */
static void gimp_context_real_set_background (GimpContext *context,
......@@ -94,56 +80,36 @@ static void gimp_context_real_set_background (GimpContext *context,
gint b);
static void gimp_context_copy_background (GimpContext *src,
GimpContext *dest);
static void gimp_context_background_changed (GimpContext *parent,
gint r,
gint g,
gint b,
GimpContext *child);
/* opacity */
static void gimp_context_real_set_opacity (GimpContext *context,
gdouble opacity);
static void gimp_context_copy_opacity (GimpContext *src,
GimpContext *dest);
static void gimp_context_opacity_changed (GimpContext *parent,
gdouble opacity,
GimpContext *child);
/* paint mode */
static void gimp_context_real_set_paint_mode (GimpContext *context,
LayerModeEffects paint_mode);
static void gimp_context_copy_paint_mode (GimpContext *src,
GimpContext *dest);
static void gimp_context_paint_mode_changed (GimpContext *parent,
LayerModeEffects paint_mode,
GimpContext *child);
/* brush */
static void gimp_context_real_set_brush (GimpContext *context,
GimpBrush *brush);
static void gimp_context_copy_brush (GimpContext *src,
GimpContext *dest);
static void gimp_context_brush_changed (GimpContext *parent,
GimpBrush *brush,
GimpContext *child);
/* pattern */
static void gimp_context_real_set_pattern (GimpContext *context,
GPattern *pattern);
static void gimp_context_copy_pattern (GimpContext *src,
GimpContext *dest);
static void gimp_context_pattern_changed (GimpContext *parent,
GPattern *pattern,
GimpContext *child);
/* gradient */
static void gimp_context_real_set_gradient (GimpContext *context,
gradient_t *gradient);
static void gimp_context_copy_gradient (GimpContext *src,
GimpContext *dest);
static void gimp_context_gradient_changed (GimpContext *parent,
gradient_t *gradient,
GimpContext *child);
/* arguments */
......@@ -225,16 +191,16 @@ static gchar *gimp_context_signal_names[] =
static GtkSignalFunc gimp_context_signal_handlers[] =
{
gimp_context_image_changed,
gimp_context_display_changed,
gimp_context_tool_changed,
gimp_context_foreground_changed,
gimp_context_background_changed,
gimp_context_opacity_changed,
gimp_context_paint_mode_changed,
gimp_context_brush_changed,
gimp_context_pattern_changed,
gimp_context_gradient_changed
gimp_context_real_set_image,
gimp_context_real_set_display,
gimp_context_real_set_tool,
gimp_context_real_set_foreground,
gimp_context_real_set_background,
gimp_context_real_set_opacity,
gimp_context_real_set_paint_mode,
gimp_context_real_set_brush,
gimp_context_real_set_pattern,
gimp_context_real_set_gradient
};
static GimpObjectClass * parent_class = NULL;
......@@ -734,10 +700,10 @@ gimp_context_set_parent (GimpContext *context,
if (! ((1 << arg) & context->defined_args))
{
gimp_context_copy_arg (parent, context, arg);
gtk_signal_connect (GTK_OBJECT (parent),
gimp_context_signal_names[arg],
gimp_context_signal_handlers[arg],
context);
gtk_signal_connect_object (GTK_OBJECT (parent),
gimp_context_signal_names[arg],
gimp_context_signal_handlers[arg],
GTK_OBJECT (context));
}
context->parent = parent;
......@@ -792,10 +758,10 @@ gimp_context_define_arg (GimpContext *context,
if (context->parent)
{
gimp_context_copy_arg (context->parent, context, arg);
gtk_signal_connect (GTK_OBJECT (context->parent),
gimp_context_signal_names[arg],
gimp_context_signal_handlers[arg],
context);
gtk_signal_connect_object (GTK_OBJECT (context->parent),
gimp_context_signal_names[arg],
gimp_context_signal_handlers[arg],
GTK_OBJECT (context));
}
}
}
......@@ -812,9 +778,9 @@ gimp_context_arg_defined (GimpContext *context,
}
void
gimp_context_define_args (GimpContext *context,
guint32 args_mask,
gboolean defined)
gimp_context_define_args (GimpContext *context,
GimpContextArgMask args_mask,
gboolean defined)
{
GimpContextArgType arg;
......@@ -886,6 +852,17 @@ gimp_context_set_image (GimpContext *context,
gimp_context_real_set_image (context, image);
}
void
gimp_context_image_changed (GimpContext *context)
{
context_check_current (context);
context_return_if_fail (context);
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[IMAGE_CHANGED],
context->image);
}
/* handle disappearing images */
static void
gimp_context_image_removed (GimpSet *set,
......@@ -912,9 +889,7 @@ gimp_context_real_set_image (GimpContext *context,
context);
context->image = image;
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[IMAGE_CHANGED],
image);
gimp_context_image_changed (context);
}
static void
......@@ -924,14 +899,6 @@ gimp_context_copy_image (GimpContext *src,
gimp_context_real_set_image (dest, src->image);
}
static void
gimp_context_image_changed (GimpContext *parent,
GimpImage *image,
GimpContext *child)
{
gimp_context_real_set_image (child, image);
}
/*****************************************************************************/
/* display *****************************************************************/
......@@ -955,15 +922,24 @@ gimp_context_set_display (GimpContext *context,
gimp_context_real_set_display (context, display);
}
void
gimp_context_display_changed (GimpContext *context)
{
context_check_current (context);
context_return_if_fail (context);
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[DISPLAY_CHANGED],
context->display);
}
/* handle dissapearing displays */
static void
gimp_context_display_destroy (GtkWidget *disp_shell,
GimpContext *context)
{
context->display = NULL;
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[DISPLAY_CHANGED],
NULL);
gimp_context_display_changed (context);
}
static void
......@@ -988,9 +964,7 @@ gimp_context_real_set_display (GimpContext *context,
if (display)
gimp_context_real_set_image (context, display->gimage);
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[DISPLAY_CHANGED],
display);
gimp_context_display_changed (context);
}
static void
......@@ -1000,14 +974,6 @@ gimp_context_copy_display (GimpContext *src,
gimp_context_real_set_display (dest, src->display);
}
static void
gimp_context_display_changed (GimpContext *parent,
GDisplay *display,
GimpContext *child)
{
gimp_context_real_set_display (child, display);
}
/*****************************************************************************/
/* tool ********************************************************************/
......@@ -1031,6 +997,17 @@ gimp_context_set_tool (GimpContext *context,
gimp_context_real_set_tool (context, tool);
}
void
gimp_context_tool_changed (GimpContext *context)
{
context_check_current (context);
context_return_if_fail (context);
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[TOOL_CHANGED],
context->tool);
}
static void
gimp_context_real_set_tool (GimpContext *context,
ToolType tool)
......@@ -1039,9 +1016,7 @@ gimp_context_real_set_tool (GimpContext *context,
return;
context->tool = tool;
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[TOOL_CHANGED],
tool);
gimp_context_tool_changed (context);
}
static void
......@@ -1051,14 +1026,6 @@ gimp_context_copy_tool (GimpContext *src,
gimp_context_real_set_tool (dest, src->tool);
}
static void
gimp_context_tool_changed (GimpContext *parent,
ToolType tool,
GimpContext *child)
{
gimp_context_real_set_tool (child, tool);
}
/*****************************************************************************/
/* foreground color ********************************************************/
......@@ -1089,6 +1056,19 @@ gimp_context_set_foreground (GimpContext *context,
gimp_context_real_set_foreground (context, r, g, b);
}
void
gimp_context_foreground_changed (GimpContext *context)
{
context_check_current (context);
context_return_if_fail (context);
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[FOREGROUND_CHANGED],
context->foreground[0],
context->foreground[1],
context->foreground[2]);
}
static void
gimp_context_real_set_foreground (GimpContext *context,
gint r,
......@@ -1104,9 +1084,7 @@ gimp_context_real_set_foreground (GimpContext *context,
context->foreground[1] = g;
context->foreground[2] = b;
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[FOREGROUND_CHANGED],
r, g, b);
gimp_context_foreground_changed (context);
}
static void
......@@ -1119,16 +1097,6 @@ gimp_context_copy_foreground (GimpContext *src,
src->foreground[2]);
}
static void
gimp_context_foreground_changed (GimpContext *parent,
gint r,
gint g,
gint b,
GimpContext *child)
{
gimp_context_real_set_foreground (child, r, g, b);
}
/*****************************************************************************/
/* background color ********************************************************/
......@@ -1159,6 +1127,19 @@ gimp_context_set_background (GimpContext *context,
gimp_context_real_set_background (context, r, g, b);
}
void
gimp_context_background_changed (GimpContext *context)
{
context_check_current (context);
context_return_if_fail (context);
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[BACKGROUND_CHANGED],
context->background[0],
context->background[1],
context->background[2]);
}
static void
gimp_context_real_set_background (GimpContext *context,
gint r,
......@@ -1174,9 +1155,7 @@ gimp_context_real_set_background (GimpContext *context,
context->background[1] = g;
context->background[2] = b;
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[BACKGROUND_CHANGED],
r, g, b);
gimp_context_background_changed (context);
}
static void
......@@ -1189,16 +1168,6 @@ gimp_context_copy_background (GimpContext *src,
src->background[2]);
}
static void
gimp_context_background_changed (GimpContext *parent,
gint r,
gint g,
gint b,
GimpContext *child)
{
gimp_context_real_set_background (child, r, g, b);
}
/*****************************************************************************/
/* color utility functions *************************************************/
......@@ -1262,6 +1231,17 @@ gimp_context_set_opacity (GimpContext *context,
gimp_context_real_set_opacity (context, opacity);
}
void
gimp_context_opacity_changed (GimpContext *context)
{
context_check_current (context);
context_return_if_fail (context);
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[OPACITY_CHANGED],
context->opacity);
}
static void
gimp_context_real_set_opacity (GimpContext *context,
gdouble opacity)
......@@ -1270,9 +1250,7 @@ gimp_context_real_set_opacity (GimpContext *context,
return;
context->opacity = opacity;
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[OPACITY_CHANGED],
opacity);
gimp_context_opacity_changed (context);
}
static void
......@@ -1282,14 +1260,6 @@ gimp_context_copy_opacity (GimpContext *src,
gimp_context_real_set_opacity (dest, src->opacity);
}
static void
gimp_context_opacity_changed (GimpContext *parent,
gdouble opacity,
GimpContext *child)
{
gimp_context_real_set_opacity (child, opacity);
}
/*****************************************************************************/
/* paint mode **************************************************************/
......@@ -1313,6 +1283,17 @@ gimp_context_set_paint_mode (GimpContext *context,
gimp_context_real_set_paint_mode (context, paint_mode);
}
void
gimp_context_paint_mode_changed (GimpContext *context)
{
context_check_current (context);
context_return_if_fail (context);
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[PAINT_MODE_CHANGED],
context->paint_mode);
}
static void
gimp_context_real_set_paint_mode (GimpContext *context,
LayerModeEffects paint_mode)
......@@ -1321,9 +1302,7 @@ gimp_context_real_set_paint_mode (GimpContext *context,
return;
context->paint_mode = paint_mode;
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[PAINT_MODE_CHANGED],
paint_mode);
gimp_context_paint_mode_changed (context);
}
static void
......@@ -1333,14 +1312,6 @@ gimp_context_copy_paint_mode (GimpContext *src,
gimp_context_real_set_paint_mode (dest, src->paint_mode);
}
static void
gimp_context_paint_mode_changed (GimpContext *parent,
LayerModeEffects paint_mode,
GimpContext *child)
{
gimp_context_real_set_paint_mode (child, paint_mode);
}
/*****************************************************************************/
/* brush *******************************************************************/
......@@ -1366,6 +1337,17 @@ gimp_context_set_brush (GimpContext *context,
gimp_context_real_set_brush (context, brush);
}
void
gimp_context_brush_changed (GimpContext *context)
{
context_check_current (context);
context_return_if_fail (context);
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[BRUSH_CHANGED],
context->brush);
}
/* the active brush was modified */
static void
gimp_context_brush_dirty (GimpBrush *brush,
......@@ -1374,9 +1356,7 @@ gimp_context_brush_dirty (GimpBrush *brush,
g_free (context->brush_name);
context->brush_name = g_strdup (brush->name);
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[BRUSH_CHANGED],
brush);
gimp_context_brush_changed (context);
}
/* the active brush disappeared */
......@@ -1464,9 +1444,7 @@ gimp_context_real_set_brush (GimpContext *context,
context->brush_name = g_strdup (brush->name);
}
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[BRUSH_CHANGED],
brush);
gimp_context_brush_changed (context);
}
static void
......@@ -1482,14 +1460,6 @@ gimp_context_copy_brush (GimpContext *src,
}
}
static void
gimp_context_brush_changed (GimpContext *parent,
GimpBrush *brush,
GimpContext *child)
{
gimp_context_real_set_brush (child, brush);
}
static void
gimp_context_refresh_brush (GimpContext *context,
gpointer data)
......@@ -1543,6 +1513,17 @@ gimp_context_set_pattern (GimpContext *context,
gimp_context_real_set_pattern (context, pattern);
}
void
gimp_context_pattern_changed (GimpContext *context)
{
context_check_current (context);
context_return_if_fail (context);
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[PATTERN_CHANGED],
context->pattern);
}
static void
gimp_context_real_set_pattern (GimpContext *context,
GPattern *pattern)
......@@ -1564,9 +1545,7 @@ gimp_context_real_set_pattern (GimpContext *context,
if (pattern && pattern != standard_pattern)
context->pattern_name = g_strdup (pattern->name);
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[PATTERN_CHANGED],
pattern);
gimp_context_pattern_changed (context);
}
static void
......@@ -1582,14 +1561,6 @@ gimp_context_copy_pattern (GimpContext *src,
}
}
static void
gimp_context_pattern_changed (GimpContext *parent,
GPattern *pattern,
GimpContext *child)
{
gimp_context_real_set_pattern (child, pattern);
}
static void
gimp_context_refresh_pattern (GimpContext *context,
gpointer data)
......@@ -1629,9 +1600,7 @@ gimp_context_update_pattern (GimpContext *context,
context->pattern_name = g_strdup (pattern->name);
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[PATTERN_CHANGED],
pattern);
gimp_context_pattern_changed (context);
}
}
......@@ -1666,6 +1635,17 @@ gimp_context_set_gradient (GimpContext *context,
gimp_context_real_set_gradient (context, gradient);
}
void
gimp_context_gradient_changed (GimpContext *context)
{
context_check_current (context);
context_return_if_fail (context);
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[GRADIENT_CHANGED],
context->gradient);
}
static void
gimp_context_real_set_gradient (GimpContext *context,
gradient_t *gradient)
......@@ -1687,9 +1667,7 @@ gimp_context_real_set_gradient (GimpContext *context,
if (gradient && gradient != standard_gradient)
context->gradient_name = g_strdup (gradient->name);
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[GRADIENT_CHANGED],
gradient);
gimp_context_gradient_changed (context);
}
static void
......@@ -1706,14 +1684,6 @@ gimp_context_copy_gradient (GimpContext *src,
}
}
static void
gimp_context_gradient_changed (GimpContext *parent,
gradient_t *gradient,
GimpContext *child)
{
gimp_context_real_set_gradient (child, gradient);
}
static void
gimp_context_refresh_gradient (GimpContext *context,
gpointer data)
......@@ -1754,9 +1724,7 @@ gimp_context_update_gradient (GimpContext *context,
context->gradient_name = g_strdup (gradient->name);
gtk_signal_emit (GTK_OBJECT (context),
gimp_context_signals[GRADIENT_CHANGED],
gradient);
gimp_context_gradient_changed (context);
}
}
......
......@@ -196,7 +196,7 @@ gboolean gimp_context_arg_defined (GimpContext *context,
GimpContextArgType arg);
void gimp_context_define_args (GimpContext *context,
guint32 args_mask,
GimpContextArgMask args_mask,
gboolean defined);
/* copying context arguments
......@@ -213,36 +213,41 @@ void gimp_context_copy_args (GimpContext *src,
GimpImage * gimp_context_get_image (GimpContext *context);
void gimp_context_set_image (GimpContext *context,
GimpImage *image);
void gimp_context_image_changed (GimpContext *context);
/* display */
GDisplay * gimp_context_get_display (GimpContext *context);
void gimp_context_set_display (GimpContext *context,
GDisplay *display);
void gimp_context_display_changed (GimpContext *context);
/* tool */
ToolType gimp_context_get_tool (GimpContext *context);
void gimp_context_set_tool (GimpContext *context,
ToolType tool_type);
void gimp_context_tool_changed (GimpContext *context);
/* foreground color */
void gimp_context_get_foreground (GimpContext *context,
guchar *r,
guchar *g,
guchar *b);
void gimp_context_set_foreground (GimpContext *context,
gint r,
gint g,
gint b);
void gimp_context_get_foreground (GimpContext *context,
guchar *r,
guchar *g,
guchar *b);
void gimp_context_set_foreground (GimpContext *context,
gint r,
gint g,
gint b);
void gimp_context_foreground_changed (GimpContext *context);
/* background color */
void gimp_context_get_background (GimpContext *context,
guchar *r,
guchar *g,
guchar *b);
void gimp_context_set_background (GimpContext *context,
gint r,
gint g,
gint b);
void gimp_context_get_background (GimpContext *context,
guchar *r,
guchar *g,
guchar *b);
void gimp_context_set_background (GimpContext *context,
gint r,
gint g,
gint b);
void gimp_context_background_changed (GimpContext *context);
/* color utility functions */
void gimp_context_set_default_colors (GimpContext *context);
......@@ -252,22 +257,26 @@ void gimp_context_swap_colors (GimpContext *context);
gdouble gimp_context_get_opacity (GimpContext *context);
void gimp_context_set_opacity (GimpContext *context,
gdouble opacity);
void gimp_context_opacity_changed (GimpContext *context);
/* paint mode */
LayerModeEffects gimp_context_get_paint_mode (GimpContext *context);
void gimp_context_set_paint_mode (GimpContext *context,
LayerModeEffects paint_mode);