[gimp] app: add gimp_gradient_segment_range_get_n_segments()



commit 082f6a4122e023562415f975d4d2315cd72ba7ae
Author: Ell <ell_se yahoo com>
Date:   Tue Aug 1 13:38:15 2017 -0400

    app: add gimp_gradient_segment_range_get_n_segments()
    
    ... which returns the number of segments in a range.

 app/core/gimpgradient.c |   19 +++++++++++++++++++
 app/core/gimpgradient.h |    5 +++++
 2 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpgradient.c b/app/core/gimpgradient.c
index 5e4206e..15a40b0 100644
--- a/app/core/gimpgradient.c
+++ b/app/core/gimpgradient.c
@@ -1155,6 +1155,25 @@ gimp_gradient_segment_get_coloring_type (GimpGradient        *gradient,
   return seg->color;
 }
 
+gint
+gimp_gradient_segment_range_get_n_segments (GimpGradient        *gradient,
+                                            GimpGradientSegment *range_l,
+                                            GimpGradientSegment *range_r)
+{
+  gint n_segments = 0;
+
+  g_return_val_if_fail (GIMP_IS_GRADIENT (gradient), 0);
+  g_return_val_if_fail (range_l != NULL, 0);
+
+  for (; range_l != range_r; range_l = range_l->next)
+    n_segments++;
+
+  if (range_r != NULL)
+    n_segments++;
+
+  return n_segments;
+}
+
 void
 gimp_gradient_segment_range_compress (GimpGradient        *gradient,
                                       GimpGradientSegment *range_l,
diff --git a/app/core/gimpgradient.h b/app/core/gimpgradient.h
index 3b9d328..f9f9987 100644
--- a/app/core/gimpgradient.h
+++ b/app/core/gimpgradient.h
@@ -199,6 +199,11 @@ gimp_gradient_segment_get_coloring_type       (GimpGradient         *gradient,
  * If the second segment is NULL, these functions will process
  * until the end of the string.
  * */
+gint    gimp_gradient_segment_range_get_n_segments
+                                              (GimpGradient         *gradient,
+                                               GimpGradientSegment  *range_l,
+                                               GimpGradientSegment  *range_r);
+
 void    gimp_gradient_segment_range_compress  (GimpGradient         *gradient,
                                                GimpGradientSegment  *range_l,
                                                GimpGradientSegment  *range_r,


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