added GErrors to gimp_selection_extract() and gimp_selection_float().
2007-12-07 Michael Natterer <mitch@gimp.org> * app/core/gimpselection.[ch]: added GErrors to gimp_selection_extract() and gimp_selection_float(). * app/core/gimp-edit.c * app/tools/gimpeditselectiontool.c * app/actions/select-commands.c: handle the returned error. * app/core/gimpdrawable-transform.c: pass NULL errors since this file knows what it does and won't get errors. * tools/pdbgen/pdb/selection.pdb: pass the error. * app/pdb/selection_cmds.c: regenerated. svn path=/trunk/; revision=24286
This commit is contained in:

committed by
Michael Natterer

parent
021abe4a74
commit
58c2dd9bba
16
ChangeLog
16
ChangeLog
@ -1,3 +1,19 @@
|
|||||||
|
2007-12-07 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
* app/core/gimpselection.[ch]: added GErrors to
|
||||||
|
gimp_selection_extract() and gimp_selection_float().
|
||||||
|
|
||||||
|
* app/core/gimp-edit.c
|
||||||
|
* app/tools/gimpeditselectiontool.c
|
||||||
|
* app/actions/select-commands.c: handle the returned error.
|
||||||
|
|
||||||
|
* app/core/gimpdrawable-transform.c: pass NULL errors since this
|
||||||
|
file knows what it does and won't get errors.
|
||||||
|
|
||||||
|
* tools/pdbgen/pdb/selection.pdb: pass the error.
|
||||||
|
|
||||||
|
* app/pdb/selection_cmds.c: regenerated.
|
||||||
|
|
||||||
2007-12-07 Sven Neumann <sven@gimp.org>
|
2007-12-07 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* plug-ins/pygimp/gimpui.py (ColorSelector.__init__): accept a
|
* plug-ins/pygimp/gimpui.py (ColorSelector.__init__): accept a
|
||||||
|
@ -119,21 +119,22 @@ select_float_cmd_callback (GtkAction *action,
|
|||||||
{
|
{
|
||||||
GimpImage *image;
|
GimpImage *image;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
|
GError *error = NULL;
|
||||||
return_if_no_image (image, data);
|
return_if_no_image (image, data);
|
||||||
return_if_no_widget (widget, data);
|
return_if_no_widget (widget, data);
|
||||||
|
|
||||||
if (gimp_selection_float (gimp_image_get_mask (image),
|
if (gimp_selection_float (gimp_image_get_mask (image),
|
||||||
gimp_image_get_active_drawable (image),
|
gimp_image_get_active_drawable (image),
|
||||||
action_data_get_context (data),
|
action_data_get_context (data),
|
||||||
TRUE, 0, 0))
|
TRUE, 0, 0, &error))
|
||||||
{
|
{
|
||||||
gimp_image_flush (image);
|
gimp_image_flush (image);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
|
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
|
||||||
_("Cannot float selection because the selected region "
|
"%s", error->message);
|
||||||
"is empty."));
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,13 +535,21 @@ gimp_edit_extract (GimpImage *image,
|
|||||||
gboolean cut_pixels)
|
gboolean cut_pixels)
|
||||||
{
|
{
|
||||||
TileManager *tiles;
|
TileManager *tiles;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
if (cut_pixels)
|
if (cut_pixels)
|
||||||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_EDIT_CUT, _("Cut"));
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_EDIT_CUT, _("Cut"));
|
||||||
|
|
||||||
/* Cut/copy the mask portion from the image */
|
/* Cut/copy the mask portion from the image */
|
||||||
tiles = gimp_selection_extract (gimp_image_get_mask (image), pickable,
|
tiles = gimp_selection_extract (gimp_image_get_mask (image), pickable,
|
||||||
context, cut_pixels, FALSE, FALSE);
|
context, cut_pixels, FALSE, FALSE, &error);
|
||||||
|
|
||||||
|
if (! tiles)
|
||||||
|
{
|
||||||
|
gimp_message (image->gimp, NULL, GIMP_MESSAGE_WARNING,
|
||||||
|
"%s", error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
|
}
|
||||||
|
|
||||||
if (cut_pixels)
|
if (cut_pixels)
|
||||||
gimp_image_undo_group_end (image);
|
gimp_image_undo_group_end (image);
|
||||||
|
@ -789,7 +789,7 @@ gimp_drawable_transform_cut (GimpDrawable *drawable,
|
|||||||
{
|
{
|
||||||
tiles = gimp_selection_extract (gimp_image_get_mask (image),
|
tiles = gimp_selection_extract (gimp_image_get_mask (image),
|
||||||
GIMP_PICKABLE (drawable),
|
GIMP_PICKABLE (drawable),
|
||||||
context, TRUE, FALSE, TRUE);
|
context, TRUE, FALSE, TRUE, NULL);
|
||||||
|
|
||||||
*new_layer = TRUE;
|
*new_layer = TRUE;
|
||||||
}
|
}
|
||||||
@ -804,11 +804,11 @@ gimp_drawable_transform_cut (GimpDrawable *drawable,
|
|||||||
if (GIMP_IS_LAYER (drawable))
|
if (GIMP_IS_LAYER (drawable))
|
||||||
tiles = gimp_selection_extract (gimp_image_get_mask (image),
|
tiles = gimp_selection_extract (gimp_image_get_mask (image),
|
||||||
GIMP_PICKABLE (drawable),
|
GIMP_PICKABLE (drawable),
|
||||||
context, FALSE, TRUE, TRUE);
|
context, FALSE, TRUE, TRUE, NULL);
|
||||||
else
|
else
|
||||||
tiles = gimp_selection_extract (gimp_image_get_mask (image),
|
tiles = gimp_selection_extract (gimp_image_get_mask (image),
|
||||||
GIMP_PICKABLE (drawable),
|
GIMP_PICKABLE (drawable),
|
||||||
context, FALSE, TRUE, FALSE);
|
context, FALSE, TRUE, FALSE, NULL);
|
||||||
|
|
||||||
*new_layer = FALSE;
|
*new_layer = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -607,7 +607,8 @@ gimp_selection_extract (GimpChannel *selection,
|
|||||||
GimpContext *context,
|
GimpContext *context,
|
||||||
gboolean cut_image,
|
gboolean cut_image,
|
||||||
gboolean keep_indexed,
|
gboolean keep_indexed,
|
||||||
gboolean add_alpha)
|
gboolean add_alpha,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
GimpImage *image;
|
GimpImage *image;
|
||||||
TileManager *tiles;
|
TileManager *tiles;
|
||||||
@ -625,6 +626,7 @@ gimp_selection_extract (GimpChannel *selection,
|
|||||||
if (GIMP_IS_ITEM (pickable))
|
if (GIMP_IS_ITEM (pickable))
|
||||||
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (pickable)), NULL);
|
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (pickable)), NULL);
|
||||||
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
||||||
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||||
|
|
||||||
image = gimp_pickable_get_image (pickable);
|
image = gimp_pickable_get_image (pickable);
|
||||||
|
|
||||||
@ -643,9 +645,9 @@ gimp_selection_extract (GimpChannel *selection,
|
|||||||
|
|
||||||
if (non_empty && ((x1 == x2) || (y1 == y2)))
|
if (non_empty && ((x1 == x2) || (y1 == y2)))
|
||||||
{
|
{
|
||||||
gimp_message (image->gimp, NULL, GIMP_MESSAGE_WARNING,
|
g_set_error (error, 0, 0,
|
||||||
_("Unable to cut or copy because the "
|
_("Unable to cut or copy because the "
|
||||||
"selected region is empty."));
|
"selected region is empty."));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -797,12 +799,13 @@ gimp_selection_extract (GimpChannel *selection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GimpLayer *
|
GimpLayer *
|
||||||
gimp_selection_float (GimpChannel *selection,
|
gimp_selection_float (GimpChannel *selection,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
GimpContext *context,
|
GimpContext *context,
|
||||||
gboolean cut_image,
|
gboolean cut_image,
|
||||||
gint off_x,
|
gint off_x,
|
||||||
gint off_y)
|
gint off_y,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
GimpImage *image;
|
GimpImage *image;
|
||||||
GimpLayer *layer;
|
GimpLayer *layer;
|
||||||
@ -814,13 +817,19 @@ gimp_selection_float (GimpChannel *selection,
|
|||||||
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
||||||
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
|
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
|
||||||
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
||||||
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||||
|
|
||||||
image = gimp_item_get_image (GIMP_ITEM (selection));
|
image = gimp_item_get_image (GIMP_ITEM (selection));
|
||||||
|
|
||||||
/* Make sure there is a region to float... */
|
/* Make sure there is a region to float... */
|
||||||
if (! gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2) ||
|
if (! gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2) ||
|
||||||
(x1 == x2 || y1 == y2))
|
(x1 == x2 || y1 == y2))
|
||||||
return NULL;
|
{
|
||||||
|
g_set_error (error, 0, 0,
|
||||||
|
_("Cannot float selection because the selected region "
|
||||||
|
"is empty."));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Start an undo group */
|
/* Start an undo group */
|
||||||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_FS_FLOAT,
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_FS_FLOAT,
|
||||||
@ -828,7 +837,7 @@ gimp_selection_float (GimpChannel *selection,
|
|||||||
|
|
||||||
/* Cut or copy the selected region */
|
/* Cut or copy the selected region */
|
||||||
tiles = gimp_selection_extract (selection, GIMP_PICKABLE (drawable), context,
|
tiles = gimp_selection_extract (selection, GIMP_PICKABLE (drawable), context,
|
||||||
cut_image, FALSE, TRUE);
|
cut_image, FALSE, TRUE, NULL);
|
||||||
|
|
||||||
/* Clear the selection as if we had cut the pixels */
|
/* Clear the selection as if we had cut the pixels */
|
||||||
if (! cut_image)
|
if (! cut_image)
|
||||||
|
@ -48,27 +48,29 @@ struct _GimpSelectionClass
|
|||||||
|
|
||||||
GType gimp_selection_get_type (void) G_GNUC_CONST;
|
GType gimp_selection_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GimpChannel * gimp_selection_new (GimpImage *image,
|
GimpChannel * gimp_selection_new (GimpImage *image,
|
||||||
gint width,
|
gint width,
|
||||||
gint height);
|
gint height);
|
||||||
|
|
||||||
void gimp_selection_load (GimpChannel *selection,
|
void gimp_selection_load (GimpChannel *selection,
|
||||||
GimpChannel *channel);
|
GimpChannel *channel);
|
||||||
GimpChannel * gimp_selection_save (GimpChannel *selection);
|
GimpChannel * gimp_selection_save (GimpChannel *selection);
|
||||||
|
|
||||||
TileManager * gimp_selection_extract (GimpChannel *selection,
|
TileManager * gimp_selection_extract (GimpChannel *selection,
|
||||||
GimpPickable *pickable,
|
GimpPickable *pickable,
|
||||||
GimpContext *context,
|
GimpContext *context,
|
||||||
gboolean cut_image,
|
gboolean cut_image,
|
||||||
gboolean keep_indexed,
|
gboolean keep_indexed,
|
||||||
gboolean add_alpha);
|
gboolean add_alpha,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
GimpLayer * gimp_selection_float (GimpChannel *selection,
|
GimpLayer * gimp_selection_float (GimpChannel *selection,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
GimpContext *context,
|
GimpContext *context,
|
||||||
gboolean cut_image,
|
gboolean cut_image,
|
||||||
gint off_x,
|
gint off_x,
|
||||||
gint off_y);
|
gint off_y,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_SELECTION_H__ */
|
#endif /* __GIMP_SELECTION_H__ */
|
||||||
|
@ -191,7 +191,8 @@ selection_float_invoker (GimpProcedure *procedure,
|
|||||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||||
|
|
||||||
layer = gimp_selection_float (gimp_image_get_mask (image),
|
layer = gimp_selection_float (gimp_image_get_mask (image),
|
||||||
drawable, context, TRUE, offx, offy);
|
drawable, context, TRUE, offx, offy,
|
||||||
|
error);
|
||||||
if (! layer)
|
if (! layer)
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -562,7 +562,9 @@ gimp_edit_selection_tool_motion (GimpTool *tool,
|
|||||||
/* if there has been movement, move the selection */
|
/* if there has been movement, move the selection */
|
||||||
if (edit_select->origx != x || edit_select->origy != y)
|
if (edit_select->origx != x || edit_select->origy != y)
|
||||||
{
|
{
|
||||||
gint xoffset, yoffset;
|
gint xoffset;
|
||||||
|
gint yoffset;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
xoffset = x - edit_select->origx;
|
xoffset = x - edit_select->origx;
|
||||||
yoffset = y - edit_select->origy;
|
yoffset = y - edit_select->origy;
|
||||||
@ -623,9 +625,13 @@ gimp_edit_selection_tool_motion (GimpTool *tool,
|
|||||||
gimp_get_user_context (display->image->gimp),
|
gimp_get_user_context (display->image->gimp),
|
||||||
edit_select->edit_mode ==
|
edit_select->edit_mode ==
|
||||||
GIMP_TRANSLATE_MODE_MASK_TO_LAYER,
|
GIMP_TRANSLATE_MODE_MASK_TO_LAYER,
|
||||||
0, 0))
|
0, 0, &error))
|
||||||
{
|
{
|
||||||
/* no region to float, abort safely */
|
/* no region to float, abort safely */
|
||||||
|
gimp_message (display->image->gimp, G_OBJECT (display),
|
||||||
|
GIMP_MESSAGE_WARNING,
|
||||||
|
"%s", error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -189,7 +189,8 @@ HELP
|
|||||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||||
|
|
||||||
layer = gimp_selection_float (gimp_image_get_mask (image),
|
layer = gimp_selection_float (gimp_image_get_mask (image),
|
||||||
drawable, context, TRUE, offx, offy);
|
drawable, context, TRUE, offx, offy,
|
||||||
|
error);
|
||||||
if (! layer)
|
if (! layer)
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user