Commit b23f231a authored by Michael Natterer's avatar Michael Natterer 😴

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.
parent 458e3130
...@@ -183,6 +183,11 @@ static const GimpStringActionEntry filters_interactive_actions[] = ...@@ -183,6 +183,11 @@ static const GimpStringActionEntry filters_interactive_actions[] =
"gegl:apply-lens", "gegl:apply-lens",
GIMP_HELP_FILTER_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, { "filters-bump-map", GIMP_ICON_GEGL,
NC_("filters-action", "_Bump Map..."), NULL, NULL, NC_("filters-action", "_Bump Map..."), NULL, NULL,
"gegl:bump-map", "gegl:bump-map",
...@@ -258,6 +263,11 @@ static const GimpStringActionEntry filters_interactive_actions[] = ...@@ -258,6 +263,11 @@ static const GimpStringActionEntry filters_interactive_actions[] =
"gegl:cubism", "gegl:cubism",
GIMP_HELP_FILTER_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, { "filters-deinterlace", GIMP_ICON_GEGL,
NC_("filters-action", "_Deinterlace..."), NULL, NULL, NC_("filters-action", "_Deinterlace..."), NULL, NULL,
"gegl:deinterlace", "gegl:deinterlace",
...@@ -398,6 +408,11 @@ static const GimpStringActionEntry filters_interactive_actions[] = ...@@ -398,6 +408,11 @@ static const GimpStringActionEntry filters_interactive_actions[] =
"gegl:lens-flare", "gegl:lens-flare",
GIMP_HELP_FILTER_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, { "filters-mantiuk-2006", GIMP_ICON_GEGL,
NC_("filters-action", "_Mantiuk 2006..."), NULL, NULL, NC_("filters-action", "_Mantiuk 2006..."), NULL, NULL,
"gegl:mantiuk06", "gegl:mantiuk06",
...@@ -618,6 +633,11 @@ static const GimpStringActionEntry filters_interactive_actions[] = ...@@ -618,6 +633,11 @@ static const GimpStringActionEntry filters_interactive_actions[] =
"gegl:supernova", "gegl:supernova",
GIMP_HELP_FILTER_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, { "filters-threshold-alpha", GIMP_ICON_GEGL,
NC_("filters-action", "_Threshold Alpha..."), NULL, NULL, NC_("filters-action", "_Threshold Alpha..."), NULL, NULL,
"gimp:threshold-alpha", "gimp:threshold-alpha",
...@@ -808,6 +828,7 @@ filters_actions_update (GimpActionGroup *group, ...@@ -808,6 +828,7 @@ filters_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("filters-antialias", writable); SET_SENSITIVE ("filters-antialias", writable);
SET_SENSITIVE ("filters-apply-canvas", writable); SET_SENSITIVE ("filters-apply-canvas", writable);
SET_SENSITIVE ("filters-apply-lens", writable); SET_SENSITIVE ("filters-apply-lens", writable);
SET_SENSITIVE ("filters-brightness-contrast", writable);
SET_SENSITIVE ("filters-bump-map", writable); SET_SENSITIVE ("filters-bump-map", writable);
SET_SENSITIVE ("filters-c2g", writable && !gray); SET_SENSITIVE ("filters-c2g", writable && !gray);
SET_SENSITIVE ("filters-cartoon", writable); SET_SENSITIVE ("filters-cartoon", writable);
...@@ -824,6 +845,7 @@ filters_actions_update (GimpActionGroup *group, ...@@ -824,6 +845,7 @@ filters_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("filters-component-extract", writable); SET_SENSITIVE ("filters-component-extract", writable);
SET_SENSITIVE ("filters-convolution-matrix", writable); SET_SENSITIVE ("filters-convolution-matrix", writable);
SET_SENSITIVE ("filters-cubism", writable); SET_SENSITIVE ("filters-cubism", writable);
SET_SENSITIVE ("filters-curves", writable);
SET_SENSITIVE ("filters-deinterlace", writable); SET_SENSITIVE ("filters-deinterlace", writable);
SET_SENSITIVE ("filters-desaturate", writable && !gray); SET_SENSITIVE ("filters-desaturate", writable && !gray);
SET_SENSITIVE ("filters-difference-of-gaussians", writable); SET_SENSITIVE ("filters-difference-of-gaussians", writable);
...@@ -857,6 +879,7 @@ filters_actions_update (GimpActionGroup *group, ...@@ -857,6 +879,7 @@ filters_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("filters-kaleidoscope", writable); SET_SENSITIVE ("filters-kaleidoscope", writable);
SET_SENSITIVE ("filters-lens-distortion", writable); SET_SENSITIVE ("filters-lens-distortion", writable);
SET_SENSITIVE ("filters-lens-flare", writable); SET_SENSITIVE ("filters-lens-flare", writable);
SET_SENSITIVE ("filters-levels", writable);
SET_SENSITIVE ("filters-mantiuk-2006", writable); SET_SENSITIVE ("filters-mantiuk-2006", writable);
SET_SENSITIVE ("filters-maze", writable); SET_SENSITIVE ("filters-maze", writable);
SET_SENSITIVE ("filters-median-blur", writable); SET_SENSITIVE ("filters-median-blur", writable);
...@@ -901,6 +924,7 @@ filters_actions_update (GimpActionGroup *group, ...@@ -901,6 +924,7 @@ filters_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("filters-stretch-contrast-hsv", writable); SET_SENSITIVE ("filters-stretch-contrast-hsv", writable);
SET_SENSITIVE ("filters-stress", writable); SET_SENSITIVE ("filters-stress", writable);
SET_SENSITIVE ("filters-supernova", writable); SET_SENSITIVE ("filters-supernova", writable);
SET_SENSITIVE ("filters-threshold", writable);
SET_SENSITIVE ("filters-threshold-alpha", writable && alpha); SET_SENSITIVE ("filters-threshold-alpha", writable && alpha);
SET_SENSITIVE ("filters-tile-glass", writable); SET_SENSITIVE ("filters-tile-glass", writable);
SET_SENSITIVE ("filters-tile-paper", writable); SET_SENSITIVE ("filters-tile-paper", writable);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Copyright (C) 1995 Spencer Kimball and Peter Mattis * Copyright (C) 1995 Spencer Kimball and Peter Mattis
* *
* gimpgeglprocedure.c * 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 * 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 * it under the terms of the GNU General Public License as published by
...@@ -272,6 +272,7 @@ gimp_gegl_procedure_execute_async (GimpProcedure *procedure, ...@@ -272,6 +272,7 @@ gimp_gegl_procedure_execute_async (GimpProcedure *procedure,
GimpRunMode run_mode; GimpRunMode run_mode;
GimpObject *settings; GimpObject *settings;
GimpTool *active_tool; GimpTool *active_tool;
const gchar *tool_name;
run_mode = g_value_get_int (gimp_value_array_index (args, 0)); run_mode = g_value_get_int (gimp_value_array_index (args, 0));
settings = g_value_get_object (gimp_value_array_index (args, 3)); settings = g_value_get_object (gimp_value_array_index (args, 3));
...@@ -321,6 +322,27 @@ gimp_gegl_procedure_execute_async (GimpProcedure *procedure, ...@@ -321,6 +322,27 @@ gimp_gegl_procedure_execute_async (GimpProcedure *procedure,
gimp_procedure_get_label (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); active_tool = tool_manager_get_active (gimp);
/* do not use the passed context because we need to set the active /* do not use the passed context because we need to set the active
...@@ -328,10 +350,9 @@ gimp_gegl_procedure_execute_async (GimpProcedure *procedure, ...@@ -328,10 +350,9 @@ gimp_gegl_procedure_execute_async (GimpProcedure *procedure,
*/ */
context = gimp_get_user_context (gimp); 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, GimpToolInfo *tool_info = gimp_get_tool_info (gimp, tool_name);
"gimp-operation-tool");
if (GIMP_IS_TOOL_INFO (tool_info)) if (GIMP_IS_TOOL_INFO (tool_info))
gimp_context_set_tool (context, tool_info); gimp_context_set_tool (context, tool_info);
...@@ -343,18 +364,20 @@ gimp_gegl_procedure_execute_async (GimpProcedure *procedure, ...@@ -343,18 +364,20 @@ gimp_gegl_procedure_execute_async (GimpProcedure *procedure,
active_tool = tool_manager_get_active (gimp); 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 /* Remember the prodecure that created this tool, because
* can't just switch to an operation tool using * we can't just switch to an operation tool using
* gimp_context_set_tool(), we also have to go through the * gimp_context_set_tool(), we also have to go through the
* initialization code below, otherwise we end up with a dummy * initialization code below, otherwise we end up with a
* tool that does nothing. See bug #776370. * dummy tool that does nothing. See bug #776370.
*/ */
g_object_set_data_full (G_OBJECT (active_tool), "gimp-gegl-procedure", g_object_set_data_full (G_OBJECT (active_tool), "gimp-gegl-procedure",
g_object_ref (procedure), g_object_ref (procedure),
(GDestroyNotify) g_object_unref); (GDestroyNotify) g_object_unref);
if (! strcmp (tool_name, "gimp-operation-tool"))
{
gimp_operation_tool_set_operation (GIMP_OPERATION_TOOL (active_tool), gimp_operation_tool_set_operation (GIMP_OPERATION_TOOL (active_tool),
procedure->original_name, procedure->original_name,
gimp_procedure_get_label (procedure), gimp_procedure_get_label (procedure),
...@@ -362,6 +385,7 @@ gimp_gegl_procedure_execute_async (GimpProcedure *procedure, ...@@ -362,6 +385,7 @@ gimp_gegl_procedure_execute_async (GimpProcedure *procedure,
gimp_procedure_get_label (procedure), gimp_procedure_get_label (procedure),
gimp_viewable_get_icon_name (GIMP_VIEWABLE (procedure)), gimp_viewable_get_icon_name (GIMP_VIEWABLE (procedure)),
gimp_procedure_get_help_id (procedure)); gimp_procedure_get_help_id (procedure));
}
tool_manager_initialize_active (gimp, GIMP_DISPLAY (display)); tool_manager_initialize_active (gimp, GIMP_DISPLAY (display));
......
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#include "gimpbrightnesscontrastconfig.h" #include "gimpbrightnesscontrastconfig.h"
#include "gimpoperationbrightnesscontrast.h" #include "gimpoperationbrightnesscontrast.h"
#include "gimp-intl.h"
static gboolean gimp_operation_brightness_contrast_process (GeglOperation *operation, static gboolean gimp_operation_brightness_contrast_process (GeglOperation *operation,
void *in_buf, void *in_buf,
...@@ -60,7 +62,7 @@ gimp_operation_brightness_contrast_class_init (GimpOperationBrightnessContrastCl ...@@ -60,7 +62,7 @@ gimp_operation_brightness_contrast_class_init (GimpOperationBrightnessContrastCl
gegl_operation_class_set_keys (operation_class, gegl_operation_class_set_keys (operation_class,
"name", "gimp:brightness-contrast", "name", "gimp:brightness-contrast",
"categories", "color", "categories", "color",
"description", "GIMP Brightness-Contrast operation", "description", _("Adjust brightness and contrast"),
NULL); NULL);
point_class->process = gimp_operation_brightness_contrast_process; point_class->process = gimp_operation_brightness_contrast_process;
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include "gimpcurvesconfig.h" #include "gimpcurvesconfig.h"
#include "gimpoperationcurves.h" #include "gimpoperationcurves.h"
#include "gimp-intl.h"
static gboolean gimp_operation_curves_process (GeglOperation *operation, static gboolean gimp_operation_curves_process (GeglOperation *operation,
void *in_buf, void *in_buf,
...@@ -62,7 +64,7 @@ gimp_operation_curves_class_init (GimpOperationCurvesClass *klass) ...@@ -62,7 +64,7 @@ gimp_operation_curves_class_init (GimpOperationCurvesClass *klass)
gegl_operation_class_set_keys (operation_class, gegl_operation_class_set_keys (operation_class,
"name", "gimp:curves", "name", "gimp:curves",
"categories", "color", "categories", "color",
"description", "GIMP Curves operation", "description", _("Adjust color curves"),
NULL); NULL);
point_class->process = gimp_operation_curves_process; point_class->process = gimp_operation_curves_process;
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include "gimplevelsconfig.h" #include "gimplevelsconfig.h"
#include "gimpoperationlevels.h" #include "gimpoperationlevels.h"
#include "gimp-intl.h"
static gboolean gimp_operation_levels_process (GeglOperation *operation, static gboolean gimp_operation_levels_process (GeglOperation *operation,
void *in_buf, void *in_buf,
...@@ -59,7 +61,7 @@ gimp_operation_levels_class_init (GimpOperationLevelsClass *klass) ...@@ -59,7 +61,7 @@ gimp_operation_levels_class_init (GimpOperationLevelsClass *klass)
gegl_operation_class_set_keys (operation_class, gegl_operation_class_set_keys (operation_class,
"name", "gimp:levels", "name", "gimp:levels",
"categories", "color", "categories", "color",
"description", "GIMP Levels operation", "description", _("Adjust color levels"),
NULL); NULL);
point_class->process = gimp_operation_levels_process; point_class->process = gimp_operation_levels_process;
......
...@@ -81,7 +81,7 @@ gimp_operation_threshold_class_init (GimpOperationThresholdClass *klass) ...@@ -81,7 +81,7 @@ gimp_operation_threshold_class_init (GimpOperationThresholdClass *klass)
gegl_operation_class_set_keys (operation_class, gegl_operation_class_set_keys (operation_class,
"name", "gimp:threshold", "name", "gimp:threshold",
"categories", "color", "categories", "color",
"description", "GIMP Threshold operation", "description", _("Reduce image to two colors using a threshold"),
NULL); NULL);
GIMP_CONFIG_PROP_ENUM (object_class, PROP_CHANNEL, GIMP_CONFIG_PROP_ENUM (object_class, PROP_CHANNEL,
......
...@@ -95,7 +95,7 @@ gimp_brightness_contrast_tool_register (GimpToolRegisterCallback callback, ...@@ -95,7 +95,7 @@ gimp_brightness_contrast_tool_register (GimpToolRegisterCallback callback,
0, 0,
"gimp-brightness-contrast-tool", "gimp-brightness-contrast-tool",
_("Brightness-Contrast"), _("Brightness-Contrast"),
_("Brightness/Contrast Tool: Adjust brightness and contrast"), _("Adjust brightness and contrast"),
N_("B_rightness-Contrast..."), NULL, N_("B_rightness-Contrast..."), NULL,
NULL, GIMP_HELP_TOOL_BRIGHTNESS_CONTRAST, NULL, GIMP_HELP_TOOL_BRIGHTNESS_CONTRAST,
GIMP_ICON_TOOL_BRIGHTNESS_CONTRAST, GIMP_ICON_TOOL_BRIGHTNESS_CONTRAST,
......
...@@ -140,7 +140,7 @@ gimp_curves_tool_register (GimpToolRegisterCallback callback, ...@@ -140,7 +140,7 @@ gimp_curves_tool_register (GimpToolRegisterCallback callback,
0, 0,
"gimp-curves-tool", "gimp-curves-tool",
_("Curves"), _("Curves"),
_("Curves Tool: Adjust color curves"), _("Adjust color curves"),
N_("_Curves..."), NULL, N_("_Curves..."), NULL,
NULL, GIMP_HELP_TOOL_CURVES, NULL, GIMP_HELP_TOOL_CURVES,
GIMP_ICON_TOOL_CURVES, GIMP_ICON_TOOL_CURVES,
......
...@@ -130,7 +130,7 @@ gimp_levels_tool_register (GimpToolRegisterCallback callback, ...@@ -130,7 +130,7 @@ gimp_levels_tool_register (GimpToolRegisterCallback callback,
0, 0,
"gimp-levels-tool", "gimp-levels-tool",
_("Levels"), _("Levels"),
_("Levels Tool: Adjust color levels"), _("Adjust color levels"),
N_("_Levels..."), NULL, N_("_Levels..."), NULL,
NULL, GIMP_HELP_TOOL_LEVELS, NULL, GIMP_HELP_TOOL_LEVELS,
GIMP_ICON_TOOL_LEVELS, GIMP_ICON_TOOL_LEVELS,
......
...@@ -85,7 +85,7 @@ gimp_threshold_tool_register (GimpToolRegisterCallback callback, ...@@ -85,7 +85,7 @@ gimp_threshold_tool_register (GimpToolRegisterCallback callback,
0, 0,
"gimp-threshold-tool", "gimp-threshold-tool",
_("Threshold"), _("Threshold"),
_("Threshold Tool: Reduce image to two colors using a threshold"), _("Reduce image to two colors using a threshold"),
N_("_Threshold..."), NULL, N_("_Threshold..."), NULL,
NULL, GIMP_HELP_TOOL_THRESHOLD, NULL, GIMP_HELP_TOOL_THRESHOLD,
GIMP_ICON_TOOL_THRESHOLD, GIMP_ICON_TOOL_THRESHOLD,
......
...@@ -330,6 +330,14 @@ gimp_action_is_gui_blacklisted (const gchar *action_name) ...@@ -330,6 +330,14 @@ gimp_action_is_gui_blacklisted (const gchar *action_name)
"tools-warp-effect-hardness-" "tools-warp-effect-hardness-"
}; };
static const gchar *actions[] =
{
"tools-brightness-contrast",
"tools-curves",
"tools-levels",
"tools-threshold"
};
gint i; gint i;
if (! (action_name && *action_name)) if (! (action_name && *action_name))
...@@ -347,6 +355,12 @@ gimp_action_is_gui_blacklisted (const gchar *action_name) ...@@ -347,6 +355,12 @@ gimp_action_is_gui_blacklisted (const gchar *action_name)
return TRUE; return TRUE;
} }
for (i = 0; i < G_N_ELEMENTS (actions); i++)
{
if (! strcmp (action_name, actions[i]))
return TRUE;
}
return FALSE; return FALSE;
} }
......
...@@ -569,9 +569,9 @@ ...@@ -569,9 +569,9 @@
<menuitem action="filters-saturation" /> <menuitem action="filters-saturation" />
<menuitem action="filters-exposure" /> <menuitem action="filters-exposure" />
<menuitem action="filters-shadows-highlights" /> <menuitem action="filters-shadows-highlights" />
<menuitem action="tools-brightness-contrast" /> <menuitem action="filters-brightness-contrast" />
<menuitem action="tools-levels" /> <menuitem action="filters-levels" />
<menuitem action="tools-curves" /> <menuitem action="filters-curves" />
<separator /> <separator />
<placeholder name="Invert"> <placeholder name="Invert">
<menuitem action="filters-invert-perceptual" /> <menuitem action="filters-invert-perceptual" />
...@@ -616,7 +616,7 @@ ...@@ -616,7 +616,7 @@
<menuitem action="dialogs-histogram" /> <menuitem action="dialogs-histogram" />
</menu> </menu>
<separator /> <separator />
<menuitem action="tools-threshold" /> <menuitem action="filters-threshold" />
<menuitem action="filters-colorize" /> <menuitem action="filters-colorize" />
<menuitem action="filters-posterize" /> <menuitem action="filters-posterize" />
<menuitem action="filters-color-to-alpha" /> <menuitem action="filters-color-to-alpha" />
......
...@@ -280,12 +280,15 @@ app/operations/gimpcolorbalanceconfig.c ...@@ -280,12 +280,15 @@ app/operations/gimpcolorbalanceconfig.c
app/operations/gimpcurvesconfig.c app/operations/gimpcurvesconfig.c
app/operations/gimphuesaturationconfig.c app/operations/gimphuesaturationconfig.c
app/operations/gimplevelsconfig.c app/operations/gimplevelsconfig.c
app/operations/gimpoperationbrightnesscontrast.c
app/operations/gimpoperationcagecoefcalc.c app/operations/gimpoperationcagecoefcalc.c
app/operations/gimpoperationcagetransform.c app/operations/gimpoperationcagetransform.c
app/operations/gimpoperationcolorbalance.c app/operations/gimpoperationcolorbalance.c
app/operations/gimpoperationcolorize.c app/operations/gimpoperationcolorize.c
app/operations/gimpoperationcurves.c
app/operations/gimpoperationdesaturate.c app/operations/gimpoperationdesaturate.c
app/operations/gimpoperationhuesaturation.c app/operations/gimpoperationhuesaturation.c
app/operations/gimpoperationlevels.c
app/operations/gimpoperationposterize.c app/operations/gimpoperationposterize.c
app/operations/gimpoperationsemiflatten.c app/operations/gimpoperationsemiflatten.c
app/operations/gimpoperationthreshold.c app/operations/gimpoperationthreshold.c
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment