~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/tools/gimperasertool.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
24
24
 
25
25
#include "tools-types.h"
26
26
 
27
 
#include "core/gimptoolinfo.h"
28
 
 
29
27
#include "paint/gimperaseroptions.h"
30
28
 
31
29
#include "widgets/gimphelp-ids.h"
32
 
#include "widgets/gimppropwidgets.h"
33
30
#include "widgets/gimpwidgets-utils.h"
34
31
 
35
32
#include "gimperasertool.h"
39
36
#include "gimp-intl.h"
40
37
 
41
38
 
42
 
static void   gimp_eraser_tool_class_init    (GimpEraserToolClass  *klass);
43
 
static void   gimp_eraser_tool_init          (GimpEraserTool       *eraser);
44
 
 
45
 
static void   gimp_eraser_tool_modifier_key  (GimpTool             *tool,
46
 
                                              GdkModifierType       key,
47
 
                                              gboolean              press,
48
 
                                              GdkModifierType       state,
49
 
                                              GimpDisplay          *gdisp);
50
 
static void   gimp_eraser_tool_cursor_update (GimpTool             *tool,
51
 
                                              GimpCoords           *coords,
52
 
                                              GdkModifierType       state,
53
 
                                              GimpDisplay          *gdisp);
54
 
 
55
 
static GtkWidget * gimp_eraser_options_gui   (GimpToolOptions      *tool_options);
56
 
 
57
 
 
58
 
static GimpPaintToolClass *parent_class = NULL;
 
39
static void   gimp_eraser_tool_modifier_key  (GimpTool        *tool,
 
40
                                              GdkModifierType  key,
 
41
                                              gboolean         press,
 
42
                                              GdkModifierType  state,
 
43
                                              GimpDisplay     *display);
 
44
static void   gimp_eraser_tool_cursor_update (GimpTool        *tool,
 
45
                                              GimpCoords      *coords,
 
46
                                              GdkModifierType  state,
 
47
                                              GimpDisplay     *display);
 
48
 
 
49
static GtkWidget * gimp_eraser_options_gui   (GimpToolOptions *tool_options);
 
50
 
 
51
 
 
52
G_DEFINE_TYPE (GimpEraserTool, gimp_eraser_tool, GIMP_TYPE_BRUSH_TOOL)
 
53
 
 
54
#define parent_class gimp_eraser_tool_parent_class
59
55
 
60
56
 
61
57
void
68
64
                GIMP_PAINT_OPTIONS_CONTEXT_MASK,
69
65
                "gimp-eraser-tool",
70
66
                _("Eraser"),
71
 
                _("Erase to background or transparency"),
 
67
                _("Eraser Tool: Erase to background or transparency using a brush"),
72
68
                N_("_Eraser"), "<shift>E",
73
69
                NULL, GIMP_HELP_TOOL_ERASER,
74
70
                GIMP_STOCK_TOOL_ERASER,
75
71
                data);
76
72
}
77
73
 
78
 
GType
79
 
gimp_eraser_tool_get_type (void)
80
 
{
81
 
  static GType tool_type = 0;
82
 
 
83
 
  if (! tool_type)
84
 
    {
85
 
      static const GTypeInfo tool_info =
86
 
      {
87
 
        sizeof (GimpEraserToolClass),
88
 
        (GBaseInitFunc) NULL,
89
 
        (GBaseFinalizeFunc) NULL,
90
 
        (GClassInitFunc) gimp_eraser_tool_class_init,
91
 
        NULL,           /* class_finalize */
92
 
        NULL,           /* class_data     */
93
 
        sizeof (GimpEraserTool),
94
 
        0,              /* n_preallocs    */
95
 
        (GInstanceInitFunc) gimp_eraser_tool_init,
96
 
      };
97
 
 
98
 
      tool_type = g_type_register_static (GIMP_TYPE_PAINT_TOOL,
99
 
                                          "GimpEraserTool",
100
 
                                          &tool_info, 0);
101
 
    }
102
 
 
103
 
  return tool_type;
104
 
}
105
 
 
106
74
static void
107
75
gimp_eraser_tool_class_init (GimpEraserToolClass *klass)
108
76
{
109
77
  GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
110
78
 
111
 
  parent_class = g_type_class_peek_parent (klass);
112
 
 
113
79
  tool_class->modifier_key  = gimp_eraser_tool_modifier_key;
114
80
  tool_class->cursor_update = gimp_eraser_tool_cursor_update;
115
81
}
117
83
static void
118
84
gimp_eraser_tool_init (GimpEraserTool *eraser)
119
85
{
120
 
  GimpTool *tool = GIMP_TOOL (eraser);
 
86
  GimpTool      *tool       = GIMP_TOOL (eraser);
 
87
  GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (eraser);
121
88
 
122
89
  gimp_tool_control_set_tool_cursor            (tool->control,
123
90
                                                GIMP_TOOL_CURSOR_ERASER);
124
 
  gimp_tool_control_set_toggle_tool_cursor     (tool->control,
125
 
                                                GIMP_TOOL_CURSOR_ERASER);
126
91
  gimp_tool_control_set_toggle_cursor_modifier (tool->control,
127
92
                                                GIMP_CURSOR_MODIFIER_MINUS);
128
93
 
129
 
  gimp_paint_tool_enable_color_picker (GIMP_PAINT_TOOL (eraser),
 
94
  gimp_paint_tool_enable_color_picker (paint_tool,
130
95
                                       GIMP_COLOR_PICK_MODE_BACKGROUND);
 
96
 
 
97
  paint_tool->status      = _("Click to erase");
 
98
  paint_tool->status_line = _("Click to erase the line");
 
99
  paint_tool->status_ctrl = _("%s to pick a background color");
131
100
}
132
101
 
133
102
static void
135
104
                               GdkModifierType  key,
136
105
                               gboolean         press,
137
106
                               GdkModifierType  state,
138
 
                               GimpDisplay     *gdisp)
 
107
                               GimpDisplay     *display)
139
108
{
140
109
  if (key == GDK_MOD1_MASK)
141
110
    {
142
 
      GimpEraserOptions *options;
143
 
 
144
 
      options = GIMP_ERASER_OPTIONS (tool->tool_info->tool_options);
 
111
      GimpEraserOptions *options = GIMP_ERASER_TOOL_GET_OPTIONS (tool);
145
112
 
146
113
      g_object_set (options,
147
114
                    "anti-erase", ! options->anti_erase,
148
115
                    NULL);
149
116
    }
150
117
 
151
 
  GIMP_TOOL_CLASS (parent_class)->modifier_key (tool, key, press, state, gdisp);
 
118
  GIMP_TOOL_CLASS (parent_class)->modifier_key (tool, key, press, state, display);
152
119
}
153
120
 
154
121
static void
155
122
gimp_eraser_tool_cursor_update (GimpTool        *tool,
156
123
                                GimpCoords      *coords,
157
124
                                GdkModifierType  state,
158
 
                                GimpDisplay     *gdisp)
 
125
                                GimpDisplay     *display)
159
126
{
160
 
  GimpEraserOptions *options;
161
 
 
162
 
  options = GIMP_ERASER_OPTIONS (tool->tool_info->tool_options);
163
 
 
164
 
  gimp_tool_control_set_toggle (tool->control, options->anti_erase);
165
 
 
166
 
  GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
 
127
  GimpEraserOptions *options = GIMP_ERASER_TOOL_GET_OPTIONS (tool);
 
128
 
 
129
  gimp_tool_control_set_toggled (tool->control, options->anti_erase);
 
130
 
 
131
  GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
167
132
}
168
133
 
169
134
 
172
137
static GtkWidget *
173
138
gimp_eraser_options_gui (GimpToolOptions *tool_options)
174
139
{
175
 
  GObject   *config;
176
 
  GtkWidget *vbox;
 
140
  GObject   *config = G_OBJECT (tool_options);
 
141
  GtkWidget *vbox   = gimp_paint_options_gui (tool_options);
177
142
  GtkWidget *button;
178
143
  gchar     *str;
179
144
 
180
 
  config = G_OBJECT (tool_options);
181
 
 
182
 
  vbox = gimp_paint_options_gui (tool_options);
183
 
 
184
145
  /* the anti_erase toggle */
185
 
  str = g_strdup_printf (_("Anti erase  %s"),
 
146
  str = g_strdup_printf (_("Anti erase  (%s)"),
186
147
                         gimp_get_mod_string (GDK_MOD1_MASK));
187
148
 
188
149
  button = gimp_prop_check_button_new (config, "anti-erase", str);