mirror of https://github.com/GNOME/gimp.git
app: turn the desaturate tool into a normal GEGL filter
This commit is contained in:
parent
6f6922006c
commit
149d3f441f
|
@ -187,6 +187,11 @@ static const GimpStringActionEntry filters_actions[] =
|
|||
"gegl:deinterlace",
|
||||
NULL /* FIXME GIMP_HELP_FILTER_DEINTERLACE */ },
|
||||
|
||||
{ "filters-desaturate", GIMP_STOCK_TOOL_DESATURATE,
|
||||
NC_("filters-action", "_Desaturate..."), NULL, NULL,
|
||||
"gimp:desaturate",
|
||||
GIMP_HELP_TOOL_DESATURATE },
|
||||
|
||||
{ "filters-difference-of-gaussians", GIMP_STOCK_GEGL,
|
||||
NC_("filters-action", "Difference of Gaussians..."), NULL, NULL,
|
||||
"gegl:difference-of-gaussians",
|
||||
|
@ -651,6 +656,7 @@ filters_actions_update (GimpActionGroup *group,
|
|||
SET_SENSITIVE ("filters-convolution-matrix", writable);
|
||||
SET_SENSITIVE ("filters-cubism", writable);
|
||||
SET_SENSITIVE ("filters-deinterlace", writable);
|
||||
SET_SENSITIVE ("filters-desaturate", writable && !gray);
|
||||
SET_SENSITIVE ("filters-difference-of-gaussians", writable);
|
||||
SET_SENSITIVE ("filters-diffraction-patterns", writable);
|
||||
SET_SENSITIVE ("filters-displace", writable);
|
||||
|
|
|
@ -33,8 +33,6 @@ libappoperations_generic_a_sources = \
|
|||
gimpcolorizeconfig.h \
|
||||
gimpcurvesconfig.c \
|
||||
gimpcurvesconfig.h \
|
||||
gimpdesaturateconfig.c \
|
||||
gimpdesaturateconfig.h \
|
||||
gimphuesaturationconfig.c \
|
||||
gimphuesaturationconfig.h \
|
||||
gimplevelsconfig.c \
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpdesaturateconfig.c
|
||||
* Copyright (C) 2008 Sven Neumann <sven@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
|
||||
* 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 <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <gegl.h>
|
||||
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
|
||||
#include "operations-types.h"
|
||||
|
||||
#include "gimpdesaturateconfig.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_MODE
|
||||
};
|
||||
|
||||
|
||||
static void gimp_desaturate_config_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_desaturate_config_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpDesaturateConfig, gimp_desaturate_config,
|
||||
GIMP_TYPE_SETTINGS,
|
||||
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, NULL))
|
||||
|
||||
#define parent_class gimp_desaturate_config_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_desaturate_config_class_init (GimpDesaturateConfigClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
|
||||
|
||||
object_class->set_property = gimp_desaturate_config_set_property;
|
||||
object_class->get_property = gimp_desaturate_config_get_property;
|
||||
|
||||
/*FIXME: change string when a desaturate icon gets added */
|
||||
viewable_class->default_icon_name = "gimp-convert-grayscale";
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_MODE,
|
||||
"mode",
|
||||
_("Desaturate mode"),
|
||||
GIMP_TYPE_DESATURATE_MODE,
|
||||
GIMP_DESATURATE_LIGHTNESS, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_desaturate_config_init (GimpDesaturateConfig *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_desaturate_config_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpDesaturateConfig *self = GIMP_DESATURATE_CONFIG (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_MODE:
|
||||
g_value_set_enum (value, self->mode);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_desaturate_config_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpDesaturateConfig *self = GIMP_DESATURATE_CONFIG (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_MODE:
|
||||
self->mode = g_value_get_enum (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpdesaturateconfig.h
|
||||
* Copyright (C) 2008 Sven Neumann <sven@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
|
||||
* 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_DESATURATE_CONFIG_H__
|
||||
#define __GIMP_DESATURATE_CONFIG_H__
|
||||
|
||||
|
||||
#include "core/gimpsettings.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_DESATURATE_CONFIG (gimp_desaturate_config_get_type ())
|
||||
#define GIMP_DESATURATE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DESATURATE_CONFIG, GimpDesaturateConfig))
|
||||
#define GIMP_DESATURATE_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DESATURATE_CONFIG, GimpDesaturateConfigClass))
|
||||
#define GIMP_IS_DESATURATE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DESATURATE_CONFIG))
|
||||
#define GIMP_IS_DESATURATE_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DESATURATE_CONFIG))
|
||||
#define GIMP_DESATURATE_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_DESATURATE_CONFIG, GimpDesaturateConfigClass))
|
||||
|
||||
|
||||
typedef struct _GimpDesaturateConfigClass GimpDesaturateConfigClass;
|
||||
|
||||
struct _GimpDesaturateConfig
|
||||
{
|
||||
GimpSettings parent_instance;
|
||||
|
||||
GimpDesaturateMode mode;
|
||||
};
|
||||
|
||||
struct _GimpDesaturateConfigClass
|
||||
{
|
||||
GimpSettingsClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_desaturate_config_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_DESATURATE_CONFIG_H__ */
|
|
@ -25,20 +25,38 @@
|
|||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
|
||||
#include "operations-types.h"
|
||||
|
||||
#include "gimpoperationdesaturate.h"
|
||||
#include "gimpdesaturateconfig.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static void gimp_operation_desaturate_prepare (GeglOperation *operation);
|
||||
static gboolean gimp_operation_desaturate_process (GeglOperation *operation,
|
||||
void *in_buf,
|
||||
void *out_buf,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_MODE
|
||||
};
|
||||
|
||||
|
||||
static void gimp_operation_desaturate_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_operation_desaturate_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gimp_operation_desaturate_prepare (GeglOperation *operation);
|
||||
static gboolean gimp_operation_desaturate_process (GeglOperation *operation,
|
||||
void *in_buf,
|
||||
void *out_buf,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpOperationDesaturate, gimp_operation_desaturate,
|
||||
|
@ -54,27 +72,24 @@ gimp_operation_desaturate_class_init (GimpOperationDesaturateClass *klass)
|
|||
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
|
||||
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
|
||||
|
||||
object_class->set_property = gimp_operation_point_filter_set_property;
|
||||
object_class->get_property = gimp_operation_point_filter_get_property;
|
||||
object_class->set_property = gimp_operation_desaturate_set_property;
|
||||
object_class->get_property = gimp_operation_desaturate_get_property;
|
||||
|
||||
operation_class->prepare = gimp_operation_desaturate_prepare;
|
||||
|
||||
point_class->process = gimp_operation_desaturate_process;
|
||||
|
||||
gegl_operation_class_set_keys (operation_class,
|
||||
"name", "gimp:desaturate",
|
||||
"categories", "color",
|
||||
"description", "GIMP Desaturate operation",
|
||||
"description", _("Turn colors into shades of gray"),
|
||||
NULL);
|
||||
|
||||
operation_class->prepare = gimp_operation_desaturate_prepare;
|
||||
|
||||
point_class->process = gimp_operation_desaturate_process;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
|
||||
g_param_spec_object ("config",
|
||||
"Config",
|
||||
"The config object",
|
||||
GIMP_TYPE_DESATURATE_CONFIG,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_MODE,
|
||||
"mode",
|
||||
_("Choose shade of gray based on"),
|
||||
GIMP_TYPE_DESATURATE_MODE,
|
||||
GIMP_DESATURATE_LIGHTNESS, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -82,14 +97,53 @@ gimp_operation_desaturate_init (GimpOperationDesaturate *self)
|
|||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_operation_desaturate_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpOperationDesaturate *desaturate = GIMP_OPERATION_DESATURATE (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_MODE:
|
||||
g_value_set_enum (value, desaturate->mode);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_operation_desaturate_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpOperationDesaturate *desaturate = GIMP_OPERATION_DESATURATE (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_MODE:
|
||||
desaturate->mode = g_value_get_enum (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_operation_desaturate_prepare (GeglOperation *operation)
|
||||
{
|
||||
GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
|
||||
GimpDesaturateConfig *config = GIMP_DESATURATE_CONFIG (point->config);
|
||||
const Babl *format;
|
||||
GimpOperationDesaturate *desaturate = GIMP_OPERATION_DESATURATE (operation);
|
||||
const Babl *format;
|
||||
|
||||
if (config->mode == GIMP_DESATURATE_LUMINANCE)
|
||||
if (desaturate->mode == GIMP_DESATURATE_LUMINANCE)
|
||||
{
|
||||
format = babl_format ("RGBA float");
|
||||
}
|
||||
|
@ -110,15 +164,11 @@ gimp_operation_desaturate_process (GeglOperation *operation,
|
|||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
|
||||
GimpDesaturateConfig *config = GIMP_DESATURATE_CONFIG (point->config);
|
||||
gfloat *src = in_buf;
|
||||
gfloat *dest = out_buf;
|
||||
GimpOperationDesaturate *desaturate = GIMP_OPERATION_DESATURATE (operation);
|
||||
gfloat *src = in_buf;
|
||||
gfloat *dest = out_buf;
|
||||
|
||||
if (! config)
|
||||
return FALSE;
|
||||
|
||||
switch (config->mode)
|
||||
switch (desaturate->mode)
|
||||
{
|
||||
case GIMP_DESATURATE_LIGHTNESS:
|
||||
while (samples--)
|
||||
|
|
|
@ -39,6 +39,8 @@ typedef struct _GimpOperationDesaturateClass GimpOperationDesaturateClass;
|
|||
struct _GimpOperationDesaturate
|
||||
{
|
||||
GimpOperationPointFilter parent_instance;
|
||||
|
||||
GimpDesaturateMode mode;
|
||||
};
|
||||
|
||||
struct _GimpOperationDesaturateClass
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "operations/gimpcolorbalanceconfig.h"
|
||||
#include "operations/gimpcolorizeconfig.h"
|
||||
#include "operations/gimpcurvesconfig.h"
|
||||
#include "operations/gimpdesaturateconfig.h"
|
||||
#include "operations/gimphuesaturationconfig.h"
|
||||
#include "operations/gimplevelsconfig.h"
|
||||
#include "operations/gimpthresholdconfig.h"
|
||||
|
@ -276,15 +275,16 @@ desaturate_invoker (GimpProcedure *procedure,
|
|||
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
|
||||
gimp_drawable_is_rgb (drawable))
|
||||
{
|
||||
GObject *config = g_object_new (GIMP_TYPE_DESATURATE_CONFIG,
|
||||
"mode", GIMP_DESATURATE_LIGHTNESS,
|
||||
NULL);
|
||||
GeglNode *node =
|
||||
gegl_node_new_child (NULL,
|
||||
"operation", "gimp:desaturate",
|
||||
"mode", GIMP_DESATURATE_LIGHTNESS,
|
||||
NULL);
|
||||
|
||||
gimp_drawable_apply_operation_by_name (drawable, progress,
|
||||
_("Desaturate"),
|
||||
"gimp:desaturate",
|
||||
config);
|
||||
g_object_unref (config);
|
||||
gimp_drawable_apply_operation (drawable, progress,
|
||||
C_("undo-type", "Desaturate"),
|
||||
node);
|
||||
g_object_unref (node);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
|
@ -316,15 +316,16 @@ desaturate_full_invoker (GimpProcedure *procedure,
|
|||
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
|
||||
gimp_drawable_is_rgb (drawable))
|
||||
{
|
||||
GObject *config = g_object_new (GIMP_TYPE_DESATURATE_CONFIG,
|
||||
"mode", desaturate_mode,
|
||||
NULL);
|
||||
GeglNode *node =
|
||||
gegl_node_new_child (NULL,
|
||||
"operation", "gimp:desaturate",
|
||||
"mode", desaturate_mode,
|
||||
NULL);
|
||||
|
||||
gimp_drawable_apply_operation_by_name (drawable, progress,
|
||||
_("Desaturate"),
|
||||
"gimp:desaturate",
|
||||
config);
|
||||
g_object_unref (config);
|
||||
gimp_drawable_apply_operation (drawable, progress,
|
||||
C_("undo-type", "Desaturate"),
|
||||
node);
|
||||
g_object_unref (node);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "operations/gimpcolorbalanceconfig.h"
|
||||
#include "operations/gimpcolorizeconfig.h"
|
||||
#include "operations/gimpcurvesconfig.h"
|
||||
#include "operations/gimpdesaturateconfig.h"
|
||||
#include "operations/gimphuesaturationconfig.h"
|
||||
#include "operations/gimplevelsconfig.h"
|
||||
#include "operations/gimpthresholdconfig.h"
|
||||
|
@ -315,15 +314,16 @@ drawable_desaturate_invoker (GimpProcedure *procedure,
|
|||
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
|
||||
gimp_drawable_is_rgb (drawable))
|
||||
{
|
||||
GObject *config = g_object_new (GIMP_TYPE_DESATURATE_CONFIG,
|
||||
"mode", desaturate_mode,
|
||||
NULL);
|
||||
GeglNode *node =
|
||||
gegl_node_new_child (NULL,
|
||||
"operation", "gimp:desaturate",
|
||||
"mode", desaturate_mode,
|
||||
NULL);
|
||||
|
||||
gimp_drawable_apply_operation_by_name (drawable, progress,
|
||||
C_("undo-type", "Desaturate"),
|
||||
"gimp:desaturate",
|
||||
config);
|
||||
g_object_unref (config);
|
||||
gimp_drawable_apply_operation (drawable, progress,
|
||||
C_("undo-type", "Desaturate"),
|
||||
node);
|
||||
g_object_unref (node);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
|
|
|
@ -68,8 +68,6 @@ libapptools_a_sources = \
|
|||
gimpcroptool.h \
|
||||
gimpcurvestool.c \
|
||||
gimpcurvestool.h \
|
||||
gimpdesaturatetool.c \
|
||||
gimpdesaturatetool.h \
|
||||
gimpdodgeburntool.c \
|
||||
gimpdodgeburntool.h \
|
||||
gimpdrawtool.c \
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
#include "gimpconvolvetool.h"
|
||||
#include "gimpcroptool.h"
|
||||
#include "gimpcurvestool.h"
|
||||
#include "gimpdesaturatetool.h"
|
||||
#include "gimpdodgeburntool.h"
|
||||
#include "gimpellipseselecttool.h"
|
||||
#include "gimperasertool.h"
|
||||
|
@ -133,7 +132,6 @@ gimp_tools_init (Gimp *gimp)
|
|||
gimp_colorize_tool_register,
|
||||
gimp_hue_saturation_tool_register,
|
||||
gimp_color_balance_tool_register,
|
||||
gimp_desaturate_tool_register,
|
||||
|
||||
/* paint tools */
|
||||
|
||||
|
|
|
@ -1,146 +0,0 @@
|
|||
/* 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 <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "tools-types.h"
|
||||
|
||||
#include "operations/gimpdesaturateconfig.h"
|
||||
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimperror.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
|
||||
#include "gimpimagemapoptions.h"
|
||||
#include "gimpdesaturatetool.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static gboolean gimp_desaturate_tool_initialize (GimpTool *tool,
|
||||
GimpDisplay *display,
|
||||
GError **error);
|
||||
|
||||
static GeglNode * gimp_desaturate_tool_get_operation (GimpImageMapTool *im_tool,
|
||||
GObject **config,
|
||||
gchar **undo_desc);
|
||||
static void gimp_desaturate_tool_dialog (GimpImageMapTool *im_tool);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpDesaturateTool, gimp_desaturate_tool,
|
||||
GIMP_TYPE_IMAGE_MAP_TOOL)
|
||||
|
||||
#define parent_class gimp_desaturate_tool_parent_class
|
||||
|
||||
|
||||
void
|
||||
gimp_desaturate_tool_register (GimpToolRegisterCallback callback,
|
||||
gpointer data)
|
||||
{
|
||||
(* callback) (GIMP_TYPE_DESATURATE_TOOL,
|
||||
GIMP_TYPE_IMAGE_MAP_OPTIONS, NULL,
|
||||
0,
|
||||
"gimp-desaturate-tool",
|
||||
_("Desaturate"),
|
||||
_("Desaturate Tool: Turn colors into shades of gray"),
|
||||
N_("_Desaturate..."), NULL,
|
||||
NULL, GIMP_HELP_TOOL_DESATURATE,
|
||||
GIMP_STOCK_TOOL_DESATURATE,
|
||||
data);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_desaturate_tool_class_init (GimpDesaturateToolClass *klass)
|
||||
{
|
||||
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
||||
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
|
||||
|
||||
tool_class->initialize = gimp_desaturate_tool_initialize;
|
||||
|
||||
im_tool_class->dialog_desc = _("Desaturate (Remove Colors)");
|
||||
|
||||
im_tool_class->get_operation = gimp_desaturate_tool_get_operation;
|
||||
im_tool_class->dialog = gimp_desaturate_tool_dialog;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_desaturate_tool_init (GimpDesaturateTool *desaturate_tool)
|
||||
{
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_desaturate_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_rgb (drawable))
|
||||
{
|
||||
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
|
||||
_("Desaturate only operates on RGB layers."));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
|
||||
}
|
||||
|
||||
static GeglNode *
|
||||
gimp_desaturate_tool_get_operation (GimpImageMapTool *image_map_tool,
|
||||
GObject **config,
|
||||
gchar **undo_desc)
|
||||
{
|
||||
*config = g_object_new (GIMP_TYPE_DESATURATE_CONFIG, NULL);
|
||||
|
||||
return gegl_node_new_child (NULL,
|
||||
"operation", "gimp:desaturate",
|
||||
"config", *config,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/***********************/
|
||||
/* Desaturate dialog */
|
||||
/***********************/
|
||||
|
||||
static void
|
||||
gimp_desaturate_tool_dialog (GimpImageMapTool *image_map_tool)
|
||||
{
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *frame;
|
||||
|
||||
main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool);
|
||||
|
||||
frame = gimp_prop_enum_radio_frame_new (image_map_tool->config, "mode",
|
||||
_("Choose shade of gray based on:"),
|
||||
0, 0);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
/* 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_DESATURATE_TOOL_H__
|
||||
#define __GIMP_DESATURATE_TOOL_H__
|
||||
|
||||
|
||||
#include "gimpimagemaptool.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_DESATURATE_TOOL (gimp_desaturate_tool_get_type ())
|
||||
#define GIMP_DESATURATE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DESATURATE_TOOL, GimpDesaturateTool))
|
||||
#define GIMP_DESATURATE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DESATURATE_TOOL, GimpDesaturateToolClass))
|
||||
#define GIMP_IS_DESATURATE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DESATURATE_TOOL))
|
||||
#define GIMP_IS_DESATURATE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DESATURATE_TOOL))
|
||||
#define GIMP_DESATURATE_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_DESATURATE_TOOL, GimpDesaturateToolClass))
|
||||
|
||||
|
||||
typedef struct _GimpDesaturateTool GimpDesaturateTool;
|
||||
typedef struct _GimpDesaturateToolClass GimpDesaturateToolClass;
|
||||
|
||||
struct _GimpDesaturateTool
|
||||
{
|
||||
GimpImageMapTool parent_instance;
|
||||
};
|
||||
|
||||
struct _GimpDesaturateToolClass
|
||||
{
|
||||
GimpImageMapToolClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
void gimp_desaturate_tool_register (GimpToolRegisterCallback callback,
|
||||
gpointer data);
|
||||
|
||||
GType gimp_desaturate_tool_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_DESATURATE_TOOL_H__ */
|
|
@ -533,7 +533,7 @@
|
|||
<menuitem action="tools-levels" />
|
||||
<menuitem action="tools-curves" />
|
||||
<menuitem action="filters-posterize" />
|
||||
<menuitem action="tools-desaturate" />
|
||||
<menuitem action="filters-desaturate" />
|
||||
<separator />
|
||||
<placeholder name="Invert">
|
||||
<menuitem action="drawable-invert" />
|
||||
|
@ -627,7 +627,6 @@
|
|||
<menuitem action="tools-threshold" />
|
||||
<menuitem action="tools-levels" />
|
||||
<menuitem action="tools-curves" />
|
||||
<menuitem action="tools-desaturate" />
|
||||
</menu>
|
||||
<menuitem action="tools-vector" />
|
||||
<menuitem action="tools-color-picker" />
|
||||
|
|
|
@ -249,11 +249,11 @@ app/operations/gimpbrightnesscontrastconfig.c
|
|||
app/operations/gimpcolorbalanceconfig.c
|
||||
app/operations/gimpcolorizeconfig.c
|
||||
app/operations/gimpcurvesconfig.c
|
||||
app/operations/gimpdesaturateconfig.c
|
||||
app/operations/gimphuesaturationconfig.c
|
||||
app/operations/gimplevelsconfig.c
|
||||
app/operations/gimpoperationcagecoefcalc.c
|
||||
app/operations/gimpoperationcagetransform.c
|
||||
app/operations/gimpoperationdesaturate.c
|
||||
app/operations/gimpoperationposterize.c
|
||||
app/operations/gimpoperationsemiflatten.c
|
||||
app/operations/gimpoperationthresholdalpha.c
|
||||
|
@ -365,7 +365,6 @@ app/tools/gimpconvolvetool.c
|
|||
app/tools/gimpcropoptions.c
|
||||
app/tools/gimpcroptool.c
|
||||
app/tools/gimpcurvestool.c
|
||||
app/tools/gimpdesaturatetool.c
|
||||
app/tools/gimpdodgeburntool.c
|
||||
app/tools/gimpeditselectiontool.c
|
||||
app/tools/gimpellipseselecttool.c
|
||||
|
|
|
@ -204,7 +204,6 @@ sub desaturate {
|
|||
);
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("operations/gimpdesaturateconfig.h") ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
|
||||
|
@ -212,15 +211,16 @@ sub desaturate {
|
|||
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
|
||||
gimp_drawable_is_rgb (drawable))
|
||||
{
|
||||
GObject *config = g_object_new (GIMP_TYPE_DESATURATE_CONFIG,
|
||||
"mode", GIMP_DESATURATE_LIGHTNESS,
|
||||
NULL);
|
||||
GeglNode *node =
|
||||
gegl_node_new_child (NULL,
|
||||
"operation", "gimp:desaturate",
|
||||
"mode", GIMP_DESATURATE_LIGHTNESS,
|
||||
NULL);
|
||||
|
||||
gimp_drawable_apply_operation_by_name (drawable, progress,
|
||||
_("Desaturate"),
|
||||
"gimp:desaturate",
|
||||
config);
|
||||
g_object_unref (config);
|
||||
gimp_drawable_apply_operation (drawable, progress,
|
||||
C_("undo-type", "Desaturate"),
|
||||
node);
|
||||
g_object_unref (node);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
|
@ -241,7 +241,6 @@ sub desaturate_full {
|
|||
);
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("operations/gimpdesaturateconfig.h") ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
|
||||
|
@ -249,15 +248,16 @@ sub desaturate_full {
|
|||
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
|
||||
gimp_drawable_is_rgb (drawable))
|
||||
{
|
||||
GObject *config = g_object_new (GIMP_TYPE_DESATURATE_CONFIG,
|
||||
"mode", desaturate_mode,
|
||||
NULL);
|
||||
GeglNode *node =
|
||||
gegl_node_new_child (NULL,
|
||||
"operation", "gimp:desaturate",
|
||||
"mode", desaturate_mode,
|
||||
NULL);
|
||||
|
||||
gimp_drawable_apply_operation_by_name (drawable, progress,
|
||||
_("Desaturate"),
|
||||
"gimp:desaturate",
|
||||
config);
|
||||
g_object_unref (config);
|
||||
gimp_drawable_apply_operation (drawable, progress,
|
||||
C_("undo-type", "Desaturate"),
|
||||
node);
|
||||
g_object_unref (node);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
|
|
|
@ -313,7 +313,6 @@ HELP
|
|||
);
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("operations/gimpdesaturateconfig.h") ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
|
||||
|
@ -321,15 +320,16 @@ HELP
|
|||
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
|
||||
gimp_drawable_is_rgb (drawable))
|
||||
{
|
||||
GObject *config = g_object_new (GIMP_TYPE_DESATURATE_CONFIG,
|
||||
"mode", desaturate_mode,
|
||||
NULL);
|
||||
GeglNode *node =
|
||||
gegl_node_new_child (NULL,
|
||||
"operation", "gimp:desaturate",
|
||||
"mode", desaturate_mode,
|
||||
NULL);
|
||||
|
||||
gimp_drawable_apply_operation_by_name (drawable, progress,
|
||||
C_("undo-type", "Desaturate"),
|
||||
"gimp:desaturate",
|
||||
config);
|
||||
g_object_unref (config);
|
||||
gimp_drawable_apply_operation (drawable, progress,
|
||||
C_("undo-type", "Desaturate"),
|
||||
node);
|
||||
g_object_unref (node);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
|
|
Loading…
Reference in New Issue