don't create a display here.

2005-09-03  Michael Natterer  <mitch@gimp.org>

	* app/core/gimp-edit.[ch] (gimp_edit_paste_as_new): don't create a
	display here.

	(gimp_edit_named_cut)
	(gimp_edit_named_copy)
	(gimp_edit_named_copy_visible): new functions containing named
	buffer wrappers around the functions affecting the global buffer
	only.

	* app/actions/edit-commands.c: use the new functions instead of
	implementing them here, create a display for the image returned
	by paste as new.

	* app/actions/buffers-commands.c
	* app/widgets/gimptoolbox-dnd.c: create displays here too.

	* tools/pdbgen/pdb/edit.pdb: added wrappers for paste as new and
	wrappers for all the cut/copy/paste named stuff.
	Fixes bug #315130. Cleaned up and de-obfuscated.

	* libgimp/gimp.def: changed accordingly.

	* app/pdb/edit_cmds.c
	* app/pdb/internal_procs.c
	* libgimp/gimpedit_pdb.[ch]: regenerated.
This commit is contained in:
Michael Natterer 2005-09-02 22:50:06 +00:00 committed by Michael Natterer
parent 5f2904f9c5
commit 89bb3fffa1
12 changed files with 1345 additions and 208 deletions

View File

@ -1,3 +1,31 @@
2005-09-03 Michael Natterer <mitch@gimp.org>
* app/core/gimp-edit.[ch] (gimp_edit_paste_as_new): don't create a
display here.
(gimp_edit_named_cut)
(gimp_edit_named_copy)
(gimp_edit_named_copy_visible): new functions containing named
buffer wrappers around the functions affecting the global buffer
only.
* app/actions/edit-commands.c: use the new functions instead of
implementing them here, create a display for the image returned
by paste as new.
* app/actions/buffers-commands.c
* app/widgets/gimptoolbox-dnd.c: create displays here too.
* tools/pdbgen/pdb/edit.pdb: added wrappers for paste as new and
wrappers for all the cut/copy/paste named stuff.
Fixes bug #315130. Cleaned up and de-obfuscated.
* libgimp/gimp.def: changed accordingly.
* app/pdb/edit_cmds.c
* app/pdb/internal_procs.c
* libgimp/gimpedit_pdb.[ch]: regenerated.
2005-09-02 Sven Neumann <sven@gimp.org>
* app/widgets/gimpcontainergridview.c

View File

@ -22,6 +22,7 @@
#include "actions-types.h"
#include "core/gimp.h"
#include "core/gimp-edit.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
@ -77,10 +78,21 @@ buffers_paste_as_new_cmd_callback (GtkAction *action,
if (buffer && gimp_container_have (container, GIMP_OBJECT (buffer)))
{
GimpImage *gimage = gimp_context_get_image (context);
GimpImage *image = gimp_context_get_image (context);
if (gimage)
gimp_edit_paste_as_new (gimage->gimp, gimage, buffer);
if (image)
{
GimpImage *new_image;
new_image = gimp_edit_paste_as_new (image->gimp, image, buffer);
if (new_image)
{
gimp_create_display (image->gimp, new_image,
GIMP_UNIT_PIXEL, 1.0);
g_object_unref (new_image);
}
}
}
}

View File

@ -225,7 +225,16 @@ edit_paste_as_new_cmd_callback (GtkAction *action,
if (buffer)
{
gimp_edit_paste_as_new (gimp, action_data_get_image (data), buffer);
GimpImage *image;
image = gimp_edit_paste_as_new (gimp, action_data_get_image (data),
buffer);
if (image)
{
gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0);
g_object_unref (image);
}
g_object_unref (buffer);
}
@ -366,9 +375,8 @@ cut_named_buffer_callback (GtkWidget *widget,
const gchar *name,
gpointer data)
{
GimpImage *gimage = GIMP_IMAGE (data);
const GimpBuffer *cut_buffer;
GimpDrawable *drawable;
GimpImage *gimage = GIMP_IMAGE (data);
GimpDrawable *drawable;
drawable = gimp_image_active_drawable (gimage);
@ -378,22 +386,12 @@ cut_named_buffer_callback (GtkWidget *widget,
return;
}
cut_buffer = gimp_edit_cut (gimage, drawable,
gimp_get_user_context (gimage->gimp));
if (! (name && strlen (name)))
name = _("(Unnamed Buffer)");
if (cut_buffer)
if (gimp_edit_named_cut (gimage, name, drawable,
gimp_get_user_context (gimage->gimp)))
{
GimpBuffer *new_buffer;
if (! (name && strlen (name)))
name = _("(Unnamed Buffer)");
new_buffer = gimp_buffer_new (cut_buffer->tiles, name, TRUE);
gimp_container_add (gimage->gimp->named_buffers,
GIMP_OBJECT (new_buffer));
g_object_unref (new_buffer);
gimp_image_flush (gimage);
}
}
@ -403,9 +401,8 @@ copy_named_buffer_callback (GtkWidget *widget,
const gchar *name,
gpointer data)
{
GimpImage *gimage = GIMP_IMAGE (data);
const GimpBuffer *copy_buffer;
GimpDrawable *drawable;
GimpImage *gimage = GIMP_IMAGE (data);
GimpDrawable *drawable;
drawable = gimp_image_active_drawable (gimage);
@ -415,22 +412,12 @@ copy_named_buffer_callback (GtkWidget *widget,
return;
}
copy_buffer = gimp_edit_copy (gimage, drawable,
gimp_get_user_context (gimage->gimp));
if (! (name && strlen (name)))
name = _("(Unnamed Buffer)");
if (copy_buffer)
if (gimp_edit_named_copy (gimage, name, drawable,
gimp_get_user_context (gimage->gimp)))
{
GimpBuffer *new_buffer;
if (! (name && strlen (name)))
name = _("(Unnamed Buffer)");
new_buffer = gimp_buffer_new (copy_buffer->tiles, name, TRUE);
gimp_container_add (gimage->gimp->named_buffers,
GIMP_OBJECT (new_buffer));
g_object_unref (new_buffer);
gimp_image_flush (gimage);
}
}

View File

@ -320,12 +320,102 @@ gimp_edit_paste_as_new (Gimp *gimp,
gimp_image_undo_enable (gimage);
gimp_create_display (gimp, gimage, GIMP_UNIT_PIXEL, 1.0);
g_object_unref (gimage);
return gimage;
}
const gchar *
gimp_edit_named_cut (GimpImage *gimage,
const gchar *name,
GimpDrawable *drawable,
GimpContext *context)
{
const GimpBuffer *buffer;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (name != NULL, 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_IS_CONTEXT (context), NULL);
buffer = gimp_edit_cut (gimage, drawable, context);
if (buffer)
{
GimpBuffer *named_buffer;
named_buffer = gimp_buffer_new (buffer->tiles, name, TRUE);
gimp_container_add (gimage->gimp->named_buffers,
GIMP_OBJECT (named_buffer));
g_object_unref (named_buffer);
return gimp_object_get_name (GIMP_OBJECT (named_buffer));
}
return NULL;
}
const gchar *
gimp_edit_named_copy (GimpImage *gimage,
const gchar *name,
GimpDrawable *drawable,
GimpContext *context)
{
const GimpBuffer *buffer;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (name != NULL, 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_IS_CONTEXT (context), NULL);
buffer = gimp_edit_copy (gimage, drawable, context);
if (buffer)
{
GimpBuffer *named_buffer;
named_buffer = gimp_buffer_new (buffer->tiles, name, TRUE);
gimp_container_add (gimage->gimp->named_buffers,
GIMP_OBJECT (named_buffer));
g_object_unref (named_buffer);
return gimp_object_get_name (GIMP_OBJECT (named_buffer));
}
return NULL;
}
const gchar *
gimp_edit_named_copy_visible (GimpImage *gimage,
const gchar *name,
GimpContext *context)
{
const GimpBuffer *buffer;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
buffer = gimp_edit_copy_visible (gimage, context);
if (buffer)
{
GimpBuffer *named_buffer;
named_buffer = gimp_buffer_new (buffer->tiles, name, TRUE);
gimp_container_add (gimage->gimp->named_buffers,
GIMP_OBJECT (named_buffer));
g_object_unref (named_buffer);
return gimp_object_get_name (GIMP_OBJECT (named_buffer));
}
return NULL;
}
gboolean
gimp_edit_clear (GimpImage *gimage,
GimpDrawable *drawable,

View File

@ -20,32 +20,45 @@
#define __GIMP_EDIT_H__
const GimpBuffer * gimp_edit_cut (GimpImage *gimage,
GimpDrawable *drawable,
GimpContext *context);
const GimpBuffer * gimp_edit_copy (GimpImage *gimage,
GimpDrawable *drawable,
GimpContext *context);
const GimpBuffer * gimp_edit_copy_visible (GimpImage *gimage,
GimpContext *context);
GimpLayer * gimp_edit_paste (GimpImage *gimage,
GimpDrawable *drawable,
GimpBuffer *paste,
gboolean paste_into,
gint viewport_x,
gint viewport_y,
gint viewport_width,
gint viewport_height);
GimpImage * gimp_edit_paste_as_new (Gimp *gimp,
GimpImage *gimage,
GimpBuffer *paste);
gboolean gimp_edit_clear (GimpImage *gimage,
GimpDrawable *drawable,
GimpContext *context);
gboolean gimp_edit_fill (GimpImage *gimage,
GimpDrawable *drawable,
GimpContext *context,
GimpFillType fill_type);
const GimpBuffer * gimp_edit_cut (GimpImage *gimage,
GimpDrawable *drawable,
GimpContext *context);
const GimpBuffer * gimp_edit_copy (GimpImage *gimage,
GimpDrawable *drawable,
GimpContext *context);
const GimpBuffer * gimp_edit_copy_visible (GimpImage *gimage,
GimpContext *context);
GimpLayer * gimp_edit_paste (GimpImage *gimage,
GimpDrawable *drawable,
GimpBuffer *paste,
gboolean paste_into,
gint viewport_x,
gint viewport_y,
gint viewport_width,
gint viewport_height);
GimpImage * gimp_edit_paste_as_new (Gimp *gimp,
GimpImage *gimage,
GimpBuffer *paste);
const gchar * gimp_edit_named_cut (GimpImage *gimage,
const gchar *name,
GimpDrawable *drawable,
GimpContext *context);
const gchar * gimp_edit_named_copy (GimpImage *gimage,
const gchar *name,
GimpDrawable *drawable,
GimpContext *context);
const gchar * gimp_edit_named_copy_visible (GimpImage *gimage,
const gchar *name,
GimpContext *context);
gboolean gimp_edit_clear (GimpImage *gimage,
GimpDrawable *drawable,
GimpContext *context);
gboolean gimp_edit_fill (GimpImage *gimage,
GimpDrawable *drawable,
GimpContext *context,
GimpFillType fill_type);
#endif /* __GIMP_EDIT_H__ */

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <string.h>
#include <glib-object.h>
@ -29,6 +30,7 @@
#include "core/gimp-edit.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontainer.h"
#include "core/gimpdrawable-blend.h"
#include "core/gimpdrawable-bucket-fill.h"
#include "core/gimpdrawable.h"
@ -42,6 +44,12 @@ static ProcRecord edit_cut_proc;
static ProcRecord edit_copy_proc;
static ProcRecord edit_copy_visible_proc;
static ProcRecord edit_paste_proc;
static ProcRecord edit_paste_as_new_proc;
static ProcRecord edit_named_cut_proc;
static ProcRecord edit_named_copy_proc;
static ProcRecord edit_named_copy_visible_proc;
static ProcRecord edit_named_paste_proc;
static ProcRecord edit_named_paste_as_new_proc;
static ProcRecord edit_clear_proc;
static ProcRecord edit_fill_proc;
static ProcRecord edit_bucket_fill_proc;
@ -55,6 +63,12 @@ register_edit_procs (Gimp *gimp)
procedural_db_register (gimp, &edit_copy_proc);
procedural_db_register (gimp, &edit_copy_visible_proc);
procedural_db_register (gimp, &edit_paste_proc);
procedural_db_register (gimp, &edit_paste_as_new_proc);
procedural_db_register (gimp, &edit_named_cut_proc);
procedural_db_register (gimp, &edit_named_copy_proc);
procedural_db_register (gimp, &edit_named_copy_visible_proc);
procedural_db_register (gimp, &edit_named_paste_proc);
procedural_db_register (gimp, &edit_named_paste_as_new_proc);
procedural_db_register (gimp, &edit_clear_proc);
procedural_db_register (gimp, &edit_fill_proc);
procedural_db_register (gimp, &edit_bucket_fill_proc);
@ -83,9 +97,9 @@ edit_cut_invoker (Gimp *gimp,
if (success)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
non_empty = gimp_edit_cut (gimage, drawable, context) != NULL;
non_empty = gimp_edit_cut (image, drawable, context) != NULL;
}
}
@ -154,9 +168,9 @@ edit_copy_invoker (Gimp *gimp,
if (success)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
non_empty = gimp_edit_copy (gimage, drawable, context) != NULL;
non_empty = gimp_edit_copy (image, drawable, context) != NULL;
}
}
@ -350,6 +364,491 @@ static ProcRecord edit_paste_proc =
{ { edit_paste_invoker } }
};
static Argument *
edit_paste_as_new_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpImage *image = NULL;
success = (gimp->global_buffer != NULL);
if (success)
{
image = gimp_edit_paste_as_new (gimp, NULL, gimp->global_buffer);
if (! image)
success = FALSE;
}
return_args = procedural_db_return_args (&edit_paste_as_new_proc, success);
if (success)
return_args[1].value.pdb_int = gimp_image_get_ID (image);
return return_args;
}
static ProcArg edit_paste_as_new_outargs[] =
{
{
GIMP_PDB_IMAGE,
"image",
"The new image"
}
};
static ProcRecord edit_paste_as_new_proc =
{
"gimp-edit-paste-as-new",
"gimp-edit-paste-as-new",
"Paste buffer to a new image.",
"This procedure pastes a copy of the internal GIMP edit buffer to a new image. The GIMP edit buffer will be empty unless a call was previously made to either 'gimp-edit-cut' or 'gimp-edit-copy'. This procedure returns the new image.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer <mitch@gimp.org>",
"2005",
NULL,
GIMP_INTERNAL,
0,
NULL,
1,
edit_paste_as_new_outargs,
{ { edit_paste_as_new_invoker } }
};
static Argument *
edit_named_cut_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpDrawable *drawable;
gchar *buffer_name;
gchar *real_name = NULL;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
buffer_name = (gchar *) args[1].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
if (success)
{
success = (strlen (buffer_name) > 0 &&
gimp_item_is_attached (GIMP_ITEM (drawable)));
if (success)
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
real_name = (gchar *) gimp_edit_named_cut (image, buffer_name,
drawable, context);
if (real_name)
real_name = g_strdup (real_name);
else
success = FALSE;
}
}
return_args = procedural_db_return_args (&edit_named_cut_proc, success);
if (success)
return_args[1].value.pdb_pointer = real_name;
return return_args;
}
static ProcArg edit_named_cut_inargs[] =
{
{
GIMP_PDB_DRAWABLE,
"drawable",
"The drawable to cut from"
},
{
GIMP_PDB_STRING,
"buffer-name",
"The name of the buffer to create"
}
};
static ProcArg edit_named_cut_outargs[] =
{
{
GIMP_PDB_STRING,
"real-name",
"The real name given to the buffer, or NULL if the selection contained only transparent pixels"
}
};
static ProcRecord edit_named_cut_proc =
{
"gimp-edit-named-cut",
"gimp-edit-named-cut",
"Cut into a named buffer.",
"This procedure works like gimp-edit-cut, but additionally stores the cut buffer into a named buffer that will stay available for later pasting, regardless of any intermediate copy or cut operations.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer <mitch@gimp.org>",
"2005",
NULL,
GIMP_INTERNAL,
2,
edit_named_cut_inargs,
1,
edit_named_cut_outargs,
{ { edit_named_cut_invoker } }
};
static Argument *
edit_named_copy_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpDrawable *drawable;
gchar *buffer_name;
gchar *real_name = NULL;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
buffer_name = (gchar *) args[1].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
if (success)
{
success = (strlen (buffer_name) > 0 &&
gimp_item_is_attached (GIMP_ITEM (drawable)));
if (success)
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
real_name = (gchar *) gimp_edit_named_copy (image, buffer_name,
drawable, context);
if (real_name)
real_name = g_strdup (real_name);
else
success = FALSE;
}
}
return_args = procedural_db_return_args (&edit_named_copy_proc, success);
if (success)
return_args[1].value.pdb_pointer = real_name;
return return_args;
}
static ProcArg edit_named_copy_inargs[] =
{
{
GIMP_PDB_DRAWABLE,
"drawable",
"The drawable to copy from"
},
{
GIMP_PDB_STRING,
"buffer-name",
"The name of the buffer to create"
}
};
static ProcArg edit_named_copy_outargs[] =
{
{
GIMP_PDB_STRING,
"real-name",
"The real name given to the buffer, or NULL if the selection contained only transparent pixels"
}
};
static ProcRecord edit_named_copy_proc =
{
"gimp-edit-named-copy",
"gimp-edit-named-copy",
"Copy into a named buffer.",
"This procedure works like gimp-edit-copy, but additionally stores the copied buffer into a named buffer that will stay available for later pasting, regardless of any intermediate copy or cut operations.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer <mitch@gimp.org>",
"2005",
NULL,
GIMP_INTERNAL,
2,
edit_named_copy_inargs,
1,
edit_named_copy_outargs,
{ { edit_named_copy_invoker } }
};
static Argument *
edit_named_copy_visible_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpImage *image;
gchar *buffer_name;
gchar *real_name = NULL;
image = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_IMAGE (image))
success = FALSE;
buffer_name = (gchar *) args[1].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
if (success)
{
if (strlen (buffer_name) > 0)
{
real_name = (gchar *) gimp_edit_named_copy_visible (image, buffer_name,
context);
if (real_name)
real_name = g_strdup (real_name);
else
success = FALSE;
}
}
return_args = procedural_db_return_args (&edit_named_copy_visible_proc, success);
if (success)
return_args[1].value.pdb_pointer = real_name;
return return_args;
}
static ProcArg edit_named_copy_visible_inargs[] =
{
{
GIMP_PDB_IMAGE,
"image",
"The image to copy from"
},
{
GIMP_PDB_STRING,
"buffer-name",
"The name of the buffer to create"
}
};
static ProcArg edit_named_copy_visible_outargs[] =
{
{
GIMP_PDB_STRING,
"real-name",
"The real name given to the buffer"
}
};
static ProcRecord edit_named_copy_visible_proc =
{
"gimp-edit-named-copy-visible",
"gimp-edit-named-copy-visible",
"Copy from the projection into a named buffer.",
"This procedure works like gimp-edit-copy-visible, but additionally stores the copied buffer into a named buffer that will stay available for later pasting, regardless of any intermediate copy or cut operations.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer <mitch@gimp.org>",
"2005",
NULL,
GIMP_INTERNAL,
2,
edit_named_copy_visible_inargs,
1,
edit_named_copy_visible_outargs,
{ { edit_named_copy_visible_invoker } }
};
static Argument *
edit_named_paste_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpDrawable *drawable;
gchar *buffer_name;
gboolean paste_into;
GimpLayer *layer = NULL;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
buffer_name = (gchar *) args[1].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
paste_into = args[2].value.pdb_int ? TRUE : FALSE;
if (success)
{
GimpBuffer *buffer;
buffer = (GimpBuffer *)
gimp_container_get_child_by_name (gimp->named_buffers, buffer_name);
success = (buffer != NULL && gimp_item_is_attached (GIMP_ITEM (drawable)));
if (success)
{
layer = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)),
drawable, buffer,
paste_into, -1, -1, -1, -1);
if (! layer)
success = FALSE;
}
}
return_args = procedural_db_return_args (&edit_named_paste_proc, success);
if (success)
return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (layer));
return return_args;
}
static ProcArg edit_named_paste_inargs[] =
{
{
GIMP_PDB_DRAWABLE,
"drawable",
"The drawable to paste to"
},
{
GIMP_PDB_STRING,
"buffer-name",
"The name of the buffer to paste"
},
{
GIMP_PDB_INT32,
"paste-into",
"Clear selection, or paste behind it?"
}
};
static ProcArg edit_named_paste_outargs[] =
{
{
GIMP_PDB_LAYER,
"floating-sel",
"The new floating selection"
}
};
static ProcRecord edit_named_paste_proc =
{
"gimp-edit-named-paste",
"gimp-edit-named-paste",
"Paste named buffer to the specified drawable.",
"This procedure works like gimp-edit-paste but pastes a named buffer instead of the global buffer.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer <mitch@gimp.org>",
"2005",
NULL,
GIMP_INTERNAL,
3,
edit_named_paste_inargs,
1,
edit_named_paste_outargs,
{ { edit_named_paste_invoker } }
};
static Argument *
edit_named_paste_as_new_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *buffer_name;
GimpImage *image = NULL;
buffer_name = (gchar *) args[0].value.pdb_pointer;
if (buffer_name == NULL || !g_utf8_validate (buffer_name, -1, NULL))
success = FALSE;
if (success)
{
GimpBuffer *buffer;
buffer = (GimpBuffer *)
gimp_container_get_child_by_name (gimp->named_buffers, buffer_name);
success = (buffer != NULL);
if (success)
{
image = gimp_edit_paste_as_new (gimp, NULL, buffer);
if (! image)
success = FALSE;
}
}
return_args = procedural_db_return_args (&edit_named_paste_as_new_proc, success);
if (success)
return_args[1].value.pdb_int = gimp_image_get_ID (image);
return return_args;
}
static ProcArg edit_named_paste_as_new_inargs[] =
{
{
GIMP_PDB_STRING,
"buffer-name",
"The name of the buffer to paste"
}
};
static ProcArg edit_named_paste_as_new_outargs[] =
{
{
GIMP_PDB_IMAGE,
"image",
"The new image"
}
};
static ProcRecord edit_named_paste_as_new_proc =
{
"gimp-edit-named-paste-as-new",
"gimp-edit-named-paste-as-new",
"Paste named buffer to a new image.",
"This procedure works like gimp-edit-paste-as-new but pastes a named buffer instead of the global buffer.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer <mitch@gimp.org>",
"2005",
NULL,
GIMP_INTERNAL,
1,
edit_named_paste_as_new_inargs,
1,
edit_named_paste_as_new_outargs,
{ { edit_named_paste_as_new_invoker } }
};
static Argument *
edit_clear_invoker (Gimp *gimp,
GimpContext *context,
@ -369,9 +868,9 @@ edit_clear_invoker (Gimp *gimp,
if (success)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
success = gimp_edit_clear (gimage, drawable, context);
success = gimp_edit_clear (image, drawable, context);
}
}
@ -429,9 +928,9 @@ edit_fill_invoker (Gimp *gimp,
if (success)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
success = gimp_edit_fill (gimage, drawable, context, (GimpFillType) fill_type);
success = gimp_edit_fill (image, drawable, context, (GimpFillType) fill_type);
}
}
@ -518,10 +1017,10 @@ edit_bucket_fill_invoker (Gimp *gimp,
if (success)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
gboolean do_seed_fill;
do_seed_fill = gimp_channel_is_empty (gimp_image_get_mask (gimage));
do_seed_fill = gimp_channel_is_empty (gimp_image_get_mask (image));
gimp_drawable_bucket_fill (drawable, context, fill_mode,
paint_mode, opacity / 100.0,
@ -820,12 +1319,12 @@ edit_stroke_invoker (Gimp *gimp,
if (success)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpStrokeDesc *desc = gimp_stroke_desc_new (gimp, context);
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpStrokeDesc *desc = gimp_stroke_desc_new (gimp, context);
g_object_set (desc, "method", GIMP_STROKE_METHOD_PAINT_CORE, NULL);
success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)),
success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (image)),
drawable, context, desc, TRUE);
g_object_unref (desc);

View File

@ -75,7 +75,7 @@ void register_undo_procs (Gimp *gimp);
void register_unit_procs (Gimp *gimp);
void register_vectors_procs (Gimp *gimp);
/* 465 procedures registered total */
/* 471 procedures registered total */
void
internal_procs_init (Gimp *gimp,
@ -90,118 +90,118 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Brush UI"), 0.047);
register_brush_select_procs (gimp);
(* status_callback) (NULL, _("Brushes"), 0.054);
(* status_callback) (NULL, _("Brushes"), 0.053);
register_brushes_procs (gimp);
(* status_callback) (NULL, _("Channel"), 0.067);
(* status_callback) (NULL, _("Channel"), 0.066);
register_channel_procs (gimp);
(* status_callback) (NULL, _("Color"), 0.088);
(* status_callback) (NULL, _("Color"), 0.087);
register_color_procs (gimp);
(* status_callback) (NULL, _("Context"), 0.123);
(* status_callback) (NULL, _("Context"), 0.121);
register_context_procs (gimp);
(* status_callback) (NULL, _("Convert"), 0.17);
(* status_callback) (NULL, _("Convert"), 0.168);
register_convert_procs (gimp);
(* status_callback) (NULL, _("Display procedures"), 0.176);
(* status_callback) (NULL, _("Display procedures"), 0.174);
register_display_procs (gimp);
(* status_callback) (NULL, _("Drawable procedures"), 0.185);
(* status_callback) (NULL, _("Drawable procedures"), 0.183);
register_drawable_procs (gimp);
(* status_callback) (NULL, _("Transformation procedures"), 0.26);
(* status_callback) (NULL, _("Transformation procedures"), 0.257);
register_drawable_transform_procs (gimp);
(* status_callback) (NULL, _("Edit procedures"), 0.295);
(* status_callback) (NULL, _("Edit procedures"), 0.291);
register_edit_procs (gimp);
(* status_callback) (NULL, _("File Operations"), 0.314);
(* status_callback) (NULL, _("File Operations"), 0.323);
register_fileops_procs (gimp);
(* status_callback) (NULL, _("Floating selections"), 0.335);
(* status_callback) (NULL, _("Floating selections"), 0.344);
register_floating_sel_procs (gimp);
(* status_callback) (NULL, _("Font UI"), 0.348);
(* status_callback) (NULL, _("Font UI"), 0.357);
register_font_select_procs (gimp);
(* status_callback) (NULL, _("Fonts"), 0.355);
(* status_callback) (NULL, _("Fonts"), 0.363);
register_fonts_procs (gimp);
(* status_callback) (NULL, _("Gimprc procedures"), 0.359);
(* status_callback) (NULL, _("Gimprc procedures"), 0.367);
register_gimprc_procs (gimp);
(* status_callback) (NULL, _("Gradient"), 0.374);
(* status_callback) (NULL, _("Gradient"), 0.382);
register_gradient_procs (gimp);
(* status_callback) (NULL, _("Gradient UI"), 0.439);
(* status_callback) (NULL, _("Gradient UI"), 0.446);
register_gradient_select_procs (gimp);
(* status_callback) (NULL, _("Gradients"), 0.445);
(* status_callback) (NULL, _("Gradients"), 0.452);
register_gradients_procs (gimp);
(* status_callback) (NULL, _("Guide procedures"), 0.456);
(* status_callback) (NULL, _("Guide procedures"), 0.463);
register_guides_procs (gimp);
(* status_callback) (NULL, _("Help procedures"), 0.469);
(* status_callback) (NULL, _("Help procedures"), 0.476);
register_help_procs (gimp);
(* status_callback) (NULL, _("Image"), 0.471);
(* status_callback) (NULL, _("Image"), 0.478);
register_image_procs (gimp);
(* status_callback) (NULL, _("Layer"), 0.606);
(* status_callback) (NULL, _("Layer"), 0.611);
register_layer_procs (gimp);
(* status_callback) (NULL, _("Message procedures"), 0.665);
(* status_callback) (NULL, _("Message procedures"), 0.669);
register_message_procs (gimp);
(* status_callback) (NULL, _("Miscellaneous"), 0.671);
(* status_callback) (NULL, _("Miscellaneous"), 0.675);
register_misc_procs (gimp);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.677);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.682);
register_paint_tools_procs (gimp);
(* status_callback) (NULL, _("Palette"), 0.71);
(* status_callback) (NULL, _("Palette"), 0.713);
register_palette_procs (gimp);
(* status_callback) (NULL, _("Palette UI"), 0.74);
(* status_callback) (NULL, _("Palette UI"), 0.743);
register_palette_select_procs (gimp);
(* status_callback) (NULL, _("Palettes"), 0.746);
(* status_callback) (NULL, _("Palettes"), 0.749);
register_palettes_procs (gimp);
(* status_callback) (NULL, _("Parasite procedures"), 0.755);
(* status_callback) (NULL, _("Parasite procedures"), 0.758);
register_parasite_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.781);
(* status_callback) (NULL, _("Paths"), 0.783);
register_paths_procs (gimp);
(* status_callback) (NULL, _("Pattern"), 0.815);
(* status_callback) (NULL, _("Pattern"), 0.817);
register_pattern_procs (gimp);
(* status_callback) (NULL, _("Pattern UI"), 0.819);
(* status_callback) (NULL, _("Pattern UI"), 0.822);
register_pattern_select_procs (gimp);
(* status_callback) (NULL, _("Patterns"), 0.826);
(* status_callback) (NULL, _("Patterns"), 0.828);
register_patterns_procs (gimp);
(* status_callback) (NULL, _("Plug-in"), 0.834);
(* status_callback) (NULL, _("Plug-in"), 0.837);
register_plug_in_procs (gimp);
(* status_callback) (NULL, _("Procedural database"), 0.847);
(* status_callback) (NULL, _("Procedural database"), 0.849);
register_procedural_db_procs (gimp);
(* status_callback) (NULL, _("Progress"), 0.867);
(* status_callback) (NULL, _("Progress"), 0.868);
register_progress_procs (gimp);
(* status_callback) (NULL, _("Image mask"), 0.882);
(* status_callback) (NULL, _("Image mask"), 0.883);
register_selection_procs (gimp);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.918);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.919);
register_selection_tools_procs (gimp);
(* status_callback) (NULL, _("Text procedures"), 0.929);
(* status_callback) (NULL, _("Text procedures"), 0.93);
register_text_tool_procs (gimp);
(* status_callback) (NULL, _("Transform Tool procedures"), 0.938);
@ -213,7 +213,7 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Units"), 0.966);
register_unit_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.991);
(* status_callback) (NULL, _("Paths"), 0.992);
register_vectors_procs (gimp);
}

View File

@ -254,11 +254,18 @@ gimp_toolbox_drop_buffer (GtkWidget *widget,
gpointer data)
{
GimpContext *context = GIMP_CONTEXT (data);
GimpImage *image;
if (context->gimp->busy)
return;
gimp_edit_paste_as_new (context->gimp, NULL, GIMP_BUFFER (viewable));
image = gimp_edit_paste_as_new (context->gimp, NULL, GIMP_BUFFER (viewable));
if (image)
{
gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0);
g_object_unref (image);
}
}
static void

View File

@ -169,7 +169,13 @@ EXPORTS
gimp_edit_copy_visible
gimp_edit_cut
gimp_edit_fill
gimp_edit_named_copy
gimp_edit_named_copy_visible
gimp_edit_named_cut
gimp_edit_named_paste
gimp_edit_named_paste_as_new
gimp_edit_paste
gimp_edit_paste_as_new
gimp_edit_stroke
gimp_ellipse_select
gimp_enums_get_type_names

View File

@ -179,6 +179,224 @@ gimp_edit_paste (gint32 drawable_ID,
return floating_sel_ID;
}
/**
* gimp_edit_paste_as_new:
*
* Paste buffer to a new image.
*
* This procedure pastes a copy of the internal GIMP edit buffer to a
* new image. The GIMP edit buffer will be empty unless a call was
* previously made to either 'gimp-edit-cut' or 'gimp-edit-copy'. This
* procedure returns the new image.
*
* Returns: The new image.
*
* Since: GIMP 2.4
*/
gint32
gimp_edit_paste_as_new (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gint32 image_ID = -1;
return_vals = gimp_run_procedure ("gimp-edit-paste-as-new",
&nreturn_vals,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
image_ID = return_vals[1].data.d_image;
gimp_destroy_params (return_vals, nreturn_vals);
return image_ID;
}
/**
* gimp_edit_named_cut:
* @drawable_ID: The drawable to cut from.
* @buffer_name: The name of the buffer to create.
*
* Cut into a named buffer.
*
* This procedure works like gimp-edit-cut, but additionally stores the
* cut buffer into a named buffer that will stay available for later
* pasting, regardless of any intermediate copy or cut operations.
*
* Returns: The real name given to the buffer, or NULL if the selection contained only transparent pixels.
*
* Since: GIMP 2.4
*/
gchar *
gimp_edit_named_cut (gint32 drawable_ID,
const gchar *buffer_name)
{
GimpParam *return_vals;
gint nreturn_vals;
gchar *real_name = NULL;
return_vals = gimp_run_procedure ("gimp-edit-named-cut",
&nreturn_vals,
GIMP_PDB_DRAWABLE, drawable_ID,
GIMP_PDB_STRING, buffer_name,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
real_name = g_strdup (return_vals[1].data.d_string);
gimp_destroy_params (return_vals, nreturn_vals);
return real_name;
}
/**
* gimp_edit_named_copy:
* @drawable_ID: The drawable to copy from.
* @buffer_name: The name of the buffer to create.
*
* Copy into a named buffer.
*
* This procedure works like gimp-edit-copy, but additionally stores
* the copied buffer into a named buffer that will stay available for
* later pasting, regardless of any intermediate copy or cut
* operations.
*
* Returns: The real name given to the buffer, or NULL if the selection contained only transparent pixels.
*
* Since: GIMP 2.4
*/
gchar *
gimp_edit_named_copy (gint32 drawable_ID,
const gchar *buffer_name)
{
GimpParam *return_vals;
gint nreturn_vals;
gchar *real_name = NULL;
return_vals = gimp_run_procedure ("gimp-edit-named-copy",
&nreturn_vals,
GIMP_PDB_DRAWABLE, drawable_ID,
GIMP_PDB_STRING, buffer_name,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
real_name = g_strdup (return_vals[1].data.d_string);
gimp_destroy_params (return_vals, nreturn_vals);
return real_name;
}
/**
* gimp_edit_named_copy_visible:
* @image_ID: The image to copy from.
* @buffer_name: The name of the buffer to create.
*
* Copy from the projection into a named buffer.
*
* This procedure works like gimp-edit-copy-visible, but additionally
* stores the copied buffer into a named buffer that will stay
* available for later pasting, regardless of any intermediate copy or
* cut operations.
*
* Returns: The real name given to the buffer.
*
* Since: GIMP 2.4
*/
gchar *
gimp_edit_named_copy_visible (gint32 image_ID,
const gchar *buffer_name)
{
GimpParam *return_vals;
gint nreturn_vals;
gchar *real_name = NULL;
return_vals = gimp_run_procedure ("gimp-edit-named-copy-visible",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_STRING, buffer_name,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
real_name = g_strdup (return_vals[1].data.d_string);
gimp_destroy_params (return_vals, nreturn_vals);
return real_name;
}
/**
* gimp_edit_named_paste:
* @drawable_ID: The drawable to paste to.
* @buffer_name: The name of the buffer to paste.
* @paste_into: Clear selection, or paste behind it?
*
* Paste named buffer to the specified drawable.
*
* This procedure works like gimp-edit-paste but pastes a named buffer
* instead of the global buffer.
*
* Returns: The new floating selection.
*
* Since: GIMP 2.4
*/
gint32
gimp_edit_named_paste (gint32 drawable_ID,
const gchar *buffer_name,
gboolean paste_into)
{
GimpParam *return_vals;
gint nreturn_vals;
gint32 floating_sel_ID = -1;
return_vals = gimp_run_procedure ("gimp-edit-named-paste",
&nreturn_vals,
GIMP_PDB_DRAWABLE, drawable_ID,
GIMP_PDB_STRING, buffer_name,
GIMP_PDB_INT32, paste_into,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
floating_sel_ID = return_vals[1].data.d_layer;
gimp_destroy_params (return_vals, nreturn_vals);
return floating_sel_ID;
}
/**
* gimp_edit_named_paste_as_new:
* @buffer_name: The name of the buffer to paste.
*
* Paste named buffer to a new image.
*
* This procedure works like gimp-edit-paste-as-new but pastes a named
* buffer instead of the global buffer.
*
* Returns: The new image.
*
* Since: GIMP 2.4
*/
gint32
gimp_edit_named_paste_as_new (const gchar *buffer_name)
{
GimpParam *return_vals;
gint nreturn_vals;
gint32 image_ID = -1;
return_vals = gimp_run_procedure ("gimp-edit-named-paste-as-new",
&nreturn_vals,
GIMP_PDB_STRING, buffer_name,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
image_ID = return_vals[1].data.d_image;
gimp_destroy_params (return_vals, nreturn_vals);
return image_ID;
}
/**
* gimp_edit_clear:
* @drawable_ID: The drawable to clear from.

View File

@ -29,39 +29,50 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean gimp_edit_cut (gint32 drawable_ID);
gboolean gimp_edit_copy (gint32 drawable_ID);
gboolean gimp_edit_copy_visible (gint32 image_ID);
gint32 gimp_edit_paste (gint32 drawable_ID,
gboolean paste_into);
gboolean gimp_edit_clear (gint32 drawable_ID);
gboolean gimp_edit_fill (gint32 drawable_ID,
GimpFillType fill_type);
gboolean gimp_edit_bucket_fill (gint32 drawable_ID,
GimpBucketFillMode fill_mode,
GimpLayerModeEffects paint_mode,
gdouble opacity,
gdouble threshold,
gboolean sample_merged,
gdouble x,
gdouble y);
gboolean gimp_edit_blend (gint32 drawable_ID,
GimpBlendMode blend_mode,
GimpLayerModeEffects paint_mode,
GimpGradientType gradient_type,
gdouble opacity,
gdouble offset,
GimpRepeatMode repeat,
gboolean reverse,
gboolean supersample,
gint max_depth,
gdouble threshold,
gboolean dither,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2);
gboolean gimp_edit_stroke (gint32 drawable_ID);
gboolean gimp_edit_cut (gint32 drawable_ID);
gboolean gimp_edit_copy (gint32 drawable_ID);
gboolean gimp_edit_copy_visible (gint32 image_ID);
gint32 gimp_edit_paste (gint32 drawable_ID,
gboolean paste_into);
gint32 gimp_edit_paste_as_new (void);
gchar* gimp_edit_named_cut (gint32 drawable_ID,
const gchar *buffer_name);
gchar* gimp_edit_named_copy (gint32 drawable_ID,
const gchar *buffer_name);
gchar* gimp_edit_named_copy_visible (gint32 image_ID,
const gchar *buffer_name);
gint32 gimp_edit_named_paste (gint32 drawable_ID,
const gchar *buffer_name,
gboolean paste_into);
gint32 gimp_edit_named_paste_as_new (const gchar *buffer_name);
gboolean gimp_edit_clear (gint32 drawable_ID);
gboolean gimp_edit_fill (gint32 drawable_ID,
GimpFillType fill_type);
gboolean gimp_edit_bucket_fill (gint32 drawable_ID,
GimpBucketFillMode fill_mode,
GimpLayerModeEffects paint_mode,
gdouble opacity,
gdouble threshold,
gboolean sample_merged,
gdouble x,
gdouble y);
gboolean gimp_edit_blend (gint32 drawable_ID,
GimpBlendMode blend_mode,
GimpLayerModeEffects paint_mode,
GimpGradientType gradient_type,
gdouble opacity,
gdouble offset,
GimpRepeatMode repeat,
gboolean reverse,
gboolean supersample,
gint max_depth,
gdouble threshold,
gboolean dither,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2);
gboolean gimp_edit_stroke (gint32 drawable_ID);
G_END_DECLS

View File

@ -17,33 +17,6 @@
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
# Common arguments
sub inargs {
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => "The drawable to @{[shift]}" }
);
}
sub outargs {
@outargs = (
{ name => 'non_empty', type => 'boolean', init => 1,
desc => "TRUE if the @{[shift]} was successful, FALSE if the selection contained only transparent pixels" }
);
}
sub drawable_arg () {{
name => 'drawable',
type => 'drawable',
desc => 'The affected drawable',
}}
sub sample_merged_arg () {{
name => 'sample_merged',
type => 'boolean',
desc => 'Use the composite image, not the drawable'
}}
# Common invoker for checking for image/drawable consistency
sub invoke {
%invoke = (
@ -53,7 +26,7 @@ sub invoke {
if (success)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
@{[shift]};
}
@ -76,9 +49,18 @@ stored in the internal GIMP edit buffer.
HELP
&std_pdb_misc;
&inargs('cut from');
&outargs('cut');
&invoke('non_empty = gimp_edit_cut (gimage, drawable, context) != NULL');
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable to cut from' }
);
@outargs = (
{ name => 'non_empty', type => 'boolean', init => 1,
desc => 'TRUE if the cut was successful, FALSE if the selection contained only transparent pixels' }
);
&invoke('non_empty = gimp_edit_cut (image, drawable, context) != NULL');
}
sub edit_copy {
@ -93,9 +75,18 @@ in the internal GIMP edit buffer.
HELP
&std_pdb_misc;
&inargs('copy from');
&outargs('copy');
&invoke('non_empty = gimp_edit_copy (gimage, drawable, context) != NULL');
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable to copy from' }
);
@outargs = (
{ name => 'non_empty', type => 'boolean', init => 1,
desc => 'TRUE if the copy was successful, FALSE if the selection contained only transparent pixels' }
);
&invoke('non_empty = gimp_edit_copy (image, drawable, context) != NULL');
}
sub edit_copy_visible {
@ -117,7 +108,11 @@ HELP
{ name => 'image', type => 'image',
desc => "The image to copy from" }
);
&outargs('copy');
@outargs = (
{ name => 'non_empty', type => 'boolean', init => 1,
desc => 'TRUE if the copy was successful, FALSE if the selection contained only transparent pixels' }
);
%invoke = (
code => <<CODE
@ -149,9 +144,12 @@ HELP
&std_pdb_misc;
&inargs('paste to');
push @inargs, { name => 'paste_into', type => 'boolean',
desc => 'Clear selection, or paste behind it?' };
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable to paste to' },
{ name => 'paste_into', type => 'boolean',
desc => 'Clear selection, or paste behind it?' }
);
@outargs = (
{ name => 'floating_sel', type => 'layer',
@ -173,10 +171,266 @@ HELP
success = FALSE;
}
}
CODE
);
}
sub edit_paste_as_new {
$blurb = 'Paste buffer to a new image.';
$help = <<'HELP';
This procedure pastes a copy of the internal GIMP edit buffer to a new
image. The GIMP edit buffer will be empty unless a call was
previously made to either 'gimp-edit-cut' or 'gimp-edit-copy'. This
procedure returns the new image.
HELP
$author = $copyright = 'Michael Natterer <mitch@gimp.org>';
$date = '2005';
$since = '2.4';
@outargs = (
{ name => 'image', type => 'image', init => 1,
desc => 'The new image' }
);
%invoke = (
code => <<CODE
{
success = (gimp->global_buffer != NULL);
if (success)
{
image = gimp_edit_paste_as_new (gimp, NULL, gimp->global_buffer);
if (! image)
success = FALSE;
}
}
CODE
);
}
sub edit_named_cut {
$blurb = 'Cut into a named buffer.';
$help = <<'HELP';
This procedure works like gimp-edit-cut, but additionally stores the cut buffer into a named buffer that will stay available for later pasting, regardless of any intermediate copy or cut operations.
HELP
$author = $copyright = 'Michael Natterer <mitch@gimp.org>';
$date = '2005';
$since = '2.4';
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => "The drawable to cut from" },
{ name => 'buffer_name', type => 'string',
desc => 'The name of the buffer to create' }
);
@outargs = (
{ name => 'real_name', type => 'string', init => 1,
desc => 'The real name given to the buffer, or NULL if the selection contained only transparent pixels' }
);
%invoke = (
code => <<CODE
{
success = (strlen (buffer_name) > 0 &&
gimp_item_is_attached (GIMP_ITEM (drawable)));
if (success)
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
real_name = (gchar *) gimp_edit_named_cut (image, buffer_name,
drawable, context);
if (real_name)
real_name = g_strdup (real_name);
else
success = FALSE;
}
}
CODE
);
}
sub edit_named_copy {
$blurb = 'Copy into a named buffer.';
$help = <<'HELP';
This procedure works like gimp-edit-copy, but additionally stores the copied buffer into a named buffer that will stay available for later pasting, regardless of any intermediate copy or cut operations.
HELP
$author = $copyright = 'Michael Natterer <mitch@gimp.org>';
$date = '2005';
$since = '2.4';
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => "The drawable to copy from" },
{ name => 'buffer_name', type => 'string',
desc => 'The name of the buffer to create' }
);
@outargs = (
{ name => 'real_name', type => 'string', init => 1,
desc => 'The real name given to the buffer, or NULL if the selection contained only transparent pixels' }
);
%invoke = (
code => <<CODE
{
success = (strlen (buffer_name) > 0 &&
gimp_item_is_attached (GIMP_ITEM (drawable)));
if (success)
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
real_name = (gchar *) gimp_edit_named_copy (image, buffer_name,
drawable, context);
if (real_name)
real_name = g_strdup (real_name);
else
success = FALSE;
}
}
CODE
);
}
sub edit_named_copy_visible {
$blurb = 'Copy from the projection into a named buffer.';
$help = <<'HELP';
This procedure works like gimp-edit-copy-visible, but additionally stores the copied buffer into a named buffer that will stay available for later pasting, regardless of any intermediate copy or cut operations.
HELP
$author = $copyright = 'Michael Natterer <mitch@gimp.org>';
$date = '2005';
$since = '2.4';
@inargs = (
{ name => 'image', type => 'image',
desc => "The image to copy from" },
{ name => 'buffer_name', type => 'string',
desc => 'The name of the buffer to create' }
);
@outargs = (
{ name => 'real_name', type => 'string', init => 1,
desc => 'The real name given to the buffer' }
);
%invoke = (
code => <<CODE
{
if (strlen (buffer_name) > 0)
{
real_name = (gchar *) gimp_edit_named_copy_visible (image, buffer_name,
context);
if (real_name)
real_name = g_strdup (real_name);
else
success = FALSE;
}
}
CODE
);
}
sub edit_named_paste {
$blurb = 'Paste named buffer to the specified drawable.';
$help = <<'HELP';
This procedure works like gimp-edit-paste but pastes a named buffer instead
of the global buffer.
HELP
$author = $copyright = 'Michael Natterer <mitch@gimp.org>';
$date = '2005';
$since = '2.4';
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable to paste to' },
{ name => 'buffer_name', type => 'string',
desc => 'The name of the buffer to paste' },
{ name => 'paste_into', type => 'boolean',
desc => 'Clear selection, or paste behind it?' }
);
@outargs = (
{ name => 'floating_sel', type => 'layer',
desc => 'The new floating selection', alias => 'layer', init => 1 }
);
%invoke = (
code => <<CODE
{
GimpBuffer *buffer;
buffer = (GimpBuffer *)
gimp_container_get_child_by_name (gimp->named_buffers, buffer_name);
success = (buffer != NULL && gimp_item_is_attached (GIMP_ITEM (drawable)));
if (success)
{
layer = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)),
drawable, buffer,
paste_into, -1, -1, -1, -1);
if (! layer)
success = FALSE;
}
}
CODE
)
}
sub edit_named_paste_as_new {
$blurb = 'Paste named buffer to a new image.';
$help = <<'HELP';
This procedure works like gimp-edit-paste-as-new but pastes a named buffer
instead of the global buffer.
HELP
$author = $copyright = 'Michael Natterer <mitch@gimp.org>';
$date = '2005';
$since = '2.4';
@inargs = (
{ name => 'buffer_name', type => 'string',
desc => 'The name of the buffer to paste' }
);
@outargs = (
{ name => 'image', type => 'image', init => 1,
desc => 'The new image' }
);
%invoke = (
code => <<CODE
{
GimpBuffer *buffer;
buffer = (GimpBuffer *)
gimp_container_get_child_by_name (gimp->named_buffers, buffer_name);
success = (buffer != NULL);
if (success)
{
image = gimp_edit_paste_as_new (gimp, NULL, buffer);
if (! image)
success = FALSE;
}
}
CODE
);
}
sub edit_clear {
$blurb = 'Clear selected area of drawable.';
@ -189,8 +443,11 @@ active.
HELP
&std_pdb_misc;
&inargs('clear from');
&invoke('success = gimp_edit_clear (gimage, drawable, context)');
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable to clear from' }
);
&invoke('success = gimp_edit_clear (image, drawable, context)');
}
sub edit_fill {
@ -214,7 +471,7 @@ HELP
{ name => 'fill_type', type => 'enum GimpFillType',
desc => 'The type of fill: %%desc%%' }
);
&invoke('success = gimp_edit_fill (gimage, drawable, context, (GimpFillType) fill_type)');
&invoke('success = gimp_edit_fill (image, drawable, context, (GimpFillType) fill_type)');
}
sub edit_bucket_fill {
@ -244,7 +501,8 @@ HELP
the specified image.';
@inargs = (
&drawable_arg,
{ name => 'drawable', type => 'drawable',
desc => 'The affected drawable' },
{ name => 'fill_mode', type => 'enum GimpBucketFillMode',
desc => 'The type of fill: { %%desc%% }' },
{ name => paint_mode, type => 'enum GimpLayerModeEffects',
@ -255,7 +513,8 @@ HELP
desc => "The threshold determines how extensive the seed fill will
be. It's value is specified in terms of intensity levels
(%%desc%%). $validity" },
&sample_merged_arg
{ name => 'sample_merged', type => 'boolean',
desc => 'Use the composite image, not the drawable' }
);
foreach (qw(x y)) {
@ -273,10 +532,10 @@ HELP
if (success)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
gboolean do_seed_fill;
do_seed_fill = gimp_channel_is_empty (gimp_image_get_mask (gimage));
do_seed_fill = gimp_channel_is_empty (gimp_image_get_mask (image));
gimp_drawable_bucket_fill (drawable, context, fill_mode,
paint_mode, opacity / 100.0,
@ -304,7 +563,8 @@ HELP
&std_pdb_misc;
@inargs = (
&drawable_arg,
{ name => 'drawable', type => 'drawable',
desc => 'The affected drawable' },
{ name => 'blend_mode', type => 'enum GimpBlendMode',
desc => 'The type of blend: { %%desc%% }' },
{ name => 'paint_mode', type => 'enum GimpLayerModeEffects',
@ -382,7 +642,10 @@ the specified drawable regardless of the active selection.
HELP
&std_pdb_misc;
&inargs('stroke to');
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable to stroke to' }
);
%invoke = (
headers => [ qw("core/gimpstrokedesc.h") ],
@ -392,12 +655,12 @@ HELP
if (success)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpStrokeDesc *desc = gimp_stroke_desc_new (gimp, context);
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpStrokeDesc *desc = gimp_stroke_desc_new (gimp, context);
g_object_set (desc, "method", GIMP_STROKE_METHOD_PAINT_CORE, NULL);
success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)),
success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (image)),
drawable, context, desc, TRUE);
g_object_unref (desc);
@ -407,12 +670,15 @@ CODE
);
}
@headers = qw("core/gimp.h" "core/gimp-edit.h" "core/gimpimage.h"
"core/gimpprogress.h"
@headers = qw(<string.h> "core/gimp.h" "core/gimp-edit.h"
"core/gimpcontainer.h" "core/gimpimage.h" "core/gimpprogress.h"
"gimp-intl.h");
@procs = qw(edit_cut edit_copy edit_copy_visible edit_paste edit_clear
edit_fill edit_bucket_fill edit_blend edit_stroke);
@procs = qw(edit_cut edit_copy edit_copy_visible
edit_paste edit_paste_as_new
edit_named_cut edit_named_copy edit_named_copy_visible
edit_named_paste edit_named_paste_as_new
edit_clear edit_fill edit_bucket_fill edit_blend edit_stroke);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Edit procedures';