plug-ins, pdb: remove the value-propagate plug-in and add PDB compat procedures

This commit is contained in:
Michael Natterer
2015-02-08 23:09:06 +01:00
parent c2371a2de9
commit b856a8ba76
9 changed files with 658 additions and 1318 deletions

View File

@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 750 procedures registered total */
/* 753 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)

View File

@ -3013,6 +3013,204 @@ plug_in_vinvert_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_vpropagate_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gint32 propagate_mode;
gint32 propagating_channel;
gdouble propagating_rate;
gint32 direction_mask;
gint32 lower_limit;
gint32 upper_limit;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
propagate_mode = g_value_get_int (gimp_value_array_index (args, 3));
propagating_channel = g_value_get_int (gimp_value_array_index (args, 4));
propagating_rate = g_value_get_double (gimp_value_array_index (args, 5));
direction_mask = g_value_get_int (gimp_value_array_index (args, 6));
lower_limit = g_value_get_int (gimp_value_array_index (args, 7));
upper_limit = g_value_get_int (gimp_value_array_index (args, 8));
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GeglNode *node;
GimpRGB color;
GeglColor *gegl_color = NULL;
gint gegl_mode = 0;
gboolean to_left = (direction_mask & (0x1 << 0)) != 0;
gboolean to_top = (direction_mask & (0x1 << 1)) != 0;
gboolean to_right = (direction_mask & (0x1 << 2)) != 0;
gboolean to_bottom = (direction_mask & (0x1 << 3)) != 0;
gboolean value = (propagating_channel & (0x1 << 0)) != 0;
gboolean alpha = (propagating_channel & (0x1 << 1)) != 0;
switch (propagate_mode)
{
case 0:
case 1:
case 2:
gegl_mode = propagate_mode;
break;
case 3:
gegl_mode = propagate_mode;
/* fall thru */
case 4:
case 5:
gegl_mode = 4;
if (propagate_mode != 3)
gimp_context_get_foreground (context, &color);
else
gimp_context_get_background (context, &color);
gegl_color = gimp_gegl_color_new (&color);
break;
case 6:
case 7:
gegl_mode = propagate_mode - 1;
break;
}
node =
gegl_node_new_child (NULL,
"operation", "gegl:value-propagate",
"mode", gegl_mode,
"lower-threshold", (gdouble) lower_limit / 255.0,
"upper-threshold", (gdouble) upper_limit / 255.0,
"rate", propagating_rate,
"color", gegl_color,
"top", to_top,
"left", to_left,
"right", to_right,
"bottom", to_bottom,
"value", value,
"alpha", alpha,
NULL);
if (gegl_color)
g_object_unref (gegl_color);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Value Propagate"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_dilate_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GeglNode *node =
gegl_node_new_child (NULL,
"operation", "gegl:value-propagate",
"mode", 0, /* GEGL_VALUE_PROPAGATE_MODE_WHITE */
"lower-threshold", 0.0,
"upper-threshold", 1.0,
"rate", 1.0,
"top", TRUE,
"left", TRUE,
"right", TRUE,
"bottom", TRUE,
"value", TRUE,
"alpha", FALSE,
NULL);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Dilate"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_erode_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GeglNode *node =
gegl_node_new_child (NULL,
"operation", "gegl:value-propagate",
"mode", 1, /* GEGL_VALUE_PROPAGATE_MODE_BLACK */
"lower-threshold", 0.0,
"upper-threshold", 1.0,
"rate", 1.0,
"top", TRUE,
"left", TRUE,
"right", TRUE,
"bottom", TRUE,
"value", TRUE,
"alpha", FALSE,
NULL);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Erode"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_waves_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -6113,6 +6311,222 @@ register_plug_in_compat_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-vpropagate
*/
procedure = gimp_procedure_new (plug_in_vpropagate_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"plug-in-vpropagate");
gimp_procedure_set_static_strings (procedure,
"plug-in-vpropagate",
"Propagate certain colors to neighboring pixels",
"Propagate values of the layer.",
"Compatibility procedure. Please see 'gegl:value-propagate' for credits.",
"Compatibility procedure. Please see 'gegl:value-propagate' for credits.",
"2015",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("run-mode",
"run mode",
"The run mode",
GIMP_TYPE_RUN_MODE,
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"Input image (unused)",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"Input drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("propagate-mode",
"propagate mode",
"Propagate mode { 0:white, 1:black, 2:middle value 3:foreground to peak, 4:foreground, 5:background, 6:opaque, 7:transparent }",
0, 7, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("propagating-channel",
"propagating channel",
"Channels which values are propagated",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("propagating-rate",
"propagating rate",
"Propagating rate",
0.0, 1.0, 0.0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("direction-mask",
"direction mask",
"Direction mask",
0, 15, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("lower-limit",
"lower limit",
"Lower limit",
0, 255, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("upper-limit",
"upper limit",
"Upper limit",
0, 255, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-dilate
*/
procedure = gimp_procedure_new (plug_in_dilate_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"plug-in-dilate");
gimp_procedure_set_static_strings (procedure,
"plug-in-dilate",
"Grow lighter areas of the image",
"Dilate image.",
"Compatibility procedure. Please see 'gegl:value-propagate' for credits.",
"Compatibility procedure. Please see 'gegl:value-propagate' for credits.",
"2015",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("run-mode",
"run mode",
"The run mode",
GIMP_TYPE_RUN_MODE,
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"Input image (unused)",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"Input drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("propagate-mode",
"propagate mode",
"Propagate mode { 0:white, 1:black, 2:middle value 3:foreground to peak, 4:foreground, 5:background, 6:opaque, 7:transparent }",
0, 7, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("propagating-channel",
"propagating channel",
"Channels which values are propagated",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("propagating-rate",
"propagating rate",
"Propagating rate",
0.0, 1.0, 0.0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("direction-mask",
"direction mask",
"Direction mask",
0, 15, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("lower-limit",
"lower limit",
"Lower limit",
0, 255, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("upper-limit",
"upper limit",
"Upper limit",
0, 255, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-erode
*/
procedure = gimp_procedure_new (plug_in_erode_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"plug-in-erode");
gimp_procedure_set_static_strings (procedure,
"plug-in-erode",
"Shrink lighter areas of the image",
"Erode image.",
"Compatibility procedure. Please see 'gegl:value-propagate' for credits.",
"Compatibility procedure. Please see 'gegl:value-propagate' for credits.",
"2015",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("run-mode",
"run mode",
"The run mode",
GIMP_TYPE_RUN_MODE,
GIMP_RUN_INTERACTIVE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"Input image (unused)",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
"Input drawable",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("propagate-mode",
"propagate mode",
"Propagate mode { 0:white, 1:black, 2:middle value 3:foreground to peak, 4:foreground, 5:background, 6:opaque, 7:transparent }",
0, 7, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("propagating-channel",
"propagating channel",
"Channels which values are propagated",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("propagating-rate",
"propagating rate",
"Propagating rate",
0.0, 1.0, 0.0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("direction-mask",
"direction mask",
"Direction mask",
0, 15, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("lower-limit",
"lower limit",
"Lower limit",
0, 255, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("upper-limit",
"upper limit",
"Upper limit",
0, 255, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-waves
*/

View File

@ -198,8 +198,6 @@
/unit-editor.exe
/unsharp-mask
/unsharp-mask.exe
/value-propagate
/value-propagate.exe
/van-gogh-lic
/van-gogh-lic.exe
/warp

View File

@ -142,7 +142,6 @@ libexec_PROGRAMS = \
tile-small \
unit-editor \
unsharp-mask \
value-propagate \
van-gogh-lic \
warp \
web-browser \
@ -1907,23 +1906,6 @@ unsharp_mask_LDADD = \
$(INTLLIBS) \
$(unsharp_mask_RC)
value_propagate_SOURCES = \
value-propagate.c
value_propagate_LDADD = \
$(libgimpui) \
$(libgimpwidgets) \
$(libgimpmodule) \
$(libgimp) \
$(libgimpmath) \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GTK_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(value_propagate_RC)
van_gogh_lic_SOURCES = \
van-gogh-lic.c

View File

@ -96,7 +96,6 @@ tile_paper_RC = tile-paper.rc.o
tile_small_RC = tile-small.rc.o
unit_editor_RC = unit-editor.rc.o
unsharp_mask_RC = unsharp-mask.rc.o
value_propagate_RC = value-propagate.rc.o
van_gogh_lic_RC = van-gogh-lic.rc.o
warp_RC = warp.rc.o
web_browser_RC = web-browser.rc.o

View File

@ -97,7 +97,6 @@
'tile-small' => { ui => 1 },
'unit-editor' => { ui => 1 },
'unsharp-mask' => { ui => 1 },
'value-propagate' => { ui => 1 },
'van-gogh-lic' => { ui => 1 },
'warp' => { ui => 1 },
'web-browser' => { ui => 1 },

File diff suppressed because it is too large Load Diff

View File

@ -101,7 +101,6 @@ plug-ins/common/tile-paper.c
plug-ins/common/tile-small.c
plug-ins/common/unit-editor.c
plug-ins/common/unsharp-mask.c
plug-ins/common/value-propagate.c
plug-ins/common/van-gogh-lic.c
plug-ins/common/warp.c
plug-ins/common/web-browser.c

View File

@ -3215,6 +3215,246 @@ CODE
);
}
sub plug_in_vpropagate {
$blurb = 'Propagate certain colors to neighboring pixels',
$help = <<'HELP';
Propagate values of the layer.
HELP
&std_pdb_compat('gegl:value-propagate');
$date = '2015';
@inargs = (
{ name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
desc => 'The run mode' },
{ name => 'image', type => 'image', dead => 1,
desc => 'Input image (unused)' },
{ name => 'drawable', type => 'drawable',
desc => 'Input drawable' },
{ name => 'propagate_mode', type => '0 <= int32 <= 7',
desc => 'Propagate mode { 0:white, 1:black, 2:middle value 3:foreground to peak, 4:foreground, 5:background, 6:opaque, 7:transparent }' },
{ name => 'propagating_channel', type => 'int32',
desc => 'Channels which values are propagated' },
{ name => 'propagating_rate', type => '0.0 <= float <= 1.0',
desc => 'Propagating rate' },
{ name => 'direction_mask', type => '0 <= int32 <= 15',
desc => 'Direction mask' },
{ name => 'lower_limit', type => '0 <= int32 <= 255',
desc => 'Lower limit' },
{ name => 'upper_limit', type => '0 <= int32 <= 255',
desc => 'Upper limit' }
);
%invoke = (
code => <<'CODE'
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GeglNode *node;
GimpRGB color;
GeglColor *gegl_color = NULL;
gint gegl_mode = 0;
gboolean to_left = (direction_mask & (0x1 << 0)) != 0;
gboolean to_top = (direction_mask & (0x1 << 1)) != 0;
gboolean to_right = (direction_mask & (0x1 << 2)) != 0;
gboolean to_bottom = (direction_mask & (0x1 << 3)) != 0;
gboolean value = (propagating_channel & (0x1 << 0)) != 0;
gboolean alpha = (propagating_channel & (0x1 << 1)) != 0;
switch (propagate_mode)
{
case 0:
case 1:
case 2:
gegl_mode = propagate_mode;
break;
case 3:
gegl_mode = propagate_mode;
/* fall thru */
case 4:
case 5:
gegl_mode = 4;
if (propagate_mode != 3)
gimp_context_get_foreground (context, &color);
else
gimp_context_get_background (context, &color);
gegl_color = gimp_gegl_color_new (&color);
break;
case 6:
case 7:
gegl_mode = propagate_mode - 1;
break;
}
node =
gegl_node_new_child (NULL,
"operation", "gegl:value-propagate",
"mode", gegl_mode,
"lower-threshold", (gdouble) lower_limit / 255.0,
"upper-threshold", (gdouble) upper_limit / 255.0,
"rate", propagating_rate,
"color", gegl_color,
"top", to_top,
"left", to_left,
"right", to_right,
"bottom", to_bottom,
"value", value,
"alpha", alpha,
NULL);
if (gegl_color)
g_object_unref (gegl_color);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Value Propagate"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
CODE
);
}
sub plug_in_dilate {
$blurb = 'Grow lighter areas of the image',
$help = <<'HELP';
Dilate image.
HELP
&std_pdb_compat('gegl:value-propagate');
$date = '2015';
@inargs = (
{ name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
desc => 'The run mode' },
{ name => 'image', type => 'image', dead => 1,
desc => 'Input image (unused)' },
{ name => 'drawable', type => 'drawable',
desc => 'Input drawable' },
{ name => 'propagate_mode', type => '0 <= int32 <= 7', dead => 1,
desc => 'Propagate mode { 0:white, 1:black, 2:middle value 3:foreground to peak, 4:foreground, 5:background, 6:opaque, 7:transparent }' },
{ name => 'propagating_channel', type => 'int32', dead => 1,
desc => 'Channels which values are propagated' },
{ name => 'propagating_rate', type => '0.0 <= float <= 1.0', dead => 1,
desc => 'Propagating rate' },
{ name => 'direction_mask', type => '0 <= int32 <= 15', dead => 1,
desc => 'Direction mask' },
{ name => 'lower_limit', type => '0 <= int32 <= 255', dead => 1,
desc => 'Lower limit' },
{ name => 'upper_limit', type => '0 <= int32 <= 255', dead => 1,
desc => 'Upper limit' }
);
%invoke = (
code => <<'CODE'
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GeglNode *node =
gegl_node_new_child (NULL,
"operation", "gegl:value-propagate",
"mode", 0, /* GEGL_VALUE_PROPAGATE_MODE_WHITE */
"lower-threshold", 0.0,
"upper-threshold", 1.0,
"rate", 1.0,
"top", TRUE,
"left", TRUE,
"right", TRUE,
"bottom", TRUE,
"value", TRUE,
"alpha", FALSE,
NULL);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Dilate"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
CODE
);
}
sub plug_in_erode {
$blurb = 'Shrink lighter areas of the image',
$help = <<'HELP';
Erode image.
HELP
&std_pdb_compat('gegl:value-propagate');
$date = '2015';
@inargs = (
{ name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
desc => 'The run mode' },
{ name => 'image', type => 'image', dead => 1,
desc => 'Input image (unused)' },
{ name => 'drawable', type => 'drawable',
desc => 'Input drawable' },
{ name => 'propagate_mode', type => '0 <= int32 <= 7', dead => 1,
desc => 'Propagate mode { 0:white, 1:black, 2:middle value 3:foreground to peak, 4:foreground, 5:background, 6:opaque, 7:transparent }' },
{ name => 'propagating_channel', type => 'int32', dead => 1,
desc => 'Channels which values are propagated' },
{ name => 'propagating_rate', type => '0.0 <= float <= 1.0', dead => 1,
desc => 'Propagating rate' },
{ name => 'direction_mask', type => '0 <= int32 <= 15', dead => 1,
desc => 'Direction mask' },
{ name => 'lower_limit', type => '0 <= int32 <= 255', dead => 1,
desc => 'Lower limit' },
{ name => 'upper_limit', type => '0 <= int32 <= 255', dead => 1,
desc => 'Upper limit' }
);
%invoke = (
code => <<'CODE'
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GeglNode *node =
gegl_node_new_child (NULL,
"operation", "gegl:value-propagate",
"mode", 1, /* GEGL_VALUE_PROPAGATE_MODE_BLACK */
"lower-threshold", 0.0,
"upper-threshold", 1.0,
"rate", 1.0,
"top", TRUE,
"left", TRUE,
"right", TRUE,
"bottom", TRUE,
"value", TRUE,
"alpha", FALSE,
NULL);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Erode"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
CODE
);
}
sub plug_in_waves {
$blurb = 'Distort the image with waves';
@ -3559,6 +3799,9 @@ CODE
plug_in_threshold_alpha
plug_in_video
plug_in_vinvert
plug_in_vpropagate
plug_in_dilate
plug_in_erode
plug_in_waves
plug_in_whirl_pinch);