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

« back to all changes in this revision

Viewing changes to app/actions/drawable-commands.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
35
35
#include "core/gimpitemundo.h"
36
36
#include "core/gimplayermask.h"
37
37
 
 
38
#include "dialogs/desaturate-dialog.h"
38
39
#include "dialogs/offset-dialog.h"
39
40
 
40
41
#include "actions.h"
43
44
#include "gimp-intl.h"
44
45
 
45
46
 
 
47
/*  local function prototypes  */
 
48
 
 
49
static void   desaturate_response (GtkWidget        *widget,
 
50
                                   gint              response_id,
 
51
                                   DesaturateDialog *dialog);
 
52
 
 
53
 
 
54
/*  private variables  */
 
55
 
 
56
static GimpDesaturateMode  desaturate_mode = GIMP_DESATURATE_LIGHTNESS;
 
57
 
 
58
 
46
59
/*  public functions  */
47
60
 
48
61
void
49
62
drawable_desaturate_cmd_callback (GtkAction *action,
50
63
                                  gpointer   data)
51
64
{
52
 
  GimpImage    *gimage;
53
 
  GimpDrawable *drawable;
54
 
  return_if_no_drawable (gimage, drawable, data);
 
65
  DesaturateDialog *dialog;
 
66
  GimpImage        *image;
 
67
  GimpDrawable     *drawable;
 
68
  GtkWidget        *widget;
 
69
  return_if_no_drawable (image, drawable, data);
 
70
  return_if_no_widget (widget, data);
55
71
 
56
72
  if (! gimp_drawable_is_rgb (drawable))
57
73
    {
58
 
      g_message (_("Desaturate operates only on RGB color layers."));
 
74
      gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
 
75
                    _("Desaturate operates only on RGB color layers."));
59
76
      return;
60
77
    }
61
78
 
62
 
  gimp_drawable_desaturate (drawable);
63
 
  gimp_image_flush (gimage);
 
79
  dialog = desaturate_dialog_new (drawable,
 
80
                                  action_data_get_context (data),
 
81
                                  widget, desaturate_mode);
 
82
 
 
83
  g_signal_connect (dialog->dialog, "response",
 
84
                    G_CALLBACK (desaturate_response),
 
85
                    dialog);
 
86
 
 
87
  gtk_widget_show (dialog->dialog);
64
88
}
65
89
 
66
90
void
67
91
drawable_equalize_cmd_callback (GtkAction *action,
68
92
                                gpointer   data)
69
93
{
70
 
  GimpImage    *gimage;
 
94
  GimpImage    *image;
71
95
  GimpDrawable *drawable;
72
 
  return_if_no_drawable (gimage, drawable, data);
 
96
  GtkWidget    *widget;
 
97
  return_if_no_drawable (image, drawable, data);
 
98
  return_if_no_widget (widget, data);
73
99
 
74
100
  if (gimp_drawable_is_indexed (drawable))
75
101
    {
76
 
      g_message (_("Equalize does not operate on indexed layers."));
 
102
      gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
 
103
                    _("Equalize does not operate on indexed layers."));
77
104
      return;
78
105
    }
79
106
 
80
107
  gimp_drawable_equalize (drawable, TRUE);
81
 
  gimp_image_flush (gimage);
 
108
  gimp_image_flush (image);
82
109
}
83
110
 
84
111
void
85
112
drawable_invert_cmd_callback (GtkAction *action,
86
113
                              gpointer   data)
87
114
{
88
 
  GimpImage    *gimage;
 
115
  GimpImage    *image;
89
116
  GimpDrawable *drawable;
90
 
  return_if_no_drawable (gimage, drawable, data);
 
117
  GtkWidget    *widget;
 
118
  return_if_no_drawable (image, drawable, data);
 
119
  return_if_no_widget (widget, data);
91
120
 
92
121
  if (gimp_drawable_is_indexed (drawable))
93
122
    {
94
 
      g_message (_("Invert does not operate on indexed layers."));
 
123
      gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
 
124
                    _("Invert does not operate on indexed layers."));
95
125
      return;
96
126
    }
97
127
 
98
128
  gimp_drawable_invert (drawable);
99
 
  gimp_image_flush (gimage);
 
129
  gimp_image_flush (image);
100
130
}
101
131
 
102
132
void
103
133
drawable_levels_stretch_cmd_callback (GtkAction *action,
104
134
                                      gpointer   data)
105
135
{
106
 
  GimpImage    *gimage;
 
136
  GimpImage    *image;
107
137
  GimpDrawable *drawable;
108
138
  GimpContext  *context;
109
 
  return_if_no_drawable (gimage, drawable, data);
 
139
  GtkWidget    *widget;
 
140
  return_if_no_drawable (image, drawable, data);
110
141
  return_if_no_context (context, data);
 
142
  return_if_no_widget (widget, data);
111
143
 
112
144
  if (! gimp_drawable_is_rgb (drawable))
113
145
    {
114
 
      g_message (_("White Balance operates only on RGB color layers."));
 
146
      gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
 
147
                    _("White Balance operates only on RGB color layers."));
115
148
      return;
116
149
    }
117
150
 
118
151
  gimp_drawable_levels_stretch (drawable, context);
119
 
  gimp_image_flush (gimage);
 
152
  gimp_image_flush (image);
120
153
}
121
154
 
122
155
void
123
156
drawable_offset_cmd_callback (GtkAction *action,
124
157
                              gpointer   data)
125
158
{
126
 
  GimpImage    *gimage;
 
159
  GimpImage    *image;
127
160
  GimpDrawable *drawable;
128
161
  GtkWidget    *widget;
129
162
  GtkWidget    *dialog;
130
 
  return_if_no_drawable (gimage, drawable, data);
 
163
  return_if_no_drawable (image, drawable, data);
131
164
  return_if_no_widget (widget, data);
132
165
 
133
 
  dialog = offset_dialog_new (drawable, widget);
 
166
  dialog = offset_dialog_new (drawable, action_data_get_context (data),
 
167
                              widget);
134
168
  gtk_widget_show (dialog);
135
169
}
136
170
 
139
173
drawable_linked_cmd_callback (GtkAction *action,
140
174
                              gpointer   data)
141
175
{
142
 
  GimpImage    *gimage;
 
176
  GimpImage    *image;
143
177
  GimpDrawable *drawable;
144
178
  gboolean      linked;
145
 
  return_if_no_drawable (gimage, drawable, data);
 
179
  return_if_no_drawable (image, drawable, data);
146
180
 
147
181
  linked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
148
182
 
155
189
      GimpUndo *undo;
156
190
      gboolean  push_undo = TRUE;
157
191
 
158
 
      undo = gimp_image_undo_can_compress (gimage, GIMP_TYPE_ITEM_UNDO,
 
192
      undo = gimp_image_undo_can_compress (image, GIMP_TYPE_ITEM_UNDO,
159
193
                                           GIMP_UNDO_ITEM_LINKED);
160
194
 
161
195
      if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (drawable))
162
196
        push_undo = FALSE;
163
197
 
164
198
      gimp_item_set_linked (GIMP_ITEM (drawable), linked, push_undo);
165
 
      gimp_image_flush (gimage);
 
199
      gimp_image_flush (image);
166
200
    }
167
201
}
168
202
 
170
204
drawable_visible_cmd_callback (GtkAction *action,
171
205
                               gpointer   data)
172
206
{
173
 
  GimpImage    *gimage;
 
207
  GimpImage    *image;
174
208
  GimpDrawable *drawable;
175
209
  gboolean      visible;
176
 
  return_if_no_drawable (gimage, drawable, data);
 
210
  return_if_no_drawable (image, drawable, data);
177
211
 
178
212
  visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
179
213
 
186
220
      GimpUndo *undo;
187
221
      gboolean  push_undo = TRUE;
188
222
 
189
 
      undo = gimp_image_undo_can_compress (gimage, GIMP_TYPE_ITEM_UNDO,
 
223
      undo = gimp_image_undo_can_compress (image, GIMP_TYPE_ITEM_UNDO,
190
224
                                           GIMP_UNDO_ITEM_VISIBILITY);
191
225
 
192
226
      if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (drawable))
193
227
        push_undo = FALSE;
194
228
 
195
229
      gimp_item_set_visible (GIMP_ITEM (drawable), visible, push_undo);
196
 
      gimp_image_flush (gimage);
 
230
      gimp_image_flush (image);
197
231
    }
198
232
}
199
233
 
203
237
                            gint       value,
204
238
                            gpointer   data)
205
239
{
206
 
  GimpImage    *gimage;
 
240
  GimpImage    *image;
207
241
  GimpDrawable *drawable;
208
242
  GimpItem     *item;
209
243
  GimpContext  *context;
210
244
  gint          off_x, off_y;
211
245
  gdouble       axis = 0.0;
212
 
  return_if_no_drawable (gimage, drawable, data);
 
246
  return_if_no_drawable (image, drawable, data);
213
247
  return_if_no_context (context, data);
214
248
 
215
249
  item = GIMP_ITEM (drawable);
231
265
    }
232
266
 
233
267
  if (gimp_item_get_linked (item))
234
 
    gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
 
268
    gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
235
269
                                 GIMP_ITEM_GET_CLASS (item)->flip_desc);
236
270
 
237
271
  gimp_item_flip (item, context, (GimpOrientationType) value, axis, FALSE);
240
274
    {
241
275
      gimp_item_linked_flip (item, context, (GimpOrientationType) action, axis,
242
276
                             FALSE);
243
 
      gimp_image_undo_group_end (gimage);
 
277
      gimp_image_undo_group_end (image);
244
278
    }
245
279
 
246
 
  gimp_image_flush (gimage);
 
280
  gimp_image_flush (image);
247
281
}
248
282
 
249
283
void
251
285
                              gint       value,
252
286
                              gpointer   data)
253
287
{
254
 
  GimpImage    *gimage;
 
288
  GimpImage    *image;
255
289
  GimpDrawable *drawable;
256
290
  GimpContext  *context;
257
291
  GimpItem     *item;
258
292
  gint          off_x, off_y;
259
293
  gdouble       center_x, center_y;
260
294
  gboolean      clip_result = FALSE;
261
 
  return_if_no_drawable (gimage, drawable, data);
 
295
  return_if_no_drawable (image, drawable, data);
262
296
  return_if_no_context (context, data);
263
297
 
264
298
  item = GIMP_ITEM (drawable);
269
303
  center_y = ((gdouble) off_y + (gdouble) gimp_item_height (item) / 2.0);
270
304
 
271
305
  if (gimp_item_get_linked (item))
272
 
    gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
 
306
    gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
273
307
                                 GIMP_ITEM_GET_CLASS (item)->rotate_desc);
274
308
 
275
309
  if (GIMP_IS_CHANNEL (item))
282
316
    {
283
317
      gimp_item_linked_rotate (item, context, (GimpRotationType) value,
284
318
                               center_x, center_y, FALSE);
285
 
      gimp_image_undo_group_end (gimage);
286
 
    }
287
 
 
288
 
  gimp_image_flush (gimage);
 
319
      gimp_image_undo_group_end (image);
 
320
    }
 
321
 
 
322
  gimp_image_flush (image);
 
323
}
 
324
 
 
325
/*  private functions  */
 
326
 
 
327
static void
 
328
desaturate_response (GtkWidget        *widget,
 
329
                     gint              response_id,
 
330
                     DesaturateDialog *dialog)
 
331
{
 
332
  if (response_id == GTK_RESPONSE_OK)
 
333
    {
 
334
      GimpDrawable *drawable = dialog->drawable;
 
335
      GimpImage    *image   = gimp_item_get_image (GIMP_ITEM (drawable));
 
336
 
 
337
      /*  remember for next invocation of the dialog  */
 
338
      desaturate_mode = dialog->mode;
 
339
 
 
340
      gimp_drawable_desaturate (drawable, desaturate_mode);
 
341
 
 
342
      gimp_image_flush (image);
 
343
    }
 
344
 
 
345
  gtk_widget_destroy (dialog->dialog);
289
346
}