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



Author: mitch
Date: Sat May 17 09:19:58 2008
New Revision: 25683
URL: http://svn.gnome.org/viewvc/gimp?rev=25683&view=rev

Log:
2008-05-17  Michael Natterer  <mitch gimp org>

	* tools/pdbgen/pdb/gradient.pdb: applied patch from Lars-Peter
	Clausen which adds gimp-gradient-get-number-of-segments. Fixes
	bug #533474.

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

	* libgimp/gimp.def: add the new symbol.



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

Modified: trunk/app/pdb/gradient-cmds.c
==============================================================================
--- trunk/app/pdb/gradient-cmds.c	(original)
+++ trunk/app/pdb/gradient-cmds.c	Sat May 17 09:19:58 2008
@@ -264,6 +264,45 @@
 }
 
 static GValueArray *
+gradient_get_number_of_segments_invoker (GimpProcedure      *procedure,
+                                         Gimp               *gimp,
+                                         GimpContext        *context,
+                                         GimpProgress       *progress,
+                                         const GValueArray  *args,
+                                         GError            **error)
+{
+  gboolean success = TRUE;
+  GValueArray *return_vals;
+  const gchar *name;
+  gint32 num_segments = 0;
+
+  name = g_value_get_string (&args->values[0]);
+
+  if (success)
+    {
+      GimpGradient        *gradient;
+      GimpGradientSegment *seg;
+
+      gradient = gimp_pdb_get_gradient (gimp, name, FALSE, error);
+
+      if (gradient)
+        {
+          for (seg = gradient->segments; seg; seg = seg->next)
+            num_segments++;
+        }
+      else
+        success = FALSE;
+    }
+
+  return_vals = gimp_procedure_get_return_values (procedure, success);
+
+  if (success)
+    g_value_set_int (&return_vals->values[1], num_segments);
+
+  return return_vals;
+}
+
+static GValueArray *
 gradient_get_uniform_samples_invoker (GimpProcedure      *procedure,
                                       Gimp               *gimp,
                                       GimpContext        *context,
@@ -1502,6 +1541,36 @@
   g_object_unref (procedure);
 
   /*
+   * gimp-gradient-get-number-of-segments
+   */
+  procedure = gimp_procedure_new (gradient_get_number_of_segments_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-gradient-get-number-of-segments");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-gradient-get-number-of-segments",
+                                     "Returns the number of segments of the specified gradient",
+                                     "This procedure returns the number of segments of the specified gradient.",
+                                     "Lars-Peter Clausen <lars metafoo de>",
+                                     "Lars-Peter Clausen",
+                                     "2008",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_string ("name",
+                                                       "name",
+                                                       "The gradient name",
+                                                       FALSE, FALSE, TRUE,
+                                                       NULL,
+                                                       GIMP_PARAM_READWRITE));
+  gimp_procedure_add_return_value (procedure,
+                                   gimp_param_spec_int32 ("num-segments",
+                                                          "num segments",
+                                                          "Number of segments",
+                                                          G_MININT32, G_MAXINT32, 0,
+                                                          GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-gradient-get-uniform-samples
    */
   procedure = gimp_procedure_new (gradient_get_uniform_samples_invoker);

Modified: trunk/app/pdb/internal-procs.c
==============================================================================
--- trunk/app/pdb/internal-procs.c	(original)
+++ trunk/app/pdb/internal-procs.c	Sat May 17 09:19:58 2008
@@ -29,7 +29,7 @@
 #include "internal-procs.h"
 
 
-/* 585 procedures registered total */
+/* 586 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)

Modified: trunk/libgimp/gimp.def
==============================================================================
--- trunk/libgimp/gimp.def	(original)
+++ trunk/libgimp/gimp.def	Sat May 17 09:19:58 2008
@@ -243,6 +243,7 @@
 	gimp_gradient_delete
 	gimp_gradient_duplicate
 	gimp_gradient_get_custom_samples
+	gimp_gradient_get_number_of_segments
 	gimp_gradient_get_uniform_samples
 	gimp_gradient_is_editable
 	gimp_gradient_new

Modified: trunk/libgimp/gimpgradient_pdb.c
==============================================================================
--- trunk/libgimp/gimpgradient_pdb.c	(original)
+++ trunk/libgimp/gimpgradient_pdb.c	Sat May 17 09:19:58 2008
@@ -190,6 +190,39 @@
 }
 
 /**
+ * gimp_gradient_get_number_of_segments:
+ * @name: The gradient name.
+ *
+ * Returns the number of segments of the specified gradient
+ *
+ * This procedure returns the number of segments of the specified
+ * gradient.
+ *
+ * Returns: Number of segments.
+ *
+ * Since: GIMP 2.6
+ */
+gint
+gimp_gradient_get_number_of_segments (const gchar *name)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gint num_segments = 0;
+
+  return_vals = gimp_run_procedure ("gimp-gradient-get-number-of-segments",
+                                    &nreturn_vals,
+                                    GIMP_PDB_STRING, name,
+                                    GIMP_PDB_END);
+
+  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
+    num_segments = return_vals[1].data.d_int32;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return num_segments;
+}
+
+/**
  * gimp_gradient_get_uniform_samples:
  * @name: The gradient name.
  * @num_samples: The number of samples to take.

Modified: trunk/libgimp/gimpgradient_pdb.h
==============================================================================
--- trunk/libgimp/gimpgradient_pdb.h	(original)
+++ trunk/libgimp/gimpgradient_pdb.h	Sat May 17 09:19:58 2008
@@ -35,6 +35,7 @@
 gchar*   gimp_gradient_rename                              (const gchar               *name,
                                                             const gchar               *new_name);
 gboolean gimp_gradient_delete                              (const gchar               *name);
+gint     gimp_gradient_get_number_of_segments              (const gchar               *name);
 gboolean gimp_gradient_get_uniform_samples                 (const gchar               *name,
                                                             gint                       num_samples,
                                                             gboolean                   reverse,

Modified: trunk/tools/pdbgen/pdb/gradient.pdb
==============================================================================
--- trunk/tools/pdbgen/pdb/gradient.pdb	(original)
+++ trunk/tools/pdbgen/pdb/gradient.pdb	Sat May 17 09:19:58 2008
@@ -176,6 +176,48 @@
     );
 }
 
+sub gradient_get_number_of_segments {
+    $blurb = 'Returns the number of segments of the specified gradient';
+
+    $help = <<'HELP';
+This procedure returns the number of segments of the specified gradient.
+HELP
+
+    $author    = 'Lars-Peter Clausen <lars metafoo de>';
+    $copyright = 'Lars-Peter Clausen';
+    $date      = '2008';
+    $since     = '2.6';
+
+
+    @inargs = (
+        { name => 'name', type => 'string', non_empty => 1,
+          desc => 'The gradient name' }
+    );
+
+    @outargs = (
+        { name => 'num_segments', type => 'int32',
+          init => 0, desc => 'Number of segments' }
+    );
+    %invoke = (
+        code => <<'CODE'
+{
+  GimpGradient        *gradient;
+  GimpGradientSegment *seg;
+
+  gradient = gimp_pdb_get_gradient (gimp, name, FALSE, error);
+
+  if (gradient)
+    {
+      for (seg = gradient->segments; seg; seg = seg->next)
+        num_segments++;
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub gradient_get_uniform_samples {
     $blurb = 'Sample the specified in uniform parts.';
 
@@ -1385,8 +1427,9 @@
 @procs = qw(gradient_new
             gradient_duplicate
             gradient_is_editable
-	    gradient_rename
+            gradient_rename
             gradient_delete
+            gradient_get_number_of_segments
             gradient_get_uniform_samples gradient_get_custom_samples
             gradient_segment_get_left_color gradient_segment_set_left_color
             gradient_segment_get_right_color gradient_segment_set_right_color



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