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

« back to all changes in this revision

Viewing changes to app/actions/gradient-editor-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
82
82
 
83
83
  editor->color_dialog =
84
84
    gimp_color_dialog_new (GIMP_VIEWABLE (gradient),
 
85
                           GIMP_DATA_EDITOR (editor)->context,
85
86
                           _("Left Endpoint Color"),
86
87
                           GIMP_STOCK_GRADIENT,
87
88
                           _("Gradient Segment's Left Endpoint Color"),
107
108
}
108
109
 
109
110
void
 
111
gradient_editor_left_color_type_cmd_callback (GtkAction *action,
 
112
                                              GtkAction *current,
 
113
                                              gpointer   data)
 
114
{
 
115
  GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
 
116
  GimpGradient       *gradient;
 
117
  gint                value;
 
118
 
 
119
  gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
 
120
 
 
121
  value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
 
122
 
 
123
  if (gradient && value >= 0)
 
124
    {
 
125
      GimpGradientColor color_type = value;
 
126
      GimpRGB           color;
 
127
 
 
128
      gimp_gradient_get_color_at (gradient,
 
129
                                  GIMP_DATA_EDITOR (editor)->context,
 
130
                                  editor->control_sel_l,
 
131
                                  editor->control_sel_l->left, FALSE,
 
132
                                  &color);
 
133
 
 
134
      gimp_data_freeze (GIMP_DATA (gradient));
 
135
 
 
136
      gimp_gradient_segment_set_left_color_type (gradient,
 
137
                                                 editor->control_sel_l,
 
138
                                                 color_type);
 
139
 
 
140
      if (color_type == GIMP_GRADIENT_COLOR_FIXED)
 
141
        gimp_gradient_segment_set_left_color (gradient,
 
142
                                              editor->control_sel_l,
 
143
                                              &color);
 
144
 
 
145
      gimp_data_thaw (GIMP_DATA (gradient));
 
146
    }
 
147
}
 
148
 
 
149
void
110
150
gradient_editor_load_left_cmd_callback (GtkAction *action,
111
151
                                        gint       value,
112
152
                                        gpointer   data)
113
153
{
114
 
  GimpGradientEditor  *editor = GIMP_GRADIENT_EDITOR (data);
 
154
  GimpGradientEditor  *editor      = GIMP_GRADIENT_EDITOR (data);
 
155
  GimpDataEditor      *data_editor = GIMP_DATA_EDITOR (data);
115
156
  GimpGradient        *gradient;
116
 
  GimpContext         *context;
117
157
  GimpGradientSegment *seg;
118
158
  GimpRGB              color;
119
 
 
120
 
  gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
121
 
 
122
 
  context =
123
 
    gimp_get_user_context (GIMP_DATA_EDITOR (editor)->data_factory->gimp);
 
159
  GimpGradientColor    color_type = GIMP_GRADIENT_COLOR_FIXED;
 
160
 
 
161
  gradient = GIMP_GRADIENT (data_editor->data);
124
162
 
125
163
  switch (value)
126
164
    {
127
 
    case 0: /* Fetch from left neighbor's right endpoint */
 
165
    case GRADIENT_EDITOR_COLOR_NEIGHBOR_ENDPOINT:
128
166
      if (editor->control_sel_l->prev != NULL)
129
 
        seg = editor->control_sel_l->prev;
 
167
        seg = editor->control_sel_l->prev;
130
168
      else
131
 
        seg = gimp_gradient_segment_get_last (editor->control_sel_l);
132
 
 
133
 
      color = seg->right_color;
134
 
      break;
135
 
 
136
 
    case 1: /* Fetch from right endpoint */
137
 
      color = editor->control_sel_r->right_color;
138
 
      break;
139
 
 
140
 
    case 2: /* Fetch from FG color */
141
 
      gimp_context_get_foreground (context, &color);
142
 
      break;
143
 
 
144
 
    case 3: /* Fetch from BG color */
145
 
      gimp_context_get_background (context, &color);
 
169
        seg = gimp_gradient_segment_get_last (editor->control_sel_l);
 
170
 
 
171
      color      = seg->right_color;
 
172
      color_type = seg->right_color_type;
 
173
      break;
 
174
 
 
175
    case GRADIENT_EDITOR_COLOR_OTHER_ENDPOINT:
 
176
      color      = editor->control_sel_r->right_color;
 
177
      color_type = editor->control_sel_l->right_color_type;
 
178
      break;
 
179
 
 
180
    case GRADIENT_EDITOR_COLOR_FOREGROUND:
 
181
      gimp_context_get_foreground (data_editor->context, &color);
 
182
      break;
 
183
 
 
184
    case GRADIENT_EDITOR_COLOR_BACKGROUND:
 
185
      gimp_context_get_background (data_editor->context, &color);
146
186
      break;
147
187
 
148
188
    default: /* Load a color */
149
 
      color = editor->saved_colors[value - 4];
 
189
      color = editor->saved_colors[value - GRADIENT_EDITOR_COLOR_FIRST_CUSTOM];
150
190
      break;
151
191
    }
152
192
 
 
193
  gimp_data_freeze (GIMP_DATA (gradient));
 
194
 
153
195
  gimp_gradient_segment_range_blend (gradient,
154
196
                                     editor->control_sel_l,
155
197
                                     editor->control_sel_r,
156
198
                                     &color,
157
199
                                     &editor->control_sel_r->right_color,
158
200
                                     TRUE, TRUE);
 
201
  gimp_gradient_segment_set_left_color_type (gradient,
 
202
                                             editor->control_sel_l,
 
203
                                             color_type);
 
204
 
 
205
  gimp_data_thaw (GIMP_DATA (gradient));
159
206
}
160
207
 
161
208
void
186
233
 
187
234
  editor->color_dialog =
188
235
    gimp_color_dialog_new (GIMP_VIEWABLE (gradient),
 
236
                           GIMP_DATA_EDITOR (editor)->context,
189
237
                           _("Right Endpoint Color"),
190
238
                           GIMP_STOCK_GRADIENT,
191
239
                           _("Gradient Segment's Right Endpoint Color"),
211
259
}
212
260
 
213
261
void
 
262
gradient_editor_right_color_type_cmd_callback (GtkAction *action,
 
263
                                               GtkAction *current,
 
264
                                               gpointer   data)
 
265
{
 
266
  GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
 
267
  GimpGradient       *gradient;
 
268
  gint                value;
 
269
 
 
270
  gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
 
271
 
 
272
  value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
 
273
 
 
274
  if (gradient && value >= 0)
 
275
    {
 
276
      GimpGradientColor color_type = value;
 
277
      GimpRGB           color;
 
278
 
 
279
      gimp_gradient_get_color_at (gradient,
 
280
                                  GIMP_DATA_EDITOR (editor)->context,
 
281
                                  editor->control_sel_r,
 
282
                                  editor->control_sel_r->right, FALSE,
 
283
                                  &color);
 
284
 
 
285
      gimp_data_freeze (GIMP_DATA (gradient));
 
286
 
 
287
      gimp_gradient_segment_set_right_color_type (gradient,
 
288
                                                  editor->control_sel_r,
 
289
                                                  color_type);
 
290
 
 
291
      if (color_type == GIMP_GRADIENT_COLOR_FIXED)
 
292
        gimp_gradient_segment_set_right_color (gradient,
 
293
                                               editor->control_sel_r,
 
294
                                               &color);
 
295
 
 
296
      gimp_data_thaw (GIMP_DATA (gradient));
 
297
    }
 
298
}
 
299
 
 
300
void
214
301
gradient_editor_load_right_cmd_callback (GtkAction *action,
215
302
                                         gint       value,
216
303
                                         gpointer   data)
217
304
{
218
 
  GimpGradientEditor  *editor = GIMP_GRADIENT_EDITOR (data);
 
305
  GimpGradientEditor  *editor      = GIMP_GRADIENT_EDITOR (data);
 
306
  GimpDataEditor      *data_editor = GIMP_DATA_EDITOR (data);
219
307
  GimpGradient        *gradient;
220
 
  GimpContext         *context;
221
308
  GimpGradientSegment *seg;
222
309
  GimpRGB              color;
223
 
 
224
 
  gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
225
 
 
226
 
  context =
227
 
    gimp_get_user_context (GIMP_DATA_EDITOR (editor)->data_factory->gimp);
 
310
  GimpGradientColor    color_type = GIMP_GRADIENT_COLOR_FIXED;
 
311
 
 
312
  gradient = GIMP_GRADIENT (data_editor->data);
228
313
 
229
314
  switch (value)
230
315
    {
231
 
    case 0: /* Fetch from right neighbor's left endpoint */
 
316
    case GRADIENT_EDITOR_COLOR_NEIGHBOR_ENDPOINT:
232
317
      if (editor->control_sel_r->next != NULL)
233
 
        seg = editor->control_sel_r->next;
 
318
        seg = editor->control_sel_r->next;
234
319
      else
235
 
        seg = gimp_gradient_segment_get_first (editor->control_sel_r);
236
 
 
237
 
      color = seg->left_color;
238
 
      break;
239
 
 
240
 
    case 1: /* Fetch from left endpoint */
241
 
      color = editor->control_sel_l->left_color;
242
 
      break;
243
 
 
244
 
    case 2: /* Fetch from FG color */
245
 
      gimp_context_get_foreground (context, &color);
246
 
      break;
247
 
 
248
 
    case 3: /* Fetch from BG color */
249
 
      gimp_context_get_background (context, &color);
 
320
        seg = gimp_gradient_segment_get_first (editor->control_sel_r);
 
321
 
 
322
      color      = seg->left_color;
 
323
      color_type = seg->left_color_type;
 
324
      break;
 
325
 
 
326
    case GRADIENT_EDITOR_COLOR_OTHER_ENDPOINT:
 
327
      color      = editor->control_sel_l->left_color;
 
328
      color_type = editor->control_sel_l->left_color_type;
 
329
      break;
 
330
 
 
331
    case GRADIENT_EDITOR_COLOR_FOREGROUND:
 
332
      gimp_context_get_foreground (data_editor->context, &color);
 
333
      break;
 
334
 
 
335
    case GRADIENT_EDITOR_COLOR_BACKGROUND:
 
336
      gimp_context_get_background (data_editor->context, &color);
250
337
      break;
251
338
 
252
339
    default: /* Load a color */
253
 
      color = editor->saved_colors[value - 4];
 
340
      color = editor->saved_colors[value - GRADIENT_EDITOR_COLOR_FIRST_CUSTOM];
254
341
      break;
255
342
    }
256
343
 
 
344
  gimp_data_freeze (GIMP_DATA (gradient));
 
345
 
257
346
  gimp_gradient_segment_range_blend (gradient,
258
347
                                     editor->control_sel_l,
259
348
                                     editor->control_sel_r,
260
349
                                     &editor->control_sel_l->left_color,
261
350
                                     &color,
262
351
                                     TRUE, TRUE);
 
352
  gimp_gradient_segment_set_right_color_type (gradient,
 
353
                                              editor->control_sel_l,
 
354
                                              color_type);
 
355
 
 
356
  gimp_data_thaw (GIMP_DATA (gradient));
263
357
}
264
358
 
265
359
void
344
438
gradient_editor_replicate_cmd_callback (GtkAction *action,
345
439
                                        gpointer   data)
346
440
{
347
 
  GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
 
441
  GimpGradientEditor *editor      = GIMP_GRADIENT_EDITOR (data);
 
442
  GimpDataEditor     *data_editor = GIMP_DATA_EDITOR (data);
348
443
  GtkWidget          *dialog;
349
444
  GtkWidget          *vbox;
350
445
  GtkWidget          *label;
365
460
    }
366
461
 
367
462
  dialog =
368
 
    gimp_viewable_dialog_new (GIMP_VIEWABLE (GIMP_DATA_EDITOR (editor)->data),
 
463
    gimp_viewable_dialog_new (GIMP_VIEWABLE (data_editor->data),
 
464
                              data_editor->context,
369
465
                              title, "gimp-gradient-segment-replicate",
370
466
                              GIMP_STOCK_GRADIENT, desc,
371
467
                              GTK_WIDGET (editor),
377
473
 
378
474
                              NULL);
379
475
 
 
476
  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
 
477
                                           GTK_RESPONSE_OK,
 
478
                                           GTK_RESPONSE_CANCEL,
 
479
                                           -1);
 
480
 
380
481
  g_signal_connect (dialog, "response",
381
482
                    G_CALLBACK (gradient_editor_replicate_response),
382
483
                    editor);
407
508
  gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, TRUE, 4);
408
509
  gtk_widget_show (scale);
409
510
 
410
 
  g_signal_connect (scale_data, "value_changed",
411
 
                    G_CALLBACK (gimp_int_adjustment_update),
412
 
                    &editor->replicate_times);
 
511
  g_signal_connect (scale_data, "value-changed",
 
512
                    G_CALLBACK (gimp_int_adjustment_update),
 
513
                    &editor->replicate_times);
413
514
 
414
515
  gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
415
516
  gimp_ui_manager_update (GIMP_EDITOR (editor)->ui_manager,
422
523
gradient_editor_split_midpoint_cmd_callback (GtkAction *action,
423
524
                                             gpointer   data)
424
525
{
425
 
  GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
426
 
  GimpGradient       *gradient;
427
 
 
428
 
  gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
 
526
  GimpGradientEditor *editor      = GIMP_GRADIENT_EDITOR (data);
 
527
  GimpDataEditor     *data_editor = GIMP_DATA_EDITOR (data);
 
528
  GimpGradient       *gradient    = GIMP_GRADIENT (data_editor->data);
429
529
 
430
530
  gimp_gradient_segment_range_split_midpoint (gradient,
 
531
                                              data_editor->context,
431
532
                                              editor->control_sel_l,
432
533
                                              editor->control_sel_r,
433
534
                                              &editor->control_sel_l,
438
539
gradient_editor_split_uniformly_cmd_callback (GtkAction *action,
439
540
                                              gpointer   data)
440
541
{
441
 
  GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
 
542
  GimpGradientEditor *editor      = GIMP_GRADIENT_EDITOR (data);
 
543
  GimpDataEditor     *data_editor = GIMP_DATA_EDITOR (data);
442
544
  GtkWidget          *dialog;
443
545
  GtkWidget          *vbox;
444
546
  GtkWidget          *label;
459
561
    }
460
562
 
461
563
  dialog =
462
 
    gimp_viewable_dialog_new (GIMP_VIEWABLE (GIMP_DATA_EDITOR (editor)->data),
 
564
    gimp_viewable_dialog_new (GIMP_VIEWABLE (data_editor->data),
 
565
                              data_editor->context,
463
566
                              title, "gimp-gradient-segment-split-uniformly",
464
567
                              GIMP_STOCK_GRADIENT, desc,
465
568
                              GTK_WIDGET (editor),
471
574
 
472
575
                              NULL);
473
576
 
 
577
  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
 
578
                                           GTK_RESPONSE_OK,
 
579
                                           GTK_RESPONSE_CANCEL,
 
580
                                           -1);
 
581
 
474
582
  g_signal_connect (dialog, "response",
475
583
                    G_CALLBACK (gradient_editor_split_uniform_response),
476
584
                    editor);
502
610
  gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 4);
503
611
  gtk_widget_show (scale);
504
612
 
505
 
  g_signal_connect (scale_data, "value_changed",
506
 
                    G_CALLBACK (gimp_int_adjustment_update),
507
 
                    &editor->split_parts);
 
613
  g_signal_connect (scale_data, "value-changed",
 
614
                    G_CALLBACK (gimp_int_adjustment_update),
 
615
                    &editor->split_parts);
508
616
 
509
617
  gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
510
618
  gimp_ui_manager_update (GIMP_EDITOR (editor)->ui_manager,
715
823
      *seg = *oseg; /* Copy everything */
716
824
 
717
825
      if (prev == NULL)
718
 
        tmp = seg; /* Remember first segment */
 
826
        tmp = seg; /* Remember first segment */
719
827
      else
720
 
        prev->next = seg;
 
828
        prev->next = seg;
721
829
 
722
830
      seg->prev = prev;
723
831
      seg->next = NULL;
770
878
 
771
879
  editor->control_sel_l = replace_seg;
772
880
  editor->control_sel_r = replace_last;
773
 
 
774
 
  gradient->last_visited = NULL; /* Force re-search */
775
881
}
776
882
 
777
883
static void
786
892
 
787
893
  if (response_id == GTK_RESPONSE_OK)
788
894
    {
789
 
      GimpGradient *gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
 
895
      GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor);
 
896
      GimpGradient   *gradient    = GIMP_GRADIENT (data_editor->data);
790
897
 
791
898
      gimp_gradient_segment_range_split_uniform (gradient,
 
899
                                                 data_editor->context,
792
900
                                                 editor->control_sel_l,
793
901
                                                 editor->control_sel_r,
794
902
                                                 editor->split_parts,