[gimp] pdb: add the procedure gimp_layer_group_new



commit 805a971d998f737b35f1572e8551b912651455d7
Author: Barak Itkin <lightningismyname gmail com>
Date:   Tue Sep 14 22:38:34 2010 +0200

    pdb: add the procedure gimp_layer_group_new

 app/pdb/internal-procs.c   |    2 +-
 app/pdb/layer-cmds.c       |   61 ++++++++++++++++++++++++++++++++++++++++++++
 libgimp/gimp.def           |    1 +
 libgimp/gimplayer.c        |   19 +++++++++++++
 libgimp/gimplayer_pdb.c    |   35 +++++++++++++++++++++++++
 libgimp/gimplayer_pdb.h    |    1 +
 tools/pdbgen/pdb/layer.pdb |   35 ++++++++++++++++++++++++-
 7 files changed, 152 insertions(+), 2 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 3427196..59c9b06 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 657 procedures registered total */
+/* 658 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)
diff --git a/app/pdb/layer-cmds.c b/app/pdb/layer-cmds.c
index 3ca4c88..31f24bd 100644
--- a/app/pdb/layer-cmds.c
+++ b/app/pdb/layer-cmds.c
@@ -1027,6 +1027,38 @@ layer_set_mode_invoker (GimpProcedure      *procedure,
                                            error ? *error : NULL);
 }
 
+static GValueArray *
+layer_group_new_invoker (GimpProcedure      *procedure,
+                         Gimp               *gimp,
+                         GimpContext        *context,
+                         GimpProgress       *progress,
+                         const GValueArray  *args,
+                         GError            **error)
+{
+  gboolean success = TRUE;
+  GValueArray *return_vals;
+  GimpImage *image;
+  GimpLayer *layer_group = NULL;
+
+  image = gimp_value_get_image (&args->values[0], gimp);
+
+  if (success)
+    {
+      layer_group = gimp_group_layer_new (image);
+
+      if (! layer_group)
+        success = FALSE;
+    }
+
+  return_vals = gimp_procedure_get_return_values (procedure, success,
+                                                  error ? *error : NULL);
+
+  if (success)
+    gimp_value_set_layer (&return_vals->values[1], layer_group);
+
+  return return_vals;
+}
+
 void
 register_layer_procs (GimpPDB *pdb)
 {
@@ -2018,4 +2050,33 @@ register_layer_procs (GimpPDB *pdb)
                                                   GIMP_PARAM_READWRITE));
   gimp_pdb_register_procedure (pdb, procedure);
   g_object_unref (procedure);
+
+  /*
+   * gimp-layer-group-new
+   */
+  procedure = gimp_procedure_new (layer_group_new_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-layer-group-new");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-layer-group-new",
+                                     "Create a new layer group.",
+                                     "This procedure creates a new layer group. Attributes such as layer mode and opacity should be set with explicit procedure calls. Add the new layer group (which is a kind of layer) with the 'gimp-image-insert-layer' command.",
+                                     "Barak Itkin <lightningismyname gmail com>",
+                                     "Barak Itkin",
+                                     "2010",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_image_id ("image",
+                                                         "image",
+                                                         "The image to which to add the layer group",
+                                                         pdb->gimp, FALSE,
+                                                         GIMP_PARAM_READWRITE));
+  gimp_procedure_add_return_value (procedure,
+                                   gimp_param_spec_layer_id ("layer-group",
+                                                             "layer group",
+                                                             "The newly created layer group",
+                                                             pdb->gimp, FALSE,
+                                                             GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
 }
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index e066bc4..3ac6b63 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -481,6 +481,7 @@ EXPORTS
 	gimp_layer_get_opacity
 	gimp_layer_get_preserve_trans
 	gimp_layer_get_show_mask
+	gimp_layer_group_new
 	gimp_layer_is_floating_sel
 	gimp_layer_mode_effects_get_type
 	gimp_layer_new
diff --git a/libgimp/gimplayer.c b/libgimp/gimplayer.c
index 9680b79..f87f38b 100644
--- a/libgimp/gimplayer.c
+++ b/libgimp/gimplayer.c
@@ -111,3 +111,22 @@ gimp_layer_set_preserve_trans (gint32   layer_ID,
 {
   return gimp_layer_set_lock_alpha (layer_ID, preserve_trans);
 }
+
+/**
+ * gimp_layer_group_new:
+ * @image_ID: The image to which to add the layer.
+ *
+ * Create a new layer group.
+ *
+ * This procedure creates a new layer group. Attributes such as layer
+ * mode and opacity should be set with explicit procedure calls. Add
+ * the new layer group (which is a kind of layer) with the
+ * gimp_image_insert_layer() command.
+ *
+ * Returns: The newly created layer group.
+ */
+gint32
+gimp_layer_group_new (gint32 image_ID)
+{
+  return _gimp_layer_group_new (image_ID);
+}
diff --git a/libgimp/gimplayer_pdb.c b/libgimp/gimplayer_pdb.c
index 53908dd..15e4557 100644
--- a/libgimp/gimplayer_pdb.c
+++ b/libgimp/gimplayer_pdb.c
@@ -1110,3 +1110,38 @@ gimp_layer_set_mode (gint32               layer_ID,
 
   return success;
 }
+
+/**
+ * _gimp_layer_group_new:
+ * @image_ID: The image to which to add the layer group.
+ *
+ * Create a new layer group.
+ *
+ * This procedure creates a new layer group. Attributes such as layer
+ * mode and opacity should be set with explicit procedure calls. Add
+ * the new layer group (which is a kind of layer) with the
+ * gimp_image_insert_layer() command.
+ *
+ * Returns: The newly created layer group.
+ *
+ * Since: GIMP 2.8
+ */
+gint32
+_gimp_layer_group_new (gint32 image_ID)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gint32 layer_group_ID = -1;
+
+  return_vals = gimp_run_procedure ("gimp-layer-group-new",
+                                    &nreturn_vals,
+                                    GIMP_PDB_IMAGE, image_ID,
+                                    GIMP_PDB_END);
+
+  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
+    layer_group_ID = return_vals[1].data.d_layer;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return layer_group_ID;
+}
diff --git a/libgimp/gimplayer_pdb.h b/libgimp/gimplayer_pdb.h
index d6858c3..ea26355 100644
--- a/libgimp/gimplayer_pdb.h
+++ b/libgimp/gimplayer_pdb.h
@@ -92,6 +92,7 @@ gboolean               gimp_layer_set_opacity          (gint32                 l
 GimpLayerModeEffects   gimp_layer_get_mode             (gint32                 layer_ID);
 gboolean               gimp_layer_set_mode             (gint32                 layer_ID,
                                                         GimpLayerModeEffects   mode);
+G_GNUC_INTERNAL gint32 _gimp_layer_group_new           (gint32                 image_ID);
 
 
 G_END_DECLS
diff --git a/tools/pdbgen/pdb/layer.pdb b/tools/pdbgen/pdb/layer.pdb
index e3a8488..b424bd7 100644
--- a/tools/pdbgen/pdb/layer.pdb
+++ b/tools/pdbgen/pdb/layer.pdb
@@ -1071,6 +1071,38 @@ CODE
     );
 }
 
+sub layer_group_new {
+    $blurb = 'Create a new layer group.';
+
+    $help = <<'HELP';
+This procedure creates a new layer group. Attributes such as layer mode
+and opacity should be set with explicit procedure calls. Add the new
+layer group (which is a kind of layer) with the
+gimp_image_insert_layer() command.
+HELP
+
+    &barak_pdb_misc('2010', '2.8');
+
+    @inargs = (
+	{ name => 'image', type => 'image',
+	  desc => 'The image to which to add the layer group' }
+    );
+
+    @outargs = (
+	{ name => 'layer_group', type => 'layer', wrap => 1,
+	  desc => 'The newly created layer group' }
+    );
+    %invoke = (
+	code => <<'CODE'
+{
+  layer_group = gimp_group_layer_new (image);
+
+  if (! layer_group)
+    success = FALSE;
+}
+CODE
+    );
+}
 
 @headers = qw("libgimpbase/gimpbase.h"
               "config/gimpcoreconfig.h"
@@ -1102,7 +1134,8 @@ CODE
             layer_get_show_mask layer_set_show_mask
             layer_get_edit_mask layer_set_edit_mask
             layer_get_opacity layer_set_opacity
-            layer_get_mode layer_set_mode);
+            layer_get_mode layer_set_mode
+            layer_group_new);
 
 %exports = (app => [ procs], lib => [ procs]);
 



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