gimp r26422 - in trunk: . app/pdb libgimp tools/pdbgen/pdb



Author: neo
Date: Thu Aug  7 16:09:39 2008
New Revision: 26422
URL: http://svn.gnome.org/viewvc/gimp?rev=26422&view=rev

Log:
2008-08-07  Sven Neumann  <sven gimp org>

	* tools/pdbgen/pdb/layer.pdb: added new procedure
	'gimp-layer-new-from-visible'.

	* app/pdb/layer-cmds.c
	* app/pdb/internal-procs.c
	* libgimp/gimplayer_pdb.[ch]: regenerated.

	* libgimp/gimp.def: updated.



Modified:
   trunk/ChangeLog
   trunk/app/pdb/internal-procs.c
   trunk/app/pdb/layer-cmds.c
   trunk/libgimp/gimp.def
   trunk/libgimp/gimplayer_pdb.c
   trunk/libgimp/gimplayer_pdb.h
   trunk/tools/pdbgen/pdb/layer.pdb

Modified: trunk/app/pdb/internal-procs.c
==============================================================================
--- trunk/app/pdb/internal-procs.c	(original)
+++ trunk/app/pdb/internal-procs.c	Thu Aug  7 16:09:39 2008
@@ -29,7 +29,7 @@
 #include "internal-procs.h"
 
 
-/* 588 procedures registered total */
+/* 589 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)

Modified: trunk/app/pdb/layer-cmds.c
==============================================================================
--- trunk/app/pdb/layer-cmds.c	(original)
+++ trunk/app/pdb/layer-cmds.c	Thu Aug  7 16:09:39 2008
@@ -35,6 +35,7 @@
 #include "core/gimplayer.h"
 #include "core/gimplayermask.h"
 #include "core/gimpparamspecs.h"
+#include "core/gimpprojection.h"
 
 #include "gimppdb.h"
 #include "gimppdb-utils.h"
@@ -89,6 +90,44 @@
 }
 
 static GValueArray *
+layer_new_from_visible_invoker (GimpProcedure      *procedure,
+                                Gimp               *gimp,
+                                GimpContext        *context,
+                                GimpProgress       *progress,
+                                const GValueArray  *args,
+                                GError            **error)
+{
+  gboolean success = TRUE;
+  GValueArray *return_vals;
+  GimpImage *image;
+  GimpImage *dest_image;
+  const gchar *name;
+  GimpLayer *layer = NULL;
+
+  image = gimp_value_get_image (&args->values[0], gimp);
+  dest_image = gimp_value_get_image (&args->values[1], gimp);
+  name = g_value_get_string (&args->values[2]);
+
+  if (success)
+    {
+      GimpProjection *projection = gimp_image_get_projection (image);
+
+      layer = gimp_layer_new_from_tiles (gimp_projection_get_tiles (projection),
+                                         dest_image,
+                                         gimp_projection_get_image_type (projection),
+                                         name,
+                                         GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
+    }
+
+  return_vals = gimp_procedure_get_return_values (procedure, success);
+
+  if (success)
+    gimp_value_set_layer (&return_vals->values[1], layer);
+
+  return return_vals;
+}
+
+static GValueArray *
 layer_new_from_drawable_invoker (GimpProcedure      *procedure,
                                  Gimp               *gimp,
                                  GimpContext        *context,
@@ -958,6 +997,48 @@
   g_object_unref (procedure);
 
   /*
+   * gimp-layer-new-from-visible
+   */
+  procedure = gimp_procedure_new (layer_new_from_visible_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-layer-new-from-visible");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-layer-new-from-visible",
+                                     "Create a new layer from what is visible in an image.",
+                                     "This procedure creates a new layer from what is visible in the given image. The new layer still needs to be added to the destination image, as this is not automatic. Add the new layer with the 'gimp-image-add-layer' command. Other attributes such as layer mask modes, and offsets should be set with explicit procedure calls.",
+                                     "Sven Neumann <sven gimp org>",
+                                     "Sven Neumann",
+                                     "2008",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_image_id ("image",
+                                                         "image",
+                                                         "The source image from where the content is copied",
+                                                         pdb->gimp, FALSE,
+                                                         GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_image_id ("dest-image",
+                                                         "dest image",
+                                                         "The destination image to which to add the layer",
+                                                         pdb->gimp, FALSE,
+                                                         GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_string ("name",
+                                                       "name",
+                                                       "The layer name",
+                                                       FALSE, TRUE, FALSE,
+                                                       NULL,
+                                                       GIMP_PARAM_READWRITE));
+  gimp_procedure_add_return_value (procedure,
+                                   gimp_param_spec_layer_id ("layer",
+                                                             "layer",
+                                                             "The newly created layer",
+                                                             pdb->gimp, FALSE,
+                                                             GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-layer-new-from-drawable
    */
   procedure = gimp_procedure_new (layer_new_from_drawable_invoker);

Modified: trunk/libgimp/gimp.def
==============================================================================
--- trunk/libgimp/gimp.def	(original)
+++ trunk/libgimp/gimp.def	Thu Aug  7 16:09:39 2008
@@ -423,6 +423,7 @@
 	gimp_layer_mode_effects_get_type
 	gimp_layer_new
 	gimp_layer_new_from_drawable
+	gimp_layer_new_from_visible
 	gimp_layer_remove_mask
 	gimp_layer_resize
 	gimp_layer_resize_to_image_size

Modified: trunk/libgimp/gimplayer_pdb.c
==============================================================================
--- trunk/libgimp/gimplayer_pdb.c	(original)
+++ trunk/libgimp/gimplayer_pdb.c	Thu Aug  7 16:09:39 2008
@@ -79,6 +79,48 @@
 }
 
 /**
+ * gimp_layer_new_from_visible:
+ * @image_ID: The source image from where the content is copied.
+ * @dest_image_ID: The destination image to which to add the layer.
+ * @name: The layer name.
+ *
+ * Create a new layer from what is visible in an image.
+ *
+ * This procedure creates a new layer from what is visible in the given
+ * image. The new layer still needs to be added to the destination
+ * image, as this is not automatic. Add the new layer with the
+ * gimp_image_add_layer() command. Other attributes such as layer mask
+ * modes, and offsets should be set with explicit procedure calls.
+ *
+ * Returns: The newly created layer.
+ *
+ * Since: GIMP 2.6
+ */
+gint32
+gimp_layer_new_from_visible (gint32       image_ID,
+                             gint32       dest_image_ID,
+                             const gchar *name)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gint32 layer_ID = -1;
+
+  return_vals = gimp_run_procedure ("gimp-layer-new-from-visible",
+                                    &nreturn_vals,
+                                    GIMP_PDB_IMAGE, image_ID,
+                                    GIMP_PDB_IMAGE, dest_image_ID,
+                                    GIMP_PDB_STRING, name,
+                                    GIMP_PDB_END);
+
+  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
+    layer_ID = return_vals[1].data.d_layer;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return layer_ID;
+}
+
+/**
  * gimp_layer_new_from_drawable:
  * @drawable_ID: The source drawable from where the new layer is copied.
  * @dest_image_ID: The destination image to which to add the layer.

Modified: trunk/libgimp/gimplayer_pdb.h
==============================================================================
--- trunk/libgimp/gimplayer_pdb.h	(original)
+++ trunk/libgimp/gimplayer_pdb.h	Thu Aug  7 16:09:39 2008
@@ -36,6 +36,9 @@
                                                         const gchar          *name,
                                                         gdouble               opacity,
                                                         GimpLayerModeEffects  mode);
+gint32                 gimp_layer_new_from_visible     (gint32                image_ID,
+                                                        gint32                dest_image_ID,
+                                                        const gchar          *name);
 gint32                 gimp_layer_new_from_drawable    (gint32                drawable_ID,
                                                         gint32                dest_image_ID);
 G_GNUC_INTERNAL gint32 _gimp_layer_copy                (gint32                layer_ID,

Modified: trunk/tools/pdbgen/pdb/layer.pdb
==============================================================================
--- trunk/tools/pdbgen/pdb/layer.pdb	(original)
+++ trunk/tools/pdbgen/pdb/layer.pdb	Thu Aug  7 16:09:39 2008
@@ -65,6 +65,97 @@
     );
 }
 
+sub layer_new_from_visible {
+    $blurb = 'Create a new layer from what is visible in an image.';
+
+    $help = <<'HELP';
+This procedure creates a new layer from what is visible in the given image.
+The new layer still needs to be added to the destination image, as this is
+not automatic. Add the new layer with the gimp_image_add_layer() command.
+Other attributes such as layer mask modes, and offsets should be set with
+explicit procedure calls.
+HELP
+
+    &neo_pdb_misc('2008', '2.6');
+
+    @inargs = (
+	{ name => 'image', type => 'image',
+	  desc => 'The source image from where the content is copied' },
+	{ name => 'dest_image', type => 'image',
+	  desc => 'The destination image to which to add the layer' },
+	{ name => 'name', type => 'string',
+	  desc => 'The layer name', null_ok => 1 }
+     );
+
+    @outargs = (
+	{ name => 'layer', type => 'layer',
+	  desc => 'The newly created layer' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  GimpProjection *projection = gimp_image_get_projection (image);
+
+  layer = gimp_layer_new_from_tiles (gimp_projection_get_tiles (projection),
+                                     dest_image,
+                                     gimp_projection_get_image_type (projection),
+                                     name,
+                                     GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
+}
+CODE
+    );
+}
+
+sub layer_new_from_drawable {
+    $blurb = 'Create a new layer by copying an existing drawable.';
+
+    $help = <<'HELP';
+This procedure creates a new layer as a copy of the specified drawable.  The
+new layer still needs to be added to the image, as this is not automatic.  Add
+the new layer with the gimp_image_add_layer() command. Other attributes such
+as layer mask modes, and offsets should be set with explicit procedure calls.
+HELP
+
+    &std_pdb_misc;
+
+    @inargs = (
+	{ name => 'drawable', type => 'drawable',
+	  desc => 'The source drawable from where the new layer is copied' },
+	{ name => 'dest_image', type => 'image',
+	  desc => 'The destination image to which to add the layer' }
+     );
+
+    @outargs = (
+	{ name => 'layer_copy', type => 'layer',
+	  desc => 'The newly copied layer' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  GType     new_type;
+  GimpItem *new_item;
+
+  if (GIMP_IS_LAYER (drawable))
+    new_type = G_TYPE_FROM_INSTANCE (drawable);
+  else
+    new_type = GIMP_TYPE_LAYER;
+
+  if (dest_image == gimp_item_get_image (GIMP_ITEM (drawable)))
+    new_item = gimp_item_duplicate (GIMP_ITEM (drawable), new_type);
+  else
+    new_item = gimp_item_convert (GIMP_ITEM (drawable), dest_image, new_type);
+
+  if (new_item)
+    layer_copy = GIMP_LAYER (new_item);
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub layer_copy {
     $blurb = 'Copy a layer.';
 
@@ -124,7 +215,7 @@
 to gimp_layer_add_mask().
 HELP
 
-    &std_pdb_misc;
+    &std_pdb_misc();
 
     @inargs = (
 	{ name => 'layer', type => 'layer',
@@ -558,55 +649,6 @@
     );
 }
 
-sub layer_new_from_drawable {
-    $blurb = 'Create a new layer by copying an existing drawable.';
-
-    $help = <<'HELP';
-This procedure creates a new layer as a copy of the specified drawable.  The
-new layer still needs to be added to the image, as this is not automatic.  Add
-the new layer with the gimp_image_add_layer() command. Other attributes such
-as layer mask modes, and offsets should be set with explicit procedure calls.
-HELP
-
-    &std_pdb_misc;
-
-    @inargs = (
-	{ name => 'drawable', type => 'drawable',
-	  desc => 'The source drawable from where the new layer is copied' },
-	{ name => 'dest_image', type => 'image',
-	  desc => 'The destination image to which to add the layer' }
-     );
-
-    @outargs = (
-	{ name => 'layer_copy', type => 'layer',
-	  desc => 'The newly copied layer' }
-    );
-
-    %invoke = (
-	code => <<'CODE'
-{
-  GType     new_type;
-  GimpItem *new_item;
-
-  if (GIMP_IS_LAYER (drawable))
-    new_type = G_TYPE_FROM_INSTANCE (drawable);
-  else
-    new_type = GIMP_TYPE_LAYER;
-
-  if (dest_image == gimp_item_get_image (GIMP_ITEM (drawable)))
-    new_item = gimp_item_duplicate (GIMP_ITEM (drawable), new_type);
-  else
-    new_item = gimp_item_convert (GIMP_ITEM (drawable), dest_image, new_type);
-
-  if (new_item)
-    layer_copy = GIMP_LAYER (new_item);
-  else
-    success = FALSE;
-}
-CODE
-    );
-}
-
 sub layer_get_lock_alpha {
     $blurb = 'Get the lock alpha channel setting of the specified layer.';
 
@@ -953,10 +995,12 @@
               "core/gimp.h"
               "core/gimpimage-undo.h"
               "core/gimpitem-linked.h"
+              "core/gimpprojection.h"
               "gimppdb-utils.h"
               "gimp-intl.h");
 
 @procs = qw(layer_new
+            layer_new_from_visible
             layer_new_from_drawable
             layer_copy
             layer_add_alpha



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]