[gimp] app: GimpBrushCore: simplify brush and dynamics setting
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: GimpBrushCore: simplify brush and dynamics setting
- Date: Tue, 5 Apr 2011 17:06:58 +0000 (UTC)
commit a50f668d8784c328ccc8ea50118070cfa70323c9
Author: Michael Natterer <mitch gimp org>
Date: Tue Apr 5 19:05:55 2011 +0200
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.
app/paint/gimpbrushcore.c | 31 ++++++++++++++++---------------
app/tools/gimpbrushtool.c | 21 ++++++++-------------
2 files changed, 24 insertions(+), 28 deletions(-)
---
diff --git a/app/paint/gimpbrushcore.c b/app/paint/gimpbrushcore.c
index b20779e..841f461 100644
--- a/app/paint/gimpbrushcore.c
+++ b/app/paint/gimpbrushcore.c
@@ -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;
-
- brush = gimp_context_get_brush (GIMP_CONTEXT (paint_options));
-
- if (core->main_brush != brush)
- gimp_brush_core_set_brush (core, brush);
+ GimpBrushCore *core = GIMP_BRUSH_CORE (paint_core);
+ GimpContext *context = GIMP_CONTEXT (paint_options);
- dynamics = gimp_context_get_dynamics (GIMP_CONTEXT (paint_options));
+ gimp_brush_core_set_brush (core, gimp_context_get_brush (context));
- 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);
}
diff --git a/app/tools/gimpbrushtool.c b/app/tools/gimpbrushtool.c
index f0038a9..ed759c1 100644
--- a/app/tools/gimpbrushtool.c
+++ b/app/tools/gimpbrushtool.c
@@ -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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]