mirror of https://github.com/GNOME/gimp.git
app: add boolean "cancelable" API to GimpImageMap and gimpdrawable-filter.[ch]
Return booleans indicating success (FALSE == user has canceled), and allow canceling only in GimpImageMapTool for now.
This commit is contained in:
parent
9604eea1c7
commit
f4803af808
|
@ -82,13 +82,15 @@ gimp_drawable_has_filter (GimpDrawable *drawable,
|
|||
GIMP_OBJECT (filter));
|
||||
}
|
||||
|
||||
void
|
||||
gboolean
|
||||
gimp_drawable_merge_filter (GimpDrawable *drawable,
|
||||
GimpFilter *filter,
|
||||
GimpProgress *progress,
|
||||
const gchar *undo_desc)
|
||||
const gchar *undo_desc,
|
||||
gboolean cancelable)
|
||||
{
|
||||
GeglRectangle rect;
|
||||
gboolean success = TRUE;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
||||
g_return_if_fail (GIMP_IS_FILTER (filter));
|
||||
|
@ -141,7 +143,7 @@ gimp_drawable_merge_filter (GimpDrawable *drawable,
|
|||
gimp_drawable_get_buffer (drawable),
|
||||
&rect,
|
||||
cache, rects, n_rects,
|
||||
TRUE))
|
||||
cancelable))
|
||||
{
|
||||
gimp_drawable_push_undo (drawable, undo_desc, undo_buffer,
|
||||
rect.x, rect.y,
|
||||
|
@ -169,6 +171,9 @@ gimp_drawable_merge_filter (GimpDrawable *drawable,
|
|||
GEGL_RECTANGLE (0, 0, rect.width, rect.height),
|
||||
gimp_drawable_get_buffer (drawable),
|
||||
GEGL_RECTANGLE (rect.x, rect.y, 0, 0));
|
||||
|
||||
/* canceled by the user */
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
g_object_unref (undo_buffer);
|
||||
|
@ -183,4 +188,6 @@ gimp_drawable_merge_filter (GimpDrawable *drawable,
|
|||
rect.x, rect.y,
|
||||
rect.width, rect.height);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
|
|
@ -31,10 +31,11 @@ void gimp_drawable_remove_filter (GimpDrawable *drawable,
|
|||
gboolean gimp_drawable_has_filter (GimpDrawable *drawable,
|
||||
GimpFilter *filter);
|
||||
|
||||
void gimp_drawable_merge_filter (GimpDrawable *drawable,
|
||||
gboolean gimp_drawable_merge_filter (GimpDrawable *drawable,
|
||||
GimpFilter *filter,
|
||||
GimpProgress *progress,
|
||||
const gchar *undo_desc);
|
||||
const gchar *undo_desc,
|
||||
gboolean cancelable);
|
||||
|
||||
|
||||
#endif /* __GIMP_DRAWABLE_FILTER_H__ */
|
||||
|
|
|
@ -397,23 +397,30 @@ gimp_image_map_apply (GimpImageMap *image_map,
|
|||
gimp_image_map_update_drawable (image_map, &update_area);
|
||||
}
|
||||
|
||||
void
|
||||
gboolean
|
||||
gimp_image_map_commit (GimpImageMap *image_map,
|
||||
GimpProgress *progress)
|
||||
GimpProgress *progress,
|
||||
gboolean cancelable)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE_MAP (image_map));
|
||||
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
|
||||
|
||||
if (gimp_image_map_is_filtering (image_map))
|
||||
{
|
||||
gimp_drawable_merge_filter (image_map->drawable, image_map->filter,
|
||||
progress,
|
||||
image_map->undo_desc);
|
||||
success = gimp_drawable_merge_filter (image_map->drawable,
|
||||
image_map->filter,
|
||||
progress,
|
||||
image_map->undo_desc,
|
||||
cancelable);
|
||||
|
||||
gimp_image_map_remove_filter (image_map);
|
||||
|
||||
g_signal_emit (image_map, image_map_signals[FLUSH], 0);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -66,8 +66,9 @@ void gimp_image_map_set_gamma_hack (GimpImageMap *image_map,
|
|||
void gimp_image_map_apply (GimpImageMap *image_map,
|
||||
const GeglRectangle *area);
|
||||
|
||||
void gimp_image_map_commit (GimpImageMap *image_map,
|
||||
GimpProgress *progress);
|
||||
gboolean gimp_image_map_commit (GimpImageMap *image_map,
|
||||
GimpProgress *progress,
|
||||
gboolean cancelable);
|
||||
void gimp_image_map_abort (GimpImageMap *image_map);
|
||||
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ floating_sel_anchor (GimpLayer *layer)
|
|||
|
||||
if (filter)
|
||||
{
|
||||
gimp_drawable_merge_filter (drawable, filter, NULL, NULL);
|
||||
gimp_drawable_merge_filter (drawable, filter, NULL, NULL, FALSE);
|
||||
g_object_unref (filter);
|
||||
}
|
||||
|
||||
|
|
|
@ -944,8 +944,7 @@ gimp_cage_tool_commit (GimpCageTool *ct)
|
|||
|
||||
gimp_tool_control_push_preserve (tool->control, TRUE);
|
||||
|
||||
gimp_image_map_commit (ct->image_map,
|
||||
GIMP_PROGRESS (tool));
|
||||
gimp_image_map_commit (ct->image_map, GIMP_PROGRESS (tool), FALSE);
|
||||
g_object_unref (ct->image_map);
|
||||
ct->image_map = NULL;
|
||||
|
||||
|
|
|
@ -651,8 +651,7 @@ gimp_image_map_tool_commit (GimpImageMapTool *im_tool)
|
|||
if (! options->preview)
|
||||
gimp_image_map_tool_map (im_tool);
|
||||
|
||||
gimp_image_map_commit (im_tool->image_map,
|
||||
GIMP_PROGRESS (tool));
|
||||
gimp_image_map_commit (im_tool->image_map, GIMP_PROGRESS (tool), TRUE);
|
||||
g_object_unref (im_tool->image_map);
|
||||
im_tool->image_map = NULL;
|
||||
|
||||
|
|
|
@ -375,7 +375,7 @@ gimp_seamless_clone_tool_commit (GimpSeamlessCloneTool *sc)
|
|||
{
|
||||
gimp_tool_control_push_preserve (tool->control, TRUE);
|
||||
|
||||
gimp_image_map_commit (sc->image_map, GIMP_PROGRESS (tool));
|
||||
gimp_image_map_commit (sc->image_map, GIMP_PROGRESS (tool), FALSE);
|
||||
g_object_unref (sc->image_map);
|
||||
sc->image_map = NULL;
|
||||
|
||||
|
@ -525,7 +525,7 @@ gimp_seamless_clone_tool_key_press (GimpTool *tool,
|
|||
* rectangle each time (in the update function) or by
|
||||
* invalidating and re-rendering all now (expensive and
|
||||
* perhaps useless */
|
||||
gimp_image_map_commit (sct->image_map, GIMP_PROGRESS (tool));
|
||||
gimp_image_map_commit (sct->image_map, GIMP_PROGRESS (tool), FALSE);
|
||||
g_object_unref (sct->image_map);
|
||||
sct->image_map = NULL;
|
||||
|
||||
|
|
|
@ -614,7 +614,7 @@ gimp_warp_tool_commit (GimpWarpTool *wt)
|
|||
{
|
||||
gimp_tool_control_push_preserve (tool->control, TRUE);
|
||||
|
||||
gimp_image_map_commit (wt->image_map, GIMP_PROGRESS (tool));
|
||||
gimp_image_map_commit (wt->image_map, GIMP_PROGRESS (tool), FALSE);
|
||||
g_object_unref (wt->image_map);
|
||||
wt->image_map = NULL;
|
||||
|
||||
|
|
Loading…
Reference in New Issue