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

app: remove the colorize tool and replace it by a generic filter action

parent d2de5a0c
......@@ -213,6 +213,11 @@ static const GimpStringActionEntry filters_interactive_actions[] =
"gegl:color-exchange",
GIMP_HELP_FILTER_COLOR_EXCHANGE },
{ "filters-colorize", GIMP_ICON_TOOL_COLORIZE,
NC_("filters-action", "Colori_ze..."), NULL, NULL,
"gimp:colorize",
GIMP_HELP_TOOL_COLORIZE },
{ "filters-dither", GIMP_ICON_GEGL,
NC_("filters-action", "Dithe_r..."), NULL, NULL,
"gegl:dither",
......@@ -785,6 +790,7 @@ filters_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("filters-checkerboard", writable);
SET_SENSITIVE ("filters-color-enhance", writable && !gray);
SET_SENSITIVE ("filters-color-exchange", writable);
SET_SENSITIVE ("filters-colorize", writable && !gray);
SET_SENSITIVE ("filters-dither", writable);
SET_SENSITIVE ("filters-color-rotate", writable);
SET_SENSITIVE ("filters-color-temperature", writable && !gray);
......
......@@ -104,8 +104,8 @@ gimp_colorize_config_class_init (GimpColorizeConfigClass *klass)
g_object_class_install_property (object_class, PROP_COLOR,
gimp_param_spec_rgb ("color",
"Color",
"The color",
_("Color"),
_("Color"),
FALSE, &rgb,
G_PARAM_READWRITE));
}
......
......@@ -31,6 +31,8 @@
#include "gimpcolorizeconfig.h"
#include "gimpoperationcolorize.h"
#include "gimp-intl.h"
static gboolean gimp_operation_colorize_process (GeglOperation *operation,
void *in_buf,
......@@ -59,7 +61,7 @@ gimp_operation_colorize_class_init (GimpOperationColorizeClass *klass)
gegl_operation_class_set_keys (operation_class,
"name", "gimp:colorize",
"categories", "color",
"description", "GIMP Colorize operation",
"description", _("Colorize the image"),
NULL);
point_class->process = gimp_operation_colorize_process;
......
......@@ -54,8 +54,6 @@ libapptools_a_sources = \
gimpcolortool.h \
gimpcolorbalancetool.c \
gimpcolorbalancetool.h \
gimpcolorizetool.c \
gimpcolorizetool.h \
gimpcolorpickeroptions.c \
gimpcolorpickeroptions.h \
gimpcolorpickertool.c \
......
......@@ -47,7 +47,6 @@
#include "gimpcagetool.h"
#include "gimpclonetool.h"
#include "gimpcolorbalancetool.h"
#include "gimpcolorizetool.h"
#include "gimpcolorpickertool.h"
#include "gimpconvolvetool.h"
#include "gimpcroptool.h"
......@@ -179,7 +178,6 @@ gimp_tools_init (Gimp *gimp)
gimp_color_balance_tool_register,
gimp_hue_saturation_tool_register,
gimp_colorize_tool_register,
gimp_brightness_contrast_tool_register,
gimp_threshold_tool_register,
gimp_levels_tool_register,
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <string.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
#include "core/gimpdrawable.h"
#include "core/gimperror.h"
#include "core/gimpimage.h"
#include "widgets/gimpcolorpanel.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimpspinscale.h"
#include "display/gimpdisplay.h"
#include "gimpcolorizetool.h"
#include "gimpfilteroptions.h"
#include "gimp-intl.h"
/* local function prototypes */
static gboolean gimp_colorize_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
static gchar * gimp_colorize_tool_get_operation (GimpFilterTool *filter_tool,
gchar **title,
gchar **description,
gchar **undo_desc,
gchar **icon_name,
gchar **help_id,
gboolean *has_settings,
gchar **settings_folder,
gchar **import_dialog_title,
gchar **export_dialog_title);
static void gimp_colorize_tool_dialog (GimpFilterTool *filter_tool);
static void gimp_colorize_tool_color_picked (GimpFilterTool *filter_tool,
gpointer identifier,
gdouble x,
gdouble y,
const Babl *sample_format,
const GimpRGB *color);
G_DEFINE_TYPE (GimpColorizeTool, gimp_colorize_tool, GIMP_TYPE_FILTER_TOOL)
#define parent_class gimp_colorize_tool_parent_class
void
gimp_colorize_tool_register (GimpToolRegisterCallback callback,
gpointer data)
{
(* callback) (GIMP_TYPE_COLORIZE_TOOL,
GIMP_TYPE_FILTER_OPTIONS,
gimp_color_options_gui,
0,
"gimp-colorize-tool",
_("Colorize"),
_("Colorize Tool: Colorize the image"),
N_("Colori_ze..."), NULL,
NULL, GIMP_HELP_TOOL_COLORIZE,
GIMP_ICON_TOOL_COLORIZE,
data);
}
static void
gimp_colorize_tool_class_init (GimpColorizeToolClass *klass)
{
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpFilterToolClass *filter_tool_class = GIMP_FILTER_TOOL_CLASS (klass);
tool_class->initialize = gimp_colorize_tool_initialize;
filter_tool_class->get_operation = gimp_colorize_tool_get_operation;
filter_tool_class->dialog = gimp_colorize_tool_dialog;
filter_tool_class->color_picked = gimp_colorize_tool_color_picked;
}
static void
gimp_colorize_tool_init (GimpColorizeTool *col_tool)
{
}
static gboolean
gimp_colorize_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error)
{
GimpImage *image = gimp_display_get_image (display);
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
if (! drawable)
return FALSE;
if (gimp_drawable_is_gray (drawable))
{
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
_("Colorize does not operate on grayscale layers."));
return FALSE;
}
return GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
}
static gchar *
gimp_colorize_tool_get_operation (GimpFilterTool *filter_tool,
gchar **title,
gchar **description,
gchar **undo_desc,
gchar **icon_name,
gchar **help_id,
gboolean *has_settings,
gchar **settings_folder,
gchar **import_dialog_title,
gchar **export_dialog_title)
{
*description = g_strdup (_("Colorize the Image"));
*has_settings = TRUE;
*settings_folder = g_strdup ("colorize");
*import_dialog_title = g_strdup (_("Import Colorize Settings"));
*export_dialog_title = g_strdup (_("Export Colorize Settings"));
return g_strdup ("gimp:colorize");
}
/***************************/
/* Hue-Saturation dialog */
/***************************/
static void
gimp_colorize_tool_dialog (GimpFilterTool *filter_tool)
{
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (filter_tool);
GtkWidget *main_vbox;
GtkWidget *frame;
GtkWidget *vbox;
GtkWidget *scale;
GtkWidget *hbox;
GtkWidget *button;
main_vbox = gimp_filter_tool_dialog_get_vbox (filter_tool);
frame = gimp_frame_new (_("Select Color"));
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_widget_show (vbox);
/* Create the hue scale widget */
scale = gimp_prop_spin_scale_new (filter_tool->config, "hue",
_("_Hue"), 1.0 / 360.0, 15.0 / 360.0, 0);
gimp_prop_widget_set_factor (scale, 360.0, 0.0, 0.0, 1);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
/* Create the saturation scale widget */
scale = gimp_prop_spin_scale_new (filter_tool->config, "saturation",
_("_Saturation"), 0.01, 0.1, 0);
gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
/* Create the lightness scale widget */
scale = gimp_prop_spin_scale_new (filter_tool->config, "lightness",
_("_Lightness"), 0.01, 0.1, 0);
gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
/* Create the color button */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
button = gimp_prop_color_button_new (filter_tool->config, "color",
_("Colorize Color"),
128, 24,
GIMP_COLOR_AREA_FLAT);
gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button),
GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (col_tool)));
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
gtk_widget_show (button);
button = gimp_filter_tool_add_color_picker (filter_tool,
"colorize",
GIMP_ICON_COLOR_PICKER_GRAY,
_("Pick color from image"),
/* pick_abyss = */ FALSE);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
}
static void
gimp_colorize_tool_color_picked (GimpFilterTool *filter_tool,
gpointer identifier,
gdouble x,
gdouble y,
const Babl *sample_format,
const GimpRGB *color)
{
g_object_set (filter_tool->config, "color", color, NULL);
}
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_COLORIZE_TOOL_H__
#define __GIMP_COLORIZE_TOOL_H__
#include "gimpfiltertool.h"
#define GIMP_TYPE_COLORIZE_TOOL (gimp_colorize_tool_get_type ())
#define GIMP_COLORIZE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLORIZE_TOOL, GimpColorizeTool))
#define GIMP_COLORIZE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLORIZE_TOOL, GimpColorizeToolClass))
#define GIMP_IS_COLORIZE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLORIZE_TOOL))
#define GIMP_IS_COLORIZE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLORIZE_TOOL))
#define GIMP_COLORIZE_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLORIZE_TOOL, GimpColorizeToolClass))
typedef struct _GimpColorizeTool GimpColorizeTool;
typedef struct _GimpColorizeToolClass GimpColorizeToolClass;
struct _GimpColorizeTool
{
GimpFilterTool parent_instance;
};
struct _GimpColorizeToolClass
{
GimpFilterToolClass parent_class;
};
void gimp_colorize_tool_register (GimpToolRegisterCallback callback,
gpointer data);
GType gimp_colorize_tool_get_type (void) G_GNUC_CONST;
#endif /* __GIMP_COLORIZE_TOOL_H__ */
......@@ -610,7 +610,7 @@
</menu>
<separator />
<menuitem action="tools-threshold" />
<menuitem action="tools-colorize" />
<menuitem action="filters-colorize" />
<menuitem action="filters-posterize" />
<menuitem action="filters-color-to-alpha" />
<menuitem action="filters-dither" />
......@@ -666,7 +666,6 @@
<menu action="tools-color-menu" name="Color Tools">
<menuitem action="tools-color-balance" />
<menuitem action="tools-hue-saturation" />
<menuitem action="tools-colorize" />
<menuitem action="tools-brightness-contrast" />
<menuitem action="tools-threshold" />
<menuitem action="tools-levels" />
......
......@@ -271,6 +271,7 @@ app/operations/gimphuesaturationconfig.c
app/operations/gimplevelsconfig.c
app/operations/gimpoperationcagecoefcalc.c
app/operations/gimpoperationcagetransform.c
app/operations/gimpoperationcolorize.c
app/operations/gimpoperationdesaturate.c
app/operations/gimpoperationposterize.c
app/operations/gimpoperationsemiflatten.c
......@@ -381,7 +382,6 @@ app/tools/gimpcagetool.c
app/tools/gimpcloneoptions-gui.c
app/tools/gimpclonetool.c
app/tools/gimpcolorbalancetool.c
app/tools/gimpcolorizetool.c
app/tools/gimpcoloroptions.c
app/tools/gimpcolorpickeroptions.c
app/tools/gimpcolorpickertool.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