Commit 20b16129 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

use enums instead of integers, cleanup.

2004-06-01  Michael Natterer  <mitch@gimp.org>

	* tools/pdbgen/pdb/gradient_edit.pdb: use enums instead of
	integers, cleanup.

	* app/pdb/gradient_edit_cmds.c
	* libgimp/gimpgradientedit_pdb.[ch]: regenerated.
parent 149888b5
2004-06-01 Michael Natterer <mitch@gimp.org>
* tools/pdbgen/pdb/gradient_edit.pdb: use enums instead of
integers, cleanup.
* app/pdb/gradient_edit_cmds.c
* libgimp/gimpgradientedit_pdb.[ch]: regenerated.
2004-06-01 Michael Natterer <mitch@gimp.org>
* app/core/gimpdatafactory.[ch]: added new function
......
......@@ -124,25 +124,22 @@ gradient_segment_get_left_color_invoker (Gimp *gimp,
gradient = gimp_context_get_gradient (context);
}
if (gradient)
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
if (seg)
success = (seg != NULL);
if (success)
{
/* Success */
gimp_gradient_segment_get_left_color (gradient, seg, &color);
opacity = color.a * 100.0;
}
else
{
success = FALSE;
}
}
else
{
success = FALSE;
}
}
......@@ -240,25 +237,22 @@ gradient_segment_set_left_color_invoker (Gimp *gimp,
gradient = gimp_context_get_gradient (context);
}
if (gradient)
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
if (seg)
success = (seg != NULL);
if (success)
{
/* Success */
color.a = opacity / 100.0;
gimp_gradient_segment_set_left_color (gradient, seg, &color);
}
else
{
success = FALSE;
}
}
else
{
success = FALSE;
}
}
......@@ -339,25 +333,22 @@ gradient_segment_get_right_color_invoker (Gimp *gimp,
gradient = gimp_context_get_gradient (context);
}
if (gradient)
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
if (seg)
success = (seg != NULL);
if (success)
{
/* Success */
gimp_gradient_segment_get_right_color (gradient, seg, &color);
opacity = color.a * 100.0;
}
else
{
success = FALSE;
}
}
else
{
success = FALSE;
}
}
......@@ -455,25 +446,22 @@ gradient_segment_set_right_color_invoker (Gimp *gimp,
gradient = gimp_context_get_gradient (context);
}
if (gradient)
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
if (seg)
success = (seg != NULL);
if (success)
{
/* Success */
color.a = opacity / 100.0;
gimp_gradient_segment_set_right_color (gradient, seg, &color);
}
else
{
success = FALSE;
}
}
else
{
success = FALSE;
}
}
......@@ -553,24 +541,21 @@ gradient_segment_get_left_pos_invoker (Gimp *gimp,
gradient = gimp_context_get_gradient (context);
}
if (gradient)
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
if (seg)
success = (seg != NULL);
if (success)
{
/* Success */
pos = gimp_gradient_segment_get_left_pos (gradient, seg);
}
else
{
success = FALSE;
}
}
else
{
success = FALSE;
}
}
......@@ -659,24 +644,21 @@ gradient_segment_set_left_pos_invoker (Gimp *gimp,
gradient = gimp_context_get_gradient (context);
}
if (gradient)
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
if (seg)
success = (seg != NULL);
if (success)
{
/* Success */
final_pos = gimp_gradient_segment_set_left_pos (gradient, seg, pos);
}
else
{
success = FALSE;
}
}
else
{
success = FALSE;
}
}
......@@ -765,24 +747,21 @@ gradient_segment_get_middle_pos_invoker (Gimp *gimp,
gradient = gimp_context_get_gradient (context);
}
if (gradient)
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
if (seg)
success = (seg != NULL);
if (success)
{
/* Success */
pos = gimp_gradient_segment_get_middle_pos (gradient, seg);
}
else
{
success = FALSE;
}
}
else
{
success = FALSE;
}
}
......@@ -871,24 +850,21 @@ gradient_segment_set_middle_pos_invoker (Gimp *gimp,
gradient = gimp_context_get_gradient (context);
}
if (gradient)
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
if (seg)
success = (seg != NULL);
if (success)
{
/* Success */
final_pos = gimp_gradient_segment_set_middle_pos (gradient, seg, pos);
}
else
{
success = FALSE;
}
}
else
{
success = FALSE;
}
}
......@@ -977,24 +953,21 @@ gradient_segment_get_right_pos_invoker (Gimp *gimp,
gradient = gimp_context_get_gradient (context);
}
if (gradient)
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
if (seg)
success = (seg != NULL);
if (success)
{
/* Success */
pos = gimp_gradient_segment_get_right_pos (gradient, seg);
}
else
{
success = FALSE;
}
}
else
{
success = FALSE;
}
}
......@@ -1083,24 +1056,21 @@ gradient_segment_set_right_pos_invoker (Gimp *gimp,
gradient = gimp_context_get_gradient (context);
}
if (gradient)
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
if (seg)
success = (seg != NULL);
if (success)
{
/* Success */
final_pos = gimp_gradient_segment_set_right_pos (gradient, seg, pos);
}
else
{
success = FALSE;
}
}
else
{
success = FALSE;
}
}
......@@ -1189,24 +1159,21 @@ gradient_segment_get_blending_function_invoker (Gimp *gimp,
gradient = gimp_context_get_gradient (context);
}
if (gradient)
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
if (seg)
success = (seg != NULL);
if (success)
{
/* Success */
blend_func = gimp_gradient_segment_get_blending_function (gradient, seg);
}
else
{
success = FALSE;
}
}
else
{
success = FALSE;
}
}
......@@ -1280,7 +1247,7 @@ gradient_segment_set_blending_function_invoker (Gimp *gimp,
end_segment = args[2].value.pdb_int;
blending_function = args[3].value.pdb_int;
if (blending_function < 0 || blending_function > 4)
if (blending_function < GIMP_GRADIENT_SEGMENT_LINEAR || blending_function > GIMP_GRADIENT_SEGMENT_SPHERE_DECREASING)
success = FALSE;
if (success)
......@@ -1357,7 +1324,7 @@ static ProcArg gradient_segment_set_blending_function_inargs[] =
{
GIMP_PDB_INT32,
"blending_function",
"The Blending Function (GRAD-LINEAR, GRAD-CURVED, GRAD-SINE, GRAD-SPHERE-INCREASING, GRAD-SPHERE-DECREASING)"
"The Blending Function: { GIMP_GRADIENT_SEGMENT_LINEAR (0), GIMP_GRADIENT_SEGMENT_CURVED (1), GIMP_GRADIENT_SEGMENT_SINE (2), GIMP_GRADIENT_SEGMENT_SPHERE_INCREASING (3), GIMP_GRADIENT_SEGMENT_SPHERE_DECREASING (4) }"
}
};
......@@ -1410,24 +1377,21 @@ gradient_segment_get_coloring_type_invoker (Gimp *gimp,
gradient = gimp_context_get_gradient (context);
}
if (gradient)
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
if (seg)
success = (seg != NULL);
if (success)
{
/* Success */
coloring_type = gimp_gradient_segment_get_coloring_type (gradient, seg);
}
else
{
success = FALSE;
}
}
else
{
success = FALSE;
}
}
......@@ -1501,7 +1465,7 @@ gradient_segment_set_coloring_type_invoker (Gimp *gimp,
end_segment = args[2].value.pdb_int;
coloring_type = args[3].value.pdb_int;
if (coloring_type < 0 || coloring_type > 2)
if (coloring_type < GIMP_GRADIENT_SEGMENT_RGB || coloring_type > GIMP_GRADIENT_SEGMENT_HSV_CW)
success = FALSE;
if (success)
......@@ -1578,7 +1542,7 @@ static ProcArg gradient_segment_set_coloring_type_inargs[] =
{
GIMP_PDB_INT32,
"coloring_type",
"The Coloring Type (GRAD-RGB, GRAD-HSV-CCW, GRAD-HSV-CW)"
"The Coloring Type: { GIMP_GRADIENT_SEGMENT_RGB (0), GIMP_GRADIENT_SEGMENT_HSV_CCW (1), GIMP_GRADIENT_SEGMENT_HSV_CW (2) }"
}
};
......
......@@ -504,7 +504,7 @@ gimp_gradient_segment_get_blending_function (const gchar *name,
* @name: The name of the gradient to operate on.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
* @blending_function: The Blending Function (GRAD-LINEAR, GRAD-CURVED, GRAD-SINE, GRAD-SPHERE-INCREASING, GRAD-SPHERE-DECREASING).
* @blending_function: The Blending Function.
*
* Change the blending function of a segments range
*
......@@ -514,10 +514,10 @@ gimp_gradient_segment_get_blending_function (const gchar *name,
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_set_blending_function (const gchar *name,
gint start_segment,
gint end_segment,
gint blending_function)
gimp_gradient_segment_set_blending_function (const gchar *name,
gint start_segment,
gint end_segment,
GimpGradientSegmentType blending_function)
{
GimpParam *return_vals;
gint nreturn_vals;
......@@ -583,7 +583,7 @@ gimp_gradient_segment_get_coloring_type (const gchar *name,
* @name: The name of the gradient to operate on.
* @start_segment: The index of the first segment to operate on.
* @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
* @coloring_type: The Coloring Type (GRAD-RGB, GRAD-HSV-CCW, GRAD-HSV-CW).
* @coloring_type: The Coloring Type.
*
* Change the coloring type of a segments range
*
......@@ -593,10 +593,10 @@ gimp_gradient_segment_get_coloring_type (const gchar *name,
* Returns: TRUE on success.
*/
gboolean
gimp_gradient_segment_set_coloring_type (const gchar *name,
gint start_segment,
gint end_segment,
gint coloring_type)
gimp_gradient_segment_set_coloring_type (const gchar *name,
gint start_segment,
gint end_segment,
GimpGradientSegmentColor coloring_type)
{
GimpParam *return_vals;
gint nreturn_vals;
......
......@@ -29,88 +29,88 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean gimp_gradient_segment_get_left_color (const gchar *name,
gint segment,
GimpRGB *color,
gdouble *opacity);
gboolean gimp_gradient_segment_set_left_color (const gchar *name,
gint segment,
const GimpRGB *color,
gdouble opacity);
gboolean gimp_gradient_segment_get_right_color (const gchar *name,
gint segment,
GimpRGB *color,
gdouble *opacity);
gboolean gimp_gradient_segment_set_right_color (const gchar *name,
gint segment,
const GimpRGB *color,
gdouble opacity);
gboolean gimp_gradient_segment_get_left_pos (const gchar *name,
gint segment,
gdouble *pos);
gboolean gimp_gradient_segment_set_left_pos (const gchar *name,
gint segment,
gdouble pos,
gdouble *final_pos);
gboolean gimp_gradient_segment_get_middle_pos (const gchar *name,
gint segment,
gdouble *pos);
gboolean gimp_gradient_segment_set_middle_pos (const gchar *name,
gint segment,
gdouble pos,
gdouble *final_pos);
gboolean gimp_gradient_segment_get_right_pos (const gchar *name,
gint segment,
gdouble *pos);
gboolean gimp_gradient_segment_set_right_pos (const gchar *name,
gint segment,
gdouble pos,
gdouble *final_pos);
gboolean gimp_gradient_segment_get_blending_function (const gchar *name,
gint segment,
gint *blend_func);
gboolean gimp_gradient_segment_set_blending_function (const gchar *name,
gint start_segment,
gint end_segment,
gint blending_function);
gboolean gimp_gradient_segment_get_coloring_type (const gchar *name,
gint segment,
gint *coloring_type);
gboolean gimp_gradient_segment_set_coloring_type (const gchar *name,
gint start_segment,
gint end_segment,
gint coloring_type);
gboolean gimp_gradient_segment_range_flip (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_replicate (const gchar *name,
gint start_segment,
gint end_segment,
gint replicate_times);
gboolean gimp_gradient_segment_range_split_midpoint (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_split_uniform (const gchar *name,
gint start_segment,
gint end_segment,
gint split_parts);
gboolean gimp_gradient_segment_range_delete (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_redistribute_handles (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_blend_colors (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_blend_opacity (const gchar *name,
gint start_segment,
gint end_segment);
gdouble gimp_gradient_segment_range_move (const gchar *name,
gint start_segment,
gint end_segment,
gdouble delta,
gboolean control_compress);
gboolean gimp_gradient_segment_get_left_color (const gchar *name,
gint segment,
GimpRGB *color,
gdouble *opacity);
gboolean gimp_gradient_segment_set_left_color (const gchar *name,
gint segment,
const GimpRGB *color,
gdouble opacity);
gboolean gimp_gradient_segment_get_right_color (const gchar *name,
gint segment,
GimpRGB *color,
gdouble *opacity);
gboolean gimp_gradient_segment_set_right_color (const gchar *name,
gint segment,
const GimpRGB *color,
gdouble opacity);
gboolean gimp_gradient_segment_get_left_pos (const gchar *name,
gint segment,
gdouble *pos);
gboolean gimp_gradient_segment_set_left_pos (const gchar *name,
gint segment,
gdouble pos,
gdouble *final_pos);
gboolean gimp_gradient_segment_get_middle_pos (const gchar *name,
gint segment,
gdouble *pos);
gboolean gimp_gradient_segment_set_middle_pos (const gchar *name,
gint segment,
gdouble pos,
gdouble *final_pos);
gboolean gimp_gradient_segment_get_right_pos (const gchar *name,
gint segment,
gdouble *pos);
gboolean gimp_gradient_segment_set_right_pos (const gchar *name,
gint segment,
gdouble pos,
gdouble *final_pos);
gboolean gimp_gradient_segment_get_blending_function (const gchar *name,
gint segment,
gint *blend_func);
gboolean gimp_gradient_segment_set_blending_function (const gchar *name,
gint start_segment,
gint end_segment,
GimpGradientSegmentType blending_function);
gboolean gimp_gradient_segment_get_coloring_type (const gchar *name,
gint segment,
gint *coloring_type);
gboolean gimp_gradient_segment_set_coloring_type (const gchar *name,
gint start_segment,
gint end_segment,
GimpGradientSegmentColor coloring_type);
gboolean gimp_gradient_segment_range_flip (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_replicate (const gchar *name,
gint start_segment,
gint end_segment,
gint replicate_times);
gboolean gimp_gradient_segment_range_split_midpoint (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_split_uniform (const gchar *name,
gint start_segment,
gint end_segment,
gint split_parts);
gboolean gimp_gradient_segment_range_delete (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_redistribute_handles (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_blend_colors (const gchar *name,
gint start_segment,
gint end_segment);
gboolean gimp_gradient_segment_range_blend_opacity (const gchar *name,
gint start_segment,
gint end_segment);
gdouble gimp_gradient_segment_range_move (const gchar *name,
gint start_segment,
gint end_segment,
gdouble delta,
gboolean control_compress);
G_END_DECLS
......
......@@ -40,23 +40,21 @@ sub _gen_gradient_search_for_segment_code
return <<"CODE";
{
$_get_gradient_from_name_code
if (gradient)
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
if (seg)
success = (seg != NULL);
if (success)
{
/* Success */
$action_on_success
}
else
{
success = FALSE;
}
}
else
{
success = FALSE;
}
}
......@@ -73,17 +71,10 @@ sub other_side
sub _grad_and_seg_params
{
return
(
{