added GErrors when functions can fail.
2007-12-14 Michael Natterer <mitch@gimp.org> * app/core/gimp-edit.[ch]: added GErrors when functions can fail. * app/actions/edit-commands.c: handle the returned errors. * tools/pdbgen/pdb/edit.pdb: same here (*don't* pass the error as usual since these functions never fail but have a boolean return value indicating success instead; ugly, but better than having the gimp_message() calls in the core). Also changed the named buffer cut and copy functions to do the same (never fail but return a NULL buffer name on failure), so they behave as documented. * app/pdb/edit_cmds.c: regenerated. svn path=/trunk/; revision=24362
This commit is contained in:

committed by
Michael Natterer

parent
146067d737
commit
db553767cd
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
|||||||
|
2007-12-14 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
* app/core/gimp-edit.[ch]: added GErrors when functions can fail.
|
||||||
|
|
||||||
|
* app/actions/edit-commands.c: handle the returned errors.
|
||||||
|
|
||||||
|
* tools/pdbgen/pdb/edit.pdb: same here (*don't* pass the error as
|
||||||
|
usual since these functions never fail but have a boolean return
|
||||||
|
value indicating success instead; ugly, but better than having the
|
||||||
|
gimp_message() calls in the core). Also changed the named buffer
|
||||||
|
cut and copy functions to do the same (never fail but return a
|
||||||
|
NULL buffer name on failure), so they behave as documented.
|
||||||
|
|
||||||
|
* app/pdb/edit_cmds.c: regenerated.
|
||||||
|
|
||||||
2007-12-14 Sven Neumann <sven@gimp.org>
|
2007-12-14 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/base/tile-pyramid.c: reduced rounding errors.
|
* app/base/tile-pyramid.c: reduced rounding errors.
|
||||||
|
@ -188,10 +188,19 @@ edit_cut_cmd_callback (GtkAction *action,
|
|||||||
{
|
{
|
||||||
GimpImage *image;
|
GimpImage *image;
|
||||||
GimpDrawable *drawable;
|
GimpDrawable *drawable;
|
||||||
|
GError *error = NULL;
|
||||||
return_if_no_drawable (image, drawable, data);
|
return_if_no_drawable (image, drawable, data);
|
||||||
|
|
||||||
if (gimp_edit_cut (image, drawable, action_data_get_context (data)))
|
if (gimp_edit_cut (image, drawable, action_data_get_context (data), &error))
|
||||||
gimp_image_flush (image);
|
{
|
||||||
|
gimp_image_flush (image);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gimp_message (image->gimp, G_OBJECT (action_data_get_display (data)),
|
||||||
|
GIMP_MESSAGE_WARNING, "%s", error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -200,9 +209,10 @@ edit_copy_cmd_callback (GtkAction *action,
|
|||||||
{
|
{
|
||||||
GimpImage *image;
|
GimpImage *image;
|
||||||
GimpDrawable *drawable;
|
GimpDrawable *drawable;
|
||||||
|
GError *error = NULL;
|
||||||
return_if_no_drawable (image, drawable, data);
|
return_if_no_drawable (image, drawable, data);
|
||||||
|
|
||||||
if (gimp_edit_copy (image, drawable, action_data_get_context (data)))
|
if (gimp_edit_copy (image, drawable, action_data_get_context (data), &error))
|
||||||
{
|
{
|
||||||
GimpDisplay *display = action_data_get_display (data);
|
GimpDisplay *display = action_data_get_display (data);
|
||||||
|
|
||||||
@ -212,6 +222,12 @@ edit_copy_cmd_callback (GtkAction *action,
|
|||||||
|
|
||||||
gimp_image_flush (image);
|
gimp_image_flush (image);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gimp_message (image->gimp, G_OBJECT (action_data_get_display (data)),
|
||||||
|
GIMP_MESSAGE_WARNING, "%s", error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -219,10 +235,19 @@ edit_copy_visible_cmd_callback (GtkAction *action,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpImage *image;
|
GimpImage *image;
|
||||||
|
GError *error = NULL;
|
||||||
return_if_no_image (image, data);
|
return_if_no_image (image, data);
|
||||||
|
|
||||||
if (gimp_edit_copy_visible (image, action_data_get_context (data)))
|
if (gimp_edit_copy_visible (image, action_data_get_context (data), &error))
|
||||||
gimp_image_flush (image);
|
{
|
||||||
|
gimp_image_flush (image);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gimp_message (image->gimp, G_OBJECT (action_data_get_display (data)),
|
||||||
|
GIMP_MESSAGE_WARNING, "%s", error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -463,6 +488,7 @@ cut_named_buffer_callback (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GimpImage *image = GIMP_IMAGE (data);
|
GimpImage *image = GIMP_IMAGE (data);
|
||||||
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
if (! drawable)
|
if (! drawable)
|
||||||
{
|
{
|
||||||
@ -475,10 +501,16 @@ cut_named_buffer_callback (GtkWidget *widget,
|
|||||||
name = _("(Unnamed Buffer)");
|
name = _("(Unnamed Buffer)");
|
||||||
|
|
||||||
if (gimp_edit_named_cut (image, name, drawable,
|
if (gimp_edit_named_cut (image, name, drawable,
|
||||||
gimp_get_user_context (image->gimp)))
|
gimp_get_user_context (image->gimp), &error))
|
||||||
{
|
{
|
||||||
gimp_image_flush (image);
|
gimp_image_flush (image);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gimp_message (image->gimp, NULL, GIMP_MESSAGE_WARNING,
|
||||||
|
"%s", error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -488,6 +520,7 @@ copy_named_buffer_callback (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GimpImage *image = GIMP_IMAGE (data);
|
GimpImage *image = GIMP_IMAGE (data);
|
||||||
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
if (! drawable)
|
if (! drawable)
|
||||||
{
|
{
|
||||||
@ -500,10 +533,16 @@ copy_named_buffer_callback (GtkWidget *widget,
|
|||||||
name = _("(Unnamed Buffer)");
|
name = _("(Unnamed Buffer)");
|
||||||
|
|
||||||
if (gimp_edit_named_copy (image, name, drawable,
|
if (gimp_edit_named_copy (image, name, drawable,
|
||||||
gimp_get_user_context (image->gimp)))
|
gimp_get_user_context (image->gimp), &error))
|
||||||
{
|
{
|
||||||
gimp_image_flush (image);
|
gimp_image_flush (image);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gimp_message (image->gimp, NULL, GIMP_MESSAGE_WARNING,
|
||||||
|
"%s", error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -512,13 +551,21 @@ copy_named_visible_buffer_callback (GtkWidget *widget,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpImage *image = GIMP_IMAGE (data);
|
GimpImage *image = GIMP_IMAGE (data);
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
if (! (name && strlen (name)))
|
if (! (name && strlen (name)))
|
||||||
name = _("(Unnamed Buffer)");
|
name = _("(Unnamed Buffer)");
|
||||||
|
|
||||||
if (gimp_edit_named_copy_visible (image, name,
|
if (gimp_edit_named_copy_visible (image, name,
|
||||||
gimp_get_user_context (image->gimp)))
|
gimp_get_user_context (image->gimp),
|
||||||
|
&error))
|
||||||
{
|
{
|
||||||
gimp_image_flush (image);
|
gimp_image_flush (image);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gimp_message (image->gimp, NULL, GIMP_MESSAGE_WARNING,
|
||||||
|
"%s", error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,8 @@
|
|||||||
static GimpBuffer * gimp_edit_extract (GimpImage *image,
|
static GimpBuffer * gimp_edit_extract (GimpImage *image,
|
||||||
GimpPickable *pickable,
|
GimpPickable *pickable,
|
||||||
GimpContext *context,
|
GimpContext *context,
|
||||||
gboolean cut_pixels);
|
gboolean cut_pixels,
|
||||||
|
GError **error);
|
||||||
static GimpBuffer * gimp_edit_make_buffer (Gimp *gimp,
|
static GimpBuffer * gimp_edit_make_buffer (Gimp *gimp,
|
||||||
TileManager *tiles);
|
TileManager *tiles);
|
||||||
static gboolean gimp_edit_fill_internal (GimpImage *image,
|
static gboolean gimp_edit_fill_internal (GimpImage *image,
|
||||||
@ -71,9 +72,10 @@ static gboolean gimp_edit_fill_internal (GimpImage *image,
|
|||||||
/* public functions */
|
/* public functions */
|
||||||
|
|
||||||
const GimpBuffer *
|
const GimpBuffer *
|
||||||
gimp_edit_cut (GimpImage *image,
|
gimp_edit_cut (GimpImage *image,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
GimpContext *context)
|
GimpContext *context,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
GimpBuffer *buffer;
|
GimpBuffer *buffer;
|
||||||
|
|
||||||
@ -81,9 +83,10 @@ gimp_edit_cut (GimpImage *image,
|
|||||||
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);
|
||||||
|
|
||||||
buffer = gimp_edit_extract (image, GIMP_PICKABLE (drawable),
|
buffer = gimp_edit_extract (image, GIMP_PICKABLE (drawable),
|
||||||
context, TRUE);
|
context, TRUE, error);
|
||||||
|
|
||||||
if (buffer)
|
if (buffer)
|
||||||
{
|
{
|
||||||
@ -97,9 +100,10 @@ gimp_edit_cut (GimpImage *image,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const GimpBuffer *
|
const GimpBuffer *
|
||||||
gimp_edit_copy (GimpImage *image,
|
gimp_edit_copy (GimpImage *image,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
GimpContext *context)
|
GimpContext *context,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
GimpBuffer *buffer;
|
GimpBuffer *buffer;
|
||||||
|
|
||||||
@ -107,9 +111,10 @@ gimp_edit_copy (GimpImage *image,
|
|||||||
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);
|
||||||
|
|
||||||
buffer = gimp_edit_extract (image, GIMP_PICKABLE (drawable),
|
buffer = gimp_edit_extract (image, GIMP_PICKABLE (drawable),
|
||||||
context, FALSE);
|
context, FALSE, error);
|
||||||
|
|
||||||
if (buffer)
|
if (buffer)
|
||||||
{
|
{
|
||||||
@ -123,16 +128,18 @@ gimp_edit_copy (GimpImage *image,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const GimpBuffer *
|
const GimpBuffer *
|
||||||
gimp_edit_copy_visible (GimpImage *image,
|
gimp_edit_copy_visible (GimpImage *image,
|
||||||
GimpContext *context)
|
GimpContext *context,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
GimpBuffer *buffer;
|
GimpBuffer *buffer;
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), 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);
|
||||||
|
|
||||||
buffer = gimp_edit_extract (image, GIMP_PICKABLE (image->projection),
|
buffer = gimp_edit_extract (image, GIMP_PICKABLE (image->projection),
|
||||||
context, FALSE);
|
context, FALSE, error);
|
||||||
|
|
||||||
if (buffer)
|
if (buffer)
|
||||||
{
|
{
|
||||||
@ -331,10 +338,11 @@ gimp_edit_paste_as_new (Gimp *gimp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
gimp_edit_named_cut (GimpImage *image,
|
gimp_edit_named_cut (GimpImage *image,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
GimpContext *context)
|
GimpContext *context,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
GimpBuffer *buffer;
|
GimpBuffer *buffer;
|
||||||
|
|
||||||
@ -343,9 +351,10 @@ gimp_edit_named_cut (GimpImage *image,
|
|||||||
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);
|
||||||
|
|
||||||
buffer = gimp_edit_extract (image, GIMP_PICKABLE (drawable),
|
buffer = gimp_edit_extract (image, GIMP_PICKABLE (drawable),
|
||||||
context, TRUE);
|
context, TRUE, error);
|
||||||
|
|
||||||
if (buffer)
|
if (buffer)
|
||||||
{
|
{
|
||||||
@ -360,10 +369,11 @@ gimp_edit_named_cut (GimpImage *image,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
gimp_edit_named_copy (GimpImage *image,
|
gimp_edit_named_copy (GimpImage *image,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
GimpContext *context)
|
GimpContext *context,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
GimpBuffer *buffer;
|
GimpBuffer *buffer;
|
||||||
|
|
||||||
@ -372,9 +382,10 @@ gimp_edit_named_copy (GimpImage *image,
|
|||||||
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);
|
||||||
|
|
||||||
buffer = gimp_edit_extract (image, GIMP_PICKABLE (drawable),
|
buffer = gimp_edit_extract (image, GIMP_PICKABLE (drawable),
|
||||||
context, FALSE);
|
context, FALSE, error);
|
||||||
|
|
||||||
if (buffer)
|
if (buffer)
|
||||||
{
|
{
|
||||||
@ -389,18 +400,20 @@ gimp_edit_named_copy (GimpImage *image,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
gimp_edit_named_copy_visible (GimpImage *image,
|
gimp_edit_named_copy_visible (GimpImage *image,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
GimpContext *context)
|
GimpContext *context,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
GimpBuffer *buffer;
|
GimpBuffer *buffer;
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||||
g_return_val_if_fail (name != NULL, NULL);
|
g_return_val_if_fail (name != NULL, 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);
|
||||||
|
|
||||||
buffer = gimp_edit_extract (image, GIMP_PICKABLE (image->projection),
|
buffer = gimp_edit_extract (image, GIMP_PICKABLE (image->projection),
|
||||||
context, FALSE);
|
context, FALSE, error);
|
||||||
|
|
||||||
if (buffer)
|
if (buffer)
|
||||||
{
|
{
|
||||||
@ -529,27 +542,20 @@ gimp_edit_fade (GimpImage *image,
|
|||||||
/* private functions */
|
/* private functions */
|
||||||
|
|
||||||
static GimpBuffer *
|
static GimpBuffer *
|
||||||
gimp_edit_extract (GimpImage *image,
|
gimp_edit_extract (GimpImage *image,
|
||||||
GimpPickable *pickable,
|
GimpPickable *pickable,
|
||||||
GimpContext *context,
|
GimpContext *context,
|
||||||
gboolean cut_pixels)
|
gboolean cut_pixels,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
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, &error);
|
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);
|
||||||
|
@ -20,48 +20,54 @@
|
|||||||
#define __GIMP_EDIT_H__
|
#define __GIMP_EDIT_H__
|
||||||
|
|
||||||
|
|
||||||
const GimpBuffer * gimp_edit_cut (GimpImage *image,
|
const GimpBuffer * gimp_edit_cut (GimpImage *image,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
GimpContext *context);
|
GimpContext *context,
|
||||||
const GimpBuffer * gimp_edit_copy (GimpImage *image,
|
GError **error);
|
||||||
GimpDrawable *drawable,
|
const GimpBuffer * gimp_edit_copy (GimpImage *image,
|
||||||
GimpContext *context);
|
GimpDrawable *drawable,
|
||||||
const GimpBuffer * gimp_edit_copy_visible (GimpImage *image,
|
GimpContext *context,
|
||||||
GimpContext *context);
|
GError **error);
|
||||||
GimpLayer * gimp_edit_paste (GimpImage *image,
|
const GimpBuffer * gimp_edit_copy_visible (GimpImage *image,
|
||||||
GimpDrawable *drawable,
|
GimpContext *context,
|
||||||
GimpBuffer *paste,
|
GError **error);
|
||||||
gboolean paste_into,
|
GimpLayer * gimp_edit_paste (GimpImage *image,
|
||||||
gint viewport_x,
|
GimpDrawable *drawable,
|
||||||
gint viewport_y,
|
GimpBuffer *paste,
|
||||||
gint viewport_width,
|
gboolean paste_into,
|
||||||
gint viewport_height);
|
gint viewport_x,
|
||||||
GimpImage * gimp_edit_paste_as_new (Gimp *gimp,
|
gint viewport_y,
|
||||||
GimpImage *image,
|
gint viewport_width,
|
||||||
GimpBuffer *paste);
|
gint viewport_height);
|
||||||
|
GimpImage * gimp_edit_paste_as_new (Gimp *gimp,
|
||||||
|
GimpImage *image,
|
||||||
|
GimpBuffer *paste);
|
||||||
|
|
||||||
const gchar * gimp_edit_named_cut (GimpImage *image,
|
const gchar * gimp_edit_named_cut (GimpImage *image,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
GimpContext *context);
|
GimpContext *context,
|
||||||
const gchar * gimp_edit_named_copy (GimpImage *image,
|
GError **error);
|
||||||
const gchar *name,
|
const gchar * gimp_edit_named_copy (GimpImage *image,
|
||||||
GimpDrawable *drawable,
|
const gchar *name,
|
||||||
GimpContext *context);
|
GimpDrawable *drawable,
|
||||||
const gchar * gimp_edit_named_copy_visible (GimpImage *image,
|
GimpContext *context,
|
||||||
const gchar *name,
|
GError **error);
|
||||||
GimpContext *context);
|
const gchar * gimp_edit_named_copy_visible (GimpImage *image,
|
||||||
|
const gchar *name,
|
||||||
|
GimpContext *context,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
gboolean gimp_edit_clear (GimpImage *image,
|
gboolean gimp_edit_clear (GimpImage *image,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
GimpContext *context);
|
GimpContext *context);
|
||||||
gboolean gimp_edit_fill (GimpImage *image,
|
gboolean gimp_edit_fill (GimpImage *image,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
GimpContext *context,
|
GimpContext *context,
|
||||||
GimpFillType fill_type);
|
GimpFillType fill_type);
|
||||||
|
|
||||||
gboolean gimp_edit_fade (GimpImage *image,
|
gboolean gimp_edit_fade (GimpImage *image,
|
||||||
GimpContext *context);
|
GimpContext *context);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_EDIT_H__ */
|
#endif /* __GIMP_EDIT_H__ */
|
||||||
|
@ -65,9 +65,17 @@ edit_cut_invoker (GimpProcedure *procedure,
|
|||||||
{
|
{
|
||||||
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
|
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
|
||||||
{
|
{
|
||||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||||
|
GError *my_error = NULL;
|
||||||
|
|
||||||
non_empty = gimp_edit_cut (image, drawable, context) != NULL;
|
non_empty = gimp_edit_cut (image, drawable, context, &my_error) != NULL;
|
||||||
|
|
||||||
|
if (! non_empty)
|
||||||
|
{
|
||||||
|
gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_WARNING,
|
||||||
|
"%s", my_error->message);
|
||||||
|
g_clear_error (&my_error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
@ -100,9 +108,17 @@ edit_copy_invoker (GimpProcedure *procedure,
|
|||||||
{
|
{
|
||||||
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
|
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
|
||||||
{
|
{
|
||||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||||
|
GError *my_error = NULL;
|
||||||
|
|
||||||
non_empty = gimp_edit_copy (image, drawable, context) != NULL;
|
non_empty = gimp_edit_copy (image, drawable, context, &my_error) != NULL;
|
||||||
|
|
||||||
|
if (! non_empty)
|
||||||
|
{
|
||||||
|
gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_WARNING,
|
||||||
|
"%s", my_error->message);
|
||||||
|
g_clear_error (&my_error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
@ -133,7 +149,16 @@ edit_copy_visible_invoker (GimpProcedure *procedure,
|
|||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
non_empty = gimp_edit_copy_visible (image, context) != NULL;
|
GError *my_error = NULL;
|
||||||
|
|
||||||
|
non_empty = gimp_edit_copy_visible (image, context, &my_error) != NULL;
|
||||||
|
|
||||||
|
if (! non_empty)
|
||||||
|
{
|
||||||
|
gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_WARNING,
|
||||||
|
"%s", my_error->message);
|
||||||
|
g_clear_error (&my_error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return_vals = gimp_procedure_get_return_values (procedure, success);
|
return_vals = gimp_procedure_get_return_values (procedure, success);
|
||||||
@ -237,15 +262,22 @@ edit_named_cut_invoker (GimpProcedure *procedure,
|
|||||||
{
|
{
|
||||||
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
|
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
|
||||||
{
|
{
|
||||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||||
|
GError *my_error = NULL;
|
||||||
|
|
||||||
real_name = (gchar *) gimp_edit_named_cut (image, buffer_name,
|
real_name = (gchar *) gimp_edit_named_cut (image, buffer_name,
|
||||||
drawable, context);
|
drawable, context, &my_error);
|
||||||
|
|
||||||
if (real_name)
|
if (real_name)
|
||||||
real_name = g_strdup (real_name);
|
{
|
||||||
else
|
real_name = g_strdup (real_name);
|
||||||
success = FALSE;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_WARNING,
|
||||||
|
"%s", my_error->message);
|
||||||
|
g_clear_error (&my_error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
@ -280,15 +312,22 @@ edit_named_copy_invoker (GimpProcedure *procedure,
|
|||||||
{
|
{
|
||||||
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
|
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
|
||||||
{
|
{
|
||||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||||
|
GError *my_error = NULL;
|
||||||
|
|
||||||
real_name = (gchar *) gimp_edit_named_copy (image, buffer_name,
|
real_name = (gchar *) gimp_edit_named_copy (image, buffer_name,
|
||||||
drawable, context);
|
drawable, context, &my_error);
|
||||||
|
|
||||||
if (real_name)
|
if (real_name)
|
||||||
real_name = g_strdup (real_name);
|
{
|
||||||
else
|
real_name = g_strdup (real_name);
|
||||||
success = FALSE;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_WARNING,
|
||||||
|
"%s", my_error->message);
|
||||||
|
g_clear_error (&my_error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
@ -321,13 +360,21 @@ edit_named_copy_visible_invoker (GimpProcedure *procedure,
|
|||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
|
GError *my_error = NULL;
|
||||||
|
|
||||||
real_name = (gchar *) gimp_edit_named_copy_visible (image, buffer_name,
|
real_name = (gchar *) gimp_edit_named_copy_visible (image, buffer_name,
|
||||||
context);
|
context, &my_error);
|
||||||
|
|
||||||
if (real_name)
|
if (real_name)
|
||||||
real_name = g_strdup (real_name);
|
{
|
||||||
|
real_name = g_strdup (real_name);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
success = FALSE;
|
{
|
||||||
|
gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_WARNING,
|
||||||
|
"%s", my_error->message);
|
||||||
|
g_clear_error (&my_error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return_vals = gimp_procedure_get_return_values (procedure, success);
|
return_vals = gimp_procedure_get_return_values (procedure, success);
|
||||||
@ -984,7 +1031,7 @@ register_edit_procs (GimpPDB *pdb)
|
|||||||
gimp_procedure_add_return_value (procedure,
|
gimp_procedure_add_return_value (procedure,
|
||||||
gimp_param_spec_string ("real-name",
|
gimp_param_spec_string ("real-name",
|
||||||
"real name",
|
"real name",
|
||||||
"The real name given to the buffer",
|
"The real name given to the buffer, or NULL if the selection contained only transparent pixels",
|
||||||
FALSE, FALSE, FALSE,
|
FALSE, FALSE, FALSE,
|
||||||
NULL,
|
NULL,
|
||||||
GIMP_PARAM_READWRITE));
|
GIMP_PARAM_READWRITE));
|
||||||
|
@ -47,9 +47,17 @@ HELP
|
|||||||
{
|
{
|
||||||
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
|
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
|
||||||
{
|
{
|
||||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||||
|
GError *my_error = NULL;
|
||||||
|
|
||||||
non_empty = gimp_edit_cut (image, drawable, context) != NULL;
|
non_empty = gimp_edit_cut (image, drawable, context, &my_error) != NULL;
|
||||||
|
|
||||||
|
if (! non_empty)
|
||||||
|
{
|
||||||
|
gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_WARNING,
|
||||||
|
"%s", my_error->message);
|
||||||
|
g_clear_error (&my_error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
@ -88,9 +96,17 @@ HELP
|
|||||||
{
|
{
|
||||||
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
|
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
|
||||||
{
|
{
|
||||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||||
|
GError *my_error = NULL;
|
||||||
|
|
||||||
non_empty = gimp_edit_copy (image, drawable, context) != NULL;
|
non_empty = gimp_edit_copy (image, drawable, context, &my_error) != NULL;
|
||||||
|
|
||||||
|
if (! non_empty)
|
||||||
|
{
|
||||||
|
gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_WARNING,
|
||||||
|
"%s", my_error->message);
|
||||||
|
g_clear_error (&my_error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
@ -126,7 +142,16 @@ HELP
|
|||||||
%invoke = (
|
%invoke = (
|
||||||
code => <<CODE
|
code => <<CODE
|
||||||
{
|
{
|
||||||
non_empty = gimp_edit_copy_visible (image, context) != NULL;
|
GError *my_error = NULL;
|
||||||
|
|
||||||
|
non_empty = gimp_edit_copy_visible (image, context, &my_error) != NULL;
|
||||||
|
|
||||||
|
if (! non_empty)
|
||||||
|
{
|
||||||
|
gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_WARNING,
|
||||||
|
"%s", my_error->message);
|
||||||
|
g_clear_error (&my_error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
CODE
|
CODE
|
||||||
);
|
);
|
||||||
@ -248,15 +273,22 @@ HELP
|
|||||||
{
|
{
|
||||||
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
|
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
|
||||||
{
|
{
|
||||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||||
|
GError *my_error = NULL;
|
||||||
|
|
||||||
real_name = (gchar *) gimp_edit_named_cut (image, buffer_name,
|
real_name = (gchar *) gimp_edit_named_cut (image, buffer_name,
|
||||||
drawable, context);
|
drawable, context, &my_error);
|
||||||
|
|
||||||
if (real_name)
|
if (real_name)
|
||||||
real_name = g_strdup (real_name);
|
{
|
||||||
else
|
real_name = g_strdup (real_name);
|
||||||
success = FALSE;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_WARNING,
|
||||||
|
"%s", my_error->message);
|
||||||
|
g_clear_error (&my_error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
@ -293,15 +325,22 @@ HELP
|
|||||||
{
|
{
|
||||||
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
|
if (gimp_item_is_attached (GIMP_ITEM (drawable)))
|
||||||
{
|
{
|
||||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||||
|
GError *my_error = NULL;
|
||||||
|
|
||||||
real_name = (gchar *) gimp_edit_named_copy (image, buffer_name,
|
real_name = (gchar *) gimp_edit_named_copy (image, buffer_name,
|
||||||
drawable, context);
|
drawable, context, &my_error);
|
||||||
|
|
||||||
if (real_name)
|
if (real_name)
|
||||||
real_name = g_strdup (real_name);
|
{
|
||||||
else
|
real_name = g_strdup (real_name);
|
||||||
success = FALSE;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_WARNING,
|
||||||
|
"%s", my_error->message);
|
||||||
|
g_clear_error (&my_error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
@ -331,19 +370,28 @@ HELP
|
|||||||
|
|
||||||
@outargs = (
|
@outargs = (
|
||||||
{ name => 'real_name', type => 'string',
|
{ name => 'real_name', type => 'string',
|
||||||
desc => 'The real name given to the buffer' }
|
desc => 'The real name given to the buffer, or NULL if the
|
||||||
|
selection contained only transparent pixels' }
|
||||||
);
|
);
|
||||||
|
|
||||||
%invoke = (
|
%invoke = (
|
||||||
code => <<CODE
|
code => <<CODE
|
||||||
{
|
{
|
||||||
|
GError *my_error = NULL;
|
||||||
|
|
||||||
real_name = (gchar *) gimp_edit_named_copy_visible (image, buffer_name,
|
real_name = (gchar *) gimp_edit_named_copy_visible (image, buffer_name,
|
||||||
context);
|
context, &my_error);
|
||||||
|
|
||||||
if (real_name)
|
if (real_name)
|
||||||
real_name = g_strdup (real_name);
|
{
|
||||||
|
real_name = g_strdup (real_name);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
success = FALSE;
|
{
|
||||||
|
gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_WARNING,
|
||||||
|
"%s", my_error->message);
|
||||||
|
g_clear_error (&my_error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
CODE
|
CODE
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user