Well, here is the up-to-date patch according to the commentary from the
core developers that I received on the IRC.

Regards,

        Shlomi Fish


----------------------------------------------------------------------
Shlomi Fish        [EMAIL PROTECTED]
Home Page:         http://t2.technion.ac.il/~shlomif/

An apple a day will keep a doctor away. Two apples a day will keep two
doctors away.

        Falk Fish
--- ../gimp-1.3.23/tools/pdbgen/Makefile.am     2003-10-05 15:16:51.000000000 +0200
+++ gimp/tools/pdbgen/Makefile.am       2003-12-12 21:00:22.000000000 +0200
@@ -15,6 +15,7 @@
        pdb/font_select.pdb     \
        pdb/fonts.pdb           \
        pdb/gimprc.pdb          \
+       pdb/gradient_edit.pdb   \
        pdb/gradient_select.pdb \
        pdb/gradients.pdb       \
        pdb/guides.pdb          \
--- ../gimp-1.3.23/app/pdb/Makefile.am  2003-10-05 15:16:14.000000000 +0200
+++ gimp/app/pdb/Makefile.am    2003-12-12 20:57:07.000000000 +0200
@@ -20,6 +20,7 @@
        font_select_cmds.c      \
        fonts_cmds.c            \
        gimprc_cmds.c           \
+       gradient_edit_cmds.c \
        gradient_select_cmds.c  \
        gradients_cmds.c        \
        guides_cmds.c           \
--- ../gimp-1.3.23/tools/pdbgen/groups.pl       2003-09-07 22:57:12.000000000 +0300
+++ gimp/tools/pdbgen/groups.pl 2003-12-12 20:45:20.000000000 +0200
@@ -13,6 +13,7 @@
     font_select
     fonts
     gimprc
+    gradient_edit
     gradient_select
     gradients
     guides
--- ../gimp-1.3.23/tools/pdbgen/pdb/gradient_edit.pdb   1970-01-01 02:00:00.000000000 
+0200
+++ gimp/tools/pdbgen/pdb/gradient_edit.pdb     2003-12-18 16:48:22.000000000 +0200
@@ -0,0 +1,212 @@
+# The GIMP -- an image manipulation program
+# Copyright (C) 1995 Spencer Kimball and Peter Mattis
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+sub pdb_misc {
+    $author = $copyright = 'Shlomi Fish';
+    $date = '2003';
+}
+
+sub _gen_gradient_search_for_segment_code
+{
+    my $action_on_success = shift;
+
+    return <<"CODE";
+{
+  if (strlen (name))
+    {
+      gradient = (GimpGradient *)
+        gimp_container_get_child_by_name (gimp->gradient_factory->container,
+                                          name);
+    }
+  else
+    {
+      gradient = gimp_context_get_gradient (gimp_get_current_context (gimp));;
+    }
+
+  if (gradient)
+    {
+      GimpGradientSegment * seg;
+      seg = gimp_gradient_get_segment_by_index (gradient, segment);
+      if (seg)
+        {
+          /* Success */
+          $action_on_success
+        }
+      else
+        {
+          success = FALSE;
+        }
+    }
+  else
+    {
+      success = FALSE;
+    }
+}
+    
+CODE
+}
+
+sub other_side
+{
+    my $side = shift;
+
+    return ($side eq "left") ? "right" : "left";
+}
+
+sub _gen_gradient_set_side_end_color
+{
+    my $side = shift;
+
+    my $other_side = other_side($side);
+
+    $blurb = "Retrieves the $side endpoint color of the specified gradient and 
segment";
+
+    $help = <<"HELP";
+This procedure retrieves the $side endpoint color of the specified segment of
+the specified gradient.
+HELP
+
+    &pdb_misc;
+
+    @inargs = (
+        {
+            name => 'name',
+            type => 'string',
+            desc => 'The name of the gradient to get the color from',
+        },
+        {
+            name => 'segment',
+            type => '0 <= int32',
+            desc => 'The index of the segment from to which the endpoint belongs',
+        },
+        {
+            name => 'color',
+            type => 'color',
+            desc => "The color to set",
+        },
+        {
+            name => "opacity",
+            type => '0 <= float <= 100.0',
+            desc => "The opacity to set for the endpoint",
+        },
+        
+    );
+
+    @outargs = (
+    );
+
+    my @blend_params = ("&color","&(seg->${other_side}_color)");
+    if ($side eq "right")
+    {
+        @blend_params = reverse(@blend_params);
+    }
+    
+    %invoke = (
+        vars => [ 'GimpGradient *gradient = NULL' ],
+        code => &_gen_gradient_search_for_segment_code(<<"CODE"),
+          color.a = opacity / 100.0;
+          gimp_gradient_set_segment_${side}_color (gradient, seg, &color);
+CODE
+    );
+}
+
+
+sub _gen_gradient_get_side_end_color
+{
+    my $side = shift;
+
+    $blurb = "Retrieves the $side endpoint color of the specified gradient and 
segment";
+
+    $help = <<"HELP";
+This procedure retrieves the $side endpoint color of the specified segment of
+the specified gradient.
+HELP
+
+    &pdb_misc;
+
+    @inargs = (
+        {
+            name => 'name',
+            type => 'string',
+            desc => 'The name of the gradient to get the color from',
+        },
+        {
+            name => 'segment',
+            type => '0 <= int32',
+            desc => 'The index of the segment from to which the endpoint belongs',
+        },
+    );
+
+    @outargs = (
+        {
+            name => 'color',
+            type => 'color',
+            desc => "The return color",
+            void_ret => 1,
+            init => 1,
+        },
+        {
+            name => "opacity",
+            type => 'float',
+            desc => "The opacity of the endpoint",
+        },
+    );
+    
+    %invoke = (
+        vars => [ 'GimpGradient *gradient = NULL' ],
+        code => &_gen_gradient_search_for_segment_code(<<"CODE"),
+          gimp_gradient_get_segment_${side}_color (gradient, seg, &color);
+          opacity = color.a * 100.0;
+CODE
+    );
+}
+
+sub gradient_get_left_end_color
+{
+    &_gen_gradient_get_side_end_color("left");
+}
+
+sub gradient_get_right_end_color
+{
+    &_gen_gradient_get_side_end_color("right");
+}
+
+sub gradient_set_left_end_color
+{
+    &_gen_gradient_set_side_end_color("left");
+}
+
+sub gradient_set_right_end_color
+{
+    &_gen_gradient_set_side_end_color("right");
+}
+
[EMAIL PROTECTED] = qw(<string.h> "core/gimp.h" "core/gimpcontext.h" 
+    "core/gimpgradient.h" "core/gimpcontainer.h" 
+    "core/gimpdatafactory.h" "core/gimplist.h");
+
[EMAIL PROTECTED] = (qw(gradient_get_left_end_color gradient_get_right_end_color),
+    qw(gradient_set_left_end_color gradient_set_right_end_color)
+    );
+
+# %exports = (app => [EMAIL PROTECTED], lib => [EMAIL PROTECTED]);
+%exports = (app => [EMAIL PROTECTED]);
+
+$desc = 'Gradient';
+
+1;
+
--- ../gimp-1.3.23/app/core/gimpgradient.c      2003-11-20 03:44:01.000000000 +0200
+++ gimp/app/core/gimpgradient.c        2003-12-18 16:47:18.000000000 +0200
@@ -1196,3 +1196,68 @@
     }
   while (aseg != rseg);
 }
+
+GimpGradientSegment * gimp_gradient_get_segment_by_index (GimpGradient *gradient,
+                                                          int index)
+{
+  GimpGradientSegment *seg;
+  int i;
+  
+  if (i < 0)
+    {
+      return NULL;
+    }
+  seg = gradient->segments;
+  i = 0;
+  while (seg && (i < index))
+    {
+      seg = seg->next;
+      i++;
+    }
+  if (seg && (i == index))
+    {
+      return seg;
+    }
+  else
+    {
+      return NULL;
+    }
+}
+
+void gimp_gradient_get_segment_left_color  (GimpGradient *gradient,
+                                            GimpGradientSegment *seg,
+                                            GimpRGB * color)
+{
+  *color = seg->left_color;
+}
+
+void gimp_gradient_get_segment_right_color (GimpGradient *gradient,
+                                            GimpGradientSegment *seg,
+                                            GimpRGB * color)
+{
+  *color = seg->right_color;
+}
+
+void gimp_gradient_set_segment_left_color (GimpGradient *gradient,
+                                            GimpGradientSegment *seg,
+                                            GimpRGB * color)
+{
+  gimp_gradient_segments_blend_endpoints (seg, seg, 
+                                          color, &(seg->right_color),
+                                          TRUE, TRUE);
+  
+  gimp_data_dirty (GIMP_DATA(gradient));
+}
+
+void gimp_gradient_set_segment_right_color (GimpGradient *gradient,
+                                            GimpGradientSegment *seg,
+                                            GimpRGB * color)
+{
+  gimp_gradient_segments_blend_endpoints (seg, seg, 
+                                          &(seg->left_color), color,
+                                          TRUE, TRUE);
+  
+  gimp_data_dirty (GIMP_DATA(gradient));
+}
+
+
--- ../gimp-1.3.23/app/core/gimpgradient.h      2003-07-22 21:30:38.000000000 +0300
+++ gimp/app/core/gimpgradient.h        2003-12-18 16:53:45.000000000 +0200
@@ -118,4 +118,23 @@
                                                gboolean              blend_colors,
                                                gboolean              blend_opacity);
 
+GimpGradientSegment * gimp_gradient_get_segment_by_index (GimpGradient *gradient,
+                                                          int index);
+
+void gimp_gradient_get_segment_left_color  (GimpGradient *gradient,
+                                            GimpGradientSegment *seg,
+                                            GimpRGB * color);
+
+void gimp_gradient_get_segment_right_color (GimpGradient *gradient,
+                                            GimpGradientSegment *seg,
+                                            GimpRGB * color);
+
+void gimp_gradient_set_segment_left_color  (GimpGradient *gradient,
+                                            GimpGradientSegment *seg,
+                                            GimpRGB * color);
+
+void gimp_gradient_set_segment_right_color (GimpGradient *gradient,
+                                            GimpGradientSegment *seg,
+                                            GimpRGB * color);
+                                               
 #endif /* __GIMP_GRADIENT_H__ */
_______________________________________________
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer

Reply via email to