[gimp] app: add gimp_edit_paste_as_new_image() and use it from GUI and PDB
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_edit_paste_as_new_image() and use it from GUI and PDB
- Date: Mon, 1 May 2017 17:13:33 +0000 (UTC)
commit 722a1a1368001699e06f11e4ebb709f4360ebf4b
Author: Michael Natterer <mitch gimp org>
Date: Mon May 1 19:10:52 2017 +0200
app: add gimp_edit_paste_as_new_image() and use it from GUI and PDB
app/actions/buffers-commands.c | 4 ++--
app/actions/edit-commands.c | 12 +-----------
app/core/gimp-edit.c | 22 ++++++++++++++++++++++
app/core/gimp-edit.h | 2 ++
app/pdb/edit-cmds.c | 17 ++---------------
tools/pdbgen/pdb/edit.pdb | 17 ++---------------
6 files changed, 31 insertions(+), 43 deletions(-)
---
diff --git a/app/actions/buffers-commands.c b/app/actions/buffers-commands.c
index 4dc559f..a0fe7c8 100644
--- a/app/actions/buffers-commands.c
+++ b/app/actions/buffers-commands.c
@@ -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)),
diff --git a/app/actions/edit-commands.c b/app/actions/edit-commands.c
index 897c08d..ef2a9a0 100644
--- a/app/actions/edit-commands.c
+++ b/app/actions/edit-commands.c
@@ -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);
}
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index d024961..a436122 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -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,
diff --git a/app/core/gimp-edit.h b/app/core/gimp-edit.h
index 8d38f78..1103841 100644
--- a/app/core/gimp-edit.h
+++ b/app/core/gimp-edit.h
@@ -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,
diff --git a/app/pdb/edit-cmds.c b/app/pdb/edit-cmds.c
index 4be7543..44282fe 100644
--- a/app/pdb/edit-cmds.c
+++ b/app/pdb/edit-cmds.c
@@ -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;
diff --git a/tools/pdbgen/pdb/edit.pdb b/tools/pdbgen/pdb/edit.pdb
index 02b469e..9999399 100644
--- a/tools/pdbgen/pdb/edit.pdb
+++ b/tools/pdbgen/pdb/edit.pdb
@@ -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"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]