diff --git a/ChangeLog b/ChangeLog index cb44d39adf..0d0574ce7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,46 @@ +2004-10-06 Michael Natterer + + * tools/pdbgen/pdb/brushes.pdb (brushes_get_brush_data) + * tools/pdbgen/pdb/gradients.pdb (gradients_sample_uniform) + (gradients_sample_custom) (gradients_get_gradient_data) + * tools/pdbgen/pdb/patterns.pdb (patterns_get_pattern_data): + deprecated. + + * tools/pdbgen/pdb/brush.pdb + * tools/pdbgen/pdb/gradient.pdb + * tools/pdbgen/pdb/palette.pdb + * tools/pdbgen/pdb/pattern.pdb: added replacements for the + deprecated functions. Removed the silly feature that passing NULL + as name operates on the current brush, pattern etc. + + * app/pdb/brush_cmds.c + * app/pdb/brushes_cmds.c + * app/pdb/gradient_cmds.c + * app/pdb/gradients_cmds.c + * app/pdb/internal_procs.c + * app/pdb/palette_cmds.c + * app/pdb/pattern_cmds.c + * app/pdb/patterns_cmds.c + * libgimp/gimpbrush_pdb.[ch] + * libgimp/gimpbrushes_pdb.[ch] + * libgimp/gimpgradient_pdb.[ch] + * libgimp/gimpgradients_pdb.[ch] + * libgimp/gimppalette_pdb.c + * libgimp/gimppattern_pdb.[ch] + * libgimp/gimppatterns_pdb.[ch]: regenerated. + + * libgimp/gimpbrushmenu.c + * libgimp/gimpgradientmenu.c + * libgimp/gimppatternmenu.c + * plug-ins/FractalExplorer/Dialogs.c + * plug-ins/common/gradmap.c + * plug-ins/common/sample_colorize.c + * plug-ins/flame/flame.c + * plug-ins/gfig/gfig-style.c + * plug-ins/gflare/gflare.c + * plug-ins/pagecurl/pagecurl.c + * plug-ins/script-fu/scripts/spyrogimp.scm: changed accordingly. + 2004-10-06 Sven Neumann * plug-ins/common/spheredesigner.c: improved the dialog a bit, diff --git a/app/pdb/brush_cmds.c b/app/pdb/brush_cmds.c index 78c40ed802..3d33d479d3 100644 --- a/app/pdb/brush_cmds.c +++ b/app/pdb/brush_cmds.c @@ -39,6 +39,7 @@ static ProcRecord brush_duplicate_proc; static ProcRecord brush_rename_proc; static ProcRecord brush_delete_proc; static ProcRecord brush_get_info_proc; +static ProcRecord brush_get_pixels_proc; static ProcRecord brush_get_spacing_proc; static ProcRecord brush_set_spacing_proc; @@ -50,6 +51,7 @@ register_brush_procs (Gimp *gimp) procedural_db_register (gimp, &brush_rename_proc); procedural_db_register (gimp, &brush_delete_proc); procedural_db_register (gimp, &brush_get_info_proc); + procedural_db_register (gimp, &brush_get_pixels_proc); procedural_db_register (gimp, &brush_get_spacing_proc); procedural_db_register (gimp, &brush_set_spacing_proc); } @@ -132,21 +134,13 @@ brush_duplicate_invoker (Gimp *gimp, GimpBrush *brush_copy = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; if (success) { - if (name && strlen (name)) - { - brush = (GimpBrush *) - gimp_container_get_child_by_name (gimp->brush_factory->container, - name); - } - else - { - brush = gimp_context_get_brush (context); - } + brush = (GimpBrush *) + gimp_container_get_child_by_name (gimp->brush_factory->container, name); if (brush) { @@ -173,7 +167,7 @@ static ProcArg brush_duplicate_inargs[] = { GIMP_PDB_STRING, "name", - "The brush name (\"\" means currently active brush)" + "The brush name" } }; @@ -215,7 +209,7 @@ brush_rename_invoker (Gimp *gimp, GimpBrush *brush = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; new_name = (gchar *) args[1].value.pdb_pointer; @@ -224,16 +218,8 @@ brush_rename_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - brush = (GimpBrush *) - gimp_container_get_child_by_name (gimp->brush_factory->container, - name); - } - else - { - brush = gimp_context_get_brush (context); - } + brush = (GimpBrush *) + gimp_container_get_child_by_name (gimp->brush_factory->container, name); if (brush && GIMP_DATA (brush)->writable) gimp_object_set_name (GIMP_OBJECT (brush), new_name); @@ -254,7 +240,7 @@ static ProcArg brush_rename_inargs[] = { GIMP_PDB_STRING, "name", - "The brush name (\"\" means currently active brush)" + "The brush name" }, { GIMP_PDB_STRING, @@ -299,21 +285,13 @@ brush_delete_invoker (Gimp *gimp, GimpBrush *brush = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; if (success) { - if (name && strlen (name)) - { - brush = (GimpBrush *) - gimp_container_get_child_by_name (gimp->brush_factory->container, - name); - } - else - { - brush = gimp_context_get_brush (context); - } + brush = (GimpBrush *) + gimp_container_get_child_by_name (gimp->brush_factory->container, name); if (brush && GIMP_DATA (brush)->deletable) { @@ -341,7 +319,7 @@ static ProcArg brush_delete_inargs[] = { GIMP_PDB_STRING, "name", - "The brush name (\"\" means currently active brush)" + "The brush name" } }; @@ -373,21 +351,13 @@ brush_get_info_invoker (Gimp *gimp, GimpBrush *brush = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; if (success) { - if (name && strlen (name)) - { - brush = (GimpBrush *) - gimp_container_get_child_by_name (gimp->brush_factory->container, - name); - } - else - { - brush = gimp_context_get_brush (context); - } + brush = (GimpBrush *) + gimp_container_get_child_by_name (gimp->brush_factory->container, name); success = (brush != NULL); } @@ -408,7 +378,7 @@ static ProcArg brush_get_info_inargs[] = { GIMP_PDB_STRING, "name", - "The brush name (\"\" means currently active brush)" + "The brush name" } }; @@ -442,6 +412,99 @@ static ProcRecord brush_get_info_proc = { { brush_get_info_invoker } } }; +static Argument * +brush_get_pixels_invoker (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + gchar *name; + gint32 num_mask_bytes = 0; + guint8 *mask_bytes = NULL; + GimpBrush *brush = NULL; + + name = (gchar *) args[0].value.pdb_pointer; + if (name == NULL || !g_utf8_validate (name, -1, NULL)) + success = FALSE; + + if (success) + { + brush = (GimpBrush *) + gimp_container_get_child_by_name (gimp->brush_factory->container, name); + + if (brush) + { + num_mask_bytes = brush->mask->height * brush->mask->width; + mask_bytes = g_memdup (temp_buf_data (brush->mask), num_mask_bytes); + } + else + success = FALSE; + } + + return_args = procedural_db_return_args (&brush_get_pixels_proc, success); + + if (success) + { + return_args[1].value.pdb_int = brush->mask->width; + return_args[2].value.pdb_int = brush->mask->height; + return_args[3].value.pdb_int = num_mask_bytes; + return_args[4].value.pdb_pointer = mask_bytes; + } + + return return_args; +} + +static ProcArg brush_get_pixels_inargs[] = +{ + { + GIMP_PDB_STRING, + "name", + "The brush name" + } +}; + +static ProcArg brush_get_pixels_outargs[] = +{ + { + GIMP_PDB_INT32, + "width", + "The brush width" + }, + { + GIMP_PDB_INT32, + "height", + "The brush height" + }, + { + GIMP_PDB_INT32, + "num_mask_bytes", + "Length of brush mask data" + }, + { + GIMP_PDB_INT8ARRAY, + "mask_bytes", + "The brush mask data" + } +}; + +static ProcRecord brush_get_pixels_proc = +{ + "gimp_brush_get_pixels", + "Retrieve information about the specified brush.", + "This procedure retrieves information about the specified brush. This includes the brush extents (width and height) and its pixels data.", + "Michael Natterer ", + "Michael Natterer", + "2004", + GIMP_INTERNAL, + 1, + brush_get_pixels_inargs, + 4, + brush_get_pixels_outargs, + { { brush_get_pixels_invoker } } +}; + static Argument * brush_get_spacing_invoker (Gimp *gimp, GimpContext *context, @@ -454,21 +517,13 @@ brush_get_spacing_invoker (Gimp *gimp, GimpBrush *brush = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; if (success) { - if (name && strlen (name)) - { - brush = (GimpBrush *) - gimp_container_get_child_by_name (gimp->brush_factory->container, - name); - } - else - { - brush = gimp_context_get_brush (context); - } + brush = (GimpBrush *) + gimp_container_get_child_by_name (gimp->brush_factory->container, name); success = (brush != NULL); } @@ -476,7 +531,7 @@ brush_get_spacing_invoker (Gimp *gimp, return_args = procedural_db_return_args (&brush_get_spacing_proc, success); if (success) - return_args[1].value.pdb_int = gimp_brush_get_spacing (gimp_context_get_brush (context)); + return_args[1].value.pdb_int = gimp_brush_get_spacing (brush); return return_args; } @@ -486,7 +541,7 @@ static ProcArg brush_get_spacing_inargs[] = { GIMP_PDB_STRING, "name", - "The brush name (\"\" means currently active brush)" + "The brush name" } }; @@ -527,7 +582,7 @@ brush_set_spacing_invoker (Gimp *gimp, GimpBrush *brush = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; spacing = args[1].value.pdb_int; @@ -536,16 +591,8 @@ brush_set_spacing_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - brush = (GimpBrush *) - gimp_container_get_child_by_name (gimp->brush_factory->container, - name); - } - else - { - brush = gimp_context_get_brush (context); - } + brush = (GimpBrush *) + gimp_container_get_child_by_name (gimp->brush_factory->container, name); if (brush && GIMP_DATA (brush)->writable) gimp_brush_set_spacing (brush, spacing); @@ -561,7 +608,7 @@ static ProcArg brush_set_spacing_inargs[] = { GIMP_PDB_STRING, "name", - "The brush name (\"\" means currently active brush)" + "The brush name" }, { GIMP_PDB_INT32, diff --git a/app/pdb/brushes_cmds.c b/app/pdb/brushes_cmds.c index 4f6a3124e7..5d3041d2ee 100644 --- a/app/pdb/brushes_cmds.c +++ b/app/pdb/brushes_cmds.c @@ -408,11 +408,11 @@ static ProcArg brushes_get_brush_data_outargs[] = static ProcRecord brushes_get_brush_data_proc = { "gimp_brushes_get_brush_data", - "Retrieve information about the currently active brush (including data).", - "This procedure retrieves information about the currently active brush. This includes the brush name, and the brush extents (width and height). It also returns the brush data.", - "Andy Thomas", - "Andy Thomas", - "1998", + "This procedure is deprecated! Use 'gimp_brush_get_pixels' instead.", + "This procedure is deprecated! Use 'gimp_brush_get_pixels' instead.", + "", + "", + "", GIMP_INTERNAL, 1, brushes_get_brush_data_inargs, diff --git a/app/pdb/gradient_cmds.c b/app/pdb/gradient_cmds.c index f26e121c1d..0dc819ec92 100644 --- a/app/pdb/gradient_cmds.c +++ b/app/pdb/gradient_cmds.c @@ -40,6 +40,8 @@ static ProcRecord gradient_new_proc; static ProcRecord gradient_duplicate_proc; static ProcRecord gradient_rename_proc; static ProcRecord gradient_delete_proc; +static ProcRecord gradient_get_uniform_samples_proc; +static ProcRecord gradient_get_custom_samples_proc; static ProcRecord gradient_segment_get_left_color_proc; static ProcRecord gradient_segment_set_left_color_proc; static ProcRecord gradient_segment_get_right_color_proc; @@ -71,6 +73,8 @@ register_gradient_procs (Gimp *gimp) procedural_db_register (gimp, &gradient_duplicate_proc); procedural_db_register (gimp, &gradient_rename_proc); procedural_db_register (gimp, &gradient_delete_proc); + procedural_db_register (gimp, &gradient_get_uniform_samples_proc); + procedural_db_register (gimp, &gradient_get_custom_samples_proc); procedural_db_register (gimp, &gradient_segment_get_left_color_proc); procedural_db_register (gimp, &gradient_segment_set_left_color_proc); procedural_db_register (gimp, &gradient_segment_get_right_color_proc); @@ -174,21 +178,13 @@ gradient_duplicate_invoker (Gimp *gimp, GimpGradient *gradient_copy = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); if (gradient) { @@ -215,7 +211,7 @@ static ProcArg gradient_duplicate_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" } }; @@ -257,7 +253,7 @@ gradient_rename_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; new_name = (gchar *) args[1].value.pdb_pointer; @@ -266,16 +262,8 @@ gradient_rename_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); if (gradient && GIMP_DATA (gradient)->writable) gimp_object_set_name (GIMP_OBJECT (gradient), new_name); @@ -296,7 +284,7 @@ static ProcArg gradient_rename_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_STRING, @@ -341,21 +329,13 @@ gradient_delete_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); if (gradient && GIMP_DATA (gradient)->deletable) { @@ -383,7 +363,7 @@ static ProcArg gradient_delete_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" } }; @@ -403,6 +383,248 @@ static ProcRecord gradient_delete_proc = { { gradient_delete_invoker } } }; +static Argument * +gradient_get_uniform_samples_invoker (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + gchar *name; + gint32 num_samples; + gboolean reverse; + gint32 num_color_samples = 0; + gdouble *color_samples = NULL; + GimpGradient *gradient; + + name = (gchar *) args[0].value.pdb_pointer; + if (name == NULL || !g_utf8_validate (name, -1, NULL)) + success = FALSE; + + num_samples = args[1].value.pdb_int; + if (num_samples < 2) + success = FALSE; + + reverse = args[2].value.pdb_int ? TRUE : FALSE; + + if (success) + { + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); + + if (gradient) + { + gdouble pos = 0.0; + gdouble delta = 1.0 / (num_samples - 1); + gdouble *sample; + + num_color_samples = num_samples * 4; + + sample = color_samples = g_new (gdouble, num_color_samples); + + while (num_samples--) + { + GimpRGB color; + + gimp_gradient_get_color_at (gradient, pos, reverse, &color); + + *sample++ = color.r; + *sample++ = color.g; + *sample++ = color.b; + *sample++ = color.a; + + pos += delta; + } + } + else + success = FALSE; + } + + return_args = procedural_db_return_args (&gradient_get_uniform_samples_proc, success); + + if (success) + { + return_args[1].value.pdb_int = num_color_samples; + return_args[2].value.pdb_pointer = color_samples; + } + + return return_args; +} + +static ProcArg gradient_get_uniform_samples_inargs[] = +{ + { + GIMP_PDB_STRING, + "name", + "The gradient name" + }, + { + GIMP_PDB_INT32, + "num_samples", + "The number of samples to take" + }, + { + GIMP_PDB_INT32, + "reverse", + "Use the reverse gradient (TRUE or FALSE)" + } +}; + +static ProcArg gradient_get_uniform_samples_outargs[] = +{ + { + GIMP_PDB_INT32, + "num_color_samples", + "Length of the color_samples array (4 * num_samples)" + }, + { + GIMP_PDB_FLOATARRAY, + "color_samples", + "Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }" + } +}; + +static ProcRecord gradient_get_uniform_samples_proc = +{ + "gimp_gradient_get_uniform_samples", + "Sample the specified in uniform parts.", + "This procedure samples the active gradient in the specified number of uniform parts. It returns a list of floating-point values which correspond to the RGBA values for each sample. The minimum number of samples to take is 2, in which case the returned colors will correspond to the { 0.0, 1.0 } positions in the gradient. For example, if the number of samples is 3, the procedure will return the colors at positions { 0.0, 0.5, 1.0 }.", + "Federico Mena Quintero", + "Federico Mena Quintero", + "1997", + GIMP_INTERNAL, + 3, + gradient_get_uniform_samples_inargs, + 2, + gradient_get_uniform_samples_outargs, + { { gradient_get_uniform_samples_invoker } } +}; + +static Argument * +gradient_get_custom_samples_invoker (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + gchar *name; + gint32 num_samples; + gdouble *pos; + gboolean reverse; + gint32 num_color_samples = 0; + gdouble *color_samples = NULL; + GimpGradient *gradient; + + name = (gchar *) args[0].value.pdb_pointer; + if (name == NULL || !g_utf8_validate (name, -1, NULL)) + success = FALSE; + + num_samples = args[1].value.pdb_int; + if (num_samples <= 0) + success = FALSE; + + pos = (gdouble *) args[2].value.pdb_pointer; + + reverse = args[3].value.pdb_int ? TRUE : FALSE; + + if (success) + { + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); + + if (gradient) + { + gdouble *sample; + + num_color_samples = num_samples * 4; + + sample = color_samples = g_new (gdouble, num_color_samples); + + while (num_samples--) + { + GimpRGB color; + + gimp_gradient_get_color_at (gradient, *pos, reverse, &color); + + *sample++ = color.r; + *sample++ = color.g; + *sample++ = color.b; + *sample++ = color.a; + + pos++; + } + } + else + success = FALSE; + } + + return_args = procedural_db_return_args (&gradient_get_custom_samples_proc, success); + + if (success) + { + return_args[1].value.pdb_int = num_color_samples; + return_args[2].value.pdb_pointer = color_samples; + } + + return return_args; +} + +static ProcArg gradient_get_custom_samples_inargs[] = +{ + { + GIMP_PDB_STRING, + "name", + "The gradient name" + }, + { + GIMP_PDB_INT32, + "num_samples", + "The number of samples to take" + }, + { + GIMP_PDB_FLOATARRAY, + "positions", + "The list of positions to sample along the gradient" + }, + { + GIMP_PDB_INT32, + "reverse", + "Use the reverse gradient (TRUE or FALSE)" + } +}; + +static ProcArg gradient_get_custom_samples_outargs[] = +{ + { + GIMP_PDB_INT32, + "num_color_samples", + "Length of the color_samples array (4 * num_samples)" + }, + { + GIMP_PDB_FLOATARRAY, + "color_samples", + "Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }" + } +}; + +static ProcRecord gradient_get_custom_samples_proc = +{ + "gimp_gradient_get_custom_samples", + "Sample the spacified gradient in custom positions.", + "This procedure samples the active gradient in the specified number of points. The procedure will sample the gradient in the specified positions from the list. The left endpoint of the gradient corresponds to position 0.0, and the right endpoint corresponds to 1.0. The procedure returns a list of floating-point values which correspond to the RGBA values for each sample.", + "Federico Mena Quintero", + "Federico Mena Quintero", + "1997", + GIMP_INTERNAL, + 4, + gradient_get_custom_samples_inargs, + 2, + gradient_get_custom_samples_outargs, + { { gradient_get_custom_samples_invoker } } +}; + static Argument * gradient_segment_get_left_color_invoker (Gimp *gimp, GimpContext *context, @@ -418,7 +640,7 @@ gradient_segment_get_left_color_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; segment = args[1].value.pdb_int; @@ -427,33 +649,25 @@ gradient_segment_get_left_color_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); - success = (gradient != NULL); - - if (success) + if (gradient) { GimpGradientSegment *seg; seg = gimp_gradient_segment_get_nth (gradient->segments, segment); - success = (seg != NULL); - - if (success) + if (seg) { gimp_gradient_segment_get_left_color (gradient, seg, &color); opacity = color.a * 100.0; } + else + success = FALSE; } + else + success = FALSE; } return_args = procedural_db_return_args (&gradient_segment_get_left_color_proc, success); @@ -472,7 +686,7 @@ static ProcArg gradient_segment_get_left_color_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -525,7 +739,7 @@ gradient_segment_set_left_color_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; segment = args[1].value.pdb_int; @@ -540,33 +754,25 @@ gradient_segment_set_left_color_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); - success = (gradient != NULL); - - if (success) + if (gradient) { GimpGradientSegment *seg; seg = gimp_gradient_segment_get_nth (gradient->segments, segment); - success = (seg != NULL); - - if (success) + if (seg) { color.a = opacity / 100.0; gimp_gradient_segment_set_left_color (gradient, seg, &color); } + else + success = FALSE; } + else + success = FALSE; } return procedural_db_return_args (&gradient_segment_set_left_color_proc, success); @@ -577,7 +783,7 @@ static ProcArg gradient_segment_set_left_color_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -627,7 +833,7 @@ gradient_segment_get_right_color_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; segment = args[1].value.pdb_int; @@ -636,33 +842,25 @@ gradient_segment_get_right_color_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); - success = (gradient != NULL); - - if (success) + if (gradient) { GimpGradientSegment *seg; seg = gimp_gradient_segment_get_nth (gradient->segments, segment); - success = (seg != NULL); - - if (success) + if (seg) { gimp_gradient_segment_get_right_color (gradient, seg, &color); opacity = color.a * 100.0; } + else + success = FALSE; } + else + success = FALSE; } return_args = procedural_db_return_args (&gradient_segment_get_right_color_proc, success); @@ -681,7 +879,7 @@ static ProcArg gradient_segment_get_right_color_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -734,7 +932,7 @@ gradient_segment_set_right_color_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; segment = args[1].value.pdb_int; @@ -749,33 +947,25 @@ gradient_segment_set_right_color_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); - success = (gradient != NULL); - - if (success) + if (gradient) { GimpGradientSegment *seg; seg = gimp_gradient_segment_get_nth (gradient->segments, segment); - success = (seg != NULL); - - if (success) + if (seg) { color.a = opacity / 100.0; gimp_gradient_segment_set_right_color (gradient, seg, &color); } + else + success = FALSE; } + else + success = FALSE; } return procedural_db_return_args (&gradient_segment_set_right_color_proc, success); @@ -786,7 +976,7 @@ static ProcArg gradient_segment_set_right_color_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -835,7 +1025,7 @@ gradient_segment_get_left_pos_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; segment = args[1].value.pdb_int; @@ -844,32 +1034,24 @@ gradient_segment_get_left_pos_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); - success = (gradient != NULL); - - if (success) + if (gradient) { GimpGradientSegment *seg; seg = gimp_gradient_segment_get_nth (gradient->segments, segment); - success = (seg != NULL); - - if (success) + if (seg) { pos = gimp_gradient_segment_get_left_pos (gradient, seg); } + else + success = FALSE; } + else + success = FALSE; } return_args = procedural_db_return_args (&gradient_segment_get_left_pos_proc, success); @@ -885,7 +1067,7 @@ static ProcArg gradient_segment_get_left_pos_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -934,7 +1116,7 @@ gradient_segment_set_left_pos_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; segment = args[1].value.pdb_int; @@ -947,33 +1129,25 @@ gradient_segment_set_left_pos_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); - success = (gradient != NULL); - - if (success) + if (gradient) { GimpGradientSegment *seg; seg = gimp_gradient_segment_get_nth (gradient->segments, segment); - success = (seg != NULL); - - if (success) + if (seg) { final_pos = gimp_gradient_segment_set_left_pos (gradient, seg, pos); } + else + success = FALSE; } + else + success = FALSE; } return_args = procedural_db_return_args (&gradient_segment_set_left_pos_proc, success); @@ -989,7 +1163,7 @@ static ProcArg gradient_segment_set_left_pos_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -1042,7 +1216,7 @@ gradient_segment_get_middle_pos_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; segment = args[1].value.pdb_int; @@ -1051,32 +1225,24 @@ gradient_segment_get_middle_pos_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); - success = (gradient != NULL); - - if (success) + if (gradient) { GimpGradientSegment *seg; seg = gimp_gradient_segment_get_nth (gradient->segments, segment); - success = (seg != NULL); - - if (success) + if (seg) { pos = gimp_gradient_segment_get_middle_pos (gradient, seg); } + else + success = FALSE; } + else + success = FALSE; } return_args = procedural_db_return_args (&gradient_segment_get_middle_pos_proc, success); @@ -1092,7 +1258,7 @@ static ProcArg gradient_segment_get_middle_pos_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -1141,7 +1307,7 @@ gradient_segment_set_middle_pos_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; segment = args[1].value.pdb_int; @@ -1154,33 +1320,25 @@ gradient_segment_set_middle_pos_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); - success = (gradient != NULL); - - if (success) + if (gradient) { GimpGradientSegment *seg; seg = gimp_gradient_segment_get_nth (gradient->segments, segment); - success = (seg != NULL); - - if (success) + if (seg) { final_pos = gimp_gradient_segment_set_middle_pos (gradient, seg, pos); } + else + success = FALSE; } + else + success = FALSE; } return_args = procedural_db_return_args (&gradient_segment_set_middle_pos_proc, success); @@ -1196,7 +1354,7 @@ static ProcArg gradient_segment_set_middle_pos_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -1249,7 +1407,7 @@ gradient_segment_get_right_pos_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; segment = args[1].value.pdb_int; @@ -1258,32 +1416,24 @@ gradient_segment_get_right_pos_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); - success = (gradient != NULL); - - if (success) + if (gradient) { GimpGradientSegment *seg; seg = gimp_gradient_segment_get_nth (gradient->segments, segment); - success = (seg != NULL); - - if (success) + if (seg) { pos = gimp_gradient_segment_get_right_pos (gradient, seg); } + else + success = FALSE; } + else + success = FALSE; } return_args = procedural_db_return_args (&gradient_segment_get_right_pos_proc, success); @@ -1299,7 +1449,7 @@ static ProcArg gradient_segment_get_right_pos_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -1348,7 +1498,7 @@ gradient_segment_set_right_pos_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; segment = args[1].value.pdb_int; @@ -1361,33 +1511,25 @@ gradient_segment_set_right_pos_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); - success = (gradient != NULL); - - if (success) + if (gradient) { GimpGradientSegment *seg; seg = gimp_gradient_segment_get_nth (gradient->segments, segment); - success = (seg != NULL); - - if (success) + if (seg) { final_pos = gimp_gradient_segment_set_right_pos (gradient, seg, pos); } + else + success = FALSE; } + else + success = FALSE; } return_args = procedural_db_return_args (&gradient_segment_set_right_pos_proc, success); @@ -1403,7 +1545,7 @@ static ProcArg gradient_segment_set_right_pos_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -1456,7 +1598,7 @@ gradient_segment_get_blending_function_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; segment = args[1].value.pdb_int; @@ -1465,33 +1607,25 @@ gradient_segment_get_blending_function_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); - success = (gradient != NULL); - - if (success) + if (gradient) { GimpGradientSegment *seg; seg = gimp_gradient_segment_get_nth (gradient->segments, segment); - success = (seg != NULL); - - if (success) + if (seg) { blend_func = gimp_gradient_segment_get_blending_function (gradient, seg); } + else + success = FALSE; } + else + success = FALSE; } return_args = procedural_db_return_args (&gradient_segment_get_blending_function_proc, success); @@ -1507,7 +1641,7 @@ static ProcArg gradient_segment_get_blending_function_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -1555,7 +1689,7 @@ gradient_segment_get_coloring_type_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; segment = args[1].value.pdb_int; @@ -1564,33 +1698,25 @@ gradient_segment_get_coloring_type_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); - success = (gradient != NULL); - - if (success) + if (gradient) { GimpGradientSegment *seg; seg = gimp_gradient_segment_get_nth (gradient->segments, segment); - success = (seg != NULL); - - if (success) + if (seg) { coloring_type = gimp_gradient_segment_get_coloring_type (gradient, seg); } + else + success = FALSE; } + else + success = FALSE; } return_args = procedural_db_return_args (&gradient_segment_get_coloring_type_proc, success); @@ -1606,7 +1732,7 @@ static ProcArg gradient_segment_get_coloring_type_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -1654,7 +1780,7 @@ gradient_segment_range_set_blending_function_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; start_segment = args[1].value.pdb_int; @@ -1669,16 +1795,8 @@ gradient_segment_range_set_blending_function_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); if (gradient) { @@ -1727,7 +1845,7 @@ static ProcArg gradient_segment_range_set_blending_function_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -1776,7 +1894,7 @@ gradient_segment_range_set_coloring_type_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; start_segment = args[1].value.pdb_int; @@ -1791,16 +1909,8 @@ gradient_segment_range_set_coloring_type_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); if (gradient) { @@ -1849,7 +1959,7 @@ static ProcArg gradient_segment_range_set_coloring_type_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -1897,7 +2007,7 @@ gradient_segment_range_flip_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; start_segment = args[1].value.pdb_int; @@ -1908,16 +2018,8 @@ gradient_segment_range_flip_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); if (gradient) { @@ -1966,7 +2068,7 @@ static ProcArg gradient_segment_range_flip_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -2010,7 +2112,7 @@ gradient_segment_range_replicate_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; start_segment = args[1].value.pdb_int; @@ -2025,16 +2127,8 @@ gradient_segment_range_replicate_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); if (gradient) { @@ -2084,7 +2178,7 @@ static ProcArg gradient_segment_range_replicate_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -2132,7 +2226,7 @@ gradient_segment_range_split_midpoint_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; start_segment = args[1].value.pdb_int; @@ -2143,16 +2237,8 @@ gradient_segment_range_split_midpoint_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); if (gradient) { @@ -2201,7 +2287,7 @@ static ProcArg gradient_segment_range_split_midpoint_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -2245,7 +2331,7 @@ gradient_segment_range_split_uniform_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; start_segment = args[1].value.pdb_int; @@ -2260,16 +2346,8 @@ gradient_segment_range_split_uniform_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); if (gradient) { @@ -2319,7 +2397,7 @@ static ProcArg gradient_segment_range_split_uniform_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -2367,7 +2445,7 @@ gradient_segment_range_delete_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; start_segment = args[1].value.pdb_int; @@ -2378,16 +2456,8 @@ gradient_segment_range_delete_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); if (gradient) { @@ -2436,7 +2506,7 @@ static ProcArg gradient_segment_range_delete_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -2479,7 +2549,7 @@ gradient_segment_range_redistribute_handles_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; start_segment = args[1].value.pdb_int; @@ -2490,16 +2560,8 @@ gradient_segment_range_redistribute_handles_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); if (gradient) { @@ -2547,7 +2609,7 @@ static ProcArg gradient_segment_range_redistribute_handles_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -2590,7 +2652,7 @@ gradient_segment_range_blend_colors_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; start_segment = args[1].value.pdb_int; @@ -2601,16 +2663,8 @@ gradient_segment_range_blend_colors_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); if (gradient) { @@ -2660,7 +2714,7 @@ static ProcArg gradient_segment_range_blend_colors_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -2703,7 +2757,7 @@ gradient_segment_range_blend_opacity_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; start_segment = args[1].value.pdb_int; @@ -2714,16 +2768,8 @@ gradient_segment_range_blend_opacity_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); if (gradient) { @@ -2773,7 +2819,7 @@ static ProcArg gradient_segment_range_blend_opacity_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, @@ -2820,7 +2866,7 @@ gradient_segment_range_move_invoker (Gimp *gimp, GimpGradient *gradient = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; start_segment = args[1].value.pdb_int; @@ -2837,16 +2883,8 @@ gradient_segment_range_move_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); if (gradient) { @@ -2902,7 +2940,7 @@ static ProcArg gradient_segment_range_move_inargs[] = { GIMP_PDB_STRING, "name", - "The gradient name (\"\" means currently active gradient)" + "The gradient name" }, { GIMP_PDB_INT32, diff --git a/app/pdb/gradients_cmds.c b/app/pdb/gradients_cmds.c index 97910d25d6..782f20e565 100644 --- a/app/pdb/gradients_cmds.c +++ b/app/pdb/gradients_cmds.c @@ -235,11 +235,11 @@ static ProcArg gradients_sample_uniform_outargs[] = static ProcRecord gradients_sample_uniform_proc = { "gimp_gradients_sample_uniform", - "Sample the active gradient in uniform parts.", - "This procedure samples the active gradient in the specified number of uniform parts. It returns a list of floating-point values which correspond to the RGBA values for each sample. The minimum number of samples to take is 2, in which case the returned colors will correspond to the { 0.0, 1.0 } positions in the gradient. For example, if the number of samples is 3, the procedure will return the colors at positions { 0.0, 0.5, 1.0 }.", - "Federico Mena Quintero", - "Federico Mena Quintero", - "1997", + "This procedure is deprecated! Use 'gimp_gradient_get_uniform_samples' instead.", + "This procedure is deprecated! Use 'gimp_gradient_get_uniform_samples' instead.", + "", + "", + "", GIMP_INTERNAL, 2, gradients_sample_uniform_inargs, @@ -341,11 +341,11 @@ static ProcArg gradients_sample_custom_outargs[] = static ProcRecord gradients_sample_custom_proc = { "gimp_gradients_sample_custom", - "Sample the active gradient in custom positions.", - "This procedure samples the active gradient in the specified number of points. The procedure will sample the gradient in the specified positions from the list. The left endpoint of the gradient corresponds to position 0.0, and the right endpoint corresponds to 1.0. The procedure returns a list of floating-point values which correspond to the RGBA values for each sample.", - "Federico Mena Quintero", - "Federico Mena Quintero", - "1997", + "This procedure is deprecated! Use 'gimp_gradient_get_custom_samples' instead.", + "This procedure is deprecated! Use 'gimp_gradient_get_custom_samples' instead.", + "", + "", + "", GIMP_INTERNAL, 3, gradients_sample_custom_inargs, @@ -381,15 +381,15 @@ gradients_get_gradient_data_invoker (Gimp *gimp, if (success) { if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } + { + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, + name); + } + else + { + gradient = gimp_context_get_gradient (context); + } if (gradient) { @@ -473,11 +473,11 @@ static ProcArg gradients_get_gradient_data_outargs[] = static ProcRecord gradients_get_gradient_data_proc = { "gimp_gradients_get_gradient_data", - "Retrieve information about the specified gradient (including data).", - "This procedure retrieves information about the gradient. This includes the gradient name, and the sample data for the gradient.", - "Federico Mena Quintero", - "Federico Mena Quintero", - "1997", + "This procedure is deprecated! Use 'gimp_gradient_get_uniform_samples' instead.", + "This procedure is deprecated! Use 'gimp_gradient_get_uniform_samples' instead.", + "", + "", + "", GIMP_INTERNAL, 3, gradients_get_gradient_data_inargs, diff --git a/app/pdb/internal_procs.c b/app/pdb/internal_procs.c index 3723de77c1..6a918d5573 100644 --- a/app/pdb/internal_procs.c +++ b/app/pdb/internal_procs.c @@ -73,7 +73,7 @@ void register_transform_tools_procs (Gimp *gimp); void register_undo_procs (Gimp *gimp); void register_unit_procs (Gimp *gimp); -/* 408 procedures registered total */ +/* 412 procedures registered total */ void internal_procs_init (Gimp *gimp, @@ -85,25 +85,25 @@ internal_procs_init (Gimp *gimp, (* status_callback) (_("Internal Procedures"), _("Brush"), 0.0); register_brush_procs (gimp); - (* status_callback) (NULL, _("Brush UI"), 0.017); + (* status_callback) (NULL, _("Brush UI"), 0.019); register_brush_select_procs (gimp); - (* status_callback) (NULL, _("Brushes"), 0.025); + (* status_callback) (NULL, _("Brushes"), 0.027); register_brushes_procs (gimp); - (* status_callback) (NULL, _("Channel"), 0.039); + (* status_callback) (NULL, _("Channel"), 0.041); register_channel_procs (gimp); - (* status_callback) (NULL, _("Color"), 0.061); + (* status_callback) (NULL, _("Color"), 0.063); register_color_procs (gimp); - (* status_callback) (NULL, _("Context"), 0.096); + (* status_callback) (NULL, _("Context"), 0.097); register_context_procs (gimp); (* status_callback) (NULL, _("Convert"), 0.15); register_convert_procs (gimp); - (* status_callback) (NULL, _("Display procedures"), 0.157); + (* status_callback) (NULL, _("Display procedures"), 0.158); register_display_procs (gimp); (* status_callback) (NULL, _("Drawable procedures"), 0.167); @@ -115,94 +115,94 @@ internal_procs_init (Gimp *gimp, (* status_callback) (NULL, _("File Operations"), 0.265); register_fileops_procs (gimp); - (* status_callback) (NULL, _("Floating selections"), 0.287); + (* status_callback) (NULL, _("Floating selections"), 0.286); register_floating_sel_procs (gimp); (* status_callback) (NULL, _("Font UI"), 0.301); register_font_select_procs (gimp); - (* status_callback) (NULL, _("Fonts"), 0.309); + (* status_callback) (NULL, _("Fonts"), 0.308); register_fonts_procs (gimp); - (* status_callback) (NULL, _("Gimprc procedures"), 0.314); + (* status_callback) (NULL, _("Gimprc procedures"), 0.313); register_gimprc_procs (gimp); (* status_callback) (NULL, _("Gradient"), 0.328); register_gradient_procs (gimp); - (* status_callback) (NULL, _("Gradient UI"), 0.395); + (* status_callback) (NULL, _("Gradient UI"), 0.398); register_gradient_select_procs (gimp); - (* status_callback) (NULL, _("Gradients"), 0.402); + (* status_callback) (NULL, _("Gradients"), 0.405); register_gradients_procs (gimp); - (* status_callback) (NULL, _("Guide procedures"), 0.414); + (* status_callback) (NULL, _("Guide procedures"), 0.417); register_guides_procs (gimp); - (* status_callback) (NULL, _("Help procedures"), 0.429); + (* status_callback) (NULL, _("Help procedures"), 0.432); register_help_procs (gimp); - (* status_callback) (NULL, _("Image"), 0.431); + (* status_callback) (NULL, _("Image"), 0.434); register_image_procs (gimp); - (* status_callback) (NULL, _("Layer"), 0.583); + (* status_callback) (NULL, _("Layer"), 0.585); register_layer_procs (gimp); - (* status_callback) (NULL, _("Message procedures"), 0.647); + (* status_callback) (NULL, _("Message procedures"), 0.648); register_message_procs (gimp); - (* status_callback) (NULL, _("Miscellaneous"), 0.654); + (* status_callback) (NULL, _("Miscellaneous"), 0.655); register_misc_procs (gimp); - (* status_callback) (NULL, _("Paint Tool procedures"), 0.659); + (* status_callback) (NULL, _("Paint Tool procedures"), 0.66); register_paint_tools_procs (gimp); - (* status_callback) (NULL, _("Palette"), 0.696); + (* status_callback) (NULL, _("Palette"), 0.697); register_palette_procs (gimp); (* status_callback) (NULL, _("Palette UI"), 0.723); register_palette_select_procs (gimp); - (* status_callback) (NULL, _("Palettes"), 0.73); + (* status_callback) (NULL, _("Palettes"), 0.731); register_palettes_procs (gimp); (* status_callback) (NULL, _("Parasite procedures"), 0.74); register_parasite_procs (gimp); - (* status_callback) (NULL, _("Paths"), 0.77); + (* status_callback) (NULL, _("Paths"), 0.769); register_paths_procs (gimp); (* status_callback) (NULL, _("Pattern"), 0.806); register_pattern_procs (gimp); - (* status_callback) (NULL, _("Pattern UI"), 0.809); + (* status_callback) (NULL, _("Pattern UI"), 0.811); register_pattern_select_procs (gimp); - (* status_callback) (NULL, _("Patterns"), 0.816); + (* status_callback) (NULL, _("Patterns"), 0.818); register_patterns_procs (gimp); - (* status_callback) (NULL, _("Plug-in"), 0.826); + (* status_callback) (NULL, _("Plug-in"), 0.828); register_plug_in_procs (gimp); - (* status_callback) (NULL, _("Procedural database"), 0.838); + (* status_callback) (NULL, _("Procedural database"), 0.84); register_procedural_db_procs (gimp); - (* status_callback) (NULL, _("Progress"), 0.86); + (* status_callback) (NULL, _("Progress"), 0.862); register_progress_procs (gimp); - (* status_callback) (NULL, _("Image mask"), 0.873); + (* status_callback) (NULL, _("Image mask"), 0.874); register_selection_procs (gimp); (* status_callback) (NULL, _("Selection Tool procedures"), 0.917); register_selection_tools_procs (gimp); - (* status_callback) (NULL, _("Text procedures"), 0.929); + (* status_callback) (NULL, _("Text procedures"), 0.93); register_text_tool_procs (gimp); (* status_callback) (NULL, _("Transform Tool procedures"), 0.939); register_transform_tools_procs (gimp); - (* status_callback) (NULL, _("Undo"), 0.953); + (* status_callback) (NULL, _("Undo"), 0.954); register_undo_procs (gimp); (* status_callback) (NULL, _("Units"), 0.971); diff --git a/app/pdb/palette_cmds.c b/app/pdb/palette_cmds.c index 68654ced2c..934dfed017 100644 --- a/app/pdb/palette_cmds.c +++ b/app/pdb/palette_cmds.c @@ -141,21 +141,13 @@ palette_duplicate_invoker (Gimp *gimp, GimpPalette *palette_copy = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; if (success) { - if (name && strlen (name)) - { - palette = (GimpPalette *) - gimp_container_get_child_by_name (gimp->palette_factory->container, - name); - } - else - { - palette = gimp_context_get_palette (context); - } + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette) { @@ -182,7 +174,7 @@ static ProcArg palette_duplicate_inargs[] = { GIMP_PDB_STRING, "name", - "The palette name (\"\" means currently active palette)" + "The palette name." } }; @@ -224,7 +216,7 @@ palette_rename_invoker (Gimp *gimp, GimpPalette *palette = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; new_name = (gchar *) args[1].value.pdb_pointer; @@ -233,16 +225,8 @@ palette_rename_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - palette = (GimpPalette *) - gimp_container_get_child_by_name (gimp->palette_factory->container, - name); - } - else - { - palette = gimp_context_get_palette (context); - } + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->writable) gimp_object_set_name (GIMP_OBJECT (palette), new_name); @@ -263,7 +247,7 @@ static ProcArg palette_rename_inargs[] = { GIMP_PDB_STRING, "name", - "The palette name (\"\" means currently active palette)" + "The palette name." }, { GIMP_PDB_STRING, @@ -308,21 +292,13 @@ palette_delete_invoker (Gimp *gimp, GimpPalette *palette = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; if (success) { - if (name && strlen (name)) - { - palette = (GimpPalette *) - gimp_container_get_child_by_name (gimp->palette_factory->container, - name); - } - else - { - palette = gimp_context_get_palette (context); - } + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->deletable) { @@ -350,7 +326,7 @@ static ProcArg palette_delete_inargs[] = { GIMP_PDB_STRING, "name", - "The palette name (\"\" means currently active palette)" + "The palette name." } }; @@ -382,21 +358,13 @@ palette_get_info_invoker (Gimp *gimp, GimpPalette *palette = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; if (success) { - if (name && strlen (name)) - { - palette = (GimpPalette *) - gimp_container_get_child_by_name (gimp->palette_factory->container, - name); - } - else - { - palette = gimp_context_get_palette (context); - } + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); success = (palette != NULL); } @@ -414,7 +382,7 @@ static ProcArg palette_get_info_inargs[] = { GIMP_PDB_STRING, "name", - "The palette name (\"\" means currently active palette)" + "The palette name." } }; @@ -458,7 +426,7 @@ palette_add_entry_invoker (Gimp *gimp, GimpPaletteEntry *entry = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; entry_name = (gchar *) args[1].value.pdb_pointer; @@ -469,16 +437,8 @@ palette_add_entry_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - palette = (GimpPalette *) - gimp_container_get_child_by_name (gimp->palette_factory->container, - name); - } - else - { - palette = gimp_context_get_palette (context); - } + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->writable) entry = gimp_palette_add_entry (palette, entry_name, &color); @@ -499,7 +459,7 @@ static ProcArg palette_add_entry_inargs[] = { GIMP_PDB_STRING, "name", - "The palette name (\"\" means currently active palette)" + "The palette name." }, { GIMP_PDB_STRING, @@ -551,23 +511,15 @@ palette_delete_entry_invoker (Gimp *gimp, GimpPaletteEntry *entry = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; entry_num = args[1].value.pdb_int; if (success) { - if (name && strlen (name)) - { - palette = (GimpPalette *) - gimp_container_get_child_by_name (gimp->palette_factory->container, - name); - } - else - { - palette = gimp_context_get_palette (context); - } + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->writable) { @@ -592,7 +544,7 @@ static ProcArg palette_delete_entry_inargs[] = { GIMP_PDB_STRING, "name", - "The palette name (\"\" means currently active palette)" + "The palette name." }, { GIMP_PDB_INT32, @@ -632,23 +584,15 @@ palette_entry_get_color_invoker (Gimp *gimp, GimpPaletteEntry *entry = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; entry_num = args[1].value.pdb_int; if (success) { - if (name && strlen (name)) - { - palette = (GimpPalette *) - gimp_container_get_child_by_name (gimp->palette_factory->container, - name); - } - else - { - palette = gimp_context_get_palette (context); - } + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette) { @@ -678,7 +622,7 @@ static ProcArg palette_entry_get_color_inargs[] = { GIMP_PDB_STRING, "name", - "The palette name (\"\" means currently active palette)" + "The palette name." }, { GIMP_PDB_INT32, @@ -726,7 +670,7 @@ palette_entry_set_color_invoker (Gimp *gimp, GimpPaletteEntry *entry = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; entry_num = args[1].value.pdb_int; @@ -735,16 +679,8 @@ palette_entry_set_color_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - palette = (GimpPalette *) - gimp_container_get_child_by_name (gimp->palette_factory->container, - name); - } - else - { - palette = gimp_context_get_palette (context); - } + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->writable) { @@ -771,7 +707,7 @@ static ProcArg palette_entry_set_color_inargs[] = { GIMP_PDB_STRING, "name", - "The palette name (\"\" means currently active palette)" + "The palette name." }, { GIMP_PDB_INT32, @@ -815,23 +751,15 @@ palette_entry_get_name_invoker (Gimp *gimp, GimpPaletteEntry *entry = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; entry_num = args[1].value.pdb_int; if (success) { - if (name && strlen (name)) - { - palette = (GimpPalette *) - gimp_container_get_child_by_name (gimp->palette_factory->container, - name); - } - else - { - palette = gimp_context_get_palette (context); - } + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette) { @@ -857,7 +785,7 @@ static ProcArg palette_entry_get_name_inargs[] = { GIMP_PDB_STRING, "name", - "The palette name (\"\" means currently active palette)" + "The palette name." }, { GIMP_PDB_INT32, @@ -905,7 +833,7 @@ palette_entry_set_name_invoker (Gimp *gimp, GimpPaletteEntry *entry = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; entry_num = args[1].value.pdb_int; @@ -916,16 +844,8 @@ palette_entry_set_name_invoker (Gimp *gimp, if (success) { - if (name && strlen (name)) - { - palette = (GimpPalette *) - gimp_container_get_child_by_name (gimp->palette_factory->container, - name); - } - else - { - palette = gimp_context_get_palette (context); - } + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->writable) { @@ -953,7 +873,7 @@ static ProcArg palette_entry_set_name_inargs[] = { GIMP_PDB_STRING, "name", - "The palette name (\"\" means currently active palette)" + "The palette name." }, { GIMP_PDB_INT32, diff --git a/app/pdb/pattern_cmds.c b/app/pdb/pattern_cmds.c index 2e423c2768..6fd0f6868a 100644 --- a/app/pdb/pattern_cmds.c +++ b/app/pdb/pattern_cmds.c @@ -35,11 +35,13 @@ #include "core/gimppattern.h" static ProcRecord pattern_get_info_proc; +static ProcRecord pattern_get_pixels_proc; void register_pattern_procs (Gimp *gimp) { procedural_db_register (gimp, &pattern_get_info_proc); + procedural_db_register (gimp, &pattern_get_pixels_proc); } static Argument * @@ -54,21 +56,13 @@ pattern_get_info_invoker (Gimp *gimp, GimpPattern *pattern = NULL; name = (gchar *) args[0].value.pdb_pointer; - if (name && !g_utf8_validate (name, -1, NULL)) + if (name == NULL || !g_utf8_validate (name, -1, NULL)) success = FALSE; if (success) { - if (name && strlen (name)) - { - pattern = (GimpPattern *) - gimp_container_get_child_by_name (gimp->pattern_factory->container, - name); - } - else - { - pattern = gimp_context_get_pattern (context); - } + pattern = (GimpPattern *) + gimp_container_get_child_by_name (gimp->pattern_factory->container, name); success = (pattern != NULL); } @@ -90,7 +84,7 @@ static ProcArg pattern_get_info_inargs[] = { GIMP_PDB_STRING, "name", - "The pattern name (\"\" means currently active pattern)" + "The pattern name." } }; @@ -128,3 +122,104 @@ static ProcRecord pattern_get_info_proc = pattern_get_info_outargs, { { pattern_get_info_invoker } } }; + +static Argument * +pattern_get_pixels_invoker (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + Argument *args) +{ + gboolean success = TRUE; + Argument *return_args; + gchar *name; + gint32 num_mask_bytes = 0; + guint8 *mask_bytes = NULL; + GimpPattern *pattern = NULL; + + name = (gchar *) args[0].value.pdb_pointer; + if (name == NULL || !g_utf8_validate (name, -1, NULL)) + success = FALSE; + + if (success) + { + pattern = (GimpPattern *) + gimp_container_get_child_by_name (gimp->pattern_factory->container, name); + + if (pattern) + { + num_mask_bytes = pattern->mask->height * pattern->mask->width * + pattern->mask->bytes; + mask_bytes = g_memdup (temp_buf_data (pattern->mask), + num_mask_bytes); + } + else + success = FALSE; + } + + return_args = procedural_db_return_args (&pattern_get_pixels_proc, success); + + if (success) + { + return_args[1].value.pdb_int = pattern->mask->width; + return_args[2].value.pdb_int = pattern->mask->height; + return_args[3].value.pdb_int = pattern->mask->bytes; + return_args[4].value.pdb_int = num_mask_bytes; + return_args[5].value.pdb_pointer = mask_bytes; + } + + return return_args; +} + +static ProcArg pattern_get_pixels_inargs[] = +{ + { + GIMP_PDB_STRING, + "name", + "The pattern name." + } +}; + +static ProcArg pattern_get_pixels_outargs[] = +{ + { + GIMP_PDB_INT32, + "width", + "The pattern width" + }, + { + GIMP_PDB_INT32, + "height", + "The pattern height" + }, + { + GIMP_PDB_INT32, + "bpp", + "The pattern bpp" + }, + { + GIMP_PDB_INT32, + "num_mask_bytes", + "Length of pattern mask data" + }, + { + GIMP_PDB_INT8ARRAY, + "mask_bytes", + "The pattern mask data" + } +}; + +static ProcRecord pattern_get_pixels_proc = +{ + "gimp_pattern_get_pixels", + "Retrieve information about the specified pattern (including pixels).", + "This procedure retrieves information about the specified. This includes the pattern extents (width and height), its bpp and its pixel data.", + "Michael Natterer ", + "Michael Natterer", + "2004", + GIMP_INTERNAL, + 1, + pattern_get_pixels_inargs, + 5, + pattern_get_pixels_outargs, + { { pattern_get_pixels_invoker } } +}; diff --git a/app/pdb/patterns_cmds.c b/app/pdb/patterns_cmds.c index 29b44c89ab..aa5f9adb71 100644 --- a/app/pdb/patterns_cmds.c +++ b/app/pdb/patterns_cmds.c @@ -305,11 +305,11 @@ static ProcArg patterns_get_pattern_data_outargs[] = static ProcRecord patterns_get_pattern_data_proc = { "gimp_patterns_get_pattern_data", - "Retrieve information about the currently active pattern (including data).", - "This procedure retrieves information about the currently active pattern. This includes the pattern name, and the pattern extents (width and height). It also returns the pattern data.", - "Andy Thomas", - "Andy Thomas", - "1998", + "This procedure is deprecated! Use 'gimp_pattern_get_data' instead.", + "This procedure is deprecated! Use 'gimp_pattern_get_data' instead.", + "", + "", + "", GIMP_INTERNAL, 1, patterns_get_pattern_data_inargs, diff --git a/libgimp/gimpbrush_pdb.c b/libgimp/gimpbrush_pdb.c index fe4ef27014..929e1fb8e5 100644 --- a/libgimp/gimpbrush_pdb.c +++ b/libgimp/gimpbrush_pdb.c @@ -23,6 +23,8 @@ #include "config.h" +#include + #include "gimp.h" /** @@ -59,7 +61,7 @@ gimp_brush_new (const gchar *name) /** * gimp_brush_duplicate: - * @name: The brush name (\"\" means currently active brush). + * @name: The brush name. * * Duplicates a brush * @@ -91,7 +93,7 @@ gimp_brush_duplicate (const gchar *name) /** * gimp_brush_rename: - * @name: The brush name (\"\" means currently active brush). + * @name: The brush name. * @new_name: The new name of the brush. * * Rename a brush @@ -126,7 +128,7 @@ gimp_brush_rename (const gchar *name, /** * gimp_brush_delete: - * @name: The brush name (\"\" means currently active brush). + * @name: The brush name. * * Deletes a brush * @@ -157,7 +159,7 @@ gimp_brush_delete (const gchar *name) /** * gimp_brush_get_info: - * @name: The brush name (\"\" means currently active brush). + * @name: The brush name. * @width: The brush width. * @height: The brush height. * @@ -200,9 +202,64 @@ gimp_brush_get_info (const gchar *name, return success; } +/** + * gimp_brush_get_pixels: + * @name: The brush name. + * @width: The brush width. + * @height: The brush height. + * @num_mask_bytes: Length of brush mask data. + * @mask_bytes: The brush mask data. + * + * Retrieve information about the specified brush. + * + * This procedure retrieves information about the specified brush. This + * includes the brush extents (width and height) and its pixels data. + * + * Returns: TRUE on success. + * + * Since: GIMP 2.2 + */ +gboolean +gimp_brush_get_pixels (const gchar *name, + gint *width, + gint *height, + gint *num_mask_bytes, + guint8 **mask_bytes) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_brush_get_pixels", + &nreturn_vals, + GIMP_PDB_STRING, name, + GIMP_PDB_END); + + *width = 0; + *height = 0; + *num_mask_bytes = 0; + *mask_bytes = NULL; + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + if (success) + { + *width = return_vals[1].data.d_int32; + *height = return_vals[2].data.d_int32; + *num_mask_bytes = return_vals[3].data.d_int32; + *mask_bytes = g_new (guint8, *num_mask_bytes); + memcpy (*mask_bytes, return_vals[4].data.d_int8array, + *num_mask_bytes * sizeof (guint8)); + } + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} + /** * gimp_brush_get_spacing: - * @name: The brush name (\"\" means currently active brush). + * @name: The brush name. * @spacing: The brush spacing. * * Get the brush spacing. @@ -242,7 +299,7 @@ gimp_brush_get_spacing (const gchar *name, /** * gimp_brush_set_spacing: - * @name: The brush name (\"\" means currently active brush). + * @name: The brush name. * @spacing: The brush spacing. * * Set the brush spacing. diff --git a/libgimp/gimpbrush_pdb.h b/libgimp/gimpbrush_pdb.h index e94a3906b8..bb377682e8 100644 --- a/libgimp/gimpbrush_pdb.h +++ b/libgimp/gimpbrush_pdb.h @@ -29,18 +29,23 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -gchar* gimp_brush_new (const gchar *name); -gchar* gimp_brush_duplicate (const gchar *name); -gchar* gimp_brush_rename (const gchar *name, - const gchar *new_name); -gboolean gimp_brush_delete (const gchar *name); -gboolean gimp_brush_get_info (const gchar *name, - gint *width, - gint *height); -gboolean gimp_brush_get_spacing (const gchar *name, - gint *spacing); -gboolean gimp_brush_set_spacing (const gchar *name, - gint spacing); +gchar* gimp_brush_new (const gchar *name); +gchar* gimp_brush_duplicate (const gchar *name); +gchar* gimp_brush_rename (const gchar *name, + const gchar *new_name); +gboolean gimp_brush_delete (const gchar *name); +gboolean gimp_brush_get_info (const gchar *name, + gint *width, + gint *height); +gboolean gimp_brush_get_pixels (const gchar *name, + gint *width, + gint *height, + gint *num_mask_bytes, + guint8 **mask_bytes); +gboolean gimp_brush_get_spacing (const gchar *name, + gint *spacing); +gboolean gimp_brush_set_spacing (const gchar *name, + gint spacing); G_END_DECLS diff --git a/libgimp/gimpbrushes_pdb.c b/libgimp/gimpbrushes_pdb.c index 32fdb700cc..91943ef085 100644 --- a/libgimp/gimpbrushes_pdb.c +++ b/libgimp/gimpbrushes_pdb.c @@ -203,12 +203,9 @@ gimp_brushes_set_spacing (gint spacing) * @length: Length of brush mask data. * @mask_data: The brush mask data. * - * Retrieve information about the currently active brush (including - * data). + * This procedure is deprecated! Use 'gimp_brush_get_pixels' instead. * - * This procedure retrieves information about the currently active - * brush. This includes the brush name, and the brush extents (width - * and height). It also returns the brush data. + * This procedure is deprecated! Use 'gimp_brush_get_pixels' instead. * * Returns: The brush name. */ diff --git a/libgimp/gimpbrushes_pdb.h b/libgimp/gimpbrushes_pdb.h index f5b089898b..d839297943 100644 --- a/libgimp/gimpbrushes_pdb.h +++ b/libgimp/gimpbrushes_pdb.h @@ -43,6 +43,7 @@ gint gimp_brushes_get_spacing (void); #ifndef GIMP_DISABLE_DEPRECATED gboolean gimp_brushes_set_spacing (gint spacing); #endif /* GIMP_DISABLE_DEPRECATED */ +#ifndef GIMP_DISABLE_DEPRECATED gchar* gimp_brushes_get_brush_data (const gchar *name, gdouble *opacity, gint *spacing, @@ -51,6 +52,7 @@ gchar* gimp_brushes_get_brush_data (const gchar *name, gint *height, gint *length, guint8 **mask_data); +#endif /* GIMP_DISABLE_DEPRECATED */ G_END_DECLS diff --git a/libgimp/gimpbrushmenu.c b/libgimp/gimpbrushmenu.c index 0e8c7b1bc8..e17cd6f01f 100644 --- a/libgimp/gimpbrushmenu.c +++ b/libgimp/gimpbrushmenu.c @@ -22,6 +22,8 @@ #include "config.h" +#include + #include "gimp.h" #include "gimpui.h" @@ -115,9 +117,6 @@ gimp_brush_select_widget_new (const gchar *title, BrushSelect *brush_sel; GtkWidget *frame; GtkWidget *hbox; - gint init_spacing; - GimpLayerModeEffects init_paint_mode; - gdouble init_opacity; gint mask_data_size; g_return_val_if_fail (callback != NULL, NULL); @@ -164,20 +163,31 @@ gimp_brush_select_widget_new (const gchar *title, brush_sel); /* Do initial brush setup */ - brush_sel->brush_name = gimp_brushes_get_brush_data (brush_name, - &init_opacity, - &init_spacing, - &init_paint_mode, - &brush_sel->width, - &brush_sel->height, - &mask_data_size, - &brush_sel->mask_data); + if (! brush_name || ! strlen (brush_name)) + brush_sel->brush_name = gimp_context_get_brush (); + else + brush_sel->brush_name = g_strdup (brush_name); - if (brush_sel->brush_name) + if (gimp_brush_get_pixels (brush_sel->brush_name, + &brush_sel->width, + &brush_sel->height, + &mask_data_size, + &brush_sel->mask_data)) { - brush_sel->opacity = (opacity == -1.0) ? init_opacity : opacity; - brush_sel->spacing = (spacing == -1) ? init_spacing : spacing; - brush_sel->paint_mode = (paint_mode == -1) ? init_paint_mode : paint_mode; + if (opacity == -1) + brush_sel->opacity = gimp_context_get_opacity (); + else + brush_sel->opacity = opacity; + + if (paint_mode == -1) + brush_sel->paint_mode = gimp_context_get_paint_mode (); + else + brush_sel->paint_mode = paint_mode; + + if (spacing == -1) + gimp_brush_get_spacing (brush_sel->brush_name, &brush_sel->spacing); + else + brush_sel->spacing = spacing; } g_object_set_data (G_OBJECT (hbox), BRUSH_SELECT_DATA_KEY, brush_sel); @@ -239,37 +249,40 @@ gimp_brush_select_widget_set (GtkWidget *widget, } else { - gint width; - gint height; - gint init_spacing; - GimpLayerModeEffects init_paint_mode; - gdouble init_opacity; - gint mask_data_size; - guint8 *mask_data; - gchar *name; + gint width; + gint height; + gint mask_data_size; + guint8 *mask_data; + gchar *name; - name = gimp_brushes_get_brush_data (brush_name, - &init_opacity, - &init_spacing, - &init_paint_mode, - &width, - &height, - &mask_data_size, - &mask_data); + if (! brush_name || ! strlen (brush_name)) + name = gimp_context_get_brush (); + else + name = g_strdup (brush_name); - if (name) + if (gimp_brush_get_pixels (name, + &width, + &height, + &mask_data_size, + &mask_data)) { - if (opacity == -1.0) opacity = init_opacity; - if (spacing == -1) spacing = init_spacing; - if (paint_mode == -1) paint_mode = init_paint_mode; + if (opacity == -1.0) + opacity = gimp_context_get_opacity (); - gimp_brush_select_widget_callback (brush_name, opacity, spacing, + if (paint_mode == -1) + paint_mode = gimp_context_get_paint_mode (); + + if (spacing == -1) + gimp_brush_get_spacing (name, &spacing); + + gimp_brush_select_widget_callback (name, opacity, spacing, paint_mode, width, height, mask_data, FALSE, brush_sel); - g_free (name); g_free (mask_data); } + + g_free (name); } } diff --git a/libgimp/gimpgradient_pdb.c b/libgimp/gimpgradient_pdb.c index 1fc7a38496..70a2d77b38 100644 --- a/libgimp/gimpgradient_pdb.c +++ b/libgimp/gimpgradient_pdb.c @@ -23,6 +23,8 @@ #include "config.h" +#include + #include "gimp.h" /** @@ -59,7 +61,7 @@ gimp_gradient_new (const gchar *name) /** * gimp_gradient_duplicate: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * * Duplicates a gradient * @@ -91,7 +93,7 @@ gimp_gradient_duplicate (const gchar *name) /** * gimp_gradient_rename: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @new_name: The new name of the gradient. * * Rename a gradient @@ -126,7 +128,7 @@ gimp_gradient_rename (const gchar *name, /** * gimp_gradient_delete: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * * Deletes a gradient * @@ -155,9 +157,127 @@ gimp_gradient_delete (const gchar *name) return success; } +/** + * gimp_gradient_get_uniform_samples: + * @name: The gradient name. + * @num_samples: The number of samples to take. + * @reverse: Use the reverse gradient. + * @num_color_samples: Length of the color_samples array (4 * num_samples). + * @color_samples: Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }. + * + * Sample the specified in uniform parts. + * + * This procedure samples the active gradient in the specified number + * of uniform parts. It returns a list of floating-point values which + * correspond to the RGBA values for each sample. The minimum number of + * samples to take is 2, in which case the returned colors will + * correspond to the { 0.0, 1.0 } positions in the gradient. For + * example, if the number of samples is 3, the procedure will return + * the colors at positions { 0.0, 0.5, 1.0 }. + * + * Returns: TRUE on success. + * + * Since: GIMP 2.2 + */ +gboolean +gimp_gradient_get_uniform_samples (const gchar *name, + gint num_samples, + gboolean reverse, + gint *num_color_samples, + gdouble **color_samples) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_gradient_get_uniform_samples", + &nreturn_vals, + GIMP_PDB_STRING, name, + GIMP_PDB_INT32, num_samples, + GIMP_PDB_INT32, reverse, + GIMP_PDB_END); + + *num_color_samples = 0; + *color_samples = NULL; + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + if (success) + { + *num_color_samples = return_vals[1].data.d_int32; + *color_samples = g_new (gdouble, *num_color_samples); + memcpy (*color_samples, return_vals[2].data.d_floatarray, + *num_color_samples * sizeof (gdouble)); + } + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} + +/** + * gimp_gradient_get_custom_samples: + * @name: The gradient name. + * @num_samples: The number of samples to take. + * @positions: The list of positions to sample along the gradient. + * @reverse: Use the reverse gradient. + * @num_color_samples: Length of the color_samples array (4 * num_samples). + * @color_samples: Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }. + * + * Sample the spacified gradient in custom positions. + * + * This procedure samples the active gradient in the specified number + * of points. The procedure will sample the gradient in the specified + * positions from the list. The left endpoint of the gradient + * corresponds to position 0.0, and the right endpoint corresponds to + * 1.0. The procedure returns a list of floating-point values which + * correspond to the RGBA values for each sample. + * + * Returns: TRUE on success. + * + * Since: GIMP 2.2 + */ +gboolean +gimp_gradient_get_custom_samples (const gchar *name, + gint num_samples, + const gdouble *positions, + gboolean reverse, + gint *num_color_samples, + gdouble **color_samples) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_gradient_get_custom_samples", + &nreturn_vals, + GIMP_PDB_STRING, name, + GIMP_PDB_INT32, num_samples, + GIMP_PDB_FLOATARRAY, positions, + GIMP_PDB_INT32, reverse, + GIMP_PDB_END); + + *num_color_samples = 0; + *color_samples = NULL; + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + if (success) + { + *num_color_samples = return_vals[1].data.d_int32; + *color_samples = g_new (gdouble, *num_color_samples); + memcpy (*color_samples, return_vals[2].data.d_floatarray, + *num_color_samples * sizeof (gdouble)); + } + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} + /** * gimp_gradient_segment_get_left_color: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @segment: The index of the segment within the gradient. * @color: The return color. * @opacity: The opacity of the endpoint. @@ -205,7 +325,7 @@ gimp_gradient_segment_get_left_color (const gchar *name, /** * gimp_gradient_segment_set_left_color: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @segment: The index of the segment within the gradient. * @color: The color to set. * @opacity: The opacity to set for the endpoint. @@ -247,7 +367,7 @@ gimp_gradient_segment_set_left_color (const gchar *name, /** * gimp_gradient_segment_get_right_color: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @segment: The index of the segment within the gradient. * @color: The return color. * @opacity: The opacity of the endpoint. @@ -295,7 +415,7 @@ gimp_gradient_segment_get_right_color (const gchar *name, /** * gimp_gradient_segment_set_right_color: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @segment: The index of the segment within the gradient. * @color: The color to set. * @opacity: The opacity to set for the endpoint. @@ -337,7 +457,7 @@ gimp_gradient_segment_set_right_color (const gchar *name, /** * gimp_gradient_segment_get_left_pos: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @segment: The index of the segment within the gradient. * @pos: The return position. * @@ -380,7 +500,7 @@ gimp_gradient_segment_get_left_pos (const gchar *name, /** * gimp_gradient_segment_set_left_pos: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @segment: The index of the segment within the gradient. * @pos: The position to set the guidepoint in. * @final_pos: The return position. @@ -429,7 +549,7 @@ gimp_gradient_segment_set_left_pos (const gchar *name, /** * gimp_gradient_segment_get_middle_pos: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @segment: The index of the segment within the gradient. * @pos: The return position. * @@ -472,7 +592,7 @@ gimp_gradient_segment_get_middle_pos (const gchar *name, /** * gimp_gradient_segment_set_middle_pos: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @segment: The index of the segment within the gradient. * @pos: The position to set the guidepoint in. * @final_pos: The return position. @@ -519,7 +639,7 @@ gimp_gradient_segment_set_middle_pos (const gchar *name, /** * gimp_gradient_segment_get_right_pos: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @segment: The index of the segment within the gradient. * @pos: The return position. * @@ -562,7 +682,7 @@ gimp_gradient_segment_get_right_pos (const gchar *name, /** * gimp_gradient_segment_set_right_pos: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @segment: The index of the segment within the gradient. * @pos: The position to set the guidepoint in. * @final_pos: The return position. @@ -611,7 +731,7 @@ gimp_gradient_segment_set_right_pos (const gchar *name, /** * gimp_gradient_segment_get_blending_function: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @segment: The index of the segment within the gradient. * @blend_func: The blending function of the segment. * @@ -653,7 +773,7 @@ gimp_gradient_segment_get_blending_function (const gchar *name, /** * gimp_gradient_segment_get_coloring_type: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @segment: The index of the segment within the gradient. * @coloring_type: The coloring type of the segment. * @@ -695,7 +815,7 @@ gimp_gradient_segment_get_coloring_type (const gchar *name, /** * gimp_gradient_segment_range_set_blending_function: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @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. @@ -736,7 +856,7 @@ gimp_gradient_segment_range_set_blending_function (const gchar *name /** * gimp_gradient_segment_range_set_coloring_type: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @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. @@ -777,7 +897,7 @@ gimp_gradient_segment_range_set_coloring_type (const gchar *name, /** * gimp_gradient_segment_range_flip: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @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. * @@ -814,7 +934,7 @@ gimp_gradient_segment_range_flip (const gchar *name, /** * gimp_gradient_segment_range_replicate: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @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. * @replicate_times: The number of times to replicate. @@ -856,7 +976,7 @@ gimp_gradient_segment_range_replicate (const gchar *name, /** * gimp_gradient_segment_range_split_midpoint: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @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. * @@ -894,7 +1014,7 @@ gimp_gradient_segment_range_split_midpoint (const gchar *name, /** * gimp_gradient_segment_range_split_uniform: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @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. * @split_parts: The number of uniform divisions to split each segment to. @@ -935,7 +1055,7 @@ gimp_gradient_segment_range_split_uniform (const gchar *name, /** * gimp_gradient_segment_range_delete: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @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. * @@ -972,7 +1092,7 @@ gimp_gradient_segment_range_delete (const gchar *name, /** * gimp_gradient_segment_range_redistribute_handles: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @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. * @@ -1010,7 +1130,7 @@ gimp_gradient_segment_range_redistribute_handles (const gchar *name, /** * gimp_gradient_segment_range_blend_colors: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @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. * @@ -1049,7 +1169,7 @@ gimp_gradient_segment_range_blend_colors (const gchar *name, /** * gimp_gradient_segment_range_blend_opacity: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @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. * @@ -1088,7 +1208,7 @@ gimp_gradient_segment_range_blend_opacity (const gchar *name, /** * gimp_gradient_segment_range_move: - * @name: The gradient name (\"\" means currently active gradient). + * @name: The gradient name. * @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. * @delta: The delta to move the segment range. diff --git a/libgimp/gimpgradient_pdb.h b/libgimp/gimpgradient_pdb.h index 36a0d073e1..b2a15b83a5 100644 --- a/libgimp/gimpgradient_pdb.h +++ b/libgimp/gimpgradient_pdb.h @@ -29,93 +29,104 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -gchar* gimp_gradient_new (const gchar *name); -gchar* gimp_gradient_duplicate (const gchar *name); -gchar* gimp_gradient_rename (const gchar *name, - const gchar *new_name); -gboolean gimp_gradient_delete (const gchar *name); -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); +gchar* gimp_gradient_new (const gchar *name); +gchar* gimp_gradient_duplicate (const gchar *name); +gchar* gimp_gradient_rename (const gchar *name, + const gchar *new_name); +gboolean gimp_gradient_delete (const gchar *name); +gboolean gimp_gradient_get_uniform_samples (const gchar *name, + gint num_samples, + gboolean reverse, + gint *num_color_samples, + gdouble **color_samples); +gboolean gimp_gradient_get_custom_samples (const gchar *name, + gint num_samples, + const gdouble *positions, + gboolean reverse, + gint *num_color_samples, + gdouble **color_samples); +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/libgimp/gimpgradientmenu.c b/libgimp/gimpgradientmenu.c index 10749e05e9..17ba3bf3e9 100644 --- a/libgimp/gimpgradientmenu.c +++ b/libgimp/gimpgradientmenu.c @@ -22,6 +22,8 @@ #include "config.h" +#include + #include "gimp.h" #include "gimpui.h" @@ -110,9 +112,12 @@ gimp_gradient_select_widget_new (const gchar *title, gradient_sel->sample_size = CELL_WIDTH; gradient_sel->reverse = FALSE; - gradient_sel->button = gtk_button_new (); + if (! gradient_name || ! strlen (gradient_name)) + gradient_sel->gradient_name = gimp_context_get_gradient (); + else + gradient_sel->gradient_name = g_strdup (gradient_name); - gradient_sel->gradient_name = g_strdup (gradient_name); + gradient_sel->button = gtk_button_new (); g_signal_connect (gradient_sel->button, "clicked", G_CALLBACK (gimp_gradient_select_widget_clicked), @@ -193,24 +198,28 @@ gimp_gradient_select_widget_set (GtkWidget *widget, else { gchar *name; - gdouble *gradient_data; - gint width; + gint n_samples; + gdouble *samples; - name = gimp_gradients_get_gradient_data (gradient_name, - gradient_sel->sample_size, - gradient_sel->reverse, - &width, - &gradient_data); + if (! gradient_name || ! strlen (gradient_name)) + name = gimp_context_get_gradient (); + else + name = g_strdup (gradient_name); - if (name) - { + if (gimp_gradient_get_uniform_samples (name, + gradient_sel->sample_size, + gradient_sel->reverse, + &n_samples, + &samples)) + { gimp_gradient_select_widget_callback (name, - width, gradient_data, + n_samples, samples, FALSE, gradient_sel); - g_free (name); - g_free (gradient_data); + g_free (samples); } + + g_free (name); } } @@ -285,26 +294,20 @@ gimp_gradient_select_preview_size_allocate (GtkWidget *widget, GtkAllocation *allocation, GradientSelect *gradient_sel) { - gchar *name; - gdouble *data; - gint width; + gint n_samples; + gdouble *samples; - name = gimp_gradients_get_gradient_data (gradient_sel->gradient_name, - allocation->width, - gradient_sel->reverse, - &width, - &data); - - if (name) + if (gimp_gradient_get_uniform_samples (gradient_sel->gradient_name, + allocation->width, + gradient_sel->reverse, + &n_samples, + &samples)) { gradient_sel->sample_size = allocation->width; - gradient_sel->width = width; - - g_free (gradient_sel->gradient_name); - gradient_sel->gradient_name = name; + gradient_sel->width = n_samples; g_free (gradient_sel->gradient_data); - gradient_sel->gradient_data = data; + gradient_sel->gradient_data = samples; } } diff --git a/libgimp/gimpgradients_pdb.c b/libgimp/gimpgradients_pdb.c index 0a88fd3db2..dee794f849 100644 --- a/libgimp/gimpgradients_pdb.c +++ b/libgimp/gimpgradients_pdb.c @@ -102,15 +102,11 @@ gimp_gradients_get_list (const gchar *filter, * @num_samples: The number of samples to take. * @reverse: Use the reverse gradient. * - * Sample the active gradient in uniform parts. + * This procedure is deprecated! Use + * 'gimp_gradient_get_uniform_samples' instead. * - * This procedure samples the active gradient in the specified number - * of uniform parts. It returns a list of floating-point values which - * correspond to the RGBA values for each sample. The minimum number of - * samples to take is 2, in which case the returned colors will - * correspond to the { 0.0, 1.0 } positions in the gradient. For - * example, if the number of samples is 3, the procedure will return - * the colors at positions { 0.0, 0.5, 1.0 }. + * This procedure is deprecated! Use + * 'gimp_gradient_get_uniform_samples' instead. * * Returns: Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }. */ @@ -148,14 +144,11 @@ gimp_gradients_sample_uniform (gint num_samples, * @positions: The list of positions to sample along the gradient. * @reverse: Use the reverse gradient. * - * Sample the active gradient in custom positions. + * This procedure is deprecated! Use 'gimp_gradient_get_custom_samples' + * instead. * - * This procedure samples the active gradient in the specified number - * of points. The procedure will sample the gradient in the specified - * positions from the list. The left endpoint of the gradient - * corresponds to position 0.0, and the right endpoint corresponds to - * 1.0. The procedure returns a list of floating-point values which - * correspond to the RGBA values for each sample. + * This procedure is deprecated! Use 'gimp_gradient_get_custom_samples' + * instead. * * Returns: Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }. */ @@ -197,10 +190,11 @@ gimp_gradients_sample_custom (gint num_samples, * @width: The gradient sample width (r,g,b,a). * @grad_data: The gradient sample data. * - * Retrieve information about the specified gradient (including data). + * This procedure is deprecated! Use + * 'gimp_gradient_get_uniform_samples' instead. * - * This procedure retrieves information about the gradient. This - * includes the gradient name, and the sample data for the gradient. + * This procedure is deprecated! Use + * 'gimp_gradient_get_uniform_samples' instead. * * Returns: The gradient name. */ diff --git a/libgimp/gimpgradients_pdb.h b/libgimp/gimpgradients_pdb.h index e0e902da9c..4e4d9c375e 100644 --- a/libgimp/gimpgradients_pdb.h +++ b/libgimp/gimpgradients_pdb.h @@ -32,16 +32,22 @@ G_BEGIN_DECLS gboolean gimp_gradients_refresh (void); gchar** gimp_gradients_get_list (const gchar *filter, gint *num_gradients); +#ifndef GIMP_DISABLE_DEPRECATED gdouble* gimp_gradients_sample_uniform (gint num_samples, gboolean reverse); +#endif /* GIMP_DISABLE_DEPRECATED */ +#ifndef GIMP_DISABLE_DEPRECATED gdouble* gimp_gradients_sample_custom (gint num_samples, const gdouble *positions, gboolean reverse); +#endif /* GIMP_DISABLE_DEPRECATED */ +#ifndef GIMP_DISABLE_DEPRECATED gchar* gimp_gradients_get_gradient_data (const gchar *name, gint sample_size, gboolean reverse, gint *width, gdouble **grad_data); +#endif /* GIMP_DISABLE_DEPRECATED */ G_END_DECLS diff --git a/libgimp/gimppalette_pdb.c b/libgimp/gimppalette_pdb.c index 365f314eed..1a6f494dff 100644 --- a/libgimp/gimppalette_pdb.c +++ b/libgimp/gimppalette_pdb.c @@ -59,7 +59,7 @@ gimp_palette_new (const gchar *name) /** * gimp_palette_duplicate: - * @name: The palette name (\"\" means currently active palette). + * @name: The palette name. * * Duplicates a palette * @@ -91,7 +91,7 @@ gimp_palette_duplicate (const gchar *name) /** * gimp_palette_rename: - * @name: The palette name (\"\" means currently active palette). + * @name: The palette name. * @new_name: The new name of the palette. * * Rename a palette @@ -126,7 +126,7 @@ gimp_palette_rename (const gchar *name, /** * gimp_palette_delete: - * @name: The palette name (\"\" means currently active palette). + * @name: The palette name. * * Deletes a palette * @@ -157,7 +157,7 @@ gimp_palette_delete (const gchar *name) /** * gimp_palette_get_info: - * @name: The palette name (\"\" means currently active palette). + * @name: The palette name. * @num_colors: The number of colors in the palette. * * Retrieve information about the specified palette. @@ -196,7 +196,7 @@ gimp_palette_get_info (const gchar *name, /** * gimp_palette_add_entry: - * @name: The palette name (\"\" means currently active palette). + * @name: The palette name. * @entry_name: The name of the entry. * @color: The new entry's color color. * @entry_num: The index of the added entry. @@ -241,7 +241,7 @@ gimp_palette_add_entry (const gchar *name, /** * gimp_palette_delete_entry: - * @name: The palette name (\"\" means currently active palette). + * @name: The palette name. * @entry_num: The index of the added entry. * * Deletes a palette entry from the specified palette. @@ -276,7 +276,7 @@ gimp_palette_delete_entry (const gchar *name, /** * gimp_palette_entry_get_color: - * @name: The palette name (\"\" means currently active palette). + * @name: The palette name. * @entry_num: The entry to retrieve. * @color: The color requested. * @@ -317,7 +317,7 @@ gimp_palette_entry_get_color (const gchar *name, /** * gimp_palette_entry_set_color: - * @name: The palette name (\"\" means currently active palette). + * @name: The palette name. * @entry_num: The entry to retrieve. * @color: The new color. * @@ -356,7 +356,7 @@ gimp_palette_entry_set_color (const gchar *name, /** * gimp_palette_entry_get_name: - * @name: The palette name (\"\" means currently active palette). + * @name: The palette name. * @entry_num: The entry to retrieve. * @entry_name: The name requested. * @@ -399,7 +399,7 @@ gimp_palette_entry_get_name (const gchar *name, /** * gimp_palette_entry_set_name: - * @name: The palette name (\"\" means currently active palette). + * @name: The palette name. * @entry_num: The entry to retrieve. * @entry_name: The new name. * diff --git a/libgimp/gimppattern_pdb.c b/libgimp/gimppattern_pdb.c index e4d8485ff1..c945059218 100644 --- a/libgimp/gimppattern_pdb.c +++ b/libgimp/gimppattern_pdb.c @@ -23,11 +23,13 @@ #include "config.h" +#include + #include "gimp.h" /** * gimp_pattern_get_info: - * @name: The pattern name (\"\" means currently active pattern). + * @name: The pattern name. * @width: The pattern width. * @height: The pattern height. * @bpp: The pattern bpp. @@ -73,3 +75,63 @@ gimp_pattern_get_info (const gchar *name, return success; } + +/** + * gimp_pattern_get_pixels: + * @name: The pattern name. + * @width: The pattern width. + * @height: The pattern height. + * @bpp: The pattern bpp. + * @num_mask_bytes: Length of pattern mask data. + * @mask_bytes: The pattern mask data. + * + * Retrieve information about the specified pattern (including pixels). + * + * This procedure retrieves information about the specified. This + * includes the pattern extents (width and height), its bpp and its + * pixel data. + * + * Returns: TRUE on success. + * + * Since: GIMP 2.2 + */ +gboolean +gimp_pattern_get_pixels (const gchar *name, + gint *width, + gint *height, + gint *bpp, + gint *num_mask_bytes, + guint8 **mask_bytes) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_pattern_get_pixels", + &nreturn_vals, + GIMP_PDB_STRING, name, + GIMP_PDB_END); + + *width = 0; + *height = 0; + *bpp = 0; + *num_mask_bytes = 0; + *mask_bytes = NULL; + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + if (success) + { + *width = return_vals[1].data.d_int32; + *height = return_vals[2].data.d_int32; + *bpp = return_vals[3].data.d_int32; + *num_mask_bytes = return_vals[4].data.d_int32; + *mask_bytes = g_new (guint8, *num_mask_bytes); + memcpy (*mask_bytes, return_vals[5].data.d_int8array, + *num_mask_bytes * sizeof (guint8)); + } + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} diff --git a/libgimp/gimppattern_pdb.h b/libgimp/gimppattern_pdb.h index 32c1e1db63..72d7d37749 100644 --- a/libgimp/gimppattern_pdb.h +++ b/libgimp/gimppattern_pdb.h @@ -29,10 +29,16 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -gboolean gimp_pattern_get_info (const gchar *name, - gint *width, - gint *height, - gint *bpp); +gboolean gimp_pattern_get_info (const gchar *name, + gint *width, + gint *height, + gint *bpp); +gboolean gimp_pattern_get_pixels (const gchar *name, + gint *width, + gint *height, + gint *bpp, + gint *num_mask_bytes, + guint8 **mask_bytes); G_END_DECLS diff --git a/libgimp/gimppatternmenu.c b/libgimp/gimppatternmenu.c index e65d17224e..190a8892a6 100644 --- a/libgimp/gimppatternmenu.c +++ b/libgimp/gimppatternmenu.c @@ -22,6 +22,8 @@ #include "config.h" +#include + #include "gimp.h" #include "gimpui.h" @@ -149,13 +151,17 @@ gimp_pattern_select_widget_new (const gchar *title, pattern_sel); /* Do initial pattern setup */ - pattern_sel->pattern_name = - gimp_patterns_get_pattern_data (pattern_name, - &pattern_sel->width, - &pattern_sel->height, - &pattern_sel->bytes, - &mask_data_size, - &pattern_sel->mask_data); + if (! pattern_name || ! strlen (pattern_name)) + pattern_sel->pattern_name = gimp_context_get_pattern (); + else + pattern_sel->pattern_name = g_strdup (pattern_name); + + gimp_pattern_get_pixels (pattern_sel->pattern_name, + &pattern_sel->width, + &pattern_sel->height, + &pattern_sel->bytes, + &mask_data_size, + &pattern_sel->mask_data); g_object_set_data (G_OBJECT (hbox), PATTERN_SELECT_DATA_KEY, pattern_sel); @@ -173,6 +179,8 @@ gimp_pattern_select_widget_close (GtkWidget *widget) { PatternSelect *pattern_sel; + g_return_if_fail (GTK_IS_WIDGET (widget)); + pattern_sel = g_object_get_data (G_OBJECT (widget), PATTERN_SELECT_DATA_KEY); g_return_if_fail (pattern_sel != NULL); @@ -199,6 +207,8 @@ gimp_pattern_select_widget_set (GtkWidget *widget, { PatternSelect *pattern_sel; + g_return_if_fail (GTK_IS_WIDGET (widget)); + pattern_sel = g_object_get_data (G_OBJECT (widget), PATTERN_SELECT_DATA_KEY); g_return_if_fail (pattern_sel != NULL); @@ -217,21 +227,25 @@ gimp_pattern_select_widget_set (GtkWidget *widget, guint8 *mask_data; gchar *name; - name = gimp_patterns_get_pattern_data (pattern_name, - &width, - &height, - &bytes, - &mask_data_size, - &mask_data); + if (! pattern_name || ! strlen (pattern_name)) + name = gimp_context_get_pattern (); + else + name = g_strdup (pattern_name); - if (name) + if (gimp_pattern_get_pixels (name, + &width, + &height, + &bytes, + &mask_data_size, + &mask_data)) { gimp_pattern_select_widget_callback (name, width, height, bytes, mask_data, FALSE, pattern_sel); - g_free (name); g_free (mask_data); } + + g_free (name); } } diff --git a/libgimp/gimppatterns_pdb.c b/libgimp/gimppatterns_pdb.c index 3b2c4c3689..7f64f0c6d2 100644 --- a/libgimp/gimppatterns_pdb.c +++ b/libgimp/gimppatterns_pdb.c @@ -143,12 +143,9 @@ gimp_patterns_get_pattern (gint *width, * @length: Length of pattern mask data. * @mask_data: The pattern mask data. * - * Retrieve information about the currently active pattern (including - * data). + * This procedure is deprecated! Use 'gimp_pattern_get_data' instead. * - * This procedure retrieves information about the currently active - * pattern. This includes the pattern name, and the pattern extents - * (width and height). It also returns the pattern data. + * This procedure is deprecated! Use 'gimp_pattern_get_data' instead. * * Returns: The pattern name. */ diff --git a/libgimp/gimppatterns_pdb.h b/libgimp/gimppatterns_pdb.h index ec4113e11e..2964a8d729 100644 --- a/libgimp/gimppatterns_pdb.h +++ b/libgimp/gimppatterns_pdb.h @@ -36,12 +36,14 @@ gchar** gimp_patterns_get_list (const gchar *filter, gchar* gimp_patterns_get_pattern (gint *width, gint *height); #endif /* GIMP_DISABLE_DEPRECATED */ +#ifndef GIMP_DISABLE_DEPRECATED gchar* gimp_patterns_get_pattern_data (const gchar *name, gint *width, gint *height, gint *mask_bpp, gint *length, guint8 **mask_data); +#endif /* GIMP_DISABLE_DEPRECATED */ G_END_DECLS diff --git a/plug-ins/FractalExplorer/Dialogs.c b/plug-ins/FractalExplorer/Dialogs.c index 843a970c0a..fa09b4e55f 100644 --- a/plug-ins/FractalExplorer/Dialogs.c +++ b/plug-ins/FractalExplorer/Dialogs.c @@ -20,6 +20,7 @@ #define ZOOM_UNDO_SIZE 100 +static gint n_gradient_samples = 0; static gdouble *gradient_samples = NULL; static gchar *gradient_name = NULL; static gboolean ready_now = FALSE; @@ -256,8 +257,6 @@ static void explorer_number_of_colors_callback (GtkAdjustment *adjustment, gpointer data) { - gint dummy; - gimp_int_adjustment_update (adjustment, data); g_free (gradient_samples); @@ -265,11 +264,11 @@ explorer_number_of_colors_callback (GtkAdjustment *adjustment, if (! gradient_name) gradient_name = gimp_context_get_gradient (); - gimp_gradients_get_gradient_data (gradient_name, - wvals.ncolors, - wvals.gradinvert, - &dummy, - &gradient_samples); + gimp_gradient_get_uniform_samples (gradient_name, + wvals.ncolors, + wvals.gradinvert, + &n_gradient_samples, + &gradient_samples); set_cmap_preview (); dialog_update_preview (); @@ -282,18 +281,16 @@ explorer_gradient_select_callback (const gchar *name, gboolean dialog_closing, gpointer data) { - gint dummy; - g_free (gradient_name); g_free (gradient_samples); gradient_name = g_strdup (name); - gimp_gradients_get_gradient_data (gradient_name, - wvals.ncolors, - wvals.gradinvert, - &dummy, - &gradient_samples); + gimp_gradient_get_uniform_samples (gradient_name, + wvals.ncolors, + wvals.gradinvert, + &n_gradient_samples, + &gradient_samples); if (wvals.colormode == 1) { @@ -303,7 +300,8 @@ explorer_gradient_select_callback (const gchar *name, } static void -preview_draw_crosshair (gint px, gint py) +preview_draw_crosshair (gint px, + gint py) { gint x, y; guchar *p_ul; @@ -1135,8 +1133,13 @@ explorer_dialog (void) "the gradient editor"), NULL); gradient_name = gimp_context_get_gradient (); - gradient_samples = gimp_gradients_sample_uniform (wvals.ncolors, - wvals.gradinvert); + + gimp_gradient_get_uniform_samples (gradient_name, + wvals.ncolors, + wvals.gradinvert, + &n_gradient_samples, + &gradient_samples); + gradient = gimp_gradient_select_widget_new (_("FractalExplorer Gradient"), gradient_name, explorer_gradient_select_callback, @@ -1500,8 +1503,17 @@ make_color_map (void) * mode for noninteractive use (bug #103470). */ if (gradient_samples == NULL) - gradient_samples = gimp_gradients_sample_uniform (wvals.ncolors, - wvals.gradinvert); + { + gchar *gradient_name = gimp_context_get_gradient (); + + gimp_gradient_get_uniform_samples (gradient_name, + wvals.ncolors, + wvals.gradinvert, + &n_gradient_samples, + &gradient_samples); + + g_free (gradient_name); + } redstretch = wvals.redstretch * 127.5; greenstretch = wvals.greenstretch * 127.5; diff --git a/plug-ins/common/gradmap.c b/plug-ins/common/gradmap.c index 49d4c827e8..ca2e87c433 100644 --- a/plug-ins/common/gradmap.c +++ b/plug-ins/common/gradmap.c @@ -194,15 +194,20 @@ gradmap (GimpDrawable *drawable) static guchar * get_samples (GimpDrawable *drawable) { + gchar *gradient_name; + gint n_f_samples; gdouble *f_samples, *f_samp; /* float samples */ guchar *b_samples, *b_samp; /* byte samples */ gint bpp, color, has_alpha, alpha; gint i, j; + gradient_name = gimp_context_get_gradient (); + #ifdef __GNUC__ #warning FIXME: "reverse" hardcoded to FALSE. #endif - f_samples = gimp_gradients_sample_uniform (NSAMPLES, FALSE); + gimp_gradient_get_uniform_samples (gradient_name, NSAMPLES, FALSE, + &n_f_samples, &f_samples); bpp = gimp_drawable_bpp (drawable->drawable_id); color = gimp_drawable_is_rgb (drawable->drawable_id); diff --git a/plug-ins/common/sample_colorize.c b/plug-ins/common/sample_colorize.c index 9a633bc571..7849f22309 100644 --- a/plug-ins/common/sample_colorize.c +++ b/plug-ins/common/sample_colorize.c @@ -2428,12 +2428,21 @@ p_fill_missing_colors (void) static void p_get_gradient (gint mode) { - gdouble *f_samples, *f_samp; /* float samples */ - gint l_lum; + gchar *name; + gint n_f_samples; + gdouble *f_samples; + gdouble *f_samp; /* float samples */ + gint l_lum; - p_free_colors(); - f_samples = gimp_gradients_sample_uniform (256 /* n_samples */, - mode == SMP_INV_GRADIENT); + p_free_colors (); + + name = gimp_context_get_gradient (); + + gimp_gradient_get_uniform_samples (name, 256 /* n_samples */, + mode == SMP_INV_GRADIENT, + &n_f_samples, &f_samples); + + g_free (name); for (l_lum = 0; l_lum < 256; l_lum++) { diff --git a/plug-ins/flame/flame.c b/plug-ins/flame/flame.c index dd46ba2948..ddca46c553 100644 --- a/plug-ins/flame/flame.c +++ b/plug-ins/flame/flame.c @@ -272,10 +272,18 @@ drawable_to_cmap (control_point *cp) } else if (GRADIENT_DRAWABLE == config.cmap_drawable) { + gchar *name = gimp_context_get_gradient (); + gint num; + gdouble *g; + #ifdef __GNUC__ #warning FIXME: "reverse" hardcoded to FALSE. #endif - gdouble *g = gimp_gradients_sample_uniform (256, FALSE); + gimp_gradient_get_uniform_samples (name, 256, FALSE, + &num, &g); + + g_free (name); + for (i = 0; i < 256; i++) for (j = 0; j < 3; j++) cp->cmap[i][j] = g[i*4 + j]; diff --git a/plug-ins/gfig/gfig-style.c b/plug-ins/gfig/gfig-style.c index de531f1173..1c43131460 100644 --- a/plug-ins/gfig/gfig-style.c +++ b/plug-ins/gfig/gfig-style.c @@ -586,8 +586,9 @@ gfig_read_gimp_style (Style *style, gimp_context_get_background (&style->background); style->brush_name = gimp_context_get_brush (); - gimp_brush_get_info (NULL, &style->brush_width, &style->brush_height); - gimp_brush_get_spacing (NULL, &style->brush_spacing); + gimp_brush_get_info (style->brush_name, + &style->brush_width, &style->brush_height); + gimp_brush_get_spacing (style->brush_name, &style->brush_spacing); style->gradient = gimp_context_get_gradient (); style->pattern = gimp_context_get_pattern (); @@ -688,7 +689,9 @@ void mygimp_brush_info (gint *width, gint *height) { - if (gimp_brush_get_info (NULL, width, height)) + gchar *name = gimp_context_get_brush (); + + if (name && gimp_brush_get_info (name, width, height)) { *width = MAX (*width, 32); *height = MAX (*height, 32); @@ -698,5 +701,6 @@ mygimp_brush_info (gint *width, g_message ("Failed to get brush info"); *width = *height = 48; } -} + g_free (name); +} diff --git a/plug-ins/gflare/gflare.c b/plug-ins/gflare/gflare.c index feebfcb066..e34a5c9f25 100644 --- a/plug-ins/gflare/gflare.c +++ b/plug-ins/gflare/gflare.c @@ -4668,7 +4668,7 @@ gradient_get_blend (guchar *fg, gint j; guchar *v = values; - for (i=0; i 'name', type => 'string', - desc => 'The brush name ("" means currently active brush)', - null_ok => '1' + desc => 'The brush name' }} sub spacing_arg () {{ @@ -37,19 +36,6 @@ sub spacing_arg () {{ desc => 'The brush spacing: %%desc%%' }} -my $get_brush_from_name = <<'CODE'; -if (name && strlen (name)) - { - brush = (GimpBrush *) - gimp_container_get_child_by_name (gimp->brush_factory->container, - name); - } -else - { - brush = gimp_context_get_brush (context); - } -CODE - # The defs @@ -103,9 +89,10 @@ sub brush_duplicate { %invoke = ( vars => [ 'GimpBrush *brush = NULL', 'GimpBrush *brush_copy = NULL' ], - code => <<"CODE" + code => <<'CODE' { - $get_brush_from_name + brush = (GimpBrush *) + gimp_container_get_child_by_name (gimp->brush_factory->container, name); if (brush) { @@ -142,9 +129,10 @@ sub brush_rename { %invoke = ( vars => [ 'GimpBrush *brush = NULL' ], - code => <<"CODE" + code => <<'CODE' { - $get_brush_from_name + brush = (GimpBrush *) + gimp_container_get_child_by_name (gimp->brush_factory->container, name); if (brush && GIMP_DATA (brush)->writable) gimp_object_set_name (GIMP_OBJECT (brush), new_name); @@ -167,9 +155,10 @@ sub brush_delete { %invoke = ( vars => [ 'GimpBrush *brush = NULL' ], - code => <<"CODE" + code => <<'CODE' { - $get_brush_from_name + brush = (GimpBrush *) + gimp_container_get_child_by_name (gimp->brush_factory->container, name); if (brush && GIMP_DATA (brush)->deletable) { @@ -216,9 +205,10 @@ HELP %invoke = ( vars => [ 'GimpBrush *brush = NULL' ], - code => <<"CODE" + code => <<'CODE' { - $get_brush_from_name + brush = (GimpBrush *) + gimp_container_get_child_by_name (gimp->brush_factory->container, name); success = (brush != NULL); } @@ -244,15 +234,16 @@ HELP @outargs = ( &spacing_arg ); - $outargs[0]->{alias} = 'gimp_brush_get_spacing (gimp_context_get_brush (context))'; + $outargs[0]->{alias} = 'gimp_brush_get_spacing (brush)'; $outargs[0]->{no_declare} = 1; $outargs[0]->{void_ret} = 1; %invoke = ( vars => [ 'GimpBrush *brush = NULL' ], - code => <<"CODE" + code => <<'CODE' { - $get_brush_from_name + brush = (GimpBrush *) + gimp_container_get_child_by_name (gimp->brush_factory->container, name); success = (brush != NULL); } @@ -277,9 +268,10 @@ HELP %invoke = ( vars => [ 'GimpBrush *brush = NULL' ], - code => <<"CODE" + code => <<'CODE' { - $get_brush_from_name + brush = (GimpBrush *) + gimp_container_get_child_by_name (gimp->brush_factory->container, name); if (brush && GIMP_DATA (brush)->writable) gimp_brush_set_spacing (brush, spacing); @@ -290,13 +282,62 @@ CODE ); } +sub brush_get_pixels { + $blurb = <<'BLURB'; +Retrieve information about the specified brush. +BLURB + + $help = <<'HELP'; +This procedure retrieves information about the specified brush. This +includes the brush extents (width and height) and its pixels data. +HELP + + &mitch_misc; + + @inargs = ( + &brush_arg + ); + + @outargs = ( + { name => 'width', type => 'int32', no_declare => '1', + alias => 'brush->mask->width', void_ret => '1', + desc => "The brush width" }, + { name => 'height', type => 'int32', no_declare => '1', + alias => 'brush->mask->height', + desc => "The brush height" }, + { name => 'mask_bytes', type => 'int8array', init => 1, + desc => 'The brush mask data', + array => { init => 1, + desc => 'Length of brush mask data' } } + ); + + %invoke = ( + vars => [ 'GimpBrush *brush = NULL' ], + code => <<'CODE' +{ + brush = (GimpBrush *) + gimp_container_get_child_by_name (gimp->brush_factory->container, name); + + if (brush) + { + num_mask_bytes = brush->mask->height * brush->mask->width; + mask_bytes = g_memdup (temp_buf_data (brush->mask), num_mask_bytes); + } + else + success = FALSE; +} +CODE + ); +} + @headers = qw( "base/temp-buf.h" "core/gimp.h" "core/gimplist.h" "core/gimpbrush.h" "core/gimpcontext.h" "core/gimpdatafactory.h"); @procs = qw(brush_new brush_duplicate brush_rename brush_delete - brush_get_info brush_get_spacing brush_set_spacing); + brush_get_info brush_get_pixels + brush_get_spacing brush_set_spacing); %exports = (app => [@procs], lib => [@procs]); $desc = 'Brush'; diff --git a/tools/pdbgen/pdb/brushes.pdb b/tools/pdbgen/pdb/brushes.pdb index b4ca89965c..126ae44b7a 100644 --- a/tools/pdbgen/pdb/brushes.pdb +++ b/tools/pdbgen/pdb/brushes.pdb @@ -172,18 +172,11 @@ sub brushes_set_spacing { } sub brushes_get_brush_data { - $blurb = <<'BLURB'; -Retrieve information about the currently active brush (including data). -BLURB + $blurb = $help = "This procedure is deprecated! Use 'gimp_brush_get_pixels' instead."; - $help = <<'HELP'; -This procedure retrieves information about the currently active brush. This -includes the brush name, and the brush extents (width and height). It also -returns the brush data. -HELP + $author = $copyright = $date = ''; - $author = $copyright = 'Andy Thomas'; - $date = '1998'; + $deprecated = 1; @inargs = ( &brush_arg diff --git a/tools/pdbgen/pdb/gradient.pdb b/tools/pdbgen/pdb/gradient.pdb index e8d5fe2e36..95d44b7a18 100644 --- a/tools/pdbgen/pdb/gradient.pdb +++ b/tools/pdbgen/pdb/gradient.pdb @@ -21,26 +21,18 @@ sub shlomi_misc { $since = '2.2'; } +sub federico_misc { + $author = $copyright = 'Federico Mena Quintero'; + $date = '1997'; + $since = '2.2'; +} + sub gradient_arg () {{ name => 'name', type => 'string', - desc => 'The gradient name ("" means currently active gradient)', - null_ok => '1' + desc => 'The gradient name' }} -my $get_gradient_from_name = <<'CODE'; - if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } - else - { - gradient = gimp_context_get_gradient (context); - } -CODE - sub _gen_gradient_search_for_segment_code { my $action_on_success = shift; @@ -54,23 +46,24 @@ sub _gen_gradient_search_for_segment_code return <<"CODE"; { -$get_gradient_from_name + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); - success = (gradient != NULL); - - if (success) + if (gradient) { GimpGradientSegment *seg; seg = gimp_gradient_segment_get_nth (gradient->segments, segment); - success = (seg != NULL); - - if (success) + if (seg) { $action_on_success } + else + success = FALSE; } + else + success = FALSE; } CODE @@ -306,7 +299,8 @@ sub gradient_duplicate { 'GimpGradient *gradient_copy = NULL' ], code => <<"CODE" { - $get_gradient_from_name + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); if (gradient) { @@ -345,7 +339,8 @@ sub gradient_rename { vars => [ 'GimpGradient *gradient = NULL' ], code => <<"CODE" { - $get_gradient_from_name + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); if (gradient && GIMP_DATA (gradient)->writable) gimp_object_set_name (GIMP_OBJECT (gradient), new_name); @@ -370,7 +365,8 @@ sub gradient_delete { vars => [ 'GimpGradient *gradient = NULL' ], code => <<"CODE" { - $get_gradient_from_name + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); if (gradient && GIMP_DATA (gradient)->deletable) { @@ -393,6 +389,149 @@ CODE ); } +sub sample_num_arg { + { name => 'num_samples', type => $_[0] . 'int32', + desc => 'The number of samples to take' } +} + +sub reverse_arg { + { name => 'reverse', type => 'boolean', + desc => 'Use the reverse gradient (%%desc%%)' } +} + +sub sample_outargs { + @outargs = ( + { name => 'color_samples', type => 'floatarray', init => 1, + void_ret => 1, + desc => 'Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }', + array => { init => 1, + desc => 'Length of the color_samples array (4 * + num_samples)' } } + ); +} + +sub gradient_get_uniform_samples { + $blurb = 'Sample the specified in uniform parts.'; + + $help = <<'HELP'; +This procedure samples the active gradient in the +specified number of uniform parts. It returns a list of floating-point values +which correspond to the RGBA values for each sample. The minimum number of +samples to take is 2, in which case the returned colors will correspond to the +{ 0.0, 1.0 } positions in the gradient. For example, if the number of samples +is 3, the procedure will return the colors at positions { 0.0, 0.5, 1.0 }. +HELP + + &federico_misc; + + @inargs = ( + &gradient_arg, + &sample_num_arg('2 <= '), + &reverse_arg + ); + + &sample_outargs; + + %invoke = ( + vars => [ 'GimpGradient *gradient' ], + code => <<'CODE' +{ + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); + + if (gradient) + { + gdouble pos = 0.0; + gdouble delta = 1.0 / (num_samples - 1); + gdouble *sample; + + num_color_samples = num_samples * 4; + + sample = color_samples = g_new (gdouble, num_color_samples); + + while (num_samples--) + { + GimpRGB color; + + gimp_gradient_get_color_at (gradient, pos, reverse, &color); + + *sample++ = color.r; + *sample++ = color.g; + *sample++ = color.b; + *sample++ = color.a; + + pos += delta; + } + } + else + success = FALSE; +} +CODE + ); +} + +sub gradient_get_custom_samples { + $blurb = 'Sample the spacified gradient in custom positions.'; + + $help = <<'HELP'; +This procedure samples the active gradient in the specified number of +points. The procedure will sample the gradient in the specified +positions from the list. The left endpoint of the gradient corresponds +to position 0.0, and the right endpoint corresponds to 1.0. The +procedure returns a list of floating-point values which correspond to +the RGBA values for each sample. +HELP + + &federico_misc; + + @inargs = ( + &gradient_arg, + { name => 'positions', + type => 'floatarray', + desc => 'The list of positions to sample along the gradient', + alias => 'pos', + array => &sample_num_arg("") }, + &reverse_arg + ); + + &sample_outargs; + + %invoke = ( + vars => [ 'GimpGradient *gradient' ], + code => <<'CODE' +{ + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); + + if (gradient) + { + gdouble *sample; + + num_color_samples = num_samples * 4; + + sample = color_samples = g_new (gdouble, num_color_samples); + + while (num_samples--) + { + GimpRGB color; + + gimp_gradient_get_color_at (gradient, *pos, reverse, &color); + + *sample++ = color.r; + *sample++ = color.g; + *sample++ = color.b; + *sample++ = color.a; + + pos++; + } + } + else + success = FALSE; +} +CODE + ); +} + sub gradient_segment_get_left_color { &_gen_gradient_get_side_color("left"); @@ -532,7 +671,8 @@ sub _gen_gradient_operate_on_segments_range vars => [ 'GimpGradient *gradient = NULL' ], code => <<"CODE", { -$get_gradient_from_name + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, name); if (gradient) { @@ -814,6 +954,7 @@ CODE "core/gimpdatafactory.h" "core/gimplist.h"); @procs = qw(gradient_new gradient_duplicate gradient_rename gradient_delete + 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 gradient_segment_get_left_pos gradient_segment_set_left_pos diff --git a/tools/pdbgen/pdb/gradients.pdb b/tools/pdbgen/pdb/gradients.pdb index 116263d060..31e524a56d 100644 --- a/tools/pdbgen/pdb/gradients.pdb +++ b/tools/pdbgen/pdb/gradients.pdb @@ -22,19 +22,6 @@ sub federico_misc { $date = '1997'; } -my $get_gradient_from_name = <<'CODE'; -if (name && strlen (name)) - { - gradient = (GimpGradient *) - gimp_container_get_child_by_name (gimp->gradient_factory->container, - name); - } -else - { - gradient = gimp_context_get_gradient (context); - } -CODE - # The defs @@ -110,18 +97,11 @@ sub sample_outargs { } sub gradients_sample_uniform { - $blurb = 'Sample the active gradient in uniform parts.'; + $blurb = $help = "This procedure is deprecated! Use 'gimp_gradient_get_uniform_samples' instead."; - $help = <<'HELP'; -This procedure samples the active gradient in the -specified number of uniform parts. It returns a list of floating-point values -which correspond to the RGBA values for each sample. The minimum number of -samples to take is 2, in which case the returned colors will correspond to the -{ 0.0, 1.0 } positions in the gradient. For example, if the number of samples -is 3, the procedure will return the colors at positions { 0.0, 0.5, 1.0 }. -HELP + $author = $copyright = $date = ''; - &federico_misc; + $deprecated = 1; @inargs = ( &sample_num_arg('2 <= '), @@ -160,18 +140,11 @@ CODE } sub gradients_sample_custom { - $blurb = 'Sample the active gradient in custom positions.'; + $blurb = $help = "This procedure is deprecated! Use 'gimp_gradient_get_custom_samples' instead."; - $help = <<'HELP'; -This procedure samples the active gradient in the specified number of -points. The procedure will sample the gradient in the specified -positions from the list. The left endpoint of the gradient corresponds -to position 0.0, and the right endpoint corresponds to 1.0. The -procedure returns a list of floating-point values which correspond to -the RGBA values for each sample. -HELP + $author = $copyright = $date = ''; - &federico_misc; + $deprecated = 1; @inargs = ( { name => 'positions', @@ -220,16 +193,11 @@ sub sample_size_arg { } sub gradients_get_gradient_data { - $blurb = <<'BLURB'; -Retrieve information about the specified gradient (including data). -BLURB + $blurb = $help = "This procedure is deprecated! Use 'gimp_gradient_get_uniform_samples' instead."; - $help = <<'HELP'; -This procedure retrieves information about the gradient. This includes the -gradient name, and the sample data for the gradient. -HELP + $author = $copyright = $date = ''; - &federico_misc; + $deprecated = 1; @inargs = ( { name => 'name', type => 'string', @@ -254,7 +222,16 @@ HELP vars => [ 'GimpGradient *gradient = NULL' ], code => <<"CODE" { - $get_gradient_from_name + if (name && strlen (name)) + { + gradient = (GimpGradient *) + gimp_container_get_child_by_name (gimp->gradient_factory->container, + name); + } + else + { + gradient = gimp_context_get_gradient (context); + } if (gradient) { diff --git a/tools/pdbgen/pdb/palette.pdb b/tools/pdbgen/pdb/palette.pdb index d267babf08..b73a8287b8 100644 --- a/tools/pdbgen/pdb/palette.pdb +++ b/tools/pdbgen/pdb/palette.pdb @@ -27,8 +27,7 @@ sub mitch_misc { sub palette_arg () {{ name => 'name', type => 'string', - desc => 'The palette name ("" means currently active palette)', - null_ok => '1' + desc => 'The palette name.' }} my $get_palette_from_name = <<'CODE'; @@ -97,9 +96,10 @@ sub palette_duplicate { %invoke = ( vars => [ 'GimpPalette *palette = NULL', 'GimpPalette *palette_copy = NULL' ], - code => <<"CODE" + code => <<'CODE' { - $get_palette_from_name + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette) { @@ -136,9 +136,10 @@ sub palette_rename { %invoke = ( vars => [ 'GimpPalette *palette = NULL' ], - code => <<"CODE" + code => <<'CODE' { - $get_palette_from_name + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->writable) gimp_object_set_name (GIMP_OBJECT (palette), new_name); @@ -161,9 +162,10 @@ sub palette_delete { %invoke = ( vars => [ 'GimpPalette *palette = NULL' ], - code => <<"CODE" + code => <<'CODE' { - $get_palette_from_name + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->deletable) { @@ -208,9 +210,10 @@ HELP %invoke = ( vars => [ 'GimpPalette *palette = NULL' ], - code => <<"CODE" + code => <<'CODE' { - $get_palette_from_name + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); success = (palette != NULL); } @@ -245,9 +248,10 @@ HELP %invoke = ( vars => [ 'GimpPalette *palette = NULL', 'GimpPaletteEntry *entry = NULL' ], - code => <<"CODE" + code => <<'CODE' { - $get_palette_from_name + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->writable) entry = gimp_palette_add_entry (palette, entry_name, &color); @@ -277,9 +281,10 @@ HELP %invoke = ( vars => [ 'GimpPalette *palette = NULL', 'GimpPaletteEntry *entry = NULL' ], - code => <<"CODE" + code => <<'CODE' { - $get_palette_from_name + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->writable) { @@ -323,9 +328,10 @@ HELP %invoke = ( vars => [ 'GimpPalette *palette = NULL', 'GimpPaletteEntry *entry = NULL' ], - code => <<"CODE" + code => <<'CODE' { - $get_palette_from_name + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette) { @@ -366,9 +372,10 @@ HELP %invoke = ( vars => [ 'GimpPalette *palette = NULL', 'GimpPaletteEntry *entry = NULL' ], - code => <<"CODE" + code => <<'CODE' { - $get_palette_from_name + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->writable) { @@ -415,9 +422,10 @@ HELP %invoke = ( vars => [ 'GimpPalette *palette = NULL', 'GimpPaletteEntry *entry = NULL' ], - code => <<"CODE" + code => <<'CODE' { - $get_palette_from_name + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette) { @@ -454,9 +462,10 @@ HELP %invoke = ( vars => [ 'GimpPalette *palette = NULL', 'GimpPaletteEntry *entry = NULL' ], - code => <<"CODE" + code => <<'CODE' { - $get_palette_from_name + palette = (GimpPalette *) + gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->writable) { diff --git a/tools/pdbgen/pdb/pattern.pdb b/tools/pdbgen/pdb/pattern.pdb index 519315bcef..fcf4bf2e4c 100644 --- a/tools/pdbgen/pdb/pattern.pdb +++ b/tools/pdbgen/pdb/pattern.pdb @@ -27,23 +27,9 @@ sub mitch_misc { sub pattern_arg () {{ name => 'name', type => 'string', - desc => 'The pattern name ("" means currently active pattern)', - null_ok => '1' + desc => 'The pattern name.' }} -my $get_pattern_from_name = <<'CODE'; -if (name && strlen (name)) - { - pattern = (GimpPattern *) - gimp_container_get_child_by_name (gimp->pattern_factory->container, - name); - } -else - { - pattern = gimp_context_get_pattern (context); - } -CODE - # The defs @@ -74,9 +60,10 @@ HELP %invoke = ( vars => [ 'GimpPattern *pattern = NULL' ], - code => <<"CODE" + code => <<'CODE' { - $get_pattern_from_name + pattern = (GimpPattern *) + gimp_container_get_child_by_name (gimp->pattern_factory->container, name); success = (pattern != NULL); } @@ -84,12 +71,66 @@ CODE ); } +sub pattern_get_pixels { + $blurb = <<'BLURB'; +Retrieve information about the specified pattern (including pixels). +BLURB + + $help = <<'HELP'; +This procedure retrieves information about the specified. This +includes the pattern extents (width and height), its bpp and its pixel +data. +HELP + + &mitch_misc; + + @inargs = ( + &pattern_arg + ); + + @outargs = ( + { name => 'width', type => 'int32', no_declare => '1', + alias => 'pattern->mask->width', void_ret => '1', + desc => "The pattern width" }, + { name => 'height', type => 'int32', no_declare => '1', + alias => 'pattern->mask->height', + desc => "The pattern height" }, + { name => 'bpp', type => 'int32', no_declare => '1', + alias => 'pattern->mask->bytes', + desc => "The pattern bpp" }, + { name => 'mask_bytes', type => 'int8array', init => 1, + desc => 'The pattern mask data', + array => { init => 1, + desc => 'Length of pattern mask data' } } + ); + + %invoke = ( + vars => [ 'GimpPattern *pattern = NULL' ], + code => <<'CODE' +{ + pattern = (GimpPattern *) + gimp_container_get_child_by_name (gimp->pattern_factory->container, name); + + if (pattern) + { + num_mask_bytes = pattern->mask->height * pattern->mask->width * + pattern->mask->bytes; + mask_bytes = g_memdup (temp_buf_data (pattern->mask), + num_mask_bytes); + } + else + success = FALSE; +} +CODE + ); +} + @headers = qw( "base/temp-buf.h" "core/gimp.h" "core/gimpcontext.h" "core/gimplist.h" "core/gimpdatafactory.h" "core/gimppattern.h" ); -@procs = qw(pattern_get_info); +@procs = qw(pattern_get_info pattern_get_pixels); %exports = (app => [@procs], lib => [@procs]); $desc = 'Pattern'; diff --git a/tools/pdbgen/pdb/patterns.pdb b/tools/pdbgen/pdb/patterns.pdb index 628ba69863..15e4ef466c 100644 --- a/tools/pdbgen/pdb/patterns.pdb +++ b/tools/pdbgen/pdb/patterns.pdb @@ -120,20 +120,15 @@ sub patterns_get_pattern { } sub patterns_get_pattern_data { - $blurb = <<'BLURB'; -Retrieve information about the currently active pattern (including data). -BLURB + $blurb = $help = "This procedure is deprecated! Use 'gimp_pattern_get_data' instead."; - $help = <<'HELP'; -This procedure retrieves information about the currently active pattern. This -includes the pattern name, and the pattern extents (width and height). It also -returns the pattern data. -HELP + $author = $copyright = $data = ''; - $author = $copyright = 'Andy Thomas'; - $date = '1998'; + $deprecated = 1; - @inargs = ( &pattern_arg ); + @inargs = ( + &pattern_arg + ); $inargs[0]->{desc} = 'The pattern name ("" means currently active pattern)'; @outargs = (