[gimp] Bug 792470 - Some filters e.g. "Levels" are not added to "Repeat last" history



commit b23f231a1ae36ea90b5822f6769fd55c07ec9c53
Author: Michael Natterer <mitch gimp org>
Date:   Sun Jan 14 15:42:29 2018 +0100

    Bug 792470 - Some filters e.g. "Levels" are not added to "Repeat last" history
    
    The four remaining "classic" color tools (Brightness-Contrast, Curves,
    Levels and Threshold) are in fact just special UIs for otherwise
    completely normal filter ops.
    
    Add normal filter actions for them and invoke them like all
    other filters, which makes them show up in the filter history
    automatically.
    
    The only small hack needed is to special case them in
    gimp_gegl_procedure_execute_async() so the right tools are created
    instead of the default GimpOperationTool. Also, blacklist the
    automatically generated tools actions from action search and the
    shortcut editor.

 app/actions/filters-actions.c                    |   24 +++++++++
 app/actions/gimpgeglprocedure.c                  |   56 +++++++++++++++------
 app/operations/gimpoperationbrightnesscontrast.c |    4 +-
 app/operations/gimpoperationcurves.c             |    4 +-
 app/operations/gimpoperationlevels.c             |    4 +-
 app/operations/gimpoperationthreshold.c          |    2 +-
 app/tools/gimpbrightnesscontrasttool.c           |    2 +-
 app/tools/gimpcurvestool.c                       |    2 +-
 app/tools/gimplevelstool.c                       |    2 +-
 app/tools/gimpthresholdtool.c                    |    2 +-
 app/widgets/gimpaction.c                         |   14 +++++
 menus/image-menu.xml.in                          |    8 ++--
 po/POTFILES.in                                   |    3 +
 13 files changed, 99 insertions(+), 28 deletions(-)
---
diff --git a/app/actions/filters-actions.c b/app/actions/filters-actions.c
index 0e6fe71..d16ca64 100644
--- a/app/actions/filters-actions.c
+++ b/app/actions/filters-actions.c
@@ -183,6 +183,11 @@ static const GimpStringActionEntry filters_interactive_actions[] =
     "gegl:apply-lens",
     GIMP_HELP_FILTER_APPLY_LENS },
 
+  { "filters-brightness-contrast", GIMP_ICON_TOOL_BRIGHTNESS_CONTRAST,
+    NC_("filters-action", "B_rightness-Contrast..."), NULL, NULL,
+    "gimp:brightness-contrast",
+    GIMP_HELP_TOOL_BRIGHTNESS_CONTRAST },
+
   { "filters-bump-map", GIMP_ICON_GEGL,
     NC_("filters-action", "_Bump Map..."), NULL, NULL,
     "gegl:bump-map",
@@ -258,6 +263,11 @@ static const GimpStringActionEntry filters_interactive_actions[] =
     "gegl:cubism",
     GIMP_HELP_FILTER_CUBISM },
 
+  { "filters-curves", GIMP_ICON_TOOL_CURVES,
+    NC_("filters-action", "_Curves..."), NULL, NULL,
+    "gimp:curves",
+    GIMP_HELP_TOOL_CURVES },
+
   { "filters-deinterlace", GIMP_ICON_GEGL,
     NC_("filters-action", "_Deinterlace..."), NULL, NULL,
     "gegl:deinterlace",
@@ -398,6 +408,11 @@ static const GimpStringActionEntry filters_interactive_actions[] =
     "gegl:lens-flare",
     GIMP_HELP_FILTER_LENS_FLARE },
 
+  { "filters-levels", GIMP_ICON_TOOL_LEVELS,
+    NC_("filters-action", "_Levels..."), NULL, NULL,
+    "gimp:levels",
+    GIMP_HELP_TOOL_LEVELS },
+
   { "filters-mantiuk-2006", GIMP_ICON_GEGL,
     NC_("filters-action", "_Mantiuk 2006..."), NULL, NULL,
     "gegl:mantiuk06",
@@ -618,6 +633,11 @@ static const GimpStringActionEntry filters_interactive_actions[] =
     "gegl:supernova",
     GIMP_HELP_FILTER_SUPERNOVA },
 
+  { "filters-threshold", GIMP_ICON_TOOL_THRESHOLD,
+    NC_("filters-action", "_Threshold..."), NULL, NULL,
+    "gimp:threshold",
+    GIMP_HELP_TOOL_THRESHOLD },
+
   { "filters-threshold-alpha", GIMP_ICON_GEGL,
     NC_("filters-action", "_Threshold Alpha..."), NULL, NULL,
     "gimp:threshold-alpha",
@@ -808,6 +828,7 @@ filters_actions_update (GimpActionGroup *group,
   SET_SENSITIVE ("filters-antialias",               writable);
   SET_SENSITIVE ("filters-apply-canvas",            writable);
   SET_SENSITIVE ("filters-apply-lens",              writable);
+  SET_SENSITIVE ("filters-brightness-contrast",     writable);
   SET_SENSITIVE ("filters-bump-map",                writable);
   SET_SENSITIVE ("filters-c2g",                     writable && !gray);
   SET_SENSITIVE ("filters-cartoon",                 writable);
@@ -824,6 +845,7 @@ filters_actions_update (GimpActionGroup *group,
   SET_SENSITIVE ("filters-component-extract",       writable);
   SET_SENSITIVE ("filters-convolution-matrix",      writable);
   SET_SENSITIVE ("filters-cubism",                  writable);
+  SET_SENSITIVE ("filters-curves",                  writable);
   SET_SENSITIVE ("filters-deinterlace",             writable);
   SET_SENSITIVE ("filters-desaturate",              writable && !gray);
   SET_SENSITIVE ("filters-difference-of-gaussians", writable);
@@ -857,6 +879,7 @@ filters_actions_update (GimpActionGroup *group,
   SET_SENSITIVE ("filters-kaleidoscope",            writable);
   SET_SENSITIVE ("filters-lens-distortion",         writable);
   SET_SENSITIVE ("filters-lens-flare",              writable);
+  SET_SENSITIVE ("filters-levels",                  writable);
   SET_SENSITIVE ("filters-mantiuk-2006",            writable);
   SET_SENSITIVE ("filters-maze",                    writable);
   SET_SENSITIVE ("filters-median-blur",             writable);
@@ -901,6 +924,7 @@ filters_actions_update (GimpActionGroup *group,
   SET_SENSITIVE ("filters-stretch-contrast-hsv",    writable);
   SET_SENSITIVE ("filters-stress",                  writable);
   SET_SENSITIVE ("filters-supernova",               writable);
+  SET_SENSITIVE ("filters-threshold",               writable);
   SET_SENSITIVE ("filters-threshold-alpha",         writable && alpha);
   SET_SENSITIVE ("filters-tile-glass",              writable);
   SET_SENSITIVE ("filters-tile-paper",              writable);
diff --git a/app/actions/gimpgeglprocedure.c b/app/actions/gimpgeglprocedure.c
index d5aa177..183efc1 100644
--- a/app/actions/gimpgeglprocedure.c
+++ b/app/actions/gimpgeglprocedure.c
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * gimpgeglprocedure.c
- * Copyright (C) 2016 Michael Natterer <mitch gimp org>
+ * Copyright (C) 2016-2018 Michael Natterer <mitch gimp org>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -272,6 +272,7 @@ gimp_gegl_procedure_execute_async (GimpProcedure  *procedure,
   GimpRunMode  run_mode;
   GimpObject  *settings;
   GimpTool    *active_tool;
+  const gchar *tool_name;
 
   run_mode = g_value_get_int    (gimp_value_array_index (args, 0));
   settings = g_value_get_object (gimp_value_array_index (args, 3));
@@ -321,6 +322,27 @@ gimp_gegl_procedure_execute_async (GimpProcedure  *procedure,
                     gimp_procedure_get_label (procedure));
     }
 
+  if (! strcmp (procedure->original_name, "gimp:brightness-contrast"))
+    {
+      tool_name = "gimp-brightness-contrast-tool";
+    }
+  else if (! strcmp (procedure->original_name, "gimp:curves"))
+    {
+      tool_name = "gimp-curves-tool";
+    }
+  else if (! strcmp (procedure->original_name, "gimp:levels"))
+    {
+      tool_name = "gimp-levels-tool";
+    }
+  else if (! strcmp (procedure->original_name, "gimp:threshold"))
+    {
+      tool_name = "gimp-threshold-tool";
+    }
+  else
+    {
+      tool_name = "gimp-operation-tool";
+    }
+
   active_tool = tool_manager_get_active (gimp);
 
   /*  do not use the passed context because we need to set the active
@@ -328,10 +350,9 @@ gimp_gegl_procedure_execute_async (GimpProcedure  *procedure,
    */
   context = gimp_get_user_context (gimp);
 
-  if (G_TYPE_FROM_INSTANCE (active_tool) != GIMP_TYPE_OPERATION_TOOL)
+  if (strcmp (gimp_object_get_name (active_tool->tool_info), tool_name))
     {
-      GimpToolInfo *tool_info = gimp_get_tool_info (gimp,
-                                                    "gimp-operation-tool");
+      GimpToolInfo *tool_info = gimp_get_tool_info (gimp, tool_name);
 
       if (GIMP_IS_TOOL_INFO (tool_info))
         gimp_context_set_tool (context, tool_info);
@@ -343,25 +364,28 @@ gimp_gegl_procedure_execute_async (GimpProcedure  *procedure,
 
   active_tool = tool_manager_get_active (gimp);
 
-  if (GIMP_IS_OPERATION_TOOL (active_tool))
+  if (! strcmp (gimp_object_get_name (active_tool->tool_info), tool_name))
     {
-      /*  Remember the prodecure that created this tool, because we
-       *  can't just switch to an operation tool using
+      /*  Remember the prodecure that created this tool, because
+       *  we can't just switch to an operation tool using
        *  gimp_context_set_tool(), we also have to go through the
-       *  initialization code below, otherwise we end up with a dummy
-       *  tool that does nothing. See bug #776370.
+       *  initialization code below, otherwise we end up with a
+       *  dummy tool that does nothing. See bug #776370.
        */
       g_object_set_data_full (G_OBJECT (active_tool), "gimp-gegl-procedure",
                               g_object_ref (procedure),
                               (GDestroyNotify) g_object_unref);
 
-      gimp_operation_tool_set_operation (GIMP_OPERATION_TOOL (active_tool),
-                                         procedure->original_name,
-                                         gimp_procedure_get_label (procedure),
-                                         gimp_procedure_get_label (procedure),
-                                         gimp_procedure_get_label (procedure),
-                                         gimp_viewable_get_icon_name (GIMP_VIEWABLE (procedure)),
-                                         gimp_procedure_get_help_id (procedure));
+      if (! strcmp (tool_name, "gimp-operation-tool"))
+        {
+          gimp_operation_tool_set_operation (GIMP_OPERATION_TOOL (active_tool),
+                                             procedure->original_name,
+                                             gimp_procedure_get_label (procedure),
+                                             gimp_procedure_get_label (procedure),
+                                             gimp_procedure_get_label (procedure),
+                                             gimp_viewable_get_icon_name (GIMP_VIEWABLE (procedure)),
+                                             gimp_procedure_get_help_id (procedure));
+        }
 
       tool_manager_initialize_active (gimp, GIMP_DISPLAY (display));
 
diff --git a/app/operations/gimpoperationbrightnesscontrast.c 
b/app/operations/gimpoperationbrightnesscontrast.c
index e21f149..8025f08 100644
--- a/app/operations/gimpoperationbrightnesscontrast.c
+++ b/app/operations/gimpoperationbrightnesscontrast.c
@@ -32,6 +32,8 @@
 #include "gimpbrightnesscontrastconfig.h"
 #include "gimpoperationbrightnesscontrast.h"
 
+#include "gimp-intl.h"
+
 
 static gboolean gimp_operation_brightness_contrast_process (GeglOperation       *operation,
                                                             void                *in_buf,
@@ -60,7 +62,7 @@ gimp_operation_brightness_contrast_class_init (GimpOperationBrightnessContrastCl
   gegl_operation_class_set_keys (operation_class,
                                  "name",        "gimp:brightness-contrast",
                                  "categories",  "color",
-                                 "description", "GIMP Brightness-Contrast operation",
+                                 "description", _("Adjust brightness and contrast"),
                                  NULL);
 
   point_class->process         = gimp_operation_brightness_contrast_process;
diff --git a/app/operations/gimpoperationcurves.c b/app/operations/gimpoperationcurves.c
index 65899c7..df72ec2 100644
--- a/app/operations/gimpoperationcurves.c
+++ b/app/operations/gimpoperationcurves.c
@@ -34,6 +34,8 @@
 #include "gimpcurvesconfig.h"
 #include "gimpoperationcurves.h"
 
+#include "gimp-intl.h"
+
 
 static gboolean gimp_operation_curves_process (GeglOperation       *operation,
                                                void                *in_buf,
@@ -62,7 +64,7 @@ gimp_operation_curves_class_init (GimpOperationCurvesClass *klass)
   gegl_operation_class_set_keys (operation_class,
                                  "name",        "gimp:curves",
                                  "categories",  "color",
-                                 "description", "GIMP Curves operation",
+                                 "description", _("Adjust color curves"),
                                  NULL);
 
   point_class->process = gimp_operation_curves_process;
diff --git a/app/operations/gimpoperationlevels.c b/app/operations/gimpoperationlevels.c
index 319be51..05582b7 100644
--- a/app/operations/gimpoperationlevels.c
+++ b/app/operations/gimpoperationlevels.c
@@ -31,6 +31,8 @@
 #include "gimplevelsconfig.h"
 #include "gimpoperationlevels.h"
 
+#include "gimp-intl.h"
+
 
 static gboolean gimp_operation_levels_process (GeglOperation       *operation,
                                                void                *in_buf,
@@ -59,7 +61,7 @@ gimp_operation_levels_class_init (GimpOperationLevelsClass *klass)
   gegl_operation_class_set_keys (operation_class,
                                  "name",        "gimp:levels",
                                  "categories",  "color",
-                                 "description", "GIMP Levels operation",
+                                 "description", _("Adjust color levels"),
                                  NULL);
 
   point_class->process = gimp_operation_levels_process;
diff --git a/app/operations/gimpoperationthreshold.c b/app/operations/gimpoperationthreshold.c
index ddcd517..dcad2f4 100644
--- a/app/operations/gimpoperationthreshold.c
+++ b/app/operations/gimpoperationthreshold.c
@@ -81,7 +81,7 @@ gimp_operation_threshold_class_init (GimpOperationThresholdClass *klass)
   gegl_operation_class_set_keys (operation_class,
                                  "name",        "gimp:threshold",
                                  "categories",  "color",
-                                 "description", "GIMP Threshold operation",
+                                 "description", _("Reduce image to two colors using a threshold"),
                                  NULL);
 
   GIMP_CONFIG_PROP_ENUM (object_class, PROP_CHANNEL,
diff --git a/app/tools/gimpbrightnesscontrasttool.c b/app/tools/gimpbrightnesscontrasttool.c
index 6bef1b2..4f45295 100644
--- a/app/tools/gimpbrightnesscontrasttool.c
+++ b/app/tools/gimpbrightnesscontrasttool.c
@@ -95,7 +95,7 @@ gimp_brightness_contrast_tool_register (GimpToolRegisterCallback  callback,
                 0,
                 "gimp-brightness-contrast-tool",
                 _("Brightness-Contrast"),
-                _("Brightness/Contrast Tool: Adjust brightness and contrast"),
+                _("Adjust brightness and contrast"),
                 N_("B_rightness-Contrast..."), NULL,
                 NULL, GIMP_HELP_TOOL_BRIGHTNESS_CONTRAST,
                 GIMP_ICON_TOOL_BRIGHTNESS_CONTRAST,
diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c
index d80177c..9b73672 100644
--- a/app/tools/gimpcurvestool.c
+++ b/app/tools/gimpcurvestool.c
@@ -140,7 +140,7 @@ gimp_curves_tool_register (GimpToolRegisterCallback  callback,
                 0,
                 "gimp-curves-tool",
                 _("Curves"),
-                _("Curves Tool: Adjust color curves"),
+                _("Adjust color curves"),
                 N_("_Curves..."), NULL,
                 NULL, GIMP_HELP_TOOL_CURVES,
                 GIMP_ICON_TOOL_CURVES,
diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c
index 751ba2f..1984270 100644
--- a/app/tools/gimplevelstool.c
+++ b/app/tools/gimplevelstool.c
@@ -130,7 +130,7 @@ gimp_levels_tool_register (GimpToolRegisterCallback  callback,
                 0,
                 "gimp-levels-tool",
                 _("Levels"),
-                _("Levels Tool: Adjust color levels"),
+                _("Adjust color levels"),
                 N_("_Levels..."), NULL,
                 NULL, GIMP_HELP_TOOL_LEVELS,
                 GIMP_ICON_TOOL_LEVELS,
diff --git a/app/tools/gimpthresholdtool.c b/app/tools/gimpthresholdtool.c
index 630d22a..a179c1c 100644
--- a/app/tools/gimpthresholdtool.c
+++ b/app/tools/gimpthresholdtool.c
@@ -85,7 +85,7 @@ gimp_threshold_tool_register (GimpToolRegisterCallback  callback,
                 0,
                 "gimp-threshold-tool",
                 _("Threshold"),
-                _("Threshold Tool: Reduce image to two colors using a threshold"),
+                _("Reduce image to two colors using a threshold"),
                 N_("_Threshold..."), NULL,
                 NULL, GIMP_HELP_TOOL_THRESHOLD,
                 GIMP_ICON_TOOL_THRESHOLD,
diff --git a/app/widgets/gimpaction.c b/app/widgets/gimpaction.c
index d02b8ec..33b60d6 100644
--- a/app/widgets/gimpaction.c
+++ b/app/widgets/gimpaction.c
@@ -330,6 +330,14 @@ gimp_action_is_gui_blacklisted (const gchar *action_name)
       "tools-warp-effect-hardness-"
     };
 
+  static const gchar *actions[] =
+    {
+      "tools-brightness-contrast",
+      "tools-curves",
+      "tools-levels",
+      "tools-threshold"
+    };
+
   gint i;
 
   if (! (action_name && *action_name))
@@ -347,6 +355,12 @@ gimp_action_is_gui_blacklisted (const gchar *action_name)
         return TRUE;
     }
 
+  for (i = 0; i < G_N_ELEMENTS (actions); i++)
+    {
+      if (! strcmp (action_name, actions[i]))
+        return TRUE;
+    }
+
   return FALSE;
 }
 
diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in
index dd99954..77e4c33 100644
--- a/menus/image-menu.xml.in
+++ b/menus/image-menu.xml.in
@@ -569,9 +569,9 @@
       <menuitem action="filters-saturation" />
       <menuitem action="filters-exposure" />
       <menuitem action="filters-shadows-highlights" />
-      <menuitem action="tools-brightness-contrast" />
-      <menuitem action="tools-levels" />
-      <menuitem action="tools-curves" />
+      <menuitem action="filters-brightness-contrast" />
+      <menuitem action="filters-levels" />
+      <menuitem action="filters-curves" />
       <separator />
       <placeholder name="Invert">
         <menuitem action="filters-invert-perceptual" />
@@ -616,7 +616,7 @@
         <menuitem action="dialogs-histogram" />
       </menu>
       <separator />
-      <menuitem action="tools-threshold" />
+      <menuitem action="filters-threshold" />
       <menuitem action="filters-colorize" />
       <menuitem action="filters-posterize" />
       <menuitem action="filters-color-to-alpha" />
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7e4e565..8081e6e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -280,12 +280,15 @@ app/operations/gimpcolorbalanceconfig.c
 app/operations/gimpcurvesconfig.c
 app/operations/gimphuesaturationconfig.c
 app/operations/gimplevelsconfig.c
+app/operations/gimpoperationbrightnesscontrast.c
 app/operations/gimpoperationcagecoefcalc.c
 app/operations/gimpoperationcagetransform.c
 app/operations/gimpoperationcolorbalance.c
 app/operations/gimpoperationcolorize.c
+app/operations/gimpoperationcurves.c
 app/operations/gimpoperationdesaturate.c
 app/operations/gimpoperationhuesaturation.c
+app/operations/gimpoperationlevels.c
 app/operations/gimpoperationposterize.c
 app/operations/gimpoperationsemiflatten.c
 app/operations/gimpoperationthreshold.c


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]