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

« back to all changes in this revision

Viewing changes to app/tools/gimpconvolvetool.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/gimpconvolveoptions.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 "gimpconvolvetool.h"
39
36
#include "gimp-intl.h"
40
37
 
41
38
 
42
 
static void   gimp_convolve_tool_class_init     (GimpConvolveToolClass *klass);
43
 
static void   gimp_convolve_tool_init           (GimpConvolveTool      *tool);
44
 
 
45
 
static void   gimp_convolve_tool_modifier_key   (GimpTool              *tool,
46
 
                                                 GdkModifierType        key,
47
 
                                                 gboolean               press,
48
 
                                                 GdkModifierType        state,
49
 
                                                 GimpDisplay           *gdisp);
50
 
static void   gimp_convolve_tool_cursor_update  (GimpTool              *tool,
51
 
                                                 GimpCoords            *coords,
52
 
                                                 GdkModifierType        state,
53
 
                                                 GimpDisplay           *gdisp);
54
 
 
55
 
static GtkWidget * gimp_convolve_options_gui    (GimpToolOptions       *options);
56
 
 
57
 
 
58
 
static GimpPaintToolClass *parent_class;
 
39
static void   gimp_convolve_tool_modifier_key  (GimpTool         *tool,
 
40
                                                GdkModifierType   key,
 
41
                                                gboolean          press,
 
42
                                                GdkModifierType   state,
 
43
                                                GimpDisplay      *display);
 
44
static void   gimp_convolve_tool_cursor_update (GimpTool         *tool,
 
45
                                                GimpCoords       *coords,
 
46
                                                GdkModifierType   state,
 
47
                                                GimpDisplay      *display);
 
48
static void   gimp_convolve_tool_oper_update   (GimpTool         *tool,
 
49
                                                GimpCoords       *coords,
 
50
                                                GdkModifierType   state,
 
51
                                                gboolean          proximity,
 
52
                                                GimpDisplay      *display);
 
53
static void   gimp_convolve_tool_status_update (GimpTool         *tool,
 
54
                                                GimpConvolveType  type);
 
55
 
 
56
static GtkWidget * gimp_convolve_options_gui   (GimpToolOptions  *options);
 
57
 
 
58
 
 
59
G_DEFINE_TYPE (GimpConvolveTool, gimp_convolve_tool, GIMP_TYPE_BRUSH_TOOL)
 
60
 
 
61
#define parent_class gimp_convolve_tool_parent_class
59
62
 
60
63
 
61
64
void
67
70
                gimp_convolve_options_gui,
68
71
                GIMP_PAINT_OPTIONS_CONTEXT_MASK,
69
72
                "gimp-convolve-tool",
70
 
                _("Convolve"),
71
 
                _("Blur or Sharpen"),
72
 
                N_("Con_volve"), "V",
 
73
                _("Blur / Sharpen"),
 
74
                _("Blur / Sharpen Tool: Selective blurring or unblurring using a brush"),
 
75
                N_("Bl_ur / Sharpen"), "<shift>U",
73
76
                NULL, GIMP_HELP_TOOL_CONVOLVE,
74
77
                GIMP_STOCK_TOOL_BLUR,
75
78
                data);
76
79
}
77
80
 
78
 
GType
79
 
gimp_convolve_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 (GimpConvolveToolClass),
88
 
        (GBaseInitFunc) NULL,
89
 
        (GBaseFinalizeFunc) NULL,
90
 
        (GClassInitFunc) gimp_convolve_tool_class_init,
91
 
        NULL,           /* class_finalize */
92
 
        NULL,           /* class_data     */
93
 
        sizeof (GimpConvolveTool),
94
 
        0,              /* n_preallocs    */
95
 
        (GInstanceInitFunc) gimp_convolve_tool_init,
96
 
      };
97
 
 
98
 
      tool_type = g_type_register_static (GIMP_TYPE_PAINT_TOOL,
99
 
                                          "GimpConvolveTool",
100
 
                                          &tool_info, 0);
101
 
    }
102
 
 
103
 
  return tool_type;
104
 
}
105
 
 
106
81
static void
107
82
gimp_convolve_tool_class_init (GimpConvolveToolClass *klass)
108
83
{
109
84
  GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
110
85
 
111
 
  parent_class = g_type_class_peek_parent (klass);
112
 
 
113
86
  tool_class->modifier_key  = gimp_convolve_tool_modifier_key;
114
87
  tool_class->cursor_update = gimp_convolve_tool_cursor_update;
 
88
  tool_class->oper_update   = gimp_convolve_tool_oper_update;
115
89
}
116
90
 
117
91
static void
121
95
 
122
96
  gimp_tool_control_set_tool_cursor            (tool->control,
123
97
                                                GIMP_TOOL_CURSOR_BLUR);
124
 
  gimp_tool_control_set_toggle_tool_cursor     (tool->control,
125
 
                                                GIMP_TOOL_CURSOR_BLUR);
126
98
  gimp_tool_control_set_toggle_cursor_modifier (tool->control,
127
99
                                                GIMP_CURSOR_MODIFIER_MINUS);
 
100
 
 
101
  gimp_convolve_tool_status_update (tool, GIMP_BLUR_CONVOLVE);
128
102
}
129
103
 
130
104
static void
131
105
gimp_convolve_tool_modifier_key (GimpTool        *tool,
132
106
                                 GdkModifierType  key,
133
107
                                 gboolean         press,
134
 
                                 GdkModifierType  state,
135
 
                                 GimpDisplay     *gdisp)
 
108
                                 GdkModifierType  state,
 
109
                                 GimpDisplay     *display)
136
110
{
137
 
  GimpConvolveOptions *options;
138
 
 
139
 
  options = GIMP_CONVOLVE_OPTIONS (tool->tool_info->tool_options);
 
111
  GimpConvolveOptions *options = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool);
140
112
 
141
113
  if ((key == GDK_CONTROL_MASK) &&
142
114
      ! (state & GDK_SHIFT_MASK)) /* leave stuff untouched in line draw mode */
160
132
static void
161
133
gimp_convolve_tool_cursor_update (GimpTool        *tool,
162
134
                                  GimpCoords      *coords,
163
 
                                  GdkModifierType  state,
164
 
                                  GimpDisplay     *gdisp)
165
 
{
166
 
  GimpConvolveOptions *options;
167
 
 
168
 
  options = GIMP_CONVOLVE_OPTIONS (tool->tool_info->tool_options);
169
 
 
170
 
  gimp_tool_control_set_toggle (tool->control,
171
 
                                (options->type == GIMP_SHARPEN_CONVOLVE));
172
 
 
173
 
  GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
 
135
                                  GdkModifierType  state,
 
136
                                  GimpDisplay     *display)
 
137
{
 
138
  GimpConvolveOptions *options = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool);
 
139
 
 
140
  gimp_tool_control_set_toggled (tool->control,
 
141
                                 (options->type == GIMP_SHARPEN_CONVOLVE));
 
142
 
 
143
  GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
 
144
}
 
145
 
 
146
static void
 
147
gimp_convolve_tool_oper_update (GimpTool        *tool,
 
148
                                GimpCoords      *coords,
 
149
                                GdkModifierType  state,
 
150
                                gboolean         proximity,
 
151
                                GimpDisplay     *display)
 
152
{
 
153
  GimpConvolveOptions *options = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool);
 
154
 
 
155
  gimp_convolve_tool_status_update (tool, options->type);
 
156
 
 
157
  GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, proximity,
 
158
                                               display);
 
159
}
 
160
 
 
161
static void
 
162
gimp_convolve_tool_status_update (GimpTool         *tool,
 
163
                                  GimpConvolveType  type)
 
164
{
 
165
  GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
 
166
 
 
167
  switch (type)
 
168
    {
 
169
    case GIMP_BLUR_CONVOLVE:
 
170
      paint_tool->status      = _("Click to blur");
 
171
      paint_tool->status_line = _("Click to blur the line");
 
172
      paint_tool->status_ctrl = _("%s to sharpen");
 
173
      break;
 
174
 
 
175
    case GIMP_SHARPEN_CONVOLVE:
 
176
      paint_tool->status      = _("Click to sharpen");
 
177
      paint_tool->status_line = _("Click to sharpen the line");
 
178
      paint_tool->status_ctrl = _("%s to blur");
 
179
      break;
 
180
 
 
181
    default:
 
182
      break;
 
183
    }
174
184
}
175
185
 
176
186
 
179
189
static GtkWidget *
180
190
gimp_convolve_options_gui (GimpToolOptions *tool_options)
181
191
{
182
 
  GObject   *config;
183
 
  GtkWidget *vbox;
 
192
  GObject   *config = G_OBJECT (tool_options);
 
193
  GtkWidget *vbox   = gimp_paint_options_gui (tool_options);
184
194
  GtkWidget *table;
185
195
  GtkWidget *frame;
186
196
  gchar     *str;
187
197
 
188
 
  config = G_OBJECT (tool_options);
189
 
 
190
 
  vbox = gimp_paint_options_gui (tool_options);
191
 
 
192
198
  /*  the type radio box  */
193
 
  str = g_strdup_printf (_("Convolve Type  %s"),
 
199
  str = g_strdup_printf (_("Convolve Type  (%s)"),
194
200
                         gimp_get_mod_string (GDK_CONTROL_MASK));
195
201
 
196
202
  frame = gimp_prop_enum_radio_frame_new (config, "type",