app: GimpBrushCore: simplify brush and dynamics setting
by checking for an actual change in the setters. Remove the "foo != core->foo" checks from all callers.
This commit is contained in:
@ -396,19 +396,12 @@ gimp_brush_core_start (GimpPaintCore *paint_core,
|
||||
const GimpCoords *coords,
|
||||
GError **error)
|
||||
{
|
||||
GimpBrushCore *core = GIMP_BRUSH_CORE (paint_core);
|
||||
GimpBrush *brush;
|
||||
GimpDynamics *dynamics;
|
||||
GimpBrushCore *core = GIMP_BRUSH_CORE (paint_core);
|
||||
GimpContext *context = GIMP_CONTEXT (paint_options);
|
||||
|
||||
brush = gimp_context_get_brush (GIMP_CONTEXT (paint_options));
|
||||
gimp_brush_core_set_brush (core, gimp_context_get_brush (context));
|
||||
|
||||
if (core->main_brush != brush)
|
||||
gimp_brush_core_set_brush (core, brush);
|
||||
|
||||
dynamics = gimp_context_get_dynamics (GIMP_CONTEXT (paint_options));
|
||||
|
||||
if (core->dynamics != dynamics)
|
||||
gimp_brush_core_set_dynamics (core, dynamics);
|
||||
gimp_brush_core_set_dynamics (core, gimp_context_get_dynamics (context));
|
||||
|
||||
if (! core->main_brush)
|
||||
{
|
||||
@ -866,6 +859,9 @@ static void
|
||||
gimp_brush_core_real_set_brush (GimpBrushCore *core,
|
||||
GimpBrush *brush)
|
||||
{
|
||||
if (brush == core->main_brush)
|
||||
return;
|
||||
|
||||
if (core->main_brush)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (core->main_brush,
|
||||
@ -890,6 +886,9 @@ static void
|
||||
gimp_brush_core_real_set_dynamics (GimpBrushCore *core,
|
||||
GimpDynamics *dynamics)
|
||||
{
|
||||
if (dynamics == core->dynamics)
|
||||
return;
|
||||
|
||||
if (core->dynamics)
|
||||
g_object_unref (core->dynamics);
|
||||
|
||||
@ -906,7 +905,8 @@ gimp_brush_core_set_brush (GimpBrushCore *core,
|
||||
g_return_if_fail (GIMP_IS_BRUSH_CORE (core));
|
||||
g_return_if_fail (brush == NULL || GIMP_IS_BRUSH (brush));
|
||||
|
||||
g_signal_emit (core, core_signals[SET_BRUSH], 0, brush);
|
||||
if (brush != core->main_brush)
|
||||
g_signal_emit (core, core_signals[SET_BRUSH], 0, brush);
|
||||
}
|
||||
|
||||
void
|
||||
@ -916,7 +916,8 @@ gimp_brush_core_set_dynamics (GimpBrushCore *core,
|
||||
g_return_if_fail (GIMP_IS_BRUSH_CORE (core));
|
||||
g_return_if_fail (dynamics == NULL || GIMP_IS_DYNAMICS (dynamics));
|
||||
|
||||
g_signal_emit (core, core_signals[SET_DYNAMICS], 0, dynamics);
|
||||
if (dynamics != core->dynamics)
|
||||
g_signal_emit (core, core_signals[SET_DYNAMICS], 0, dynamics);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1018,9 +1019,9 @@ gimp_brush_core_invalidate_cache (GimpBrush *brush,
|
||||
core->cache_invalid = TRUE;
|
||||
core->solid_cache_invalid = TRUE;
|
||||
|
||||
/* Set the same brush again so the "set-brush" signal is emitted */
|
||||
/* Notify of the brush change */
|
||||
|
||||
gimp_brush_core_set_brush (core, brush);
|
||||
g_signal_emit (core, core_signals[SET_BRUSH], 0, brush);
|
||||
}
|
||||
|
||||
|
||||
|
@ -196,23 +196,18 @@ gimp_brush_tool_oper_update (GimpTool *tool,
|
||||
if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)) &&
|
||||
drawable && proximity)
|
||||
{
|
||||
GimpContext *context = GIMP_CONTEXT (paint_options);
|
||||
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
||||
GimpBrushCore *brush_core = GIMP_BRUSH_CORE (paint_tool->core);
|
||||
GimpBrush *brush;
|
||||
GimpDynamics *dynamics;
|
||||
|
||||
brush_tool->brush_x = coords->x;
|
||||
brush_tool->brush_y = coords->y;
|
||||
|
||||
brush = gimp_context_get_brush (GIMP_CONTEXT (paint_options));
|
||||
gimp_brush_core_set_brush (brush_core,
|
||||
gimp_context_get_brush (context));
|
||||
|
||||
if (brush_core->main_brush != brush)
|
||||
gimp_brush_core_set_brush (brush_core, brush);
|
||||
|
||||
dynamics = gimp_context_get_dynamics (GIMP_CONTEXT (paint_options));
|
||||
|
||||
if (brush_core->dynamics != dynamics)
|
||||
gimp_brush_core_set_dynamics (brush_core, dynamics);
|
||||
gimp_brush_core_set_dynamics (brush_core,
|
||||
gimp_context_get_dynamics (context));
|
||||
|
||||
if (GIMP_BRUSH_CORE_GET_CLASS (brush_core)->handles_transforming_brush)
|
||||
{
|
||||
@ -274,7 +269,8 @@ gimp_brush_tool_options_notify (GimpTool *tool,
|
||||
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
||||
GimpBrushCore *brush_core = GIMP_BRUSH_CORE (paint_tool->core);
|
||||
|
||||
gimp_brush_core_set_brush (brush_core, brush_core->main_brush);
|
||||
g_signal_emit_by_name (brush_core, "set-brush",
|
||||
brush_core->main_brush);
|
||||
}
|
||||
}
|
||||
|
||||
@ -370,8 +366,7 @@ gimp_brush_tool_brush_changed (GimpContext *context,
|
||||
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (brush_tool);
|
||||
GimpBrushCore *brush_core = GIMP_BRUSH_CORE (paint_tool->core);
|
||||
|
||||
if (brush_core->main_brush != brush)
|
||||
gimp_brush_core_set_brush (brush_core, brush);
|
||||
gimp_brush_core_set_brush (brush_core, brush);
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user