[gimp] app: implement Dilate and Erode as wrappers around gegl:value-propagate
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: implement Dilate and Erode as wrappers around gegl:value-propagate
- Date: Sun, 8 Feb 2015 18:59:37 +0000 (UTC)
commit c2371a2de95381909c4fbd2a4fdc76ac0e49410d
Author: Michael Natterer <mitch gimp org>
Date: Sun Feb 8 19:56:45 2015 +0100
app: implement Dilate and Erode as wrappers around gegl:value-propagate
Add them to the "drawable" actions. Remove menu registration for
the value-propagate plug-in's dilate and erode procedures.
app/actions/drawable-actions.c | 14 ++++++++
app/actions/drawable-commands.c | 64 +++++++++++++++++++++++++++++++++++++
app/actions/drawable-commands.h | 4 ++
app/widgets/gimphelp-ids.h | 2 +
menus/image-menu.xml.in | 2 +
plug-ins/common/value-propagate.c | 2 -
6 files changed, 86 insertions(+), 2 deletions(-)
---
diff --git a/app/actions/drawable-actions.c b/app/actions/drawable-actions.c
index b80ca64..f4ee705 100644
--- a/app/actions/drawable-actions.c
+++ b/app/actions/drawable-actions.c
@@ -65,6 +65,18 @@ static const GimpActionEntry drawable_actions[] =
G_CALLBACK (drawable_levels_stretch_cmd_callback),
GIMP_HELP_LAYER_WHITE_BALANCE },
+ { "drawable-dilate", GIMP_STOCK_GEGL,
+ NC_("drawable-action", "_Dilate"), NULL,
+ NC_("drawable-action", "Grow lighter areas of the image"),
+ G_CALLBACK (drawable_dilate_cmd_callback),
+ GIMP_HELP_LAYER_DILATE },
+
+ { "drawable-erode", GIMP_STOCK_GEGL,
+ NC_("drawable-action", "E_rode"), NULL,
+ NC_("drawable-action", "Grow darker areas of the image"),
+ G_CALLBACK (drawable_erode_cmd_callback),
+ GIMP_HELP_LAYER_ERODE },
+
{ "drawable-offset", NULL,
NC_("drawable-action", "_Offset..."), "<primary><shift>O",
NC_("drawable-action",
@@ -231,6 +243,8 @@ drawable_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("drawable-invert", writable && !children);
SET_SENSITIVE ("drawable-value-invert", writable && !children);
SET_SENSITIVE ("drawable-levels-stretch", writable && !children && is_rgb);
+ SET_SENSITIVE ("drawable-dilate", writable && !children);
+ SET_SENSITIVE ("drawable-erode", writable && !children);
SET_SENSITIVE ("drawable-offset", writable && !children);
SET_SENSITIVE ("drawable-visible", drawable);
diff --git a/app/actions/drawable-commands.c b/app/actions/drawable-commands.c
index 503e9f5..2d6a9de 100644
--- a/app/actions/drawable-commands.c
+++ b/app/actions/drawable-commands.c
@@ -115,6 +115,70 @@ drawable_levels_stretch_cmd_callback (GtkAction *action,
}
void
+drawable_dilate_cmd_callback (GtkAction *action,
+ gpointer data)
+{
+ GimpImage *image;
+ GimpDrawable *drawable;
+ GimpDisplay *display;
+ GeglNode *node;
+ return_if_no_drawable (image, drawable, data);
+ return_if_no_display (display, data);
+
+ 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, GIMP_PROGRESS (display),
+ _("Dilate"), node);
+ g_object_unref (node);
+
+ gimp_image_flush (image);
+}
+
+void
+drawable_erode_cmd_callback (GtkAction *action,
+ gpointer data)
+{
+ GimpImage *image;
+ GimpDrawable *drawable;
+ GimpDisplay *display;
+ GeglNode *node;
+ return_if_no_drawable (image, drawable, data);
+ return_if_no_display (display, data);
+
+ 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, GIMP_PROGRESS (display),
+ _("Erode"), node);
+ g_object_unref (node);
+
+ gimp_image_flush (image);
+}
+
+void
drawable_offset_cmd_callback (GtkAction *action,
gpointer data)
{
diff --git a/app/actions/drawable-commands.h b/app/actions/drawable-commands.h
index e206e0e..6159b10 100644
--- a/app/actions/drawable-commands.h
+++ b/app/actions/drawable-commands.h
@@ -27,6 +27,10 @@ void drawable_value_invert_cmd_callback (GtkAction *action,
gpointer data);
void drawable_levels_stretch_cmd_callback (GtkAction *action,
gpointer data);
+void drawable_dilate_cmd_callback (GtkAction *action,
+ gpointer data);
+void drawable_erode_cmd_callback (GtkAction *action,
+ gpointer data);
void drawable_offset_cmd_callback (GtkAction *action,
gpointer data);
diff --git a/app/widgets/gimphelp-ids.h b/app/widgets/gimphelp-ids.h
index 95d7464..6a6e537 100644
--- a/app/widgets/gimphelp-ids.h
+++ b/app/widgets/gimphelp-ids.h
@@ -171,6 +171,8 @@
#define GIMP_HELP_LAYER_INVERT "gimp-layer-invert"
#define GIMP_HELP_LAYER_WHITE_BALANCE "gimp-layer-white-balance"
#define GIMP_HELP_LAYER_EQUALIZE "gimp-layer-equalize"
+#define GIMP_HELP_LAYER_DILATE "gimp-layer-dilate"
+#define GIMP_HELP_LAYER_ERODE "gimp-layer-erode"
#define GIMP_HELP_LAYER_VISIBLE "gimp-layer-visible"
#define GIMP_HELP_LAYER_LINKED "gimp-layer-linked"
#define GIMP_HELP_LAYER_OPACITY "gimp-layer-opacity"
diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in
index ae031d6..72d951a 100644
--- a/menus/image-menu.xml.in
+++ b/menus/image-menu.xml.in
@@ -696,6 +696,8 @@
<menu action="plug-in-generic-menu" name="Generic">
<menuitem action="filters-convolution-matrix" />
<menuitem action="filters-distance-map" />
+ <menuitem action="drawable-dilate" />
+ <menuitem action="drawable-erode" />
</menu>
<menu action="plug-in-combine-menu" name="Combine" />
<menu action="plug-in-artistic-menu" name="Artistic">
diff --git a/plug-ins/common/value-propagate.c b/plug-ins/common/value-propagate.c
index 71b421e..cdd5a98 100644
--- a/plug-ins/common/value-propagate.c
+++ b/plug-ins/common/value-propagate.c
@@ -266,8 +266,6 @@ query (void)
args, NULL);
gimp_plugin_menu_register (VPROPAGATE_PROC, "<Image>/Filters/Distorts");
- gimp_plugin_menu_register (ERODE_PROC, "<Image>/Filters/Generic");
- gimp_plugin_menu_register (DILATE_PROC, "<Image>/Filters/Generic");
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]