1
/* The GIMP -- an image manipulation program
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
#include "libgimpwidgets/gimpwidgets.h"
25
#include "tools-types.h"
27
#include "core/gimptoolinfo.h"
29
#include "paint/gimperaseroptions.h"
31
#include "widgets/gimphelp-ids.h"
32
#include "widgets/gimppropwidgets.h"
33
#include "widgets/gimpwidgets-utils.h"
35
#include "gimperasertool.h"
36
#include "gimppaintoptions-gui.h"
37
#include "gimptoolcontrol.h"
39
#include "gimp-intl.h"
42
static void gimp_eraser_tool_class_init (GimpEraserToolClass *klass);
43
static void gimp_eraser_tool_init (GimpEraserTool *eraser);
45
static void gimp_eraser_tool_modifier_key (GimpTool *tool,
48
GdkModifierType state,
50
static void gimp_eraser_tool_cursor_update (GimpTool *tool,
52
GdkModifierType state,
55
static GtkWidget * gimp_eraser_options_gui (GimpToolOptions *tool_options);
58
static GimpPaintToolClass *parent_class = NULL;
62
gimp_eraser_tool_register (GimpToolRegisterCallback callback,
65
(* callback) (GIMP_TYPE_ERASER_TOOL,
66
GIMP_TYPE_ERASER_OPTIONS,
67
gimp_eraser_options_gui,
68
GIMP_PAINT_OPTIONS_CONTEXT_MASK,
71
_("Erase to background or transparency"),
72
N_("_Eraser"), "<shift>E",
73
NULL, GIMP_HELP_TOOL_ERASER,
74
GIMP_STOCK_TOOL_ERASER,
79
gimp_eraser_tool_get_type (void)
81
static GType tool_type = 0;
85
static const GTypeInfo tool_info =
87
sizeof (GimpEraserToolClass),
89
(GBaseFinalizeFunc) NULL,
90
(GClassInitFunc) gimp_eraser_tool_class_init,
91
NULL, /* class_finalize */
92
NULL, /* class_data */
93
sizeof (GimpEraserTool),
95
(GInstanceInitFunc) gimp_eraser_tool_init,
98
tool_type = g_type_register_static (GIMP_TYPE_PAINT_TOOL,
107
gimp_eraser_tool_class_init (GimpEraserToolClass *klass)
109
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
111
parent_class = g_type_class_peek_parent (klass);
113
tool_class->modifier_key = gimp_eraser_tool_modifier_key;
114
tool_class->cursor_update = gimp_eraser_tool_cursor_update;
118
gimp_eraser_tool_init (GimpEraserTool *eraser)
120
GimpTool *tool = GIMP_TOOL (eraser);
122
gimp_tool_control_set_tool_cursor (tool->control,
123
GIMP_TOOL_CURSOR_ERASER);
124
gimp_tool_control_set_toggle_tool_cursor (tool->control,
125
GIMP_TOOL_CURSOR_ERASER);
126
gimp_tool_control_set_toggle_cursor_modifier (tool->control,
127
GIMP_CURSOR_MODIFIER_MINUS);
129
gimp_paint_tool_enable_color_picker (GIMP_PAINT_TOOL (eraser),
130
GIMP_COLOR_PICK_MODE_BACKGROUND);
134
gimp_eraser_tool_modifier_key (GimpTool *tool,
137
GdkModifierType state,
140
if (key == GDK_MOD1_MASK)
142
GimpEraserOptions *options;
144
options = GIMP_ERASER_OPTIONS (tool->tool_info->tool_options);
146
g_object_set (options,
147
"anti-erase", ! options->anti_erase,
151
GIMP_TOOL_CLASS (parent_class)->modifier_key (tool, key, press, state, gdisp);
155
gimp_eraser_tool_cursor_update (GimpTool *tool,
157
GdkModifierType state,
160
GimpEraserOptions *options;
162
options = GIMP_ERASER_OPTIONS (tool->tool_info->tool_options);
164
gimp_tool_control_set_toggle (tool->control, options->anti_erase);
166
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
170
/* tool options stuff */
173
gimp_eraser_options_gui (GimpToolOptions *tool_options)
180
config = G_OBJECT (tool_options);
182
vbox = gimp_paint_options_gui (tool_options);
184
/* the anti_erase toggle */
185
str = g_strdup_printf (_("Anti erase %s"),
186
gimp_get_mod_string (GDK_MOD1_MASK));
188
button = gimp_prop_check_button_new (config, "anti-erase", str);
189
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
190
gtk_widget_show (button);