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

« back to all changes in this revision

Viewing changes to app/actions/channels-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
71
71
                                       gpointer   data)
72
72
{
73
73
  ChannelOptionsDialog *options;
74
 
  GimpImage            *gimage;
 
74
  GimpImage            *image;
75
75
  GimpChannel          *channel;
76
76
  GtkWidget            *widget;
77
 
  return_if_no_channel (gimage, channel, data);
 
77
  return_if_no_channel (image, channel, data);
78
78
  return_if_no_widget (widget, data);
79
79
 
80
 
  options = channel_options_dialog_new (gimage,
 
80
  options = channel_options_dialog_new (image, channel,
81
81
                                        action_data_get_context (data),
82
 
                                        channel,
83
82
                                        widget,
84
83
                                        &channel->color,
85
84
                                        gimp_object_get_name (GIMP_OBJECT (channel)),
86
85
                                        _("Channel Attributes"),
87
86
                                        "gimp-channel-edit",
88
 
                                        GIMP_STOCK_EDIT,
 
87
                                        GTK_STOCK_EDIT,
89
88
                                        _("Edit Channel Attributes"),
90
89
                                        GIMP_HELP_CHANNEL_EDIT,
91
90
                                        _("Edit Channel Color"),
92
 
                                        _("Fill Opacity:"));
 
91
                                        _("_Fill opacity:"),
 
92
                                        FALSE);
93
93
 
94
94
  g_signal_connect (options->dialog, "response",
95
95
                    G_CALLBACK (channels_edit_channel_response),
103
103
                           gpointer   data)
104
104
{
105
105
  ChannelOptionsDialog *options;
106
 
  GimpImage            *gimage;
 
106
  GimpImage            *image;
107
107
  GtkWidget            *widget;
108
 
  return_if_no_image (gimage, data);
 
108
  return_if_no_image (image, data);
109
109
  return_if_no_widget (widget, data);
110
110
 
111
 
  options = channel_options_dialog_new (gimage,
 
111
  options = channel_options_dialog_new (image, NULL,
112
112
                                        action_data_get_context (data),
113
 
                                        NULL,
114
113
                                        widget,
115
114
                                        &channel_color,
116
115
                                        channel_name ? channel_name :
121
120
                                        _("New Channel Options"),
122
121
                                        GIMP_HELP_CHANNEL_NEW,
123
122
                                        _("New Channel Color"),
124
 
                                        _("Fill Opacity:"));
 
123
                                        _("_Fill opacity:"),
 
124
                                        TRUE);
125
125
 
126
126
  g_signal_connect (options->dialog, "response",
127
127
                    G_CALLBACK (channels_new_channel_response),
134
134
channels_new_last_vals_cmd_callback (GtkAction *action,
135
135
                                     gpointer   data)
136
136
{
137
 
  GimpImage   *gimage;
 
137
  GimpImage   *image;
138
138
  GimpChannel *new_channel;
139
139
  gint         width, height;
140
140
  GimpRGB      color;
141
 
  return_if_no_image (gimage, data);
 
141
  return_if_no_image (image, data);
142
142
 
143
143
  if (GIMP_IS_CHANNEL (GIMP_ACTION (action)->viewable))
144
144
    {
150
150
    }
151
151
  else
152
152
    {
153
 
      width  = gimp_image_get_width (gimage);
154
 
      height = gimp_image_get_height (gimage);
 
153
      width  = gimp_image_get_width (image);
 
154
      height = gimp_image_get_height (image);
155
155
      color  = channel_color;
156
156
    }
157
157
 
158
 
  gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_EDIT_PASTE,
 
158
  gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_EDIT_PASTE,
159
159
                               _("New Channel"));
160
160
 
161
 
  new_channel = gimp_channel_new (gimage, width, height,
 
161
  new_channel = gimp_channel_new (image, width, height,
162
162
                                  channel_name ? channel_name :
163
163
                                  _("New Channel"), &color);
164
164
 
166
166
                              action_data_get_context (data),
167
167
                              GIMP_TRANSPARENT_FILL);
168
168
 
169
 
  gimp_image_add_channel (gimage, new_channel, -1);
170
 
 
171
 
  gimp_image_undo_group_end (gimage);
172
 
 
173
 
  gimp_image_flush (gimage);
 
169
  gimp_image_add_channel (image, new_channel, -1);
 
170
 
 
171
  gimp_image_undo_group_end (image);
 
172
 
 
173
  gimp_image_flush (image);
174
174
}
175
175
 
176
176
void
177
177
channels_raise_cmd_callback (GtkAction *action,
178
178
                             gpointer   data)
179
179
{
180
 
  GimpImage   *gimage;
 
180
  GimpImage   *image;
181
181
  GimpChannel *channel;
182
 
  return_if_no_channel (gimage, channel, data);
 
182
  return_if_no_channel (image, channel, data);
183
183
 
184
 
  gimp_image_raise_channel (gimage, channel);
185
 
  gimp_image_flush (gimage);
 
184
  gimp_image_raise_channel (image, channel);
 
185
  gimp_image_flush (image);
186
186
}
187
187
 
188
188
void
189
189
channels_raise_to_top_cmd_callback (GtkAction *action,
190
190
                                    gpointer   data)
191
191
{
192
 
  GimpImage   *gimage;
 
192
  GimpImage   *image;
193
193
  GimpChannel *channel;
194
 
  return_if_no_channel (gimage, channel, data);
 
194
  return_if_no_channel (image, channel, data);
195
195
 
196
 
  gimp_image_raise_channel_to_top (gimage, channel);
197
 
  gimp_image_flush (gimage);
 
196
  gimp_image_raise_channel_to_top (image, channel);
 
197
  gimp_image_flush (image);
198
198
}
199
199
 
200
200
void
201
201
channels_lower_cmd_callback (GtkAction *action,
202
202
                             gpointer   data)
203
203
{
204
 
  GimpImage   *gimage;
 
204
  GimpImage   *image;
205
205
  GimpChannel *channel;
206
 
  return_if_no_channel (gimage, channel, data);
 
206
  return_if_no_channel (image, channel, data);
207
207
 
208
 
  gimp_image_lower_channel (gimage, channel);
209
 
  gimp_image_flush (gimage);
 
208
  gimp_image_lower_channel (image, channel);
 
209
  gimp_image_flush (image);
210
210
}
211
211
 
212
212
void
213
213
channels_lower_to_bottom_cmd_callback (GtkAction *action,
214
214
                                       gpointer   data)
215
215
{
216
 
  GimpImage   *gimage;
 
216
  GimpImage   *image;
217
217
  GimpChannel *channel;
218
 
  return_if_no_channel (gimage, channel, data);
 
218
  return_if_no_channel (image, channel, data);
219
219
 
220
 
  gimp_image_lower_channel_to_bottom (gimage, channel);
221
 
  gimp_image_flush (gimage);
 
220
  gimp_image_lower_channel_to_bottom (image, channel);
 
221
  gimp_image_flush (image);
222
222
}
223
223
 
224
224
void
225
225
channels_duplicate_cmd_callback (GtkAction *action,
226
226
                                 gpointer   data)
227
227
{
228
 
  GimpImage   *gimage;
 
228
  GimpImage   *image;
229
229
  GimpChannel *new_channel;
230
230
 
231
231
  if (GIMP_IS_COMPONENT_EDITOR (data))
232
232
    {
233
 
      GimpRGB          color;
234
233
      GimpChannelType  component;
235
234
      const gchar     *desc;
236
235
      gchar           *name;
237
 
      return_if_no_image (gimage, data);
238
 
 
239
 
      gimp_rgba_set (&color, 0, 0, 0, 0.5);
 
236
      return_if_no_image (image, data);
240
237
 
241
238
      component = GIMP_COMPONENT_EDITOR (data)->clicked_component;
242
239
 
245
242
 
246
243
      name = g_strdup_printf (_("%s Channel Copy"), desc);
247
244
 
248
 
      new_channel = gimp_channel_new_from_component (gimage, component,
249
 
                                                     name, &color);
 
245
      new_channel = gimp_channel_new_from_component (image, component,
 
246
                                                     name, NULL);
250
247
 
251
248
      /*  copied components are invisible by default so subsequent copies
252
249
       *  of components don't affect each other
258
255
  else
259
256
    {
260
257
      GimpChannel *channel;
261
 
      return_if_no_channel (gimage, channel, data);
 
258
      return_if_no_channel (image, channel, data);
262
259
 
263
260
      new_channel =
264
261
        GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (channel),
266
263
                                           TRUE));
267
264
    }
268
265
 
269
 
  gimp_image_add_channel (gimage, new_channel, -1);
270
 
  gimp_image_flush (gimage);
 
266
  gimp_image_add_channel (image, new_channel, -1);
 
267
  gimp_image_flush (image);
271
268
}
272
269
 
273
270
void
274
271
channels_delete_cmd_callback (GtkAction *action,
275
272
                              gpointer   data)
276
273
{
277
 
  GimpImage   *gimage;
 
274
  GimpImage   *image;
278
275
  GimpChannel *channel;
279
 
  return_if_no_channel (gimage, channel, data);
 
276
  return_if_no_channel (image, channel, data);
280
277
 
281
 
  gimp_image_remove_channel (gimage, channel);
282
 
  gimp_image_flush (gimage);
 
278
  gimp_image_remove_channel (image, channel);
 
279
  gimp_image_flush (image);
283
280
}
284
281
 
285
282
void
288
285
                                    gpointer   data)
289
286
{
290
287
  GimpChannelOps  op;
291
 
  GimpImage      *gimage;
 
288
  GimpImage      *image;
292
289
 
293
290
  op = (GimpChannelOps) value;
294
291
 
295
292
  if (GIMP_IS_COMPONENT_EDITOR (data))
296
293
    {
297
294
      GimpChannelType component;
298
 
      return_if_no_image (gimage, data);
 
295
      return_if_no_image (image, data);
299
296
 
300
297
      component = GIMP_COMPONENT_EDITOR (data)->clicked_component;
301
298
 
302
 
      gimp_channel_select_component (gimp_image_get_mask (gimage), component,
 
299
      gimp_channel_select_component (gimp_image_get_mask (image), component,
303
300
                                     op, FALSE, 0.0, 0.0);
304
301
    }
305
302
  else
306
303
    {
307
304
      GimpChannel *channel;
308
 
      return_if_no_channel (gimage, channel, data);
 
305
      return_if_no_channel (image, channel, data);
309
306
 
310
 
      gimp_channel_select_channel (gimp_image_get_mask (gimage),
 
307
      gimp_channel_select_channel (gimp_image_get_mask (image),
311
308
                                   _("Channel to Selection"),
312
309
                                   channel, 0, 0,
313
310
                                   op, FALSE, 0.0, 0.0);
314
311
    }
315
312
 
316
 
  gimp_image_flush (gimage);
 
313
  gimp_image_flush (image);
317
314
}
318
315
 
319
316
 
336
333
      gimp_color_button_get_color (GIMP_COLOR_BUTTON (options->color_panel),
337
334
                                   &channel_color);
338
335
 
339
 
      new_channel = gimp_channel_new (options->gimage,
340
 
                                      options->gimage->width,
341
 
                                      options->gimage->height,
342
 
                                      channel_name,
343
 
                                      &channel_color);
344
 
 
345
 
      gimp_drawable_fill_by_type (GIMP_DRAWABLE (new_channel),
346
 
                                  options->context,
347
 
                                  GIMP_TRANSPARENT_FILL);
348
 
 
349
 
      gimp_image_add_channel (options->gimage, new_channel, -1);
350
 
      gimp_image_flush (options->gimage);
 
336
      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (options->save_sel_checkbutton)))
 
337
        {
 
338
          GimpChannel *selection = gimp_image_get_mask (options->image);
 
339
 
 
340
          new_channel =
 
341
            GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (selection),
 
342
                                               GIMP_TYPE_CHANNEL,
 
343
                                               FALSE));
 
344
 
 
345
          gimp_object_set_name (GIMP_OBJECT (new_channel), channel_name);
 
346
          gimp_channel_set_color (new_channel, &channel_color, FALSE);
 
347
        }
 
348
      else
 
349
        {
 
350
          new_channel = gimp_channel_new (options->image,
 
351
                                          options->image->width,
 
352
                                          options->image->height,
 
353
                                          channel_name,
 
354
                                          &channel_color);
 
355
 
 
356
          gimp_drawable_fill_by_type (GIMP_DRAWABLE (new_channel),
 
357
                                      options->context,
 
358
                                      GIMP_TRANSPARENT_FILL);
 
359
        }
 
360
 
 
361
      gimp_image_add_channel (options->image, new_channel, -1);
 
362
      gimp_image_flush (options->image);
351
363
    }
352
364
 
353
365
  gtk_widget_destroy (options->dialog);
378
390
        color_changed = TRUE;
379
391
 
380
392
      if (name_changed && color_changed)
381
 
        gimp_image_undo_group_start (options->gimage,
 
393
        gimp_image_undo_group_start (options->image,
382
394
                                     GIMP_UNDO_GROUP_ITEM_PROPERTIES,
383
395
                                     _("Channel Attributes"));
384
396
 
389
401
        gimp_channel_set_color (channel, &color, TRUE);
390
402
 
391
403
      if (name_changed && color_changed)
392
 
        gimp_image_undo_group_end (options->gimage);
 
404
        gimp_image_undo_group_end (options->image);
393
405
 
394
406
      if (name_changed || color_changed)
395
 
        gimp_image_flush (options->gimage);
 
407
        gimp_image_flush (options->image);
396
408
    }
397
409
 
398
410
  gtk_widget_destroy (options->dialog);