app: return the created item from gimp_draw_tool_draw_foo()

This commit is contained in:
Michael Natterer 2010-09-25 17:52:56 +02:00
parent 02924e1e70
commit 5cda4393d0
2 changed files with 191 additions and 167 deletions

View File

@ -411,7 +411,7 @@ gimp_draw_tool_in_radius (GimpDrawTool *draw_tool,
* screen window coordinates, then draws a line between the resulting * screen window coordinates, then draws a line between the resulting
* coordindates. * coordindates.
**/ **/
void GimpCanvasItem *
gimp_draw_tool_draw_line (GimpDrawTool *draw_tool, gimp_draw_tool_draw_line (GimpDrawTool *draw_tool,
gdouble x1, gdouble x1,
gdouble y1, gdouble y1,
@ -420,12 +420,14 @@ gimp_draw_tool_draw_line (GimpDrawTool *draw_tool,
{ {
GimpCanvasItem *item; GimpCanvasItem *item;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool)); g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL);
item = gimp_canvas_line_new (x1, y1, x2, y2); item = gimp_canvas_line_new (x1, y1, x2, y2);
gimp_draw_tool_add_item (draw_tool, item); gimp_draw_tool_add_item (draw_tool, item);
g_object_unref (item); g_object_unref (item);
return item;
} }
/** /**
@ -440,7 +442,7 @@ gimp_draw_tool_draw_line (GimpDrawTool *draw_tool,
* screen window coordinates, then draws a dashed line between the * screen window coordinates, then draws a dashed line between the
* resulting coordindates. * resulting coordindates.
**/ **/
void GimpCanvasItem *
gimp_draw_tool_draw_dashed_line (GimpDrawTool *draw_tool, gimp_draw_tool_draw_dashed_line (GimpDrawTool *draw_tool,
gdouble x1, gdouble x1,
gdouble y1, gdouble y1,
@ -449,13 +451,15 @@ gimp_draw_tool_draw_dashed_line (GimpDrawTool *draw_tool,
{ {
GimpCanvasItem *item; GimpCanvasItem *item;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool)); g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL);
item = gimp_canvas_line_new (x1, y1, x2, y2); item = gimp_canvas_line_new (x1, y1, x2, y2);
gimp_canvas_item_set_highlight (item, TRUE); gimp_canvas_item_set_highlight (item, TRUE);
gimp_draw_tool_add_item (draw_tool, item); gimp_draw_tool_add_item (draw_tool, item);
g_object_unref (item); g_object_unref (item);
return item;
} }
/** /**
@ -466,19 +470,21 @@ gimp_draw_tool_draw_dashed_line (GimpDrawTool *draw_tool,
* *
* This function draws a guide line across the canvas. * This function draws a guide line across the canvas.
**/ **/
void GimpCanvasItem *
gimp_draw_tool_draw_guide_line (GimpDrawTool *draw_tool, gimp_draw_tool_draw_guide_line (GimpDrawTool *draw_tool,
GimpOrientationType orientation, GimpOrientationType orientation,
gint position) gint position)
{ {
GimpCanvasItem *item; GimpCanvasItem *item;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool)); g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL);
item = gimp_canvas_guide_new (orientation, position); item = gimp_canvas_guide_new (orientation, position);
gimp_draw_tool_add_item (draw_tool, item); gimp_draw_tool_add_item (draw_tool, item);
g_object_unref (item); g_object_unref (item);
return item;
} }
/** /**
@ -493,7 +499,7 @@ gimp_draw_tool_draw_guide_line (GimpDrawTool *draw_tool,
* This function takes image space coordinates and transforms them to * This function takes image space coordinates and transforms them to
* screen window coordinates, then draws the resulting rectangle. * screen window coordinates, then draws the resulting rectangle.
**/ **/
void GimpCanvasItem *
gimp_draw_tool_draw_rectangle (GimpDrawTool *draw_tool, gimp_draw_tool_draw_rectangle (GimpDrawTool *draw_tool,
gboolean filled, gboolean filled,
gdouble x, gdouble x,
@ -503,15 +509,17 @@ gimp_draw_tool_draw_rectangle (GimpDrawTool *draw_tool,
{ {
GimpCanvasItem *item; GimpCanvasItem *item;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool)); g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL);
item = gimp_canvas_rectangle_new (x, y, width, height, filled); item = gimp_canvas_rectangle_new (x, y, width, height, filled);
gimp_draw_tool_add_item (draw_tool, item); gimp_draw_tool_add_item (draw_tool, item);
g_object_unref (item); g_object_unref (item);
return item;
} }
void GimpCanvasItem *
gimp_draw_tool_draw_arc (GimpDrawTool *draw_tool, gimp_draw_tool_draw_arc (GimpDrawTool *draw_tool,
gboolean filled, gboolean filled,
gdouble x, gdouble x,
@ -523,7 +531,7 @@ gimp_draw_tool_draw_arc (GimpDrawTool *draw_tool,
{ {
GimpCanvasItem *item; GimpCanvasItem *item;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool)); g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL);
item = gimp_canvas_arc_new (x + width / 2.0, item = gimp_canvas_arc_new (x + width / 2.0,
y + height / 2.0, y + height / 2.0,
@ -535,9 +543,11 @@ gimp_draw_tool_draw_arc (GimpDrawTool *draw_tool,
gimp_draw_tool_add_item (draw_tool, item); gimp_draw_tool_add_item (draw_tool, item);
g_object_unref (item); g_object_unref (item);
return item;
} }
void GimpCanvasItem *
gimp_draw_tool_draw_arc_by_anchor (GimpDrawTool *draw_tool, gimp_draw_tool_draw_arc_by_anchor (GimpDrawTool *draw_tool,
gboolean filled, gboolean filled,
gdouble x, gdouble x,
@ -550,7 +560,7 @@ gimp_draw_tool_draw_arc_by_anchor (GimpDrawTool *draw_tool,
{ {
GimpCanvasItem *item; GimpCanvasItem *item;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool)); g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL);
item = gimp_canvas_handle_new (filled ? item = gimp_canvas_handle_new (filled ?
GIMP_HANDLE_FILLED_CIRCLE : GIMP_HANDLE_FILLED_CIRCLE :
@ -562,9 +572,11 @@ gimp_draw_tool_draw_arc_by_anchor (GimpDrawTool *draw_tool,
gimp_draw_tool_add_item (draw_tool, item); gimp_draw_tool_add_item (draw_tool, item);
g_object_unref (item); g_object_unref (item);
return item;
} }
void GimpCanvasItem *
gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool, gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool,
GimpHandleType type, GimpHandleType type,
gdouble x, gdouble x,
@ -575,12 +587,14 @@ gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool,
{ {
GimpCanvasItem *item; GimpCanvasItem *item;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool)); g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL);
item = gimp_canvas_handle_new (type, anchor, x, y, width, height); item = gimp_canvas_handle_new (type, anchor, x, y, width, height);
gimp_draw_tool_add_item (draw_tool, item); gimp_draw_tool_add_item (draw_tool, item);
g_object_unref (item); g_object_unref (item);
return item;
} }
/** /**
@ -600,7 +614,7 @@ gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool,
* screen window coordinates. It draws a corner into an already drawn * screen window coordinates. It draws a corner into an already drawn
* rectangle outline, taking care of not drawing over an already drawn line. * rectangle outline, taking care of not drawing over an already drawn line.
**/ **/
void GimpCanvasItem *
gimp_draw_tool_draw_corner (GimpDrawTool *draw_tool, gimp_draw_tool_draw_corner (GimpDrawTool *draw_tool,
gboolean highlight, gboolean highlight,
gboolean put_outside, gboolean put_outside,
@ -614,7 +628,7 @@ gimp_draw_tool_draw_corner (GimpDrawTool *draw_tool,
{ {
GimpCanvasItem *item; GimpCanvasItem *item;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool)); g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL);
item = gimp_canvas_corner_new (x1, y1, x2 - x1, y2 - y1, item = gimp_canvas_corner_new (x1, y1, x2 - x1, y2 - y1,
anchor, width, height, put_outside); anchor, width, height, put_outside);
@ -622,9 +636,11 @@ gimp_draw_tool_draw_corner (GimpDrawTool *draw_tool,
gimp_draw_tool_add_item (draw_tool, item); gimp_draw_tool_add_item (draw_tool, item);
g_object_unref (item); g_object_unref (item);
return item;
} }
void GimpCanvasItem *
gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool, gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool,
const GimpVector2 *points, const GimpVector2 *points,
gint n_points, gint n_points,
@ -632,18 +648,20 @@ gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool,
{ {
GimpCanvasItem *item; GimpCanvasItem *item;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool)); g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL);
if (points == NULL || n_points < 2) if (points == NULL || n_points < 2)
return; return NULL;
item = gimp_canvas_polygon_new (points, n_points, filled); item = gimp_canvas_polygon_new (points, n_points, filled);
gimp_draw_tool_add_item (draw_tool, item); gimp_draw_tool_add_item (draw_tool, item);
g_object_unref (item); g_object_unref (item);
return item;
} }
void GimpCanvasItem *
gimp_draw_tool_draw_strokes (GimpDrawTool *draw_tool, gimp_draw_tool_draw_strokes (GimpDrawTool *draw_tool,
const GimpCoords *points, const GimpCoords *points,
gint n_points, gint n_points,
@ -651,15 +669,17 @@ gimp_draw_tool_draw_strokes (GimpDrawTool *draw_tool,
{ {
GimpCanvasItem *item; GimpCanvasItem *item;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool)); g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL);
if (points == NULL || n_points < 2) if (points == NULL || n_points < 2)
return; return NULL;
item = gimp_canvas_polygon_new_from_coords (points, n_points, filled); item = gimp_canvas_polygon_new_from_coords (points, n_points, filled);
gimp_draw_tool_add_item (draw_tool, item); gimp_draw_tool_add_item (draw_tool, item);
g_object_unref (item); g_object_unref (item);
return item;
} }
/** /**
@ -675,7 +695,7 @@ gimp_draw_tool_draw_strokes (GimpDrawTool *draw_tool,
* include the sentinel segments inserted by sort_boundary() that * include the sentinel segments inserted by sort_boundary() that
* indicate the end of connected segment sequences (groups) . * indicate the end of connected segment sequences (groups) .
*/ */
void GimpCanvasItem *
gimp_draw_tool_draw_boundary (GimpDrawTool *draw_tool, gimp_draw_tool_draw_boundary (GimpDrawTool *draw_tool,
const BoundSeg *bound_segs, const BoundSeg *bound_segs,
gint n_bound_segs, gint n_bound_segs,
@ -684,30 +704,34 @@ gimp_draw_tool_draw_boundary (GimpDrawTool *draw_tool,
{ {
GimpCanvasItem *item; GimpCanvasItem *item;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool)); g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL);
g_return_if_fail (n_bound_segs > 0); g_return_val_if_fail (n_bound_segs > 0, NULL);
g_return_if_fail (bound_segs != NULL); g_return_val_if_fail (bound_segs != NULL, NULL);
item = gimp_canvas_boundary_new (bound_segs, n_bound_segs, item = gimp_canvas_boundary_new (bound_segs, n_bound_segs,
offset_x, offset_y); offset_x, offset_y);
gimp_draw_tool_add_item (draw_tool, item); gimp_draw_tool_add_item (draw_tool, item);
g_object_unref (item); g_object_unref (item);
return item;
} }
void GimpCanvasItem *
gimp_draw_tool_draw_text_cursor (GimpDrawTool *draw_tool, gimp_draw_tool_draw_text_cursor (GimpDrawTool *draw_tool,
PangoRectangle *cursor, PangoRectangle *cursor,
gboolean overwrite) gboolean overwrite)
{ {
GimpCanvasItem *item; GimpCanvasItem *item;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool)); g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL);
item = gimp_canvas_text_cursor_new (cursor, overwrite); item = gimp_canvas_text_cursor_new (cursor, overwrite);
gimp_draw_tool_add_item (draw_tool, item); gimp_draw_tool_add_item (draw_tool, item);
g_object_unref (item); g_object_unref (item);
return item;
} }
gboolean gboolean

View File

@ -89,26 +89,26 @@ gboolean gimp_draw_tool_in_radius (GimpDrawTool *draw_tool,
gdouble y2, gdouble y2,
gint radius); gint radius);
void gimp_draw_tool_draw_line (GimpDrawTool *draw_tool, GimpCanvasItem * gimp_draw_tool_draw_line (GimpDrawTool *draw_tool,
gdouble x1, gdouble x1,
gdouble y1, gdouble y1,
gdouble x2, gdouble x2,
gdouble y2); gdouble y2);
void gimp_draw_tool_draw_dashed_line (GimpDrawTool *draw_tool, GimpCanvasItem * gimp_draw_tool_draw_dashed_line (GimpDrawTool *draw_tool,
gdouble x1, gdouble x1,
gdouble y1, gdouble y1,
gdouble x2, gdouble x2,
gdouble y2); gdouble y2);
void gimp_draw_tool_draw_guide_line (GimpDrawTool *draw_tool, GimpCanvasItem * gimp_draw_tool_draw_guide_line (GimpDrawTool *draw_tool,
GimpOrientationType orientation, GimpOrientationType orientation,
gint position); gint position);
void gimp_draw_tool_draw_rectangle (GimpDrawTool *draw_tool, GimpCanvasItem * gimp_draw_tool_draw_rectangle (GimpDrawTool *draw_tool,
gboolean filled, gboolean filled,
gdouble x, gdouble x,
gdouble y, gdouble y,
gdouble width, gdouble width,
gdouble height); gdouble height);
void gimp_draw_tool_draw_arc (GimpDrawTool *draw_tool, GimpCanvasItem * gimp_draw_tool_draw_arc (GimpDrawTool *draw_tool,
gboolean filled, gboolean filled,
gdouble x, gdouble x,
gdouble y, gdouble y,
@ -117,7 +117,7 @@ void gimp_draw_tool_draw_arc (GimpDrawTool *draw_tool,
gdouble start_angle, gdouble start_angle,
gdouble slice_angle); gdouble slice_angle);
void gimp_draw_tool_draw_arc_by_anchor (GimpDrawTool *draw_tool, GimpCanvasItem * gimp_draw_tool_draw_arc_by_anchor (GimpDrawTool *draw_tool,
gboolean filled, gboolean filled,
gdouble x, gdouble x,
gdouble y, gdouble y,
@ -127,14 +127,14 @@ void gimp_draw_tool_draw_arc_by_anchor (GimpDrawTool *draw_tool,
gdouble slice_angle, gdouble slice_angle,
GtkAnchorType anchor); GtkAnchorType anchor);
void gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool, GimpCanvasItem * gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool,
GimpHandleType type, GimpHandleType type,
gdouble x, gdouble x,
gdouble y, gdouble y,
gint width, gint width,
gint height, gint height,
GtkAnchorType anchor); GtkAnchorType anchor);
void gimp_draw_tool_draw_corner (GimpDrawTool *draw_tool, GimpCanvasItem * gimp_draw_tool_draw_corner (GimpDrawTool *draw_tool,
gboolean highlight, gboolean highlight,
gboolean put_outside, gboolean put_outside,
gdouble x1, gdouble x1,
@ -144,23 +144,23 @@ void gimp_draw_tool_draw_corner (GimpDrawTool *draw_tool,
gint width, gint width,
gint height, gint height,
GtkAnchorType anchor); GtkAnchorType anchor);
void gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool, GimpCanvasItem * gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool,
const GimpVector2 *points, const GimpVector2 *points,
gint n_points, gint n_points,
gboolean filled); gboolean filled);
void gimp_draw_tool_draw_strokes (GimpDrawTool *draw_tool, GimpCanvasItem * gimp_draw_tool_draw_strokes (GimpDrawTool *draw_tool,
const GimpCoords *points, const GimpCoords *points,
gint n_points, gint n_points,
gboolean filled); gboolean filled);
void gimp_draw_tool_draw_boundary (GimpDrawTool *draw_tool, GimpCanvasItem * gimp_draw_tool_draw_boundary (GimpDrawTool *draw_tool,
const BoundSeg *bound_segs, const BoundSeg *bound_segs,
gint n_bound_segs, gint n_bound_segs,
gdouble offset_x, gdouble offset_x,
gdouble offset_y); gdouble offset_y);
void gimp_draw_tool_draw_text_cursor (GimpDrawTool *draw_tool, GimpCanvasItem * gimp_draw_tool_draw_text_cursor (GimpDrawTool *draw_tool,
PangoRectangle *cursor, PangoRectangle *cursor,
gboolean overwrite); gboolean overwrite);