diff --git a/ChangeLog b/ChangeLog index 4a363b8705..cc158ebf21 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-06-02 Michael Natterer + + * tools/pdbgen/pdb/gradient_edit.pdb: set_blending_function() and + set_coloring_type() work on segment ranges, renamed them + accordingly. Spotted by Shlomi Fish. + + * app/pdb/gradient_edit_cmds.c + * libgimp/gimpgradientedit_pdb.[ch]: regenerated. + 2004-06-02 Michael Natterer * app/widgets/gimpdnd.[ch]: removed utility funtion diff --git a/app/pdb/gradient_edit_cmds.c b/app/pdb/gradient_edit_cmds.c index 1fcb40d586..4110e870c1 100644 --- a/app/pdb/gradient_edit_cmds.c +++ b/app/pdb/gradient_edit_cmds.c @@ -49,9 +49,9 @@ static ProcRecord gradient_segment_set_middle_pos_proc; static ProcRecord gradient_segment_get_right_pos_proc; static ProcRecord gradient_segment_set_right_pos_proc; static ProcRecord gradient_segment_get_blending_function_proc; -static ProcRecord gradient_segment_set_blending_function_proc; static ProcRecord gradient_segment_get_coloring_type_proc; -static ProcRecord gradient_segment_set_coloring_type_proc; +static ProcRecord gradient_segment_range_set_blending_function_proc; +static ProcRecord gradient_segment_range_set_coloring_type_proc; static ProcRecord gradient_segment_range_flip_proc; static ProcRecord gradient_segment_range_replicate_proc; static ProcRecord gradient_segment_range_split_midpoint_proc; @@ -76,9 +76,9 @@ register_gradient_edit_procs (Gimp *gimp) procedural_db_register (gimp, &gradient_segment_get_right_pos_proc); procedural_db_register (gimp, &gradient_segment_set_right_pos_proc); procedural_db_register (gimp, &gradient_segment_get_blending_function_proc); - procedural_db_register (gimp, &gradient_segment_set_blending_function_proc); procedural_db_register (gimp, &gradient_segment_get_coloring_type_proc); - procedural_db_register (gimp, &gradient_segment_set_coloring_type_proc); + procedural_db_register (gimp, &gradient_segment_range_set_blending_function_proc); + procedural_db_register (gimp, &gradient_segment_range_set_coloring_type_proc); procedural_db_register (gimp, &gradient_segment_range_flip_proc); procedural_db_register (gimp, &gradient_segment_range_replicate_proc); procedural_db_register (gimp, &gradient_segment_range_split_midpoint_proc); @@ -1224,126 +1224,6 @@ static ProcRecord gradient_segment_get_blending_function_proc = { { gradient_segment_get_blending_function_invoker } } }; -static Argument * -gradient_segment_set_blending_function_invoker (Gimp *gimp, - GimpContext *context, - Argument *args) -{ - gboolean success = TRUE; - gchar *name; - gint32 start_segment; - gint32 end_segment; - gint32 blending_function; - GimpGradient *gradient = NULL; - - name = (gchar *) args[0].value.pdb_pointer; - if (name == NULL || !g_utf8_validate (name, -1, NULL)) - success = FALSE; - - start_segment = args[1].value.pdb_int; - if (start_segment < 0) - success = FALSE; - - end_segment = args[2].value.pdb_int; - - blending_function = args[3].value.pdb_int; - if (blending_function < GIMP_GRADIENT_SEGMENT_LINEAR || blending_function > GIMP_GRADIENT_SEGMENT_SPHERE_DECREASING) - success = FALSE; - - if (success) - { - if (strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } - - if (gradient) - { - GimpGradientSegment *start_seg, *end_seg; - start_seg = gimp_gradient_segment_get_nth (gradient->segments, start_segment); - if (start_seg) - { - if ((end_segment < start_segment) && (end_segment >= 0)) - { - /* Do Nothing */ - success = FALSE; - } - else - { - if (end_segment < 0) - { - end_seg = NULL; - } - else - { - end_seg = gimp_gradient_segment_get_nth (start_seg, - end_segment - start_segment); - } - - /* Success */ - gimp_gradient_segment_range_set_blending_function (gradient, - start_seg, - end_seg, - blending_function); - - } - } - else - { - success = FALSE; - } - } - } - - return procedural_db_return_args (&gradient_segment_set_blending_function_proc, success); -} - -static ProcArg gradient_segment_set_blending_function_inargs[] = -{ - { - GIMP_PDB_STRING, - "name", - "The name of the gradient to operate on." - }, - { - GIMP_PDB_INT32, - "start_segment", - "The index of the first segment to operate on" - }, - { - GIMP_PDB_INT32, - "end_segment", - "The index of the last segment to operate on. If negative, the selection will extend to the end of the string." - }, - { - GIMP_PDB_INT32, - "blending_function", - "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) }" - } -}; - -static ProcRecord gradient_segment_set_blending_function_proc = -{ - "gimp_gradient_segment_set_blending_function", - "Change the blending function of a segments range", - "This function changes the blending function of a segment range to the specified blending function.", - "Shlomi Fish", - "Shlomi Fish", - "2003", - GIMP_INTERNAL, - 4, - gradient_segment_set_blending_function_inargs, - 0, - NULL, - { { gradient_segment_set_blending_function_invoker } } -}; - static Argument * gradient_segment_get_coloring_type_invoker (Gimp *gimp, GimpContext *context, @@ -1443,9 +1323,129 @@ static ProcRecord gradient_segment_get_coloring_type_proc = }; static Argument * -gradient_segment_set_coloring_type_invoker (Gimp *gimp, - GimpContext *context, - Argument *args) +gradient_segment_range_set_blending_function_invoker (Gimp *gimp, + GimpContext *context, + Argument *args) +{ + gboolean success = TRUE; + gchar *name; + gint32 start_segment; + gint32 end_segment; + gint32 blending_function; + GimpGradient *gradient = NULL; + + name = (gchar *) args[0].value.pdb_pointer; + if (name == NULL || !g_utf8_validate (name, -1, NULL)) + success = FALSE; + + start_segment = args[1].value.pdb_int; + if (start_segment < 0) + success = FALSE; + + end_segment = args[2].value.pdb_int; + + blending_function = args[3].value.pdb_int; + if (blending_function < GIMP_GRADIENT_SEGMENT_LINEAR || blending_function > GIMP_GRADIENT_SEGMENT_SPHERE_DECREASING) + success = FALSE; + + if (success) + { + if (strlen (name)) + { + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, + name); + } + else + { + gradient = gimp_context_get_gradient (context); + } + + if (gradient) + { + GimpGradientSegment *start_seg, *end_seg; + start_seg = gimp_gradient_segment_get_nth (gradient->segments, start_segment); + if (start_seg) + { + if ((end_segment < start_segment) && (end_segment >= 0)) + { + /* Do Nothing */ + success = FALSE; + } + else + { + if (end_segment < 0) + { + end_seg = NULL; + } + else + { + end_seg = gimp_gradient_segment_get_nth (start_seg, + end_segment - start_segment); + } + + /* Success */ + gimp_gradient_segment_range_set_blending_function (gradient, + start_seg, + end_seg, + blending_function); + + } + } + else + { + success = FALSE; + } + } + } + + return procedural_db_return_args (&gradient_segment_range_set_blending_function_proc, success); +} + +static ProcArg gradient_segment_range_set_blending_function_inargs[] = +{ + { + GIMP_PDB_STRING, + "name", + "The name of the gradient to operate on." + }, + { + GIMP_PDB_INT32, + "start_segment", + "The index of the first segment to operate on" + }, + { + GIMP_PDB_INT32, + "end_segment", + "The index of the last segment to operate on. If negative, the selection will extend to the end of the string." + }, + { + GIMP_PDB_INT32, + "blending_function", + "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) }" + } +}; + +static ProcRecord gradient_segment_range_set_blending_function_proc = +{ + "gimp_gradient_segment_range_set_blending_function", + "Change the blending function of a segments range", + "This function changes the blending function of a segment range to the specified blending function.", + "Shlomi Fish", + "Shlomi Fish", + "2003", + GIMP_INTERNAL, + 4, + gradient_segment_range_set_blending_function_inargs, + 0, + NULL, + { { gradient_segment_range_set_blending_function_invoker } } +}; + +static Argument * +gradient_segment_range_set_coloring_type_invoker (Gimp *gimp, + GimpContext *context, + Argument *args) { gboolean success = TRUE; gchar *name; @@ -1519,10 +1519,10 @@ gradient_segment_set_coloring_type_invoker (Gimp *gimp, } } - return procedural_db_return_args (&gradient_segment_set_coloring_type_proc, success); + return procedural_db_return_args (&gradient_segment_range_set_coloring_type_proc, success); } -static ProcArg gradient_segment_set_coloring_type_inargs[] = +static ProcArg gradient_segment_range_set_coloring_type_inargs[] = { { GIMP_PDB_STRING, @@ -1546,9 +1546,9 @@ static ProcArg gradient_segment_set_coloring_type_inargs[] = } }; -static ProcRecord gradient_segment_set_coloring_type_proc = +static ProcRecord gradient_segment_range_set_coloring_type_proc = { - "gimp_gradient_segment_set_coloring_type", + "gimp_gradient_segment_range_set_coloring_type", "Change the coloring type of a segments range", "This function changes the coloring type of a segment range to the specified coloring type.", "Shlomi Fish", @@ -1556,10 +1556,10 @@ static ProcRecord gradient_segment_set_coloring_type_proc = "2003", GIMP_INTERNAL, 4, - gradient_segment_set_coloring_type_inargs, + gradient_segment_range_set_coloring_type_inargs, 0, NULL, - { { gradient_segment_set_coloring_type_invoker } } + { { gradient_segment_range_set_coloring_type_invoker } } }; static Argument * diff --git a/libgimp/gimpgradientedit_pdb.c b/libgimp/gimpgradientedit_pdb.c index b78896189f..58cf2be1b7 100644 --- a/libgimp/gimpgradientedit_pdb.c +++ b/libgimp/gimpgradientedit_pdb.c @@ -521,47 +521,6 @@ gimp_gradient_segment_get_blending_function (const gchar *name, return success; } -/** - * gimp_gradient_segment_set_blending_function: - * @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. - * - * Change the blending function of a segments range - * - * This function changes the blending function of a segment range to - * the specified blending function. - * - * Returns: TRUE on success. - * - * Since: GIMP 2.2 - */ -gboolean -gimp_gradient_segment_set_blending_function (const gchar *name, - gint start_segment, - gint end_segment, - GimpGradientSegmentType blending_function) -{ - GimpParam *return_vals; - gint nreturn_vals; - gboolean success = TRUE; - - return_vals = gimp_run_procedure ("gimp_gradient_segment_set_blending_function", - &nreturn_vals, - GIMP_PDB_STRING, name, - GIMP_PDB_INT32, start_segment, - GIMP_PDB_INT32, end_segment, - GIMP_PDB_INT32, blending_function, - GIMP_PDB_END); - - success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; - - gimp_destroy_params (return_vals, nreturn_vals); - - return success; -} - /** * gimp_gradient_segment_get_coloring_type: * @name: The name of the gradient to operate on. @@ -605,7 +564,48 @@ gimp_gradient_segment_get_coloring_type (const gchar *name, } /** - * gimp_gradient_segment_set_coloring_type: + * gimp_gradient_segment_range_set_blending_function: + * @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. + * + * Change the blending function of a segments range + * + * This function changes the blending function of a segment range to + * the specified blending function. + * + * Returns: TRUE on success. + * + * Since: GIMP 2.2 + */ +gboolean +gimp_gradient_segment_range_set_blending_function (const gchar *name, + gint start_segment, + gint end_segment, + GimpGradientSegmentType blending_function) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_gradient_segment_range_set_blending_function", + &nreturn_vals, + GIMP_PDB_STRING, name, + GIMP_PDB_INT32, start_segment, + GIMP_PDB_INT32, end_segment, + GIMP_PDB_INT32, blending_function, + GIMP_PDB_END); + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} + +/** + * gimp_gradient_segment_range_set_coloring_type: * @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. @@ -621,16 +621,16 @@ gimp_gradient_segment_get_coloring_type (const gchar *name, * Since: GIMP 2.2 */ gboolean -gimp_gradient_segment_set_coloring_type (const gchar *name, - gint start_segment, - gint end_segment, - GimpGradientSegmentColor coloring_type) +gimp_gradient_segment_range_set_coloring_type (const gchar *name, + gint start_segment, + gint end_segment, + GimpGradientSegmentColor coloring_type) { GimpParam *return_vals; gint nreturn_vals; gboolean success = TRUE; - return_vals = gimp_run_procedure ("gimp_gradient_segment_set_coloring_type", + return_vals = gimp_run_procedure ("gimp_gradient_segment_range_set_coloring_type", &nreturn_vals, GIMP_PDB_STRING, name, GIMP_PDB_INT32, start_segment, diff --git a/libgimp/gimpgradientedit_pdb.h b/libgimp/gimpgradientedit_pdb.h index 02c88a7fe7..995230ccef 100644 --- a/libgimp/gimpgradientedit_pdb.h +++ b/libgimp/gimpgradientedit_pdb.h @@ -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, - GimpGradientSegmentType *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, - GimpGradientSegmentColor *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); +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, + GimpGradientSegmentType *blend_func); +gboolean gimp_gradient_segment_get_coloring_type (const gchar *name, + gint segment, + GimpGradientSegmentColor *coloring_type); +gboolean gimp_gradient_segment_range_set_blending_function (const gchar *name, + gint start_segment, + gint end_segment, + GimpGradientSegmentType blending_function); +gboolean gimp_gradient_segment_range_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 diff --git a/tools/pdbgen/pdb/gradient.pdb b/tools/pdbgen/pdb/gradient.pdb index ec2b3aa298..be6523ca5b 100644 --- a/tools/pdbgen/pdb/gradient.pdb +++ b/tools/pdbgen/pdb/gradient.pdb @@ -407,7 +407,7 @@ CODE ); } -sub gradient_segment_set_blending_function +sub gradient_segment_range_set_blending_function { &_gen_gradient_operate_on_segments_range( 'blurb' => "Change the blending function of a segments range", @@ -430,7 +430,7 @@ CODE ); } -sub gradient_segment_set_coloring_type +sub gradient_segment_range_set_coloring_type { &_gen_gradient_operate_on_segments_range( 'blurb' => "Change the coloring type of a segments range", @@ -651,9 +651,9 @@ CODE gradient_segment_get_middle_pos gradient_segment_set_middle_pos gradient_segment_get_right_pos gradient_segment_set_right_pos gradient_segment_get_blending_function - gradient_segment_set_blending_function gradient_segment_get_coloring_type - gradient_segment_set_coloring_type + gradient_segment_range_set_blending_function + gradient_segment_range_set_coloring_type gradient_segment_range_flip gradient_segment_range_replicate gradient_segment_range_split_midpoint diff --git a/tools/pdbgen/pdb/gradient_edit.pdb b/tools/pdbgen/pdb/gradient_edit.pdb index ec2b3aa298..be6523ca5b 100644 --- a/tools/pdbgen/pdb/gradient_edit.pdb +++ b/tools/pdbgen/pdb/gradient_edit.pdb @@ -407,7 +407,7 @@ CODE ); } -sub gradient_segment_set_blending_function +sub gradient_segment_range_set_blending_function { &_gen_gradient_operate_on_segments_range( 'blurb' => "Change the blending function of a segments range", @@ -430,7 +430,7 @@ CODE ); } -sub gradient_segment_set_coloring_type +sub gradient_segment_range_set_coloring_type { &_gen_gradient_operate_on_segments_range( 'blurb' => "Change the coloring type of a segments range", @@ -651,9 +651,9 @@ CODE gradient_segment_get_middle_pos gradient_segment_set_middle_pos gradient_segment_get_right_pos gradient_segment_set_right_pos gradient_segment_get_blending_function - gradient_segment_set_blending_function gradient_segment_get_coloring_type - gradient_segment_set_coloring_type + gradient_segment_range_set_blending_function + gradient_segment_range_set_coloring_type gradient_segment_range_flip gradient_segment_range_replicate gradient_segment_range_split_midpoint