[gimp] pdb: add a lot of state for a new item-based transform API



commit 23aaf69779c438fe27e73189ae3ce90989c8e410
Author: Michael Natterer <mitch gimp org>
Date:   Tue Sep 7 02:33:13 2010 +0200

    pdb: add a lot of state for a new item-based transform API
    
    interpolation, transform-direction, transform-resize, transform-recursion

 app/pdb/context-cmds.c       |  370 ++++++++++++++++++++++++++++++++++++++++++
 app/pdb/gimppdbcontext.c     |   61 +++++++-
 app/pdb/gimppdbcontext.h     |   15 ++-
 app/pdb/internal-procs.c     |    2 +-
 libgimp/gimp.def             |    8 +
 libgimp/gimpcontext_pdb.c    |  257 +++++++++++++++++++++++++++++
 libgimp/gimpcontext_pdb.h    |   76 +++++----
 tools/pdbgen/pdb/context.pdb |  219 +++++++++++++++++++++++++-
 8 files changed, 966 insertions(+), 42 deletions(-)
---
diff --git a/app/pdb/context-cmds.c b/app/pdb/context-cmds.c
index 26e470b..7b5ff5c 100644
--- a/app/pdb/context-cmds.c
+++ b/app/pdb/context-cmds.c
@@ -769,6 +769,186 @@ context_set_feather_radius_invoker (GimpProcedure      *procedure,
                                            error ? *error : NULL);
 }
 
+static GValueArray *
+context_get_interpolation_invoker (GimpProcedure      *procedure,
+                                   Gimp               *gimp,
+                                   GimpContext        *context,
+                                   GimpProgress       *progress,
+                                   const GValueArray  *args,
+                                   GError            **error)
+{
+  GValueArray *return_vals;
+  gint32 interpolation = 0;
+
+  g_object_get (context,
+                "interpolation", &interpolation,
+                NULL);
+
+  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
+  g_value_set_enum (&return_vals->values[1], interpolation);
+
+  return return_vals;
+}
+
+static GValueArray *
+context_set_interpolation_invoker (GimpProcedure      *procedure,
+                                   Gimp               *gimp,
+                                   GimpContext        *context,
+                                   GimpProgress       *progress,
+                                   const GValueArray  *args,
+                                   GError            **error)
+{
+  gboolean success = TRUE;
+  gint32 interpolation;
+
+  interpolation = g_value_get_enum (&args->values[0]);
+
+  if (success)
+    {
+      g_object_set (context,
+                    "interpolation", interpolation,
+                    NULL);
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GValueArray *
+context_get_transform_direction_invoker (GimpProcedure      *procedure,
+                                         Gimp               *gimp,
+                                         GimpContext        *context,
+                                         GimpProgress       *progress,
+                                         const GValueArray  *args,
+                                         GError            **error)
+{
+  GValueArray *return_vals;
+  gint32 transform_direction = 0;
+
+  g_object_get (context,
+                "transform-direction", &transform_direction,
+                NULL);
+
+  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
+  g_value_set_enum (&return_vals->values[1], transform_direction);
+
+  return return_vals;
+}
+
+static GValueArray *
+context_set_transform_direction_invoker (GimpProcedure      *procedure,
+                                         Gimp               *gimp,
+                                         GimpContext        *context,
+                                         GimpProgress       *progress,
+                                         const GValueArray  *args,
+                                         GError            **error)
+{
+  gboolean success = TRUE;
+  gint32 transform_direction;
+
+  transform_direction = g_value_get_enum (&args->values[0]);
+
+  if (success)
+    {
+      g_object_set (context,
+                    "transform-direction", transform_direction,
+                    NULL);
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GValueArray *
+context_get_transform_resize_invoker (GimpProcedure      *procedure,
+                                      Gimp               *gimp,
+                                      GimpContext        *context,
+                                      GimpProgress       *progress,
+                                      const GValueArray  *args,
+                                      GError            **error)
+{
+  GValueArray *return_vals;
+  gint32 transform_resize = 0;
+
+  g_object_get (context,
+                "transform-resize", &transform_resize,
+                NULL);
+
+  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
+  g_value_set_enum (&return_vals->values[1], transform_resize);
+
+  return return_vals;
+}
+
+static GValueArray *
+context_set_transform_resize_invoker (GimpProcedure      *procedure,
+                                      Gimp               *gimp,
+                                      GimpContext        *context,
+                                      GimpProgress       *progress,
+                                      const GValueArray  *args,
+                                      GError            **error)
+{
+  gboolean success = TRUE;
+  gint32 transform_resize;
+
+  transform_resize = g_value_get_enum (&args->values[0]);
+
+  if (success)
+    {
+      g_object_set (context,
+                    "transform-resize", transform_resize,
+                    NULL);
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GValueArray *
+context_get_transform_recursion_invoker (GimpProcedure      *procedure,
+                                         Gimp               *gimp,
+                                         GimpContext        *context,
+                                         GimpProgress       *progress,
+                                         const GValueArray  *args,
+                                         GError            **error)
+{
+  GValueArray *return_vals;
+  gint32 transform_recursion = 0;
+
+  g_object_get (context,
+                "transform-recursion", &transform_recursion,
+                NULL);
+
+  return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
+  g_value_set_int (&return_vals->values[1], transform_recursion);
+
+  return return_vals;
+}
+
+static GValueArray *
+context_set_transform_recursion_invoker (GimpProcedure      *procedure,
+                                         Gimp               *gimp,
+                                         GimpContext        *context,
+                                         GimpProgress       *progress,
+                                         const GValueArray  *args,
+                                         GError            **error)
+{
+  gboolean success = TRUE;
+  gint32 transform_recursion;
+
+  transform_recursion = g_value_get_int (&args->values[0]);
+
+  if (success)
+    {
+      g_object_set (context,
+                    "transform-recursion", transform_recursion,
+                    NULL);
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
 void
 register_context_procs (GimpPDB *pdb)
 {
@@ -1497,4 +1677,194 @@ register_context_procs (GimpPDB *pdb)
                                                     GIMP_PARAM_READWRITE));
   gimp_pdb_register_procedure (pdb, procedure);
   g_object_unref (procedure);
+
+  /*
+   * gimp-context-get-interpolation
+   */
+  procedure = gimp_procedure_new (context_get_interpolation_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-context-get-interpolation");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-context-get-interpolation",
+                                     "Get the interpolation type.",
+                                     "This procedure returns the interpolation setting. The return value is an integer which corresponds to the values listed in the argument description.",
+                                     "Michael Natterer <mitch gimp org>",
+                                     "Michael Natterer",
+                                     "2010",
+                                     NULL);
+  gimp_procedure_add_return_value (procedure,
+                                   g_param_spec_enum ("interpolation",
+                                                      "interpolation",
+                                                      "The interpolation type",
+                                                      GIMP_TYPE_INTERPOLATION_TYPE,
+                                                      GIMP_INTERPOLATION_NONE,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
+   * gimp-context-set-interpolation
+   */
+  procedure = gimp_procedure_new (context_set_interpolation_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-context-set-interpolation");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-context-set-interpolation",
+                                     "Set the interpolation type.",
+                                     "This procedure modifies the interpolation setting. It affects all transform procedures which can produce sub-pixel results.",
+                                     "Michael Natterer <mitch gimp org>",
+                                     "Michael Natterer",
+                                     "2010",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_enum ("interpolation",
+                                                  "interpolation",
+                                                  "The interpolation type",
+                                                  GIMP_TYPE_INTERPOLATION_TYPE,
+                                                  GIMP_INTERPOLATION_NONE,
+                                                  GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
+   * gimp-context-get-transform-direction
+   */
+  procedure = gimp_procedure_new (context_get_transform_direction_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-context-get-transform-direction");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-context-get-transform-direction",
+                                     "Get the transform direction.",
+                                     "This procedure returns the transform direction. The return value is an integer which corresponds to the values listed in the argument description.",
+                                     "Michael Natterer <mitch gimp org>",
+                                     "Michael Natterer",
+                                     "2010",
+                                     NULL);
+  gimp_procedure_add_return_value (procedure,
+                                   g_param_spec_enum ("transform-direction",
+                                                      "transform direction",
+                                                      "The transform direction",
+                                                      GIMP_TYPE_TRANSFORM_DIRECTION,
+                                                      GIMP_TRANSFORM_FORWARD,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
+   * gimp-context-set-transform-direction
+   */
+  procedure = gimp_procedure_new (context_set_transform_direction_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-context-set-transform-direction");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-context-set-transform-direction",
+                                     "Set the transform direction.",
+                                     "This procedure modifies the transform direction setting.",
+                                     "Michael Natterer <mitch gimp org>",
+                                     "Michael Natterer",
+                                     "2010",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_enum ("transform-direction",
+                                                  "transform direction",
+                                                  "The transform direction",
+                                                  GIMP_TYPE_TRANSFORM_DIRECTION,
+                                                  GIMP_TRANSFORM_FORWARD,
+                                                  GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
+   * gimp-context-get-transform-resize
+   */
+  procedure = gimp_procedure_new (context_get_transform_resize_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-context-get-transform-resize");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-context-get-transform-resize",
+                                     "Get the transform resize type.",
+                                     "This procedure returns the transform resize setting. The return value is an integer which corresponds to the values listed in the argument description.",
+                                     "Michael Natterer <mitch gimp org>",
+                                     "Michael Natterer",
+                                     "2010",
+                                     NULL);
+  gimp_procedure_add_return_value (procedure,
+                                   g_param_spec_enum ("transform-resize",
+                                                      "transform resize",
+                                                      "The transform resize type",
+                                                      GIMP_TYPE_TRANSFORM_RESIZE,
+                                                      GIMP_TRANSFORM_RESIZE_ADJUST,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
+   * gimp-context-set-transform-resize
+   */
+  procedure = gimp_procedure_new (context_set_transform_resize_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-context-set-transform-resize");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-context-set-transform-resize",
+                                     "Set the transform resize type.",
+                                     "This procedure modifies the transform resize setting. When transforming pixels, if the result of a transform operation has a different size than the original area, this setting determines how the resulting area is sized.",
+                                     "Michael Natterer <mitch gimp org>",
+                                     "Michael Natterer",
+                                     "2010",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_enum ("transform-resize",
+                                                  "transform resize",
+                                                  "The transform resize type",
+                                                  GIMP_TYPE_TRANSFORM_RESIZE,
+                                                  GIMP_TRANSFORM_RESIZE_ADJUST,
+                                                  GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
+   * gimp-context-get-transform-recursion
+   */
+  procedure = gimp_procedure_new (context_get_transform_recursion_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-context-get-transform-recursion");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-context-get-transform-recursion",
+                                     "Get the transform supersampling recursion.",
+                                     "This procedure returns the transform supersampling recursion level.",
+                                     "Michael Natterer <mitch gimp org>",
+                                     "Michael Natterer",
+                                     "2010",
+                                     NULL);
+  gimp_procedure_add_return_value (procedure,
+                                   gimp_param_spec_int32 ("transform-recursion",
+                                                          "transform recursion",
+                                                          "The transform recursion level",
+                                                          1, G_MAXINT32, 1,
+                                                          GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
+   * gimp-context-set-transform-recursion
+   */
+  procedure = gimp_procedure_new (context_set_transform_recursion_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-context-set-transform-recursion");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-context-set-transform-recursion",
+                                     "Set the transform supersampling recursion.",
+                                     "This procedure modifies the transform supersampling recursion level setting. Whether or not a transformation does supersampling is determined by the interplolation type. The recursion level defaults to 3, which is a nice default value.",
+                                     "Michael Natterer <mitch gimp org>",
+                                     "Michael Natterer",
+                                     "2010",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("transform-recursion",
+                                                      "transform recursion",
+                                                      "The transform recursion level",
+                                                      1, G_MAXINT32, 1,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
 }
diff --git a/app/pdb/gimppdbcontext.c b/app/pdb/gimppdbcontext.c
index 1a53f5a..5e27376 100644
--- a/app/pdb/gimppdbcontext.c
+++ b/app/pdb/gimppdbcontext.c
@@ -38,7 +38,11 @@ enum
   PROP_ANTIALIAS,
   PROP_FEATHER,
   PROP_FEATHER_RADIUS_X,
-  PROP_FEATHER_RADIUS_Y
+  PROP_FEATHER_RADIUS_Y,
+  PROP_INTERPOLATION,
+  PROP_TRANSFORM_DIRECTION,
+  PROP_TRANSFORM_RESIZE,
+  PROP_TRANSFORM_RECURSION
 };
 
 
@@ -85,6 +89,29 @@ gimp_pdb_context_class_init (GimpPDBContextClass *klass)
                                    "feather-radius-y", NULL,
                                    0.0, 1000.0, 10.0,
                                    GIMP_PARAM_STATIC_STRINGS);
+
+  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_INTERPOLATION,
+                                 "interpolation", NULL,
+                                 GIMP_TYPE_INTERPOLATION_TYPE,
+                                 GIMP_INTERPOLATION_CUBIC,
+                                 GIMP_PARAM_STATIC_STRINGS);
+
+  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_TRANSFORM_DIRECTION,
+                                 "transform-direction", NULL,
+                                 GIMP_TYPE_TRANSFORM_DIRECTION,
+                                 GIMP_TRANSFORM_FORWARD,
+                                 GIMP_PARAM_STATIC_STRINGS);
+
+  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_TRANSFORM_RESIZE,
+                                 "transform-resize", NULL,
+                                 GIMP_TYPE_TRANSFORM_RESIZE,
+                                 GIMP_TRANSFORM_RESIZE_ADJUST,
+                                 GIMP_PARAM_STATIC_STRINGS);
+
+  GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_TRANSFORM_RECURSION,
+                                "transform-recursion", NULL,
+                                1, G_MAXINT32, 3,
+                                GIMP_PARAM_STATIC_STRINGS);
 }
 
 static void
@@ -118,6 +145,22 @@ gimp_pdb_context_set_property (GObject      *object,
       options->feather_radius_y = g_value_get_double (value);
       break;
 
+    case PROP_INTERPOLATION:
+      options->interpolation = g_value_get_enum (value);
+      break;
+
+    case PROP_TRANSFORM_DIRECTION:
+      options->transform_direction = g_value_get_enum (value);
+      break;
+
+    case PROP_TRANSFORM_RESIZE:
+      options->transform_resize = g_value_get_enum (value);
+      break;
+
+    case PROP_TRANSFORM_RECURSION:
+      options->transform_recursion = g_value_get_int (value);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -150,6 +193,22 @@ gimp_pdb_context_get_property (GObject    *object,
       g_value_set_double (value, options->feather_radius_y);
       break;
 
+    case PROP_INTERPOLATION:
+      g_value_set_enum (value, options->interpolation);
+      break;
+
+    case PROP_TRANSFORM_DIRECTION:
+      g_value_set_enum (value, options->transform_direction);
+      break;
+
+    case PROP_TRANSFORM_RESIZE:
+      g_value_set_enum (value, options->transform_resize);
+      break;
+
+    case PROP_TRANSFORM_RECURSION:
+      g_value_set_int (value, options->transform_recursion);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
diff --git a/app/pdb/gimppdbcontext.h b/app/pdb/gimppdbcontext.h
index b8c0d3a..40ba0b7 100644
--- a/app/pdb/gimppdbcontext.h
+++ b/app/pdb/gimppdbcontext.h
@@ -37,12 +37,17 @@ typedef struct _GimpPDBContextClass GimpPDBContextClass;
 
 struct _GimpPDBContext
 {
-  GimpContext  parent_instance;
+  GimpContext             parent_instance;
 
-  gboolean     antialias;
-  gboolean     feather;
-  gdouble      feather_radius_x;
-  gdouble      feather_radius_y;
+  gboolean                antialias;
+  gboolean                feather;
+  gdouble                 feather_radius_x;
+  gdouble                 feather_radius_y;
+
+  GimpInterpolationType   interpolation;
+  GimpTransformDirection  transform_direction;
+  GimpTransformResize     transform_resize;
+  gint                    transform_recursion;
 };
 
 struct _GimpPDBContextClass
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index dad1125..88bdb4e 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 640 procedures registered total */
+/* 648 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index 2dfac04..db066c3 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -76,11 +76,15 @@ EXPORTS
 	gimp_context_get_font
 	gimp_context_get_foreground
 	gimp_context_get_gradient
+	gimp_context_get_interpolation
 	gimp_context_get_opacity
 	gimp_context_get_paint_method
 	gimp_context_get_paint_mode
 	gimp_context_get_palette
 	gimp_context_get_pattern
+	gimp_context_get_transform_direction
+	gimp_context_get_transform_recursion
+	gimp_context_get_transform_resize
 	gimp_context_list_paint_methods
 	gimp_context_pop
 	gimp_context_push
@@ -93,11 +97,15 @@ EXPORTS
 	gimp_context_set_font
 	gimp_context_set_foreground
 	gimp_context_set_gradient
+	gimp_context_set_interpolation
 	gimp_context_set_opacity
 	gimp_context_set_paint_method
 	gimp_context_set_paint_mode
 	gimp_context_set_palette
 	gimp_context_set_pattern
+	gimp_context_set_transform_direction
+	gimp_context_set_transform_recursion
+	gimp_context_set_transform_resize
 	gimp_context_swap_colors
 	gimp_convert_dither_type_get_type
 	gimp_convert_palette_type_get_type
diff --git a/libgimp/gimpcontext_pdb.c b/libgimp/gimpcontext_pdb.c
index fa2b6e1..791253f 100644
--- a/libgimp/gimpcontext_pdb.c
+++ b/libgimp/gimpcontext_pdb.c
@@ -1065,3 +1065,260 @@ gimp_context_set_feather_radius (gdouble feather_radius_x,
 
   return success;
 }
+
+/**
+ * gimp_context_get_interpolation:
+ *
+ * Get the interpolation type.
+ *
+ * This procedure returns the interpolation setting. The return value
+ * is an integer which corresponds to the values listed in the argument
+ * description.
+ *
+ * Returns: The interpolation type.
+ *
+ * Since: GIMP 2.8
+ */
+GimpInterpolationType
+gimp_context_get_interpolation (void)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  GimpInterpolationType interpolation = 0;
+
+  return_vals = gimp_run_procedure ("gimp-context-get-interpolation",
+                                    &nreturn_vals,
+                                    GIMP_PDB_END);
+
+  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
+    interpolation = return_vals[1].data.d_int32;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return interpolation;
+}
+
+/**
+ * gimp_context_set_interpolation:
+ * @interpolation: The interpolation type.
+ *
+ * Set the interpolation type.
+ *
+ * This procedure modifies the interpolation setting. It affects all
+ * transform procedures which can produce sub-pixel results.
+ *
+ * Returns: TRUE on success.
+ *
+ * Since: GIMP 2.8
+ */
+gboolean
+gimp_context_set_interpolation (GimpInterpolationType interpolation)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gboolean success = TRUE;
+
+  return_vals = gimp_run_procedure ("gimp-context-set-interpolation",
+                                    &nreturn_vals,
+                                    GIMP_PDB_INT32, interpolation,
+                                    GIMP_PDB_END);
+
+  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return success;
+}
+
+/**
+ * gimp_context_get_transform_direction:
+ *
+ * Get the transform direction.
+ *
+ * This procedure returns the transform direction. The return value is
+ * an integer which corresponds to the values listed in the argument
+ * description.
+ *
+ * Returns: The transform direction.
+ *
+ * Since: GIMP 2.8
+ */
+GimpTransformDirection
+gimp_context_get_transform_direction (void)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  GimpTransformDirection transform_direction = 0;
+
+  return_vals = gimp_run_procedure ("gimp-context-get-transform-direction",
+                                    &nreturn_vals,
+                                    GIMP_PDB_END);
+
+  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
+    transform_direction = return_vals[1].data.d_int32;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return transform_direction;
+}
+
+/**
+ * gimp_context_set_transform_direction:
+ * @transform_direction: The transform direction.
+ *
+ * Set the transform direction.
+ *
+ * This procedure modifies the transform direction setting.
+ *
+ * Returns: TRUE on success.
+ *
+ * Since: GIMP 2.8
+ */
+gboolean
+gimp_context_set_transform_direction (GimpTransformDirection transform_direction)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gboolean success = TRUE;
+
+  return_vals = gimp_run_procedure ("gimp-context-set-transform-direction",
+                                    &nreturn_vals,
+                                    GIMP_PDB_INT32, transform_direction,
+                                    GIMP_PDB_END);
+
+  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return success;
+}
+
+/**
+ * gimp_context_get_transform_resize:
+ *
+ * Get the transform resize type.
+ *
+ * This procedure returns the transform resize setting. The return
+ * value is an integer which corresponds to the values listed in the
+ * argument description.
+ *
+ * Returns: The transform resize type.
+ *
+ * Since: GIMP 2.8
+ */
+GimpTransformResize
+gimp_context_get_transform_resize (void)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  GimpTransformResize transform_resize = 0;
+
+  return_vals = gimp_run_procedure ("gimp-context-get-transform-resize",
+                                    &nreturn_vals,
+                                    GIMP_PDB_END);
+
+  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
+    transform_resize = return_vals[1].data.d_int32;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return transform_resize;
+}
+
+/**
+ * gimp_context_set_transform_resize:
+ * @transform_resize: The transform resize type.
+ *
+ * Set the transform resize type.
+ *
+ * This procedure modifies the transform resize setting. When
+ * transforming pixels, if the result of a transform operation has a
+ * different size than the original area, this setting determines how
+ * the resulting area is sized.
+ *
+ * Returns: TRUE on success.
+ *
+ * Since: GIMP 2.8
+ */
+gboolean
+gimp_context_set_transform_resize (GimpTransformResize transform_resize)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gboolean success = TRUE;
+
+  return_vals = gimp_run_procedure ("gimp-context-set-transform-resize",
+                                    &nreturn_vals,
+                                    GIMP_PDB_INT32, transform_resize,
+                                    GIMP_PDB_END);
+
+  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return success;
+}
+
+/**
+ * gimp_context_get_transform_recursion:
+ *
+ * Get the transform supersampling recursion.
+ *
+ * This procedure returns the transform supersampling recursion level.
+ *
+ * Returns: The transform recursion level.
+ *
+ * Since: GIMP 2.8
+ */
+gint
+gimp_context_get_transform_recursion (void)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gint transform_recursion = 0;
+
+  return_vals = gimp_run_procedure ("gimp-context-get-transform-recursion",
+                                    &nreturn_vals,
+                                    GIMP_PDB_END);
+
+  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
+    transform_recursion = return_vals[1].data.d_int32;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return transform_recursion;
+}
+
+/**
+ * gimp_context_set_transform_recursion:
+ * @transform_recursion: The transform recursion level.
+ *
+ * Set the transform supersampling recursion.
+ *
+ * This procedure modifies the transform supersampling recursion level
+ * setting. Whether or not a transformation does supersampling is
+ * determined by the interplolation type. The recursion level defaults
+ * to 3, which is a nice default value.
+ *
+ * Returns: TRUE on success.
+ *
+ * Since: GIMP 2.8
+ */
+gboolean
+gimp_context_set_transform_recursion (gint transform_recursion)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gboolean success = TRUE;
+
+  return_vals = gimp_run_procedure ("gimp-context-set-transform-recursion",
+                                    &nreturn_vals,
+                                    GIMP_PDB_INT32, transform_recursion,
+                                    GIMP_PDB_END);
+
+  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return success;
+}
diff --git a/libgimp/gimpcontext_pdb.h b/libgimp/gimpcontext_pdb.h
index 06ab3d7..2822982 100644
--- a/libgimp/gimpcontext_pdb.h
+++ b/libgimp/gimpcontext_pdb.h
@@ -28,40 +28,48 @@ G_BEGIN_DECLS
 /* For information look into the C source or the html documentation */
 
 
-gboolean             gimp_context_push               (void);
-gboolean             gimp_context_pop                (void);
-gboolean             gimp_context_list_paint_methods (gint                   *num_paint_methods,
-                                                      gchar                ***paint_methods);
-gchar*               gimp_context_get_paint_method   (void);
-gboolean             gimp_context_set_paint_method   (const gchar            *name);
-gboolean             gimp_context_get_foreground     (GimpRGB                *foreground);
-gboolean             gimp_context_set_foreground     (const GimpRGB          *foreground);
-gboolean             gimp_context_get_background     (GimpRGB                *background);
-gboolean             gimp_context_set_background     (const GimpRGB          *background);
-gboolean             gimp_context_set_default_colors (void);
-gboolean             gimp_context_swap_colors        (void);
-gdouble              gimp_context_get_opacity        (void);
-gboolean             gimp_context_set_opacity        (gdouble                 opacity);
-GimpLayerModeEffects gimp_context_get_paint_mode     (void);
-gboolean             gimp_context_set_paint_mode     (GimpLayerModeEffects    paint_mode);
-gchar*               gimp_context_get_brush          (void);
-gboolean             gimp_context_set_brush          (const gchar            *name);
-gchar*               gimp_context_get_pattern        (void);
-gboolean             gimp_context_set_pattern        (const gchar            *name);
-gchar*               gimp_context_get_gradient       (void);
-gboolean             gimp_context_set_gradient       (const gchar            *name);
-gchar*               gimp_context_get_palette        (void);
-gboolean             gimp_context_set_palette        (const gchar            *name);
-gchar*               gimp_context_get_font           (void);
-gboolean             gimp_context_set_font           (const gchar            *name);
-gboolean             gimp_context_get_antialias      (void);
-gboolean             gimp_context_set_antialias      (gboolean                antialias);
-gboolean             gimp_context_get_feather        (void);
-gboolean             gimp_context_set_feather        (gboolean                feather);
-gboolean             gimp_context_get_feather_radius (gdouble                *feather_radius_x,
-                                                      gdouble                *feather_radius_y);
-gboolean             gimp_context_set_feather_radius (gdouble                 feather_radius_x,
-                                                      gdouble                 feather_radius_y);
+gboolean               gimp_context_push                    (void);
+gboolean               gimp_context_pop                     (void);
+gboolean               gimp_context_list_paint_methods      (gint                     *num_paint_methods,
+                                                             gchar                  ***paint_methods);
+gchar*                 gimp_context_get_paint_method        (void);
+gboolean               gimp_context_set_paint_method        (const gchar              *name);
+gboolean               gimp_context_get_foreground          (GimpRGB                  *foreground);
+gboolean               gimp_context_set_foreground          (const GimpRGB            *foreground);
+gboolean               gimp_context_get_background          (GimpRGB                  *background);
+gboolean               gimp_context_set_background          (const GimpRGB            *background);
+gboolean               gimp_context_set_default_colors      (void);
+gboolean               gimp_context_swap_colors             (void);
+gdouble                gimp_context_get_opacity             (void);
+gboolean               gimp_context_set_opacity             (gdouble                   opacity);
+GimpLayerModeEffects   gimp_context_get_paint_mode          (void);
+gboolean               gimp_context_set_paint_mode          (GimpLayerModeEffects      paint_mode);
+gchar*                 gimp_context_get_brush               (void);
+gboolean               gimp_context_set_brush               (const gchar              *name);
+gchar*                 gimp_context_get_pattern             (void);
+gboolean               gimp_context_set_pattern             (const gchar              *name);
+gchar*                 gimp_context_get_gradient            (void);
+gboolean               gimp_context_set_gradient            (const gchar              *name);
+gchar*                 gimp_context_get_palette             (void);
+gboolean               gimp_context_set_palette             (const gchar              *name);
+gchar*                 gimp_context_get_font                (void);
+gboolean               gimp_context_set_font                (const gchar              *name);
+gboolean               gimp_context_get_antialias           (void);
+gboolean               gimp_context_set_antialias           (gboolean                  antialias);
+gboolean               gimp_context_get_feather             (void);
+gboolean               gimp_context_set_feather             (gboolean                  feather);
+gboolean               gimp_context_get_feather_radius      (gdouble                  *feather_radius_x,
+                                                             gdouble                  *feather_radius_y);
+gboolean               gimp_context_set_feather_radius      (gdouble                   feather_radius_x,
+                                                             gdouble                   feather_radius_y);
+GimpInterpolationType  gimp_context_get_interpolation       (void);
+gboolean               gimp_context_set_interpolation       (GimpInterpolationType     interpolation);
+GimpTransformDirection gimp_context_get_transform_direction (void);
+gboolean               gimp_context_set_transform_direction (GimpTransformDirection    transform_direction);
+GimpTransformResize    gimp_context_get_transform_resize    (void);
+gboolean               gimp_context_set_transform_resize    (GimpTransformResize       transform_resize);
+gint                   gimp_context_get_transform_recursion (void);
+gboolean               gimp_context_set_transform_recursion (gint                      transform_recursion);
 
 
 G_END_DECLS
diff --git a/tools/pdbgen/pdb/context.pdb b/tools/pdbgen/pdb/context.pdb
index 1312bd9..d3c3fbc 100644
--- a/tools/pdbgen/pdb/context.pdb
+++ b/tools/pdbgen/pdb/context.pdb
@@ -864,6 +864,219 @@ CODE
     );
 }
 
+sub context_get_interpolation {
+    $blurb = 'Get the interpolation type.';
+
+    $help = <<'HELP';
+This procedure returns the interpolation setting. The return value
+is an integer which corresponds to the values listed in the argument
+description.
+HELP
+
+    &mitch_pdb_misc('2010', '2.8');
+
+    @outargs = (
+        { name => 'interpolation', type => 'enum GimpInterpolationType',
+          desc => 'The interpolation type' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  g_object_get (context,
+                "interpolation", &interpolation,
+                NULL);
+}
+CODE
+    );
+}
+
+sub context_set_interpolation {
+    $blurb = 'Set the interpolation type.';
+
+    $help = <<'HELP';
+This procedure modifies the interpolation setting. It affects all
+transform procedures which can produce sub-pixel results.
+HELP
+
+    &mitch_pdb_misc('2010', '2.8');
+
+    @inargs = (
+        { name => 'interpolation', type => 'enum GimpInterpolationType',
+          desc => 'The interpolation type' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  g_object_set (context,
+                "interpolation", interpolation,
+                NULL);
+}
+CODE
+    );
+}
+
+sub context_get_transform_direction {
+    $blurb = 'Get the transform direction.';
+
+    $help = <<'HELP';
+This procedure returns the transform direction. The return value
+is an integer which corresponds to the values listed in the argument
+description.
+HELP
+
+    &mitch_pdb_misc('2010', '2.8');
+
+    @outargs = (
+        { name => 'transform_direction', type => 'enum GimpTransformDirection',
+          desc => 'The transform direction' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  g_object_get (context,
+                "transform-direction", &transform_direction,
+                NULL);
+}
+CODE
+    );
+}
+
+sub context_set_transform_direction {
+    $blurb = 'Set the transform direction.';
+
+    $help = <<'HELP';
+This procedure modifies the transform direction setting.
+HELP
+
+    &mitch_pdb_misc('2010', '2.8');
+
+    @inargs = (
+        { name => 'transform_direction', type => 'enum GimpTransformDirection',
+          desc => 'The transform direction' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  g_object_set (context,
+                "transform-direction", transform_direction,
+                NULL);
+}
+CODE
+    );
+}
+
+sub context_get_transform_resize {
+    $blurb = 'Get the transform resize type.';
+
+    $help = <<'HELP';
+This procedure returns the transform resize setting. The return value
+is an integer which corresponds to the values listed in the argument
+description.
+HELP
+
+    &mitch_pdb_misc('2010', '2.8');
+
+    @outargs = (
+        { name => 'transform_resize', type => 'enum GimpTransformResize',
+          desc => 'The transform resize type' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  g_object_get (context,
+                "transform-resize", &transform_resize,
+                NULL);
+}
+CODE
+    );
+}
+
+sub context_set_transform_resize {
+    $blurb = 'Set the transform resize type.';
+
+    $help = <<'HELP';
+This procedure modifies the transform resize setting. When transforming
+pixels, if the result of a transform operation  has a different size
+than the original area, this setting determines how the resulting area
+is sized.
+HELP
+
+    &mitch_pdb_misc('2010', '2.8');
+
+    @inargs = (
+        { name => 'transform_resize', type => 'enum GimpTransformResize',
+          desc => 'The transform resize type' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  g_object_set (context,
+                "transform-resize", transform_resize,
+                NULL);
+}
+CODE
+    );
+}
+
+sub context_get_transform_recursion {
+    $blurb = 'Get the transform supersampling recursion.';
+
+    $help = <<'HELP';
+This procedure returns the transform supersampling recursion level.
+HELP
+
+    &mitch_pdb_misc('2010', '2.8');
+
+    @outargs = (
+        { name => 'transform_recursion', type => '1 <= int32',
+          desc => 'The transform recursion level' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  g_object_get (context,
+                "transform-recursion", &transform_recursion,
+                NULL);
+}
+CODE
+    );
+}
+
+sub context_set_transform_recursion {
+    $blurb = 'Set the transform supersampling recursion.';
+
+    $help = <<'HELP';
+This procedure modifies the transform supersampling recursion level
+setting. Whether or not a transformation does supersampling is
+determined by the interplolation type. The recursion level defaults
+to 3, which is a nice default value.
+HELP
+
+    &mitch_pdb_misc('2010', '2.8');
+
+    @inargs = (
+        { name => 'transform_recursion', type => '1 <= int32',
+          desc => 'The transform recursion level' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  g_object_set (context,
+                "transform-recursion", transform_recursion,
+                NULL);
+}
+CODE
+    );
+}
+
 @headers = qw("core/gimp.h"
               "core/gimpcontainer.h"
               "core/gimpdatafactory.h"
@@ -889,7 +1102,11 @@ CODE
             context_get_font context_set_font
             context_get_antialias context_set_antialias
             context_get_feather context_set_feather
-            context_get_feather_radius context_set_feather_radius);
+            context_get_feather_radius context_set_feather_radius
+            context_get_interpolation context_set_interpolation
+            context_get_transform_direction context_set_transform_direction
+            context_get_transform_resize context_set_transform_resize
+            context_get_transform_recursion context_set_transform_recursion);
 
 %exports = (app => [ procs], lib => [ procs]);
 



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