Commit 722a1a13 authored by Michael Natterer's avatar Michael Natterer 😴
Browse files

app: add gimp_edit_paste_as_new_image() and use it from GUI and PDB

parent 4f5bd08b
......@@ -29,7 +29,6 @@
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-new.h"
#include "widgets/gimpbufferview.h"
#include "widgets/gimpcontainerview.h"
......@@ -92,7 +91,8 @@ buffers_paste_as_new_image_cmd_callback (GtkAction *action,
GtkWidget *widget = GTK_WIDGET (editor);
GimpImage *new_image;
new_image = gimp_image_new_from_buffer (context->gimp, buffer);
new_image = gimp_edit_paste_as_new_image (context->gimp,
GIMP_OBJECT (buffer));
gimp_create_display (context->gimp, new_image,
GIMP_UNIT_PIXEL, 1.0,
G_OBJECT (gtk_widget_get_screen (widget)),
......
......@@ -36,8 +36,6 @@
#include "core/gimplayer.h"
#include "core/gimplayer-new.h"
#include "core/gimpimage.h"
#include "core/gimpimage-duplicate.h"
#include "core/gimpimage-new.h"
#include "core/gimpimage-undo.h"
#include "vectors/gimpvectors-import.h"
......@@ -378,15 +376,7 @@ edit_paste_as_new_image_cmd_callback (GtkAction *action,
if (paste)
{
if (GIMP_IS_IMAGE (paste))
{
image = gimp_image_duplicate (GIMP_IMAGE (paste));
}
else if (GIMP_IS_BUFFER (paste))
{
image = gimp_image_new_from_buffer (gimp, GIMP_BUFFER (paste));
}
image = gimp_edit_paste_as_new_image (gimp, paste);
g_object_unref (paste);
}
......
......@@ -39,6 +39,7 @@
#include "gimpfilloptions.h"
#include "gimpdrawableundo.h"
#include "gimpimage.h"
#include "gimpimage-duplicate.h"
#include "gimpimage-new.h"
#include "gimpimage-undo.h"
#include "gimplayer.h"
......@@ -478,6 +479,27 @@ gimp_edit_paste (GimpImage *image,
return layer;
}
GimpImage *
gimp_edit_paste_as_new_image (Gimp *gimp,
GimpObject *paste)
{
GimpImage *image = NULL;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (paste) || GIMP_IS_BUFFER (paste), NULL);
if (GIMP_IS_IMAGE (paste))
{
image = gimp_image_duplicate (GIMP_IMAGE (paste));
}
else if (GIMP_IS_BUFFER (paste))
{
image = gimp_image_new_from_buffer (gimp, GIMP_BUFFER (paste));
}
return image;
}
const gchar *
gimp_edit_named_cut (GimpImage *image,
const gchar *name,
......
......@@ -49,6 +49,8 @@ GimpLayer * gimp_edit_paste (GimpImage *image,
gint viewport_y,
gint viewport_width,
gint viewport_height);
GimpImage * gimp_edit_paste_as_new_image (Gimp *gimp,
GimpObject *paste);
const gchar * gimp_edit_named_cut (GimpImage *image,
const gchar *name,
......
......@@ -37,8 +37,6 @@
#include "core/gimpdrawable-blend.h"
#include "core/gimpdrawable-bucket-fill.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage-duplicate.h"
#include "core/gimpimage-new.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
#include "core/gimpparamspecs.h"
......@@ -251,22 +249,11 @@ edit_paste_as_new_image_invoker (GimpProcedure *procedure,
if (paste)
{
if (GIMP_IS_IMAGE (paste))
{
image = gimp_image_duplicate (GIMP_IMAGE (paste));
}
else if (GIMP_IS_BUFFER (paste))
{
image = gimp_image_new_from_buffer (gimp, GIMP_BUFFER (paste));
}
image = gimp_edit_paste_as_new_image (gimp, paste);
if (! image)
success = FALSE;
}
else
{
image = NULL;
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
......@@ -500,7 +487,7 @@ edit_named_paste_as_new_image_invoker (GimpProcedure *procedure,
if (buffer)
{
image = gimp_image_new_from_buffer (gimp, buffer);
image = gimp_edit_paste_as_new_image (gimp, GIMP_OBJECT (buffer));
if (! image)
success = FALSE;
......
......@@ -248,22 +248,11 @@ HELP
if (paste)
{
if (GIMP_IS_IMAGE (paste))
{
image = gimp_image_duplicate (GIMP_IMAGE (paste));
}
else if (GIMP_IS_BUFFER (paste))
{
image = gimp_image_new_from_buffer (gimp, GIMP_BUFFER (paste));
}
image = gimp_edit_paste_as_new_image (gimp, paste);
if (! image)
success = FALSE;
}
else
{
image = NULL;
}
}
CODE
);
......@@ -505,7 +494,7 @@ HELP
if (buffer)
{
image = gimp_image_new_from_buffer (gimp, buffer);
image = gimp_edit_paste_as_new_image (gimp, GIMP_OBJECT (buffer));
if (! image)
success = FALSE;
......@@ -1027,8 +1016,6 @@ CODE
"core/gimp-edit.h"
"core/gimpbuffer.h"
"core/gimpimage.h"
"core/gimpimage-duplicate.h"
"core/gimpimage-new.h"
"core/gimpprogress.h"
"gimppdb-utils.h"
"gimppdbcontext.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment