diff --git a/ChangeLog b/ChangeLog index 0a9080baae..46a7e7ba02 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2006-03-22 Michael Natterer + + * tools/pdbgen/pdb/buffer.pdb + * tools/pdbgen/pdb/color.pdb + * tools/pdbgen/pdb/display.pdb + * tools/pdbgen/pdb/drawable.pdb + * tools/pdbgen/pdb/drawable_transform.pdb + * tools/pdbgen/pdb/fileops.pdb + * tools/pdbgen/pdb/font_select.pdb + * tools/pdbgen/pdb/gimprc.pdb + * tools/pdbgen/pdb/layer.pdb + * tools/pdbgen/pdb/selection.pdb + * tools/pdbgen/pdb/text_tool.pdb + * tools/pdbgen/pdb/transform_tools.pdb: more perl stuff flattened, + cleanup, nitpickyness. + + * app/pdb/buffer_cmds.c + * app/pdb/color_cmds.c + * app/pdb/display_cmds.c + * app/pdb/drawable_cmds.c + * app/pdb/layer_cmds.c + * app/pdb/selection_cmds.c + * libgimp/gimpselection_pdb.[ch]: regenerated. + 2006-03-22 Sven Neumann * app/base/siox.c (siox_foreground_extract): fixed assertions and diff --git a/app/pdb/buffer_cmds.c b/app/pdb/buffer_cmds.c index bd8620ca6b..53f5c21b85 100644 --- a/app/pdb/buffer_cmds.c +++ b/app/pdb/buffer_cmds.c @@ -70,7 +70,10 @@ buffers_get_list_invoker (Gimp *gimp, success = FALSE; if (success) - buffer_list = gimp_container_get_filtered_name_array (gimp->named_buffers, filter, &num_buffers); + { + buffer_list = gimp_container_get_filtered_name_array (gimp->named_buffers, + filter, &num_buffers); + } return_args = procedural_db_return_args (&buffers_get_list_proc, success); @@ -149,13 +152,13 @@ buffer_rename_invoker (Gimp *gimp, GimpBuffer *buffer = (GimpBuffer *) gimp_container_get_child_by_name (gimp->named_buffers, buffer_name); - success = (buffer != NULL && strlen (new_name) > 0); - - if (success) + if (buffer && strlen (new_name)) { gimp_object_set_name (GIMP_OBJECT (buffer), new_name); real_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (buffer))); } + else + success = FALSE; } return_args = procedural_db_return_args (&buffer_rename_proc, success); @@ -225,10 +228,10 @@ buffer_delete_invoker (Gimp *gimp, GimpBuffer *buffer = (GimpBuffer *) gimp_container_get_child_by_name (gimp->named_buffers, buffer_name); - success = (buffer != NULL); - - if (success) + if (buffer) success = gimp_container_remove (gimp->named_buffers, GIMP_OBJECT (buffer)); + else + success = FALSE; } return procedural_db_return_args (&buffer_delete_proc, success); diff --git a/app/pdb/color_cmds.c b/app/pdb/color_cmds.c index c5fcc3f247..077b448882 100644 --- a/app/pdb/color_cmds.c +++ b/app/pdb/color_cmds.c @@ -241,11 +241,9 @@ levels_invoker (Gimp *gimp, if (success) gimp_drawable_levels (drawable, context, channel, - low_input, - high_input, + low_input, high_input, gamma, - low_output, - high_output); + low_output, high_output); } return procedural_db_return_args (&levels_proc, success); @@ -580,7 +578,7 @@ desaturate_full_invoker (Gimp *gimp, success = FALSE; if (success) - gimp_drawable_desaturate (drawable, (GimpDesaturateMode) desaturate_mode); + gimp_drawable_desaturate (drawable, desaturate_mode); } return procedural_db_return_args (&desaturate_full_proc, success); diff --git a/app/pdb/display_cmds.c b/app/pdb/display_cmds.c index 20ac340e04..21aba297e8 100644 --- a/app/pdb/display_cmds.c +++ b/app/pdb/display_cmds.c @@ -65,11 +65,14 @@ display_new_invoker (Gimp *gimp, { display = gimp_create_display (gimp, gimage, GIMP_UNIT_PIXEL, 1.0); - success = (display != NULL); - - /* the first display takes ownership of the image */ - if (success && gimage->disp_count == 1) - g_object_unref (gimage); + if (display) + { + /* the first display takes ownership of the image */ + if (gimage->disp_count == 1) + g_object_unref (gimage); + } + else + success = FALSE; } return_args = procedural_db_return_args (&display_new_proc, success); diff --git a/app/pdb/drawable_cmds.c b/app/pdb/drawable_cmds.c index e8fd508a7a..74e1de40c8 100644 --- a/app/pdb/drawable_cmds.c +++ b/app/pdb/drawable_cmds.c @@ -1026,7 +1026,7 @@ drawable_get_image_invoker (Gimp *gimp, if (success) { - success = (gimage = gimp_item_get_image (GIMP_ITEM (drawable))) != NULL; + gimage = gimp_item_get_image (GIMP_ITEM (drawable)); } return_args = procedural_db_return_args (&drawable_get_image_proc, success); @@ -1093,7 +1093,8 @@ drawable_set_image_invoker (Gimp *gimp, if (success) { - success = (gimage == gimp_item_get_image (GIMP_ITEM (drawable))); + if (gimage != gimp_item_get_image (GIMP_ITEM (drawable))) + success = FALSE; } return procedural_db_return_args (&drawable_set_image_proc, success); diff --git a/app/pdb/layer_cmds.c b/app/pdb/layer_cmds.c index 62e39684f2..45244188f6 100644 --- a/app/pdb/layer_cmds.c +++ b/app/pdb/layer_cmds.c @@ -756,7 +756,10 @@ layer_set_offsets_invoker (Gimp *gimp, gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_ITEM_DISPLACE, _("Move Layer")); - gimp_item_translate (GIMP_ITEM (layer), offx - GIMP_ITEM (layer)->offset_x, offy - GIMP_ITEM (layer)->offset_y, TRUE); + offx -= GIMP_ITEM (layer)->offset_x; + offy -= GIMP_ITEM (layer)->offset_y; + + gimp_item_translate (GIMP_ITEM (layer), offx, offy, TRUE); if (gimp_item_get_linked (GIMP_ITEM (layer))) gimp_item_linked_translate (GIMP_ITEM (layer), offx, offy, TRUE); diff --git a/app/pdb/selection_cmds.c b/app/pdb/selection_cmds.c index a58f317b4c..cc49620899 100644 --- a/app/pdb/selection_cmds.c +++ b/app/pdb/selection_cmds.c @@ -477,7 +477,9 @@ selection_invert_invoker (Gimp *gimp, success = FALSE; if (success) - gimp_channel_invert (gimp_image_get_mask (gimage), TRUE); + { + gimp_channel_invert (gimp_image_get_mask (gimage), TRUE); + } return procedural_db_return_args (&selection_invert_proc, success); } @@ -523,7 +525,9 @@ selection_sharpen_invoker (Gimp *gimp, success = FALSE; if (success) - gimp_channel_sharpen (gimp_image_get_mask (gimage), TRUE); + { + gimp_channel_sharpen (gimp_image_get_mask (gimage), TRUE); + } return procedural_db_return_args (&selection_sharpen_proc, success); } @@ -569,7 +573,9 @@ selection_all_invoker (Gimp *gimp, success = FALSE; if (success) - gimp_channel_all (gimp_image_get_mask (gimage), TRUE); + { + gimp_channel_all (gimp_image_get_mask (gimage), TRUE); + } return procedural_db_return_args (&selection_all_proc, success); } @@ -615,7 +621,9 @@ selection_none_invoker (Gimp *gimp, success = FALSE; if (success) - gimp_channel_clear (gimp_image_get_mask (gimage), NULL, TRUE); + { + gimp_channel_clear (gimp_image_get_mask (gimage), NULL, TRUE); + } return procedural_db_return_args (&selection_none_proc, success); } @@ -666,7 +674,10 @@ selection_feather_invoker (Gimp *gimp, success = FALSE; if (success) - gimp_channel_feather (gimp_image_get_mask (gimage), radius, radius, TRUE); + { + gimp_channel_feather (gimp_image_get_mask (gimage), + radius, radius, TRUE); + } return procedural_db_return_args (&selection_feather_proc, success); } @@ -722,7 +733,10 @@ selection_border_invoker (Gimp *gimp, success = FALSE; if (success) - gimp_channel_border (gimp_image_get_mask (gimage), radius, radius, TRUE); + { + gimp_channel_border (gimp_image_get_mask (gimage), + radius, radius, TRUE); + } return procedural_db_return_args (&selection_border_proc, success); } @@ -778,7 +792,10 @@ selection_grow_invoker (Gimp *gimp, success = FALSE; if (success) - gimp_channel_grow (gimp_image_get_mask (gimage), steps, steps, TRUE); + { + gimp_channel_grow (gimp_image_get_mask (gimage), + steps, steps, TRUE); + } return procedural_db_return_args (&selection_grow_proc, success); } @@ -823,18 +840,21 @@ selection_shrink_invoker (Gimp *gimp, { gboolean success = TRUE; GimpImage *gimage; - gint32 radius; + gint32 steps; gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int); if (! GIMP_IS_IMAGE (gimage)) success = FALSE; - radius = args[1].value.pdb_int; - if (radius < 0) + steps = args[1].value.pdb_int; + if (steps < 0) success = FALSE; if (success) - gimp_channel_shrink (gimp_image_get_mask (gimage), radius, radius, FALSE, TRUE); + { + gimp_channel_shrink (gimp_image_get_mask (gimage), + steps, steps, FALSE, TRUE); + } return procedural_db_return_args (&selection_shrink_proc, success); } @@ -848,8 +868,8 @@ static ProcArg selection_shrink_inargs[] = }, { GIMP_PDB_INT32, - "radius", - "Radius of shrink (in pixels)" + "steps", + "Steps of shrink (in pixels)" } }; @@ -998,7 +1018,12 @@ selection_save_invoker (Gimp *gimp, success = FALSE; if (success) - success = (channel = gimp_selection_save (gimp_image_get_mask (gimage))) != NULL; + { + channel = gimp_selection_save (gimp_image_get_mask (gimage)); + + if (! channel) + success = FALSE; + } return_args = procedural_db_return_args (&selection_save_proc, success); diff --git a/libgimp/gimpselection_pdb.c b/libgimp/gimpselection_pdb.c index 09c22b180e..fc100cc944 100644 --- a/libgimp/gimpselection_pdb.c +++ b/libgimp/gimpselection_pdb.c @@ -459,7 +459,7 @@ gimp_selection_grow (gint32 image_ID, /** * gimp_selection_shrink: * @image_ID: The image. - * @radius: Radius of shrink (in pixels). + * @steps: Steps of shrink (in pixels). * * Shrink the image's selection * @@ -471,7 +471,7 @@ gimp_selection_grow (gint32 image_ID, */ gboolean gimp_selection_shrink (gint32 image_ID, - gint radius) + gint steps) { GimpParam *return_vals; gint nreturn_vals; @@ -480,7 +480,7 @@ gimp_selection_shrink (gint32 image_ID, return_vals = gimp_run_procedure ("gimp-selection-shrink", &nreturn_vals, GIMP_PDB_IMAGE, image_ID, - GIMP_PDB_INT32, radius, + GIMP_PDB_INT32, steps, GIMP_PDB_END); success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; diff --git a/libgimp/gimpselection_pdb.h b/libgimp/gimpselection_pdb.h index 5a61aed2cc..816d34c8a0 100644 --- a/libgimp/gimpselection_pdb.h +++ b/libgimp/gimpselection_pdb.h @@ -56,7 +56,7 @@ gboolean gimp_selection_border (gint32 image_ID, gboolean gimp_selection_grow (gint32 image_ID, gint steps); gboolean gimp_selection_shrink (gint32 image_ID, - gint radius); + gint steps); gboolean gimp_selection_layer_alpha (gint32 layer_ID); gboolean gimp_selection_load (gint32 channel_ID); gint32 gimp_selection_save (gint32 image_ID); diff --git a/tools/pdbgen/pdb/buffer.pdb b/tools/pdbgen/pdb/buffer.pdb index d99f195f7f..18cc2921f8 100644 --- a/tools/pdbgen/pdb/buffer.pdb +++ b/tools/pdbgen/pdb/buffer.pdb @@ -39,7 +39,12 @@ HELP ); %invoke = ( - code => 'buffer_list = gimp_container_get_filtered_name_array (gimp->named_buffers, filter, &num_buffers);' + code => <<'CODE' +{ + buffer_list = gimp_container_get_filtered_name_array (gimp->named_buffers, + filter, &num_buffers); +} +CODE ); } @@ -62,18 +67,18 @@ sub buffer_rename { ); %invoke = ( - code => < <<'CODE' { GimpBuffer *buffer = (GimpBuffer *) gimp_container_get_child_by_name (gimp->named_buffers, buffer_name); - success = (buffer != NULL && strlen (new_name) > 0); - - if (success) + if (buffer && strlen (new_name)) { gimp_object_set_name (GIMP_OBJECT (buffer), new_name); real_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (buffer))); } + else + success = FALSE; } CODE ); @@ -93,15 +98,15 @@ sub buffer_delete { ); %invoke = ( - code => < <<'CODE' { GimpBuffer *buffer = (GimpBuffer *) gimp_container_get_child_by_name (gimp->named_buffers, buffer_name); - success = (buffer != NULL); - - if (success) + if (buffer) success = gimp_container_remove (gimp->named_buffers, GIMP_OBJECT (buffer)); + else + success = FALSE; } CODE ); diff --git a/tools/pdbgen/pdb/color.pdb b/tools/pdbgen/pdb/color.pdb index 2ca4961c11..6668a62509 100644 --- a/tools/pdbgen/pdb/color.pdb +++ b/tools/pdbgen/pdb/color.pdb @@ -131,11 +131,9 @@ HELP if (success) gimp_drawable_levels (drawable, context, channel, - low_input, - high_input, + low_input, high_input, gamma, - low_output, - high_output); + low_output, high_output); } CODE ); @@ -178,8 +176,6 @@ CODE ); } - - sub levels_auto { &std_pdb_deprecated ('gimp_levels_stretch'); @@ -294,11 +290,14 @@ CODE } sub desaturate_full { - $blurb = 'Desaturate the contents of the specified drawable, with the specified formula.'; + $blurb = <<'BLURB'; +Desaturate the contents of the specified drawable, with the specified formula. +BLURB $help = <<'HELP'; -This procedure desaturates the contents of the specified drawable, with the specified -formula. This procedure only works on drawables of type RGB color. +This procedure desaturates the contents of the specified drawable, +with the specified formula. This procedure only works on drawables of +type RGB color. HELP $author = $copyright = 'Karine Delvare'; @@ -321,7 +320,7 @@ HELP success = FALSE; if (success) - gimp_drawable_desaturate (drawable, (GimpDesaturateMode) desaturate_mode); + gimp_drawable_desaturate (drawable, desaturate_mode); } CODE ); diff --git a/tools/pdbgen/pdb/display.pdb b/tools/pdbgen/pdb/display.pdb index a1e42b6a9c..819a12a1d8 100644 --- a/tools/pdbgen/pdb/display.pdb +++ b/tools/pdbgen/pdb/display.pdb @@ -44,11 +44,14 @@ HELP { display = gimp_create_display (gimp, gimage, GIMP_UNIT_PIXEL, 1.0); - success = (display != NULL); - - /* the first display takes ownership of the image */ - if (success && gimage->disp_count == 1) - g_object_unref (gimage); + if (display) + { + /* the first display takes ownership of the image */ + if (gimage->disp_count == 1) + g_object_unref (gimage); + } + else + success = FALSE; } CODE ); diff --git a/tools/pdbgen/pdb/drawable.pdb b/tools/pdbgen/pdb/drawable.pdb index 71ca0d462a..913b017761 100644 --- a/tools/pdbgen/pdb/drawable.pdb +++ b/tools/pdbgen/pdb/drawable.pdb @@ -240,7 +240,7 @@ sub drawable_get_image { %invoke = ( code => <<'CODE' { - success = (gimage = gimp_item_get_image (GIMP_ITEM (drawable))) != NULL; + gimage = gimp_item_get_image (GIMP_ITEM (drawable)); } CODE ); @@ -954,7 +954,8 @@ sub drawable_set_image { %invoke = ( code =><<'CODE' { - success = (gimage == gimp_item_get_image (GIMP_ITEM (drawable))); + if (gimage != gimp_item_get_image (GIMP_ITEM (drawable))) + success = FALSE; } CODE ); diff --git a/tools/pdbgen/pdb/drawable_transform.pdb b/tools/pdbgen/pdb/drawable_transform.pdb index 569f4b52dc..f1806deb6c 100644 --- a/tools/pdbgen/pdb/drawable_transform.pdb +++ b/tools/pdbgen/pdb/drawable_transform.pdb @@ -305,21 +305,32 @@ HELP @inargs = ( { name => 'drawable', type => 'drawable', - desc => 'The affected drawable' } - ); - - my $pos = 0; - foreach $where (qw(upper-left upper-right lower-left lower-right)) { - foreach (qw(x y)) { - push @inargs, - { name => "$_$pos", type => 'float', - desc => "The new $_ coordinate of $where corner of original - bounding box" } - } - $pos++; - } - @inargs = (@inargs, - &transform_options_args + desc => 'The affected drawable' }, + { name => 'x0', type => 'float', + desc => 'The new x coordinate of upper-left corner of original + bounding box' }, + { name => 'y0', type => 'float', + desc => 'The new y coordinate of upper-left corner of original + bounding box' }, + { name => 'x1', type => 'float', + desc => 'The new x coordinate of upper-right corner of original + bounding box' }, + { name => 'y1', type => 'float', + desc => 'The new y coordinate of upper-right corner of original + bounding box' }, + { name => 'x2', type => 'float', + desc => 'The new x coordinate of lower-left corner of original + bounding box' }, + { name => 'y2', type => 'float', + desc => 'The new y coordinate of lower-left corner of original + bounding box' }, + { name => 'x3', type => 'float', + desc => 'The new x coordinate of lower-right corner of original + bounding box' }, + { name => 'y3', type => 'float', + desc => 'The new y coordinate of lower-right corner of original + bounding box' }, + &transform_options_args ); @outargs = ( @@ -354,21 +365,32 @@ HELP @inargs = ( { name => 'drawable', type => 'drawable', - desc => 'The affected drawable' } - ); - - my $pos = 0; - foreach $where (qw(upper-left upper-right lower-left lower-right)) { - foreach (qw(x y)) { - push @inargs, - { name => "$_$pos", type => 'float', - desc => "The new $_ coordinate of $where corner of original - bounding box" } - } - $pos++; - } - @inargs = (@inargs, - &transform_options_default_args + desc => 'The affected drawable' }, + { name => 'x0', type => 'float', + desc => 'The new x coordinate of upper-left corner of original + bounding box' }, + { name => 'y0', type => 'float', + desc => 'The new y coordinate of upper-left corner of original + bounding box' }, + { name => 'x1', type => 'float', + desc => 'The new x coordinate of upper-right corner of original + bounding box' }, + { name => 'y1', type => 'float', + desc => 'The new y coordinate of upper-right corner of original + bounding box' }, + { name => 'x2', type => 'float', + desc => 'The new x coordinate of lower-left corner of original + bounding box' }, + { name => 'y2', type => 'float', + desc => 'The new y coordinate of lower-left corner of original + bounding box' }, + { name => 'x3', type => 'float', + desc => 'The new x coordinate of lower-right corner of original + bounding box' }, + { name => 'y3', type => 'float', + desc => 'The new y coordinate of lower-right corner of original + bounding box' }, + &transform_options_default_args ); @outargs = ( diff --git a/tools/pdbgen/pdb/fileops.pdb b/tools/pdbgen/pdb/fileops.pdb index 913374e0c6..c232edefe4 100644 --- a/tools/pdbgen/pdb/fileops.pdb +++ b/tools/pdbgen/pdb/fileops.pdb @@ -42,7 +42,9 @@ HELP desc => 'The name as entered by the user' } ); - @outargs = ( &std_image_arg ); + @outargs = ( + &std_image_arg + ); $outargs[0]->{desc} = 'The output image'; %invoke = ( diff --git a/tools/pdbgen/pdb/font_select.pdb b/tools/pdbgen/pdb/font_select.pdb index 130e8d0351..451b6f074d 100644 --- a/tools/pdbgen/pdb/font_select.pdb +++ b/tools/pdbgen/pdb/font_select.pdb @@ -28,9 +28,8 @@ sub fonts_popup { desc => 'The callback PDB proc to call when font selection is made' }, { name => 'popup_title', type => 'string', desc => 'Title to give the font popup window' }, - { name => 'initial_font', type => 'string', - desc => 'The name of the font to set as the first selected', - null_ok => 1 } + { name => 'initial_font', type => 'string', null_ok => 1, + desc => 'The name of the font to set as the first selected' } ); %invoke = ( diff --git a/tools/pdbgen/pdb/gimprc.pdb b/tools/pdbgen/pdb/gimprc.pdb index c05ecca793..4e1962fe98 100644 --- a/tools/pdbgen/pdb/gimprc.pdb +++ b/tools/pdbgen/pdb/gimprc.pdb @@ -85,7 +85,7 @@ HELP ); %invoke = ( - code => <<'CODE' + code => <<'CODE' { if (strlen (token)) { diff --git a/tools/pdbgen/pdb/layer.pdb b/tools/pdbgen/pdb/layer.pdb index 81e519d1e8..1f7f6931ff 100644 --- a/tools/pdbgen/pdb/layer.pdb +++ b/tools/pdbgen/pdb/layer.pdb @@ -379,8 +379,6 @@ CODE } sub layer_set_offsets { - &layer_translate; - $blurb = 'Set the layer offsets.'; $help = <<'HELP'; @@ -389,10 +387,37 @@ relative to the image origin and can be any values. This operation is valid only on layers which have been added to an image. HELP - foreach (qw(x y)) { - $invoke{code} =~ - s/(off$_),/$1 - GIMP_ITEM (layer)->offset_$_,/; - } + &std_pdb_misc; + + @inargs = ( + { name => 'layer', type => 'layer', + desc => 'The layer' }, + { name => 'offx', type => 'int32', + desc => "Offset in x direction" }, + { name => 'offy', type => 'int32', + desc => "Offset in y direction" } + ); + + %invoke = ( + code => <<'CODE' +{ + GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (layer)); + + gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_ITEM_DISPLACE, + _("Move Layer")); + + offx -= GIMP_ITEM (layer)->offset_x; + offy -= GIMP_ITEM (layer)->offset_y; + + gimp_item_translate (GIMP_ITEM (layer), offx, offy, TRUE); + + if (gimp_item_get_linked (GIMP_ITEM (layer))) + gimp_item_linked_translate (GIMP_ITEM (layer), offx, offy, TRUE); + + gimp_image_undo_group_end (gimage); +} +CODE + ); } sub layer_get_mask { diff --git a/tools/pdbgen/pdb/selection.pdb b/tools/pdbgen/pdb/selection.pdb index 4315d3f0cf..26e449d263 100644 --- a/tools/pdbgen/pdb/selection.pdb +++ b/tools/pdbgen/pdb/selection.pdb @@ -17,37 +17,6 @@ # "Perlized" from C source by Manish Singh -sub selection_simple_proc { - my $op = shift; - - &std_pdb_misc; - - @inargs = ( - &std_image_arg - ); - - %invoke = ( code => "gimp_channel_$op (gimp_image_get_mask (gimage), TRUE);" ); -} - -sub selection_change_proc { - my ($op, $arg, $type, $edge_lock) = @_; - - $blurb = "\u$op the image's selection"; - $help = "This procedure ${op}s the selection. "; - - &std_pdb_misc; - - @inargs = ( - &std_image_arg, - { name => $arg, type => "0 <= $type", - desc => "\u$arg of $op (in pixels)" } - ); - - %invoke = ( code => "gimp_channel_$op (gimp_image_get_mask (gimage), $arg, $arg$edge_lock, TRUE);" ); -} - -# The defs - sub selection_bounds { $blurb = 'Find the bounding box of the current selection.'; @@ -217,19 +186,29 @@ CODE } sub selection_invert { - &selection_simple_proc('invert'); - $blurb = 'Invert the selection mask.'; $help = <<'HELP'; This procedure inverts the selection mask. For every pixel in the selection channel, its new value is calculated as (255 - old_value). HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg + ); + + %invoke = ( + code => <<'CODE' +{ + gimp_channel_invert (gimp_image_get_mask (gimage), TRUE); +} +CODE + ); } sub selection_sharpen { - &selection_simple_proc('sharpen'); - $blurb = 'Sharpen the selection mask.'; $help = <<'HELP'; @@ -237,17 +216,43 @@ This procedure sharpens the selection mask. For every pixel in the selection channel, if the value is > 0, the new pixel is assigned a value of 255. This removes any "anti-aliasing" that might exist in the selection mask's boundary. HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg + ); + + %invoke = ( + code => <<'CODE' +{ + gimp_channel_sharpen (gimp_image_get_mask (gimage), TRUE); +} +CODE + ); } sub selection_all { - &selection_simple_proc('all'); - $blurb = 'Select all of the image.'; $help = <<'HELP'; This procedure sets the selection mask to completely encompass the image. Every pixel in the selection channel is set to 255. HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg + ); + + %invoke = ( + code => <<'CODE' +{ + gimp_channel_all (gimp_image_get_mask (gimage), TRUE); +} +CODE + ); } sub selection_none { @@ -264,40 +269,119 @@ HELP &std_image_arg ); - %invoke = ( code => "gimp_channel_clear (gimp_image_get_mask (gimage), NULL, TRUE);" ); + %invoke = ( + code => <<'CODE' +{ + gimp_channel_clear (gimp_image_get_mask (gimage), NULL, TRUE); +} +CODE + ); } sub selection_feather { - &selection_change_proc('feather', 'radius', 'float', ''); + $blurb = "Feather the image's selection"; - $help .= 'Feathering is implemented using a gaussian blur.'; + $help = <<'HELP'; +This procedure feathers the selection. Feathering is implemented +using a gaussian blur. +HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + { name => 'radius', type => '0 <= float', + desc => 'Radius of feather (in pixels)' } + ); + + %invoke = ( + code => <<'CODE' +{ + gimp_channel_feather (gimp_image_get_mask (gimage), + radius, radius, TRUE); +} +CODE + ); } sub selection_border { - &selection_change_proc('border', 'radius', 'int32', ''); + $blurb = "Border the image's selection"; $help .= <<'HELP'; -Bordering creates a new selection which is defined along the boundary of the -previous selection at every point within the specified radius. +This procedure borders the selection. Bordering creates a new +selection which is defined along the boundary of the previous +selection at every point within the specified radius. HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + { name => 'radius', type => '0 <= int32', + desc => 'Radius of border (in pixels)' } + ); + + %invoke = ( + code => <<'CODE' +{ + gimp_channel_border (gimp_image_get_mask (gimage), + radius, radius, TRUE); +} +CODE + ); } sub selection_grow { - &selection_change_proc('grow', 'steps', 'int32', ''); + $blurb = "Grow the image's selection"; $help .= <<'HELP'; -Growing involves expanding the boundary in all directions by the specified -pixel amount. +This procedure grows the selection. Growing involves expanding the +boundary in all directions by the specified pixel amount. HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + { name => 'steps', type => '0 <= int32', + desc => 'Steps of grow (in pixels)' } + ); + + %invoke = ( + code => <<'CODE' +{ + gimp_channel_grow (gimp_image_get_mask (gimage), + steps, steps, TRUE); +} +CODE + ); } sub selection_shrink { - &selection_change_proc('shrink', 'radius', 'int32', ', FALSE'); + $blurb = "Shrink the image's selection"; $help .= <<'HELP'; -Shrinking invovles trimming the existing selection boundary on all sides by the -specified number of pixels. +This procedure shrinks the selection. Shrinking invovles trimming the +existing selection boundary on all sides by the specified number of +pixels. HELP + + &std_pdb_misc; + + @inargs = ( + &std_image_arg, + { name => 'steps', type => '0 <= int32', + desc => 'Steps of shrink (in pixels)' } + ); + + %invoke = ( + code => <<'CODE' +{ + gimp_channel_shrink (gimp_image_get_mask (gimage), + steps, steps, FALSE, TRUE); +} +CODE + ); } sub selection_layer_alpha { @@ -425,7 +509,14 @@ HELP %invoke = ( headers => [qw("core/gimpselection.h") ], - code => 'success = (channel = gimp_selection_save (gimp_image_get_mask (gimage))) != NULL;' + code => <<'CODE' +{ + channel = gimp_selection_save (gimp_image_get_mask (gimage)); + + if (! channel) + success = FALSE; +} +CODE ); } diff --git a/tools/pdbgen/pdb/text_tool.pdb b/tools/pdbgen/pdb/text_tool.pdb index 08a37fd21a..dd253d39bd 100644 --- a/tools/pdbgen/pdb/text_tool.pdb +++ b/tools/pdbgen/pdb/text_tool.pdb @@ -17,7 +17,28 @@ # "Perlized" from C source by Manish Singh -sub render_args () {( +sub text_fontname { + $blurb = <<'BLURB'; +Add text at the specified location as a floating selection or a new layer. +BLURB + + $help = <<'HELP'; +This tool requires a fontname matching an installed PangoFT2 font. +You can specify the fontsize in units of pixels +or points, and the appropriate metric is specified using the size_type +argument. The x and y parameters together control the placement of the new +text by specifying the upper left corner of the text bounding box. If the +specified drawable parameter is valid, the text will be created as a floating +selection attached to the drawable. If the drawable parameter is not valid +(-1), the text will appear as a new layer. Finally, a border can be specified +around the final rendered text. The border is measured in pixels. +HELP + + &std_pdb_misc; + $author = 'Martin Edlman & Sven Neumann'; + $date = '1998- 2001'; + + @inargs = ( &std_image_arg, { name => 'drawable', type => 'drawable', desc => 'The affected drawable: (-1 for a new text layer)', @@ -34,45 +55,7 @@ sub render_args () {( { name => 'size', type => '0 < float', desc => 'The size of text in either pixels or points' }, { name => 'size_type', type => 'enum GimpSizeType', - desc => 'The units of specified size: %%desc%%' } -)} - -@props = qw(foundry family weight slant set_width spacing registry encoding); - -sub font_prop_args { - my @result; - foreach (@props) { - (my $desc = $_) =~ s/_/-/g; - push @result, { name => $_, type => 'string', no_validate => 1, - desc => qq/The font $desc/ } - } - @result; -} - -sub text_fontname { - $blurb = <<'BLURB'; -Add text at the specified location as a floating selection or a new layer. -BLURB - - $help = <<'HELP'; -This tool requires a fontname matching an installed PangoFT2 font. -You can specify the fontsize in units of pixels -or points, and the appropriate metric is specified using the size_type -argument. The x and y parameters together control the placement of the new -text by specifying the upper left corner of the text bounding box. If the -specified drawable parameter is valid, the text will be created as a floating -selection attached to the drawable. If the drawable parameter is not valid -(-1), the text will appear as a new layer. Finally, a border can be specified -around the final rendered text. The border is measured in pixels. - -HELP - - &std_pdb_misc; - $author = 'Martin Edlman & Sven Neumann'; - $date = '1998- 2001'; - - @inargs = ( - &render_args, + desc => 'The units of specified size: %%desc%%' }, { name => 'fontname', type => 'string', desc => 'The name of the font' } ); @@ -157,8 +140,39 @@ sub text { &std_pdb_deprecated ('gimp-text-fontname'); @inargs = ( - &render_args, - &font_prop_args + &std_image_arg, + { name => 'drawable', type => 'drawable', + desc => 'The affected drawable: (-1 for a new text layer)', + no_success => 1 }, + { name => 'x', type => 'float', + desc => 'The x coordinate for the left of the text bounding box' }, + { name => 'y', type => 'float', + desc => 'The y coordinate for the top of the text bounding box' }, + { name => 'text', type => 'string', + desc => 'The text to generate (in UTF-8 encoding)' }, + { name => 'border', type => '-1 <= int32', + desc => 'The size of the border: %%desc%%' }, + &std_antialias_arg, + { name => 'size', type => '0 < float', + desc => 'The size of text in either pixels or points' }, + { name => 'size_type', type => 'enum GimpSizeType', + desc => 'The units of specified size: %%desc%%' }, + { name => 'foundry', type => 'string', no_validate => 1, + desc => 'The font foundry' }, + { name => 'family', type => 'string', no_validate => 1, + desc => 'The font family' }, + { name => 'weight', type => 'string', no_validate => 1, + desc => 'The font weight' }, + { name => 'slant', type => 'string', no_validate => 1, + desc => 'The font slant' }, + { name => 'set_width', type => 'string', no_validate => 1, + desc => 'The font set-width' }, + { name => 'spacing', type => 'string', no_validate => 1, + desc => 'The font spacing' }, + { name => 'registry', type => 'string', no_validate => 1, + desc => 'The font registry' }, + { name => 'encoding', type => 'string', no_validate => 1, + desc => 'The font encoding' } ); @outargs = ( @@ -197,7 +211,22 @@ sub text_get_extents { desc => 'The size of text in either pixels or points' }, { name => 'size_type', type => 'enum GimpSizeType', desc => 'The units of specified size: %%desc%%' }, - &font_prop_args + { name => 'foundry', type => 'string', no_validate => 1, + desc => 'The font foundry' }, + { name => 'family', type => 'string', no_validate => 1, + desc => 'The font family' }, + { name => 'weight', type => 'string', no_validate => 1, + desc => 'The font weight' }, + { name => 'slant', type => 'string', no_validate => 1, + desc => 'The font slant' }, + { name => 'set_width', type => 'string', no_validate => 1, + desc => 'The font set-width' }, + { name => 'spacing', type => 'string', no_validate => 1, + desc => 'The font spacing' }, + { name => 'registry', type => 'string', no_validate => 1, + desc => 'The font registry' }, + { name => 'encoding', type => 'string', no_validate => 1, + desc => 'The font encoding' } ); @outargs = ( diff --git a/tools/pdbgen/pdb/transform_tools.pdb b/tools/pdbgen/pdb/transform_tools.pdb index 56e3ceabb0..fa830ff76c 100644 --- a/tools/pdbgen/pdb/transform_tools.pdb +++ b/tools/pdbgen/pdb/transform_tools.pdb @@ -57,20 +57,33 @@ sub perspective { { name => 'drawable', type => 'drawable', desc => 'The affected drawable' }, { name => 'interpolation', type => 'boolean', - desc => 'Whether to use interpolation' } + desc => 'Whether to use interpolation' }, + { name => 'x0', type => 'float', + desc => 'The new x coordinate of upper-left corner of original + bounding box' }, + { name => 'y0', type => 'float', + desc => 'The new y coordinate of upper-left corner of original + bounding box' }, + { name => 'x1', type => 'float', + desc => 'The new x coordinate of upper-right corner of original + bounding box' }, + { name => 'y1', type => 'float', + desc => 'The new y coordinate of upper-right corner of original + bounding box' }, + { name => 'x2', type => 'float', + desc => 'The new x coordinate of lower-left corner of original + bounding box' }, + { name => 'y2', type => 'float', + desc => 'The new y coordinate of lower-left corner of original + bounding box' }, + { name => 'x3', type => 'float', + desc => 'The new x coordinate of lower-right corner of original + bounding box' }, + { name => 'y3', type => 'float', + desc => 'The new y coordinate of lower-right corner of original + bounding box' } ); - my $pos = 0; - foreach $where (qw(upper-left upper-right lower-left lower-right)) { - foreach (qw(x y)) { - push @inargs, - { name => "$_$pos", type => 'float', - desc => "The new $_ coordinate of $where corner of original - bounding box" } - } - $pos++; - } - @outargs = ( { name => 'drawable', type => 'drawable', no_declare => 1, desc => 'The newly mapped drawable' }