From 33ab94517f517e3f2c214c2e7e8f41ba4ca3dc03 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Fri, 1 Oct 2010 14:24:46 +0200 Subject: [PATCH] app: add gimp_draw_tool_add_stroke_group() and add_fill_group() and use it in all tools which have groups. --- app/tools/gimpdrawtool.c | 32 ++++++++++++++++++++++++++++ app/tools/gimpdrawtool.h | 3 +++ app/tools/gimpfreeselecttool.c | 6 +----- app/tools/gimpmeasuretool.c | 6 +----- app/tools/gimpperspectiveclonetool.c | 6 +----- app/tools/gimprectangletool.c | 6 +----- app/tools/gimptexttool.c | 5 +---- app/tools/gimptransformtool.c | 6 +----- 8 files changed, 41 insertions(+), 29 deletions(-) diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c index 11e2a051b0..b255a2ca02 100644 --- a/app/tools/gimpdrawtool.c +++ b/app/tools/gimpdrawtool.c @@ -362,6 +362,38 @@ gimp_draw_tool_remove_item (GimpDrawTool *draw_tool, gimp_canvas_group_remove_item (GIMP_CANVAS_GROUP (draw_tool->item), item); } +GimpCanvasItem * +gimp_draw_tool_add_stroke_group (GimpDrawTool *draw_tool) +{ + GimpCanvasItem *item; + + g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL); + + item = gimp_canvas_group_new (gimp_display_get_shell (draw_tool->display)); + gimp_canvas_group_set_group_stroking (GIMP_CANVAS_GROUP (item), TRUE); + + gimp_draw_tool_add_item (draw_tool, item); + g_object_unref (item); + + return item; +} + +GimpCanvasItem * +gimp_draw_tool_add_fill_group (GimpDrawTool *draw_tool) +{ + GimpCanvasItem *item; + + g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL); + + item = gimp_canvas_group_new (gimp_display_get_shell (draw_tool->display)); + gimp_canvas_group_set_group_filling (GIMP_CANVAS_GROUP (item), TRUE); + + gimp_draw_tool_add_item (draw_tool, item); + g_object_unref (item); + + return item; +} + /** * gimp_draw_tool_add_line: * @draw_tool: the #GimpDrawTool diff --git a/app/tools/gimpdrawtool.h b/app/tools/gimpdrawtool.h index 55bde3cafa..c931035d28 100644 --- a/app/tools/gimpdrawtool.h +++ b/app/tools/gimpdrawtool.h @@ -84,6 +84,9 @@ void gimp_draw_tool_add_item (GimpDrawTool *draw_too void gimp_draw_tool_remove_item (GimpDrawTool *draw_tool, GimpCanvasItem *item); +GimpCanvasItem * gimp_draw_tool_add_stroke_group (GimpDrawTool *draw_tool); +GimpCanvasItem * gimp_draw_tool_add_fill_group (GimpDrawTool *draw_tool); + GimpCanvasItem * gimp_draw_tool_add_line (GimpDrawTool *draw_tool, gdouble x1, gdouble y1, diff --git a/app/tools/gimpfreeselecttool.c b/app/tools/gimpfreeselecttool.c index 078225db85..ea29f2e382 100644 --- a/app/tools/gimpfreeselecttool.c +++ b/app/tools/gimpfreeselecttool.c @@ -1545,11 +1545,7 @@ gimp_free_select_tool_draw (GimpDrawTool *draw_tool) NO_CLICK_TIME_AVAILABLE, &coords); - stroke_group = gimp_canvas_group_new (gimp_display_get_shell (draw_tool->display)); - gimp_canvas_group_set_group_stroking (GIMP_CANVAS_GROUP (stroke_group), - TRUE); - gimp_draw_tool_add_item (draw_tool, stroke_group); - g_object_unref (stroke_group); + stroke_group = gimp_draw_tool_add_stroke_group (draw_tool); item = gimp_draw_tool_add_lines (draw_tool, priv->points, priv->n_points, diff --git a/app/tools/gimpmeasuretool.c b/app/tools/gimpmeasuretool.c index eff18cdcbd..7182af1e47 100644 --- a/app/tools/gimpmeasuretool.c +++ b/app/tools/gimpmeasuretool.c @@ -660,11 +660,7 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool) gint i; gint draw_arc = 0; - stroke_group = gimp_canvas_group_new (gimp_display_get_shell (draw_tool->display)); - gimp_canvas_group_set_group_stroking (GIMP_CANVAS_GROUP (stroke_group), - TRUE); - gimp_draw_tool_add_item (draw_tool, stroke_group); - g_object_unref (stroke_group); + stroke_group = gimp_draw_tool_add_stroke_group (draw_tool); for (i = 0; i < measure->num_points; i++) { diff --git a/app/tools/gimpperspectiveclonetool.c b/app/tools/gimpperspectiveclonetool.c index e5852ba865..54a9b4481d 100644 --- a/app/tools/gimpperspectiveclonetool.c +++ b/app/tools/gimpperspectiveclonetool.c @@ -750,11 +750,7 @@ gimp_perspective_clone_tool_draw (GimpDrawTool *draw_tool) GimpCanvasItem *stroke_group; GimpCanvasItem *item; - stroke_group = gimp_canvas_group_new (gimp_display_get_shell (draw_tool->display)); - gimp_canvas_group_set_group_stroking (GIMP_CANVAS_GROUP (stroke_group), - TRUE); - gimp_draw_tool_add_item (draw_tool, stroke_group); - g_object_unref (stroke_group); + stroke_group = gimp_draw_tool_add_stroke_group (draw_tool); /* draw the bounding box */ item = gimp_draw_tool_add_line (draw_tool, diff --git a/app/tools/gimprectangletool.c b/app/tools/gimprectangletool.c index b8c3b3ad8a..258a5133c1 100644 --- a/app/tools/gimprectangletool.c +++ b/app/tools/gimprectangletool.c @@ -1738,11 +1738,7 @@ gimp_rectangle_tool_draw (GimpDrawTool *draw_tool) if (private->function == GIMP_RECTANGLE_TOOL_INACTIVE) return; - stroke_group = gimp_canvas_group_new (gimp_display_get_shell (draw_tool->display)); - gimp_canvas_group_set_group_stroking (GIMP_CANVAS_GROUP (stroke_group), - TRUE); - gimp_draw_tool_add_item (draw_tool, stroke_group); - g_object_unref (stroke_group); + stroke_group = gimp_draw_tool_add_stroke_group (draw_tool); gimp_rectangle_tool_draw_guides (draw_tool, GIMP_CANVAS_GROUP (stroke_group)); diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c index 440c815275..a43d8046ec 100644 --- a/app/tools/gimptexttool.c +++ b/app/tools/gimptexttool.c @@ -833,10 +833,7 @@ gimp_text_tool_draw_selection (GimpDrawTool *draw_tool) gint min, max; gint i; - fill_group = gimp_canvas_group_new (gimp_display_get_shell (draw_tool->display)); - gimp_canvas_group_set_group_filling (GIMP_CANVAS_GROUP (fill_group), TRUE); - gimp_draw_tool_add_item (draw_tool, fill_group); - g_object_unref (fill_group); + fill_group = gimp_draw_tool_add_fill_group (draw_tool); gtk_text_buffer_get_selection_bounds (buffer, &sel_start, &sel_end); diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c index b47ec7dc19..d04754f17c 100644 --- a/app/tools/gimptransformtool.c +++ b/app/tools/gimptransformtool.c @@ -785,11 +785,7 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool) GimpCanvasItem *item; gdouble z1, z2, z3, z4; - stroke_group = gimp_canvas_group_new (gimp_display_get_shell (draw_tool->display)); - gimp_canvas_group_set_group_stroking (GIMP_CANVAS_GROUP (stroke_group), - TRUE); - gimp_draw_tool_add_item (draw_tool, stroke_group); - g_object_unref (stroke_group); + stroke_group = gimp_draw_tool_add_stroke_group (draw_tool); if (tr_tool->use_grid) {